[PATCH] D65670: Use switch instead of series of comparisons
Serge Pavlov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 11:38:32 PDT 2019
sepavloff created this revision.
sepavloff added reviewers: rjmccall, alexfh.
Herald added a project: clang.
This is style correction, no functional changes.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D65670
Files:
clang/include/clang/Basic/TokenKinds.h
clang/lib/Basic/TokenKinds.cpp
Index: clang/lib/Basic/TokenKinds.cpp
===================================================================
--- clang/lib/Basic/TokenKinds.cpp
+++ clang/lib/Basic/TokenKinds.cpp
@@ -46,6 +46,16 @@
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;
Index: clang/include/clang/Basic/TokenKinds.h
===================================================================
--- clang/include/clang/Basic/TokenKinds.h
+++ clang/include/clang/Basic/TokenKinds.h
@@ -90,13 +90,7 @@
}
/// 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65670.213100.patch
Type: text/x-patch
Size: 1155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190802/686f7296/attachment-0001.bin>
More information about the cfe-commits
mailing list