diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html --- a/clang/docs/LibASTMatchersReference.html +++ b/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"). diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/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; } diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h +++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h @@ -170,7 +170,7 @@ private: static Optional getCastKind(llvm::StringRef AttrKind) { return llvm::StringSwitch>(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); } diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp +++ b/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; }