Skip to content

Commit 7f40c5c

Browse files
committed
Reland "[clang-format] Update FormatToken::isSimpleTypeSpecifier() (#80241)"
1 parent 33108fa commit 7f40c5c

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

clang/lib/Format/FormatToken.cpp

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
#include "FormatToken.h"
1616
#include "ContinuationIndenter.h"
17-
#include "llvm/ADT/SmallVector.h"
18-
#include "llvm/Support/Debug.h"
19-
#include <climits>
17+
#include "TokenAnalyzer.h"
2018

2119
namespace clang {
2220
namespace format {
@@ -34,41 +32,9 @@ const char *getTokenTypeName(TokenType Type) {
3432
return nullptr;
3533
}
3634

37-
// FIXME: This is copy&pasted from Sema. Put it in a common place and remove
38-
// duplication.
3935
bool FormatToken::isSimpleTypeSpecifier() const {
40-
switch (Tok.getKind()) {
41-
case tok::kw_short:
42-
case tok::kw_long:
43-
case tok::kw___int64:
44-
case tok::kw___int128:
45-
case tok::kw_signed:
46-
case tok::kw_unsigned:
47-
case tok::kw_void:
48-
case tok::kw_char:
49-
case tok::kw_int:
50-
case tok::kw_half:
51-
case tok::kw_float:
52-
case tok::kw_double:
53-
case tok::kw___bf16:
54-
case tok::kw__Float16:
55-
case tok::kw___float128:
56-
case tok::kw___ibm128:
57-
case tok::kw_wchar_t:
58-
case tok::kw_bool:
59-
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
60-
#include "clang/Basic/TransformTypeTraits.def"
61-
case tok::annot_typename:
62-
case tok::kw_char8_t:
63-
case tok::kw_char16_t:
64-
case tok::kw_char32_t:
65-
case tok::kw_typeof:
66-
case tok::kw_decltype:
67-
case tok::kw__Atomic:
68-
return true;
69-
default:
70-
return false;
71-
}
36+
assert(LangOpts.CPlusPlus);
37+
return Tok.isSimpleTypeSpecifier(LangOpts);
7238
}
7339

7440
bool FormatToken::isTypeOrIdentifier() const {

0 commit comments

Comments
 (0)