Browse Source

Use switch instead of series of comparisons

This is style correction, no functional changes.

Differential Revision: https://reviews.llvm.org/D65670

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367759 91177308-0d34-0410-b5e6-96231b3b80d8
Serge Pavlov 6 năm trước cách đây
mục cha
commit
1a1c8f42c6
2 tập tin đã thay đổi với 11 bổ sung7 xóa
  1. 1 7
      include/clang/Basic/TokenKinds.h
  2. 10 0
      lib/Basic/TokenKinds.cpp

+ 1 - 7
include/clang/Basic/TokenKinds.h

@@ -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);

+ 10 - 0
lib/Basic/TokenKinds.cpp

@@ -46,6 +46,16 @@ const char *tok::getKeywordSpelling(TokenKind Kind) {
   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;