[PATCH] D72505: [ASTMatchers] extract public matchers from const-analysis into own patch

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 10 07:52:52 PST 2020


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4207-4208
+  if (const auto *Call = dyn_cast<CallExpr>(&Node)) {
+    if (const Decl *Callee = Call->getCalleeDecl()) {
+      if (const auto *Value = dyn_cast<ValueDecl>(Callee)) {
+        QualType QT = Value->getType();
----------------
`if (const auto *Value = dyn_cast_or_null<ValueDecl>(Call->getCalleeDecl())) { ... }`


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4209
+      if (const auto *Value = dyn_cast<ValueDecl>(Callee)) {
+        QualType QT = Value->getType();
+
----------------
Should you be getting the canonical type here? That would skip over things like paren types and typedefs.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4214-4215
+          FProto = FPT->getAs<FunctionProtoType>();
+          assert(FProto &&
+                 "The call must have happened through a function pointer");
+        }
----------------
This seems like an invalid assertion -- K&R C functions would have a function pointer type but not a prototype, for instance.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4243
+      if (FProto) {
+        QualType ParamType = FProto->getParamType(ParamIndex);
+        if (ParamMatcher.matches(ParamType, Finder, &ParamMatches)) {
----------------
Should we be canonicalizing this type as well?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72505/new/

https://reviews.llvm.org/D72505





More information about the cfe-commits mailing list