================
@@ -66,22 +89,45 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder 
*Finder) {
                            hasParent(varDecl(isExternC())),
                            hasParent(fieldDecl(
                                hasParent(recordDecl(isExternCContext())))),
-                           hasAncestor(functionDecl(isExternC())))),
+                           hasAncestor(functionDecl(isExternC())),
+                           isWithinImplicitTemplateInstantiation())),
               std::move(IgnoreStringArrayIfNeededMatcher))
           .bind("typeloc"),
       this);
+
+  Finder->addMatcher(templateArgumentLoc(hasTypeLoc(hasType(arrayType())))
+                         .bind("template_arg_with_array_type_loc"),
+                     this);
 }
 
 void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
-  const auto *ArrayType = Result.Nodes.getNodeAs<TypeLoc>("typeloc");
+  TypeLoc ArrayTypeLoc{};
+
+  if (const auto *MatchedTypeLoc = Result.Nodes.getNodeAs<TypeLoc>("typeloc");
+      MatchedTypeLoc != nullptr) {
----------------
vbvictor wrote:

```suggestion
  if (const auto *MatchedTypeLoc = Result.Nodes.getNodeAs<TypeLoc>("typeloc")) {
```
`operator=` already return `MatchedTypeLoc` and we check it for null

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