[clang] [ASTMatcher] Fix redundant macro expansion checks in getExpansionLocOfMacro (PR #117143)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 26 05:28:19 PST 2024


================
@@ -697,27 +698,61 @@ static bool isTokenAtLoc(const SourceManager &SM, const LangOptions &LangOpts,
   return !Invalid && Text == TokenText;
 }
 
-std::optional<SourceLocation>
-getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
-                       const ASTContext &Context) {
+namespace {
+struct SourceLocationHash {
+  std::size_t operator()(const SourceLocation &Loc) const {
----------------
AaronBallman wrote:

```suggestion
  std::size_t operator()(SourceLocation Loc) const {
```
A `SourceLocation` is a 32-bit value, so no need to pass by const reference. The same change can be made elsewhere in the patch.

https://github.com/llvm/llvm-project/pull/117143


More information about the cfe-commits mailing list