|
|
c81f37a |
From 2592a6e3393ebc75e16c91e606ad2015a16295c3 Mon Sep 17 00:00:00 2001
|
|
|
c81f37a |
From: =?UTF-8?q?Christian=20Sch=C3=A4rf?= <c.schaerf@t-online.de>
|
|
|
c81f37a |
Date: Sat, 23 Jan 2021 15:34:10 +0100
|
|
|
c81f37a |
Subject: [PATCH] Fix build with Clang 12
|
|
|
c81f37a |
|
|
|
c81f37a |
Required due to Clang changes https://github.com/llvm/llvm-project/commit/b3eff6b7bb31e7ef059a3d238de138849839fbbd and https://github.com/llvm/llvm-project/commit/d758f79e5d381bd4f5122193a9538d89c907c812
|
|
|
c81f37a |
---
|
|
|
c81f37a |
src/SourceCompatibilityHelpers.h | 26 ++++++++++++++++++++++++++
|
|
|
c81f37a |
src/SuppressionManager.cpp | 5 ++---
|
|
|
c81f37a |
2 files changed, 28 insertions(+), 3 deletions(-)
|
|
|
c81f37a |
|
|
|
c81f37a |
diff --git a/src/SourceCompatibilityHelpers.h b/src/SourceCompatibilityHelpers.h
|
|
|
c81f37a |
index 4db141ab..1737d5a5 100644
|
|
|
c81f37a |
--- a/src/SourceCompatibilityHelpers.h
|
|
|
c81f37a |
+++ b/src/SourceCompatibilityHelpers.h
|
|
|
c81f37a |
@@ -29,6 +29,7 @@
|
|
|
c81f37a |
#include <clang/Basic/SourceLocation.h>
|
|
|
c81f37a |
#include <clang/Basic/SourceManager.h>
|
|
|
c81f37a |
#include <clang/Frontend/FrontendDiagnostic.h>
|
|
|
c81f37a |
+#include <clang/Lex/Lexer.h>
|
|
|
c81f37a |
#include <clang/Tooling/Core/Diagnostic.h>
|
|
|
c81f37a |
|
|
|
c81f37a |
#if defined(CLAZY_USES_BOOST_REGEX)
|
|
|
c81f37a |
@@ -103,6 +104,31 @@ inline clang::tooling::Replacements& DiagnosticFix(clang::tooling::Diagnostic &d
|
|
|
c81f37a |
#endif
|
|
|
c81f37a |
}
|
|
|
c81f37a |
|
|
|
c81f37a |
+inline auto getBuffer(const clang::SourceManager &sm, clang::FileID id, bool *invalid)
|
|
|
c81f37a |
+{
|
|
|
c81f37a |
+#if LLVM_VERSION_MAJOR >= 12
|
|
|
c81f37a |
+ auto buffer = sm.getBufferOrNone(id);
|
|
|
c81f37a |
+ *invalid = !buffer.hasValue();
|
|
|
c81f37a |
+ return buffer;
|
|
|
c81f37a |
+#else
|
|
|
c81f37a |
+ return sm.getBuffer(id, invalid);
|
|
|
c81f37a |
+#endif
|
|
|
c81f37a |
+}
|
|
|
c81f37a |
+
|
|
|
c81f37a |
+#if LLVM_VERSION_MAJOR >= 12
|
|
|
c81f37a |
+inline clang::Lexer getLexer(clang::FileID id, llvm::Optional<llvm::MemoryBufferRef> inputFile,
|
|
|
c81f37a |
+ const clang::SourceManager &sm, const clang::LangOptions &lo)
|
|
|
c81f37a |
+{
|
|
|
c81f37a |
+ return clang::Lexer(id, inputFile.getValue(), sm, lo);
|
|
|
c81f37a |
+}
|
|
|
c81f37a |
+#else
|
|
|
c81f37a |
+inline clang::Lexer getLexer(clang::FileID id, const llvm::MemoryBuffer *inputFile,
|
|
|
c81f37a |
+ const clang::SourceManager &sm, const clang::LangOptions &lo)
|
|
|
c81f37a |
+{
|
|
|
c81f37a |
+ return clang::Lexer(id, inputFile, sm, lo);
|
|
|
c81f37a |
+}
|
|
|
c81f37a |
+#endif
|
|
|
c81f37a |
+
|
|
|
c81f37a |
}
|
|
|
c81f37a |
|
|
|
c81f37a |
#endif
|
|
|
c81f37a |
diff --git a/src/SuppressionManager.cpp b/src/SuppressionManager.cpp
|
|
|
c81f37a |
index 9d774ea6..9881388d 100644
|
|
|
c81f37a |
--- a/src/SuppressionManager.cpp
|
|
|
c81f37a |
+++ b/src/SuppressionManager.cpp
|
|
|
c81f37a |
@@ -24,7 +24,6 @@
|
|
|
c81f37a |
#include "clazy_stl.h"
|
|
|
c81f37a |
|
|
|
c81f37a |
#include <clang/Basic/SourceManager.h>
|
|
|
c81f37a |
-#include <clang/Lex/Lexer.h>
|
|
|
c81f37a |
#include <clang/Basic/SourceLocation.h>
|
|
|
c81f37a |
#include <clang/Basic/TokenKinds.h>
|
|
|
c81f37a |
#include <clang/Lex/Token.h>
|
|
|
c81f37a |
@@ -84,7 +83,7 @@ void SuppressionManager::parseFile(FileID id, const SourceManager &sm, const cla
|
|
|
c81f37a |
Suppressions &suppressions = (*it).second;
|
|
|
c81f37a |
|
|
|
c81f37a |
bool invalid = false;
|
|
|
c81f37a |
- auto buffer = sm.getBuffer(id, &invalid);
|
|
|
c81f37a |
+ auto buffer = clazy::getBuffer(sm, id, &invalid);
|
|
|
c81f37a |
if (invalid) {
|
|
|
c81f37a |
llvm::errs() << "SuppressionManager::parseFile: Invalid buffer ";
|
|
|
c81f37a |
if (buffer)
|
|
|
c81f37a |
@@ -92,7 +91,7 @@ void SuppressionManager::parseFile(FileID id, const SourceManager &sm, const cla
|
|
|
c81f37a |
return;
|
|
|
c81f37a |
}
|
|
|
c81f37a |
|
|
|
c81f37a |
- Lexer lexer(id, buffer, sm, lo);
|
|
|
c81f37a |
+ auto lexer = clazy::getLexer(id, buffer, sm, lo);
|
|
|
c81f37a |
lexer.SetCommentRetentionState(true);
|
|
|
c81f37a |
|
|
|
c81f37a |
Token token;
|
|
|
c81f37a |
--
|
|
|
c81f37a |
GitLab
|
|
|
c81f37a |
|