Skip to content

Commit c41b73f

Browse files
zsrkmynMaskRay
authored andcommitted
Accommodate changes of LLVM 21 & 22 to fix builds (#985)
1 parent f5f8f2f commit c41b73f

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/clang_tu.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,18 @@ std::unique_ptr<CompilerInvocation> buildCompilerInvocation(const std::string &m
116116
args.insert(args.begin() + 1, std::begin(arr), std::end(arr));
117117
}
118118

119+
#if (LLVM_VERSION_MAJOR == 21 && LLVM_VERSION_MINOR >= 1) || \
120+
(LLVM_VERSION_MAJOR >= 22) // llvmorg-21-init-12923-g13e1a2cb2246
121+
DiagnosticOptions DiagOpt;
122+
#else
123+
DiagnosticOptions *DiagOpt = new DiagnosticOptions;
124+
#endif
125+
119126
IntrusiveRefCntPtr<DiagnosticsEngine> diags(CompilerInstance::createDiagnostics(
120127
#if LLVM_VERSION_MAJOR >= 20
121128
*vfs,
122129
#endif
123-
new DiagnosticOptions, new IgnoringDiagConsumer, true));
130+
DiagOpt, new IgnoringDiagConsumer, true));
124131
#if LLVM_VERSION_MAJOR < 12 // llvmorg-12-init-5498-g257b29715bb
125132
driver::Driver d(args[0], llvm::sys::getDefaultTargetTriple(), *diags, vfs);
126133
#else

src/messages/textDocument_completion.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class CompletionConsumer : public CodeCompleteConsumer {
350350
if (fd->getTemplatedDecl()->getKind() == Decl::CXXDeductionGuide)
351351
continue;
352352
}
353-
if (auto *rd = dyn_cast<RecordDecl>(r.Declaration))
353+
if (auto *rd = dyn_cast<CXXRecordDecl>(r.Declaration))
354354
if (rd->isInjectedClassName())
355355
continue;
356356
auto nk = r.Declaration->getDeclName().getNameKind();

src/sema_manager.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,13 @@ void buildPreamble(Session &session, CompilerInvocation &ci, IntrusiveRefCntPtr<
352352
#if LLVM_VERSION_MAJOR >= 20
353353
*fs,
354354
#endif
355-
&ci.getDiagnosticOpts(), &dc, false);
355+
#if (LLVM_VERSION_MAJOR == 21 && LLVM_VERSION_MINOR >= 1) || \
356+
(LLVM_VERSION_MAJOR >= 22) // llvmorg-21-init-12923-g13e1a2cb2246
357+
ci.getDiagnosticOpts(),
358+
#else
359+
&ci.getDiagnosticOpts(),
360+
#endif
361+
&dc, false);
356362
if (oldP) {
357363
std::lock_guard lock(session.wfiles->mutex);
358364
for (auto &include : oldP->includes)
@@ -362,7 +368,13 @@ void buildPreamble(Session &session, CompilerInvocation &ci, IntrusiveRefCntPtr<
362368
}
363369

364370
CclsPreambleCallbacks pc;
365-
if (auto newPreamble = PrecompiledPreamble::Build(ci, buf.get(), bounds, *de, fs, session.pch, true,
371+
if (auto newPreamble = PrecompiledPreamble::Build(ci, buf.get(), bounds,
372+
#if LLVM_VERSION_MAJOR >= 22 // llvmorg-22-init-2136-gc7f343750744
373+
de,
374+
#else
375+
*de,
376+
#endif
377+
fs, session.pch, true,
366378
#if LLVM_VERSION_MAJOR >= 17 // llvmorg-17-init-4072-gcc929590ad30
367379
"",
368380
#endif

0 commit comments

Comments
 (0)