From c415e709e9926b4aed897b55931f319a5f512e85 Mon Sep 17 00:00:00 2001 From: Nathan James Date: Wed, 16 Dec 2020 01:56:30 +0000 Subject: [PATCH] [ASTMatchers][NFC] Strip prefixes eagerly in dynamic matcher arg traits. --- clang/lib/ASTMatchers/Dynamic/Marshallers.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h index 9758d36..a4f9b7c 100644 --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h +++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h @@ -161,8 +161,10 @@ template <> struct ArgTypeTraits { template <> struct ArgTypeTraits { private: static Optional getAttrKind(llvm::StringRef AttrKind) { + if (!AttrKind.consume_front("attr::")) + return llvm::None; return llvm::StringSwitch>(AttrKind) -#define ATTR(X) .Case("attr::" #X, attr:: X) +#define ATTR(X) .Case(#X, attr::X) #include "clang/Basic/AttrList.inc" .Default(llvm::None); } @@ -189,8 +191,10 @@ public: template <> struct ArgTypeTraits { private: static Optional getCastKind(llvm::StringRef AttrKind) { + if (!AttrKind.consume_front("CK_")) + return llvm::None; return llvm::StringSwitch>(AttrKind) -#define CAST_OPERATION(Name) .Case("CK_" #Name, CK_##Name) +#define CAST_OPERATION(Name) .Case(#Name, CK_##Name) #include "clang/AST/OperationKinds.def" .Default(llvm::None); } @@ -265,11 +269,12 @@ template <> struct ArgTypeTraits { private: static Optional getUnaryOrTypeTraitKind(llvm::StringRef ClauseKind) { + if (!ClauseKind.consume_front("UETT_")) + return llvm::None; return llvm::StringSwitch>(ClauseKind) -#define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) \ - .Case("UETT_" #Name, UETT_##Name) +#define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) .Case(#Name, UETT_##Name) #define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) \ - .Case("UETT_" #Name, UETT_##Name) + .Case(#Name, UETT_##Name) #include "clang/Basic/TokenKinds.def" .Default(llvm::None); } -- 2.7.4