From 4aba25c79aa71d1a21427a5be778198d9d0b698f Mon Sep 17 00:00:00 2001 From: Florent Revest Date: Tue, 20 Jan 2026 18:41:41 +0100 Subject: tools/clang/codesearch: support building with -Wchanges-meaning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tools/clang/codesearch/codesearch.cpp | 22 +++++++++++----------- 1 file 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; class Instance : public tooling::SourceFileCallbacks { public: - Instance(Output& Output) : Output(Output) {} + Instance(Output& Output) : Out(Output) {} std::unique_ptr 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 { 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 Instance::newASTConsumer() { return std::make_unique(Output, Macros); } +std::unique_ptr Instance::newASTConsumer() { return std::make_unique(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(), -- cgit mrf-deployment