[PATCH] D65670: Use switch instead of series of comparisons

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 3 09:32:19 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL367759: Use switch instead of series of comparisons (authored by sepavloff, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65670?vs=213100&id=213192#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65670/new/

https://reviews.llvm.org/D65670

Files:
  cfe/trunk/include/clang/Basic/TokenKinds.h
  cfe/trunk/lib/Basic/TokenKinds.cpp


Index: cfe/trunk/include/clang/Basic/TokenKinds.h
===================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.h
+++ cfe/trunk/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);
Index: cfe/trunk/lib/Basic/TokenKinds.cpp
===================================================================
--- cfe/trunk/lib/Basic/TokenKinds.cpp
+++ cfe/trunk/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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65670.213192.patch
Type: text/x-patch
Size: 1179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190803/16f3c8fe/attachment.bin>


More information about the cfe-commits mailing list