[PATCH] D77503: [ASTMatchers] Fixed CastKind being parsed incorrectly for dynamic matchers
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 04:18:31 PDT 2020
njames93 updated this revision to Diff 256237.
njames93 added a comment.
Fixed up documentation for CastKind matcher.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77503/new/
https://reviews.llvm.org/D77503
Files:
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===================================================================
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -170,7 +170,7 @@
private:
static Optional<CastKind> getCastKind(llvm::StringRef AttrKind) {
return llvm::StringSwitch<Optional<CastKind>>(AttrKind)
-#define CAST_OPERATION(Name) .Case( #Name, CK_##Name)
+#define CAST_OPERATION(Name) .Case("CK_" #Name, CK_##Name)
#include "clang/AST/OperationKinds.def"
.Default(llvm::None);
}
Index: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
===================================================================
--- clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
@@ -75,11 +75,12 @@
clang::ast_matchers::dynamic::internal::ArgTypeTraits<
clang::CastKind>::getBestGuess(const VariantValue &Value) {
static constexpr llvm::StringRef Allowed[] = {
-#define CAST_OPERATION(Name) #Name,
+#define CAST_OPERATION(Name) "CK_" #Name,
#include "clang/AST/OperationKinds.def"
};
if (Value.isString())
- return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed));
+ return ::getBestGuess(Value.getString(), llvm::makeArrayRef(Allowed),
+ "CK_");
return llvm::None;
}
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4913,7 +4913,7 @@
/// \endcode
///
/// If the matcher is use from clang-query, CastKind parameter
-/// should be passed as a quoted string. e.g., ofKind("CK_NullToPointer").
+/// should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").
AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
return Node.getCastKind() == Kind;
}
Index: clang/docs/LibASTMatchersReference.html
===================================================================
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2790,7 +2790,7 @@
int *p = 0;
If the matcher is use from clang-query, CastKind parameter
-should be passed as a quoted string. e.g., ofKind("CK_NullToPointer").
+should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").
</pre></td></tr>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77503.256237.patch
Type: text/x-patch
Size: 2397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200409/2e235668/attachment.bin>
More information about the cfe-commits
mailing list