================
@@ -39,6 +39,30 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) {
   return FD ? FD->isMain() : false;
 }
 
+bool isWithinImplicitTemplateInstantiation(const TypeLoc *MatchedTypeLoc,
----------------
vbvictor wrote:

Also, if this function is still needed, we should move it to matchers.
The easy way is to write
```cpp
AST_MATCHER(clang::TypeLoc, isWithinImplicitTemplateInstantiation) {
 ...
}
```
And add it to
```cpp
unless(anyOf(
  hasParent(parmVarDecl(isArgvOfMain())),
  hasParent(varDecl(isExternC())),
  hasParent(fieldDecl(hasParent(recordDecl(isExternCContext())))),
  hasAncestor(functionDecl(isExternC())),
  isWithinImplicitTemplateInstantiation())),
```

But I think that this function should not be even needed because we can write 
something like:
```cpp
AST_POLYMORPHIC_MATCHER(isImplicitTemplateSpecialization,
                        AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl,
                                                        CXXRecordDecl)) {
  return (Node.getTemplateSpecializationKind() == TSK_ImplicitInstantiation);
}

auto IsInImplicitTemplateInstantiation =
      anyOf(hasAncestor(cxxRecordDecl(isImplicitTemplateSpecialization())),
            hasAncestor(functionDecl(isImplicitTemplateSpecialization())),
            hasAncestor(varDecl(isImplicitTemplateSpecialization())));

Finder->addMatcher(
  typeLoc(hasValidBeginLoc(), hasType(arrayType()),
  unless(IsInImplicitTemplateInstantiation),
  //...
```
I guess example will have the same semantics as your function.

 

https://github.com/llvm/llvm-project/pull/132924
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to