[clang] [analyzer][HTMLRewriter] Cache partial rewrite results. (PR #80220)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 31 16:26:33 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff b21a2f9365b6c5fd464a97be5dfe7085742870ef 13fbeb5411f1b877dc86dd6bebd3bf607c7fba7e -- clang/test/Analysis/html_diagnostics/counter.c clang/include/clang/Rewrite/Core/HTMLRewrite.h clang/lib/Rewrite/HTMLRewrite.cpp clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Rewrite/Core/HTMLRewrite.h b/clang/include/clang/Rewrite/Core/HTMLRewrite.h
index e1252dc4e8..414c64c8b5 100644
--- a/clang/include/clang/Rewrite/Core/HTMLRewrite.h
+++ b/clang/include/clang/Rewrite/Core/HTMLRewrite.h
@@ -15,8 +15,8 @@
#define LLVM_CLANG_REWRITE_CORE_HTMLREWRITE_H
#include "clang/Basic/SourceLocation.h"
-#include <string>
#include <map>
+#include <string>
namespace clang {
@@ -25,31 +25,31 @@ class RewriteBuffer;
class Preprocessor;
namespace html {
- struct RelexRewriteCache;
- using RelexRewriteCacheRef = std::shared_ptr<RelexRewriteCache>;
-
- /// If you need to rewrite the same file multiple times, you can instantiate
- /// a RelexRewriteCache and refer functions such as SyntaxHighlight()
- /// and HighlightMacros() to it so that to avoid re-lexing the file each time.
- /// The cache may outlive the rewriter as long as cached FileIDs and source
- /// locations continue to make sense for the translation unit as a whole.
- RelexRewriteCacheRef instantiateRelexRewriteCache();
-
- /// HighlightRange - Highlight a range in the source code with the specified
- /// start/end tags. B/E must be in the same file. This ensures that
- /// start/end tags are placed at the start/end of each line if the range is
- /// multiline.
- void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
- const char *StartTag, const char *EndTag,
- bool IsTokenRange = true);
-
- /// HighlightRange - Highlight a range in the source code with the specified
- /// start/end tags. The Start/end of the range must be in the same file.
- /// This ensures that start/end tags are placed at the start/end of each line
- /// if the range is multiline.
- inline void HighlightRange(Rewriter &R, SourceRange Range,
- const char *StartTag, const char *EndTag) {
- HighlightRange(R, Range.getBegin(), Range.getEnd(), StartTag, EndTag);
+struct RelexRewriteCache;
+using RelexRewriteCacheRef = std::shared_ptr<RelexRewriteCache>;
+
+/// If you need to rewrite the same file multiple times, you can instantiate
+/// a RelexRewriteCache and refer functions such as SyntaxHighlight()
+/// and HighlightMacros() to it so that to avoid re-lexing the file each time.
+/// The cache may outlive the rewriter as long as cached FileIDs and source
+/// locations continue to make sense for the translation unit as a whole.
+RelexRewriteCacheRef instantiateRelexRewriteCache();
+
+/// HighlightRange - Highlight a range in the source code with the specified
+/// start/end tags. B/E must be in the same file. This ensures that
+/// start/end tags are placed at the start/end of each line if the range is
+/// multiline.
+void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
+ const char *StartTag, const char *EndTag,
+ bool IsTokenRange = true);
+
+/// HighlightRange - Highlight a range in the source code with the specified
+/// start/end tags. The Start/end of the range must be in the same file.
+/// This ensures that start/end tags are placed at the start/end of each line
+/// if the range is multiline.
+inline void HighlightRange(Rewriter &R, SourceRange Range, const char *StartTag,
+ const char *EndTag) {
+ HighlightRange(R, Range.getBegin(), Range.getEnd(), StartTag, EndTag);
}
/// HighlightRange - This is the same as the above method, but takes
diff --git a/clang/lib/Rewrite/HTMLRewrite.cpp b/clang/lib/Rewrite/HTMLRewrite.cpp
index 50cdacfe33..a96ca0764a 100644
--- a/clang/lib/Rewrite/HTMLRewrite.cpp
+++ b/clang/lib/Rewrite/HTMLRewrite.cpp
@@ -26,7 +26,6 @@ using namespace clang;
using namespace llvm;
using namespace html;
-
/// HighlightRange - Highlight a range in the source code with the specified
/// start/end tags. B/E must be in the same file. This ensures that
/// start/end tags are placed at the start/end of each line if the range is
@@ -755,8 +754,7 @@ void html::HighlightMacros(Rewriter &R, FileID FID, const Preprocessor &PP,
auto HighlightRangeCallback = [&](Rewriter &R, SourceLocation B,
SourceLocation E, const char *StartTag,
const char *EndTag, bool isTokenRange) {
- HighlightRange(R, B, E, StartTag,
- EndTag, isTokenRange);
+ HighlightRange(R, B, E, StartTag, EndTag, isTokenRange);
if (Cache) {
Cache->MacroHighlights[FID].push_back(
``````````
</details>
https://github.com/llvm/llvm-project/pull/80220
More information about the cfe-commits
mailing list