r367759 - Use switch instead of series of comparisons
Serge Pavlov via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 3 09:32:49 PDT 2019
Author: sepavloff
Date: Sat Aug 3 09:32:49 2019
New Revision: 367759
URL: http://llvm.org/viewvc/llvm-project?rev=367759&view=rev
Log:
Use switch instead of series of comparisons
This is style correction, no functional changes.
Differential Revision: https://reviews.llvm.org/D65670
Modified:
cfe/trunk/include/clang/Basic/TokenKinds.h
cfe/trunk/lib/Basic/TokenKinds.cpp
Modified: cfe/trunk/include/clang/Basic/TokenKinds.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.h?rev=367759&r1=367758&r2=367759&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.h (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.h Sat Aug 3 09:32:49 2019
@@ -90,13 +90,7 @@ inline bool isLiteral(TokenKind K) {
}
/// Return true if this is any of tok::annot_* kinds.
-inline bool isAnnotation(TokenKind K) {
-#define ANNOTATION(NAME) \
- if (K == tok::annot_##NAME) \
- return true;
-#include "clang/Basic/TokenKinds.def"
- return false;
-}
+bool isAnnotation(TokenKind K);
/// Return true if this is an annotation token representing a pragma.
bool isPragmaAnnotation(TokenKind K);
Modified: cfe/trunk/lib/Basic/TokenKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TokenKinds.cpp?rev=367759&r1=367758&r2=367759&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TokenKinds.cpp (original)
+++ cfe/trunk/lib/Basic/TokenKinds.cpp Sat Aug 3 09:32:49 2019
@@ -46,6 +46,16 @@ const char *tok::getKeywordSpelling(Toke
return nullptr;
}
+bool tok::isAnnotation(TokenKind Kind) {
+ switch (Kind) {
+#define ANNOTATION(X) case annot_ ## X: return true;
+#include "clang/Basic/TokenKinds.def"
+ default:
+ break;
+ }
+ return false;
+}
+
bool tok::isPragmaAnnotation(TokenKind Kind) {
switch (Kind) {
#define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;
More information about the cfe-commits
mailing list