================
@@ -83,7 +88,28 @@ namespace {
       return "";
     }
     bool filterMatches(Decl *D) {
-      return getName(D).find(FilterString) != std::string::npos;
+      if (!FilterString.empty() &&
+          getName(D).find(FilterString) == std::string::npos)
+        return false;
+
+      if (!FilterPath.empty()) {
+        const SourceManager &SM = D->getASTContext().getSourceManager();
+
+        SourceLocation Loc = SM.getSpellingLoc(D->getLocation());
----------------
AaronBallman wrote:

I think we want `getPresumedLoc()` because there can be things like line 
directive markers that set the file name explicitly. But this raises a question 
of how to handle declarations formed via macro expansions. e.g.,
```
// In foo.h
#define BLAH(name) int name

// In bar.c
#include "foo.h"

BLAH(x);
```
If the user has `-ast-dump-filter-path=bar.c` I think they'd expect `int x;` to 
be dumped. Going with the spelling location means we'd not dump that 
declaration, going with the expansion location means we would. (Using the 
presumed location would give you the expansion location + any changes due to 
line markers.)

https://github.com/llvm/llvm-project/pull/194266
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to