aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Revest <revest@chromium.org>2026-01-20 18:41:41 +0100
committerDmitry Vyukov <dvyukov@google.com>2026-01-20 19:22:54 +0000
commit4aba25c79aa71d1a21427a5be778198d9d0b698f (patch)
tree45e76f3c412b87fd4971d56bfaeaca5b4272d1c9
parent31d0cb6a61684e72e5a49a7522c7595eb42c81ea (diff)
tools/clang/codesearch: support building with -Wchanges-meaning
When compiling with the changes-meaning flag, syz-codesearch gets a bunch of errors such as this one: codesearch.cpp:30:15: error: declaration of ‘clang::SourceRange MacroDef::SourceRange’ changes meaning of ‘SourceRange’ [-Wchanges-meaning] 30 | SourceRange SourceRange; // soruce range of the value | ^~~~~~~~~~~ codesearch.cpp:30:3: note: used here to mean ‘class clang::SourceRange’ 30 | SourceRange SourceRange; // soruce range of the value | ^~~~~~~~~~~ Let's iron them out early before the code base grows too reliant on this pattern.
-rw-r--r--tools/clang/codesearch/codesearch.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/clang/codesearch/codesearch.cpp b/tools/clang/codesearch/codesearch.cpp
index 8895d5307..80c9f012a 100644
--- a/tools/clang/codesearch/codesearch.cpp
+++ b/tools/clang/codesearch/codesearch.cpp
@@ -26,18 +26,18 @@ using namespace clang;
// MacroDef/MacroMap hold information about macros defined in the file.
struct MacroDef {
- std::string Value; // value as written in the source
- SourceRange SourceRange; // soruce range of the value
+ std::string Value; // value as written in the source
+ SourceRange Range; // soruce range of the value
};
using MacroMap = std::unordered_map<std::string, MacroDef>;
class Instance : public tooling::SourceFileCallbacks {
public:
- Instance(Output& Output) : Output(Output) {}
+ Instance(Output& Output) : Out(Output) {}
std::unique_ptr<ASTConsumer> newASTConsumer();
private:
- Output& Output;
+ Output& Out;
MacroMap Macros;
bool handleBeginSource(CompilerInstance& CI) override;
@@ -57,10 +57,10 @@ private:
class IndexerAstConsumer : public ASTConsumer {
public:
- IndexerAstConsumer(Output& Output, const MacroMap& Macros) : Output(Output), Macros(Macros) {}
+ IndexerAstConsumer(Output& Output, const MacroMap& Macros) : Out(Output), Macros(Macros) {}
private:
- Output& Output;
+ Output& Out;
const MacroMap& Macros;
void HandleTranslationUnit(ASTContext& context) override;
@@ -69,14 +69,14 @@ private:
class Indexer : public RecursiveASTVisitor<Indexer> {
public:
Indexer(ASTContext& Context, Output& Output, const MacroMap& Macros)
- : Context(Context), SM(Context.getSourceManager()), Output(Output) {}
+ : Context(Context), SM(Context.getSourceManager()), Out(Output) {}
bool VisitFunctionDecl(const FunctionDecl*);
private:
ASTContext& Context;
SourceManager& SM;
- Output& Output;
+ Output& Out;
};
bool Instance::handleBeginSource(CompilerInstance& CI) {
@@ -85,10 +85,10 @@ bool Instance::handleBeginSource(CompilerInstance& CI) {
return true;
}
-std::unique_ptr<ASTConsumer> Instance::newASTConsumer() { return std::make_unique<IndexerAstConsumer>(Output, Macros); }
+std::unique_ptr<ASTConsumer> Instance::newASTConsumer() { return std::make_unique<IndexerAstConsumer>(Out, Macros); }
void IndexerAstConsumer::HandleTranslationUnit(ASTContext& Context) {
- Indexer Indexer(Context, Output, Macros);
+ Indexer Indexer(Context, Out, Macros);
Indexer.TraverseDecl(Context.getTranslationUnitDecl());
}
@@ -115,7 +115,7 @@ bool Indexer::VisitFunctionDecl(const FunctionDecl* Func) {
EndLine = std::max(EndLine, CommentEndLine);
}
}
- Output.emit(Definition{
+ Out.emit(Definition{
.Kind = KindFunction,
.Name = Func->getNameAsString(),
.Type = Func->getType().getAsString(),