[clang] f5d71b7 - Reland "[clang-format][NFC] Make LangOpts global in namespace Format (#81390)"

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 12 00:04:41 PST 2024


Author: Owen Pan
Date: 2024-02-12T00:04:34-08:00
New Revision: f5d71b79fe978f1e70f4a41adfd15f65dec6e210

URL: https://github.com/llvm/llvm-project/commit/f5d71b79fe978f1e70f4a41adfd15f65dec6e210
DIFF: https://github.com/llvm/llvm-project/commit/f5d71b79fe978f1e70f4a41adfd15f65dec6e210.diff

LOG: Reland "[clang-format][NFC] Make LangOpts global in namespace Format (#81390)"

Added: 
    

Modified: 
    clang/lib/Format/FormatToken.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index b791c5a26bbe3..33bcde3c25ece 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -14,9 +14,7 @@
 
 #include "FormatToken.h"
 #include "ContinuationIndenter.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Debug.h"
-#include <climits>
+#include "TokenAnalyzer.h"
 
 namespace clang {
 namespace format {
@@ -34,41 +32,9 @@ const char *getTokenTypeName(TokenType Type) {
   return nullptr;
 }
 
-// FIXME: This is copy&pasted from Sema. Put it in a common place and remove
-// duplication.
 bool FormatToken::isSimpleTypeSpecifier() const {
-  switch (Tok.getKind()) {
-  case tok::kw_short:
-  case tok::kw_long:
-  case tok::kw___int64:
-  case tok::kw___int128:
-  case tok::kw_signed:
-  case tok::kw_unsigned:
-  case tok::kw_void:
-  case tok::kw_char:
-  case tok::kw_int:
-  case tok::kw_half:
-  case tok::kw_float:
-  case tok::kw_double:
-  case tok::kw___bf16:
-  case tok::kw__Float16:
-  case tok::kw___float128:
-  case tok::kw___ibm128:
-  case tok::kw_wchar_t:
-  case tok::kw_bool:
-#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
-#include "clang/Basic/TransformTypeTraits.def"
-  case tok::annot_typename:
-  case tok::kw_char8_t:
-  case tok::kw_char16_t:
-  case tok::kw_char32_t:
-  case tok::kw_typeof:
-  case tok::kw_decltype:
-  case tok::kw__Atomic:
-    return true;
-  default:
-    return false;
-  }
+  assert(LangOpts.CPlusPlus);
+  return Tok.isSimpleTypeSpecifier(LangOpts);
 }
 
 bool FormatToken::isTypeOrIdentifier() const {


        


More information about the cfe-commits mailing list