aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Čukić <ivan.cukic@kdab.com>2023-02-07 11:06:19 +0100
committerCristian Adam <cristian.adam@qt.io>2023-02-09 15:05:02 +0000
commitbeee0860f2f5ed2d92fb1b11c4c29c491247fd46 (patch)
treed859987c8595a6b63adc96d3803798357952ba56
parent4b851b419784f8067dd9c5b211ed1010360dfa4c (diff)
Adapt to API changes in clang/llvm 16
Change-Id: I1f1d473ea2fe188e9791554668acff1eb08c2c60 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
-rw-r--r--src/SourceCompatibilityHelpers.h17
-rw-r--r--src/checkbase.h1
-rw-r--r--src/checks/level0/lambda-in-connect.cpp2
3 files changed, 14 insertions, 6 deletions
diff --git a/src/SourceCompatibilityHelpers.h b/src/SourceCompatibilityHelpers.h
index c1a23a4b..5e2dc606 100644
--- a/src/SourceCompatibilityHelpers.h
+++ b/src/SourceCompatibilityHelpers.h
@@ -107,7 +107,11 @@ inline clang::tooling::Replacements& DiagnosticFix(clang::tooling::Diagnostic &d
inline auto getBuffer(const clang::SourceManager &sm, clang::FileID id, bool *invalid)
{
-#if LLVM_VERSION_MAJOR >= 12
+#if LLVM_VERSION_MAJOR >= 16
+ auto buffer = sm.getBufferOrNone(id);
+ *invalid = !buffer.has_value();
+ return buffer;
+#elif LLVM_VERSION_MAJOR >= 12
auto buffer = sm.getBufferOrNone(id);
*invalid = !buffer.hasValue();
return buffer;
@@ -116,11 +120,12 @@ inline auto getBuffer(const clang::SourceManager &sm, clang::FileID id, bool *in
#endif
}
-#if LLVM_VERSION_MAJOR >= 12
-
+#if LLVM_VERSION_MAJOR >= 16
+#define GET_LEXER(id, inputFile, sm, lo) \
+clang::Lexer(id, inputFile.value(), sm, lo)
+#elif LLVM_VERSION_MAJOR >= 12
#define GET_LEXER(id, inputFile, sm, lo) \
clang::Lexer(id, inputFile.getValue(), sm, lo)
-
#else
#define GET_LEXER(id, inputFile, sm, lo) \
clang::Lexer(id, inputFile, sm, lo)
@@ -144,7 +149,9 @@ inline bool contains_lower(clang::StringRef haystack, clang::StringRef needle)
#endif
}
-#if LLVM_VERSION_MAJOR >= 15
+#if LLVM_VERSION_MAJOR >= 16
+using OptionalFileEntryRef = clang::CustomizableOptional<clang::FileEntryRef>;
+#elif LLVM_VERSION_MAJOR >= 15
using OptionalFileEntryRef = clang::Optional<clang::FileEntryRef>;
#else
using OptionalFileEntryRef = const clang::FileEntry*;
diff --git a/src/checkbase.h b/src/checkbase.h
index 02f6a6bf..6a8c634b 100644
--- a/src/checkbase.h
+++ b/src/checkbase.h
@@ -93,6 +93,7 @@ public:
void InclusionDirective(clang::SourceLocation HashLoc, const clang::Token &IncludeTok, clang::StringRef FileName, bool IsAngled,
clang::CharSourceRange FilenameRange, clazy::OptionalFileEntryRef File, clang::StringRef SearchPath,
clang::StringRef RelativePath, const clang::Module *Imported, clang::SrcMgr::CharacteristicKind FileType) override;
+
private:
CheckBase *const check;
};
diff --git a/src/checks/level0/lambda-in-connect.cpp b/src/checks/level0/lambda-in-connect.cpp
index b0da926f..1ba1126f 100644
--- a/src/checks/level0/lambda-in-connect.cpp
+++ b/src/checks/level0/lambda-in-connect.cpp
@@ -71,7 +71,7 @@ void LambdaInConnect::VisitStmt(clang::Stmt *stmt)
for (auto capture : captures) {
if (capture.getCaptureKind() == clang::LCK_ByRef) {
- VarDecl *declForCapture = capture.getCapturedVar();
+ auto *declForCapture = capture.getCapturedVar();
if (declForCapture && declForCapture != receiverDecl && clazy::isValueDeclInFunctionContext(declForCapture))
emitWarning(capture.getLocation(), "captured local variable by reference might go out of scope before lambda is called");
}