This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Add support for dynamic matching of ofKind narrowing matcher
ClosedPublic

Authored by njames93 on Apr 9 2020, 4:44 AM.

Details

Summary

Adds support for using the ofKind in clang-query and other dynamic matcher use cases

Diff Detail

Event Timeline

njames93 created this revision.Apr 9 2020, 4:44 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thank you for this! It basically LG, but can you also add a dynamic matcher unit test for this functionality?

clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
102–106

Did clang-format produce this formatting?

107

Elide braces

clang/lib/ASTMatchers/Dynamic/Marshallers.h
222

Typetraits - > Type traits
Also, missing a full stop at the end of the comment.

njames93 updated this revision to Diff 256262.Apr 9 2020, 5:41 AM
njames93 marked 4 inline comments as done.

Added test cases and address nits

clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
102–106

when I ran git-clang-format I dont think it did, but when i went to upload the patch i got this in the pre-upload linting

--- /home/nathan/src/llvm-project/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp 2020-04-09 12:12:28.810339833 +0100
+++ /tmp/6p7zxlltj4g8wgcc/9888-onMes8   2020-04-09 12:44:11.187257096 +0100
@@ -99,11 +99,11 @@
 llvm::Optional<std::string>
 clang::ast_matchers::dynamic::internal::ArgTypeTraits<
     clang::UnaryExprOrTypeTrait>::getBestGuess(const VariantValue &Value) {
-  static constexpr llvm::StringRef Allowed[] = {"UETT_SizeOf",
-                                                "UETT_AlignOf",
-                                                "UETT_VecStep",
-                                                "UETT_OpenMPRequiredSimdAlign",
-                                                "UETT_PreferredAlignOf",};
+  static constexpr llvm::StringRef Allowed[] = {
+      "UETT_SizeOf",           "UETT_AlignOf",
+      "UETT_VecStep",          "UETT_OpenMPRequiredSimdAlign",
+      "UETT_PreferredAlignOf",
+  };
aaron.ballman accepted this revision.Apr 9 2020, 6:05 AM

LGTM, thank you!

clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
102–106

I think the pre-upload linting is wrong (I can't find many instances of lists that look like that in LLVM anyway, but I know of plenty of instances of the other style). Not a huge deal though.

This revision is now accepted and ready to land.Apr 9 2020, 6:05 AM
njames93 marked an inline comment as done.Apr 9 2020, 6:34 AM
njames93 added inline comments.
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
102–106

I tried to manually invoke clang-format on it (using trunk) and it suggested the same format

This revision was automatically updated to reflect the committed changes.