[PATCH] D42273: Add hasTrailingReturn AST matcher
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 19 05:53:34 PST 2018
aaron.ballman added inline comments.
================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:5902
+AST_MATCHER(FunctionDecl, hasTrailingReturn) {
+ return Node.getType()->castAs<FunctionProtoType>()->hasTrailingReturn();
+}
----------------
I think this may cause failed assertions on code like `void f();` when compiled in C mode because that `FunctionDecl` should have a type of `FunctionNoProtoType`. You should use `getAs<FunctionProtoType>()` and test for null.
================
Comment at: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:2121
+ functionDecl(hasTrailingReturn())));
+ EXPECT_TRUE(notMatches("int X() {};", functionDecl(hasTrailingReturn())));
+}
----------------
Spurious semicolon in the test.
https://reviews.llvm.org/D42273
More information about the cfe-commits
mailing list