Author: Baranov Victor Date: 2025-11-21T23:29:27+03:00 New Revision: a52e1af7f766e26a78d10d31da98af041dd66410
URL: https://github.com/llvm/llvm-project/commit/a52e1af7f766e26a78d10d31da98af041dd66410 DIFF: https://github.com/llvm/llvm-project/commit/a52e1af7f766e26a78d10d31da98af041dd66410.diff LOG: [ASTMatchers] Make isExpandedFromMacro accept llvm::StringRef (#167060) We can use non-owning `StringRef` in `MacroName` parameter to avoid unnecessary copy because `MacroName` only used as an argument to `internal::getExpansionLocOfMacro` which already accept `StringRef`. Added: Modified: clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp clang/docs/LibASTMatchersReference.html clang/include/clang/ASTMatchers/ASTMatchers.h Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp index a9e6a4b9ea9bb..35f952602a3dd 100644 --- a/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp +++ b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp @@ -25,7 +25,7 @@ void AssertEqualsCheck::registerMatchers(MatchFinder *Finder) { for (const auto &[CurrName, _] : NameMap) { Finder->addMatcher( binaryOperator(anyOf(hasOperatorName("!="), hasOperatorName("==")), - isExpandedFromMacro(std::string(CurrName)), + isExpandedFromMacro(CurrName), anyOf(hasLHS(hasType(qualType( hasCanonicalType(asString("NSString *"))))), hasRHS(hasType(qualType( diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index ac1abb4d9f381..2db0c72c9a931 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -4222,7 +4222,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> </pre></td></tr> -<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpandedFromMacro0')"><a name="isExpandedFromMacro0Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpandedFromMacro0')"><a name="isExpandedFromMacro0Anchor">isExpandedFromMacro</a></td><td>StringRef MacroName</td></tr> <tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro. Does not match if only part of the statement is expanded from that macro or if diff erent parts of the statement are expanded from diff erent @@ -5643,7 +5643,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> </pre></td></tr> -<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpandedFromMacro1')"><a name="isExpandedFromMacro1Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpandedFromMacro1')"><a name="isExpandedFromMacro1Anchor">isExpandedFromMacro</a></td><td>StringRef MacroName</td></tr> <tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro. Does not match if only part of the statement is expanded from that macro or if diff erent parts of the statement are expanded from diff erent @@ -5843,7 +5843,7 @@ <h2 id="narrowing-matchers">Narrowing Matchers</h2> </pre></td></tr> -<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpandedFromMacro2')"><a name="isExpandedFromMacro2Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpandedFromMacro2')"><a name="isExpandedFromMacro2Anchor">isExpandedFromMacro</a></td><td>StringRef MacroName</td></tr> <tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro. Does not match if only part of the statement is expanded from that macro or if diff erent parts of the statement are expanded from diff erent diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index bca2d8425b3f5..5d3be8e06bd42 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -330,7 +330,7 @@ AST_POLYMORPHIC_MATCHER_REGEX(isExpansionInFileMatching, /// appearances of the macro. AST_POLYMORPHIC_MATCHER_P(isExpandedFromMacro, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc), - std::string, MacroName) { + StringRef, MacroName) { // Verifies that the statement' beginning and ending are both expanded from // the same instance of the given macro. auto& Context = Finder->getASTContext(); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
