Skip to content

Commit 49cbf37

Browse files
committed
Adapt llvm 22 changes
Type::Elaborated is removed by llvmorg-22-init-3166-g91cdd35008e9 llvm::sys::fs and clang functions are changed due to https://discourse.llvm.org/t/rfc-file-system-sandboxing-in-clang-llvm/88791
1 parent 22ab870 commit 49cbf37

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/indexer.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,11 @@ const Decl *getTypeDecl(QualType t, bool *specialization = nullptr) {
364364

365365
// FIXME: Template type parameters!
366366

367+
#if LLVM_VERSION_MAJOR < 22 // llvmorg-22-init-3166-g91cdd35008e9
367368
case Type::Elaborated:
368369
tp = cast<ElaboratedType>(tp)->getNamedType().getTypePtrOrNull();
369370
goto try_again;
371+
#endif
370372

371373
default:
372374
break;
@@ -1266,7 +1268,7 @@ IndexResult index(WorkingFiles *wfiles, VFS *vfs, const std::string &opt_wdir, c
12661268
clang->setInvocation(std::move(ci));
12671269
#endif
12681270
clang->createDiagnostics(
1269-
#if LLVM_VERSION_MAJOR >= 20
1271+
#if LLVM_VERSION_MAJOR >= 20 && LLVM_VERSION_MAJOR < 22
12701272
*fs,
12711273
#endif
12721274
&dc, false);
@@ -1279,7 +1281,11 @@ IndexResult index(WorkingFiles *wfiles, VFS *vfs, const std::string &opt_wdir, c
12791281
if (!clang->hasTarget())
12801282
return {};
12811283
clang->getPreprocessorOpts().RetainRemappedFileBuffers = true;
1284+
#if LLVM_VERSION_MAJOR >= 22
1285+
clang->createFileManager();
1286+
#else
12821287
clang->createFileManager(fs);
1288+
#endif
12831289
clang->setSourceManager(new SourceManager(clang->getDiagnostics(), clang->getFileManager(), true));
12841290

12851291
IndexParam param(*vfs, no_linkage);

src/messages/initialize.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ void do_initialize(MessageHandler *m, InitializeParam &param, ReplyOnce &reply)
345345

346346
if (g_config->cache.directory.size()) {
347347
SmallString<256> path(g_config->cache.directory);
348+
#if LLVM_VERSION_MAJOR >= 22
349+
sys::path::make_absolute(project_path, path);
350+
#else
348351
sys::fs::make_absolute(project_path, path);
352+
#endif
349353
// Use upper case for the Driver letter on Windows.
350354
g_config->cache.directory = normalizePath(path.str());
351355
ensureEndsInSlash(g_config->cache.directory);

src/sema_manager.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ std::unique_ptr<CompilerInstance> buildCompilerInstance(Session &session, std::u
268268
clang->setInvocation(std::move(ci));
269269
#endif
270270
clang->createDiagnostics(
271-
#if LLVM_VERSION_MAJOR >= 20
271+
#if LLVM_VERSION_MAJOR >= 20 && LLVM_VERSION_MAJOR < 22
272272
*fs,
273273
#endif
274274
&dc, false);
@@ -283,7 +283,11 @@ std::unique_ptr<CompilerInstance> buildCompilerInstance(Session &session, std::u
283283
// Construct SourceManager with UserFilesAreVolatile: true because otherwise
284284
// RequiresNullTerminator: true may cause out-of-bounds read when a file is
285285
// mmap'ed but is saved concurrently.
286+
#if LLVM_VERSION_MAJOR >= 22
287+
clang->createFileManager();
288+
#else
286289
clang->createFileManager(fs);
290+
#endif
287291
clang->setSourceManager(new SourceManager(clang->getDiagnostics(), clang->getFileManager(), true));
288292
auto &isec = clang->getFrontendOpts().Inputs;
289293
if (isec.size()) {

0 commit comments

Comments
 (0)