aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/FormatToken.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein.wu@gmail.com>2024-02-12 15:05:48 +0100
committerHaojian Wu <hokein.wu@gmail.com>2024-02-12 15:24:27 +0100
commit50ed98f1cf2516c59de0351fa683639c937782ea (patch)
tree13929856b12704b17b5a4fe77b19fdca2095a459 /clang/lib/Format/FormatToken.cpp
parentf5fd0deb2371d0bae3bef2563f50e005a140fc6d (diff)
downloadllvm-50ed98f1cf2516c59de0351fa683639c937782ea.zip
llvm-50ed98f1cf2516c59de0351fa683639c937782ea.tar.gz
llvm-50ed98f1cf2516c59de0351fa683639c937782ea.tar.bz2
Revert "Reland "[clang-format] Update FormatToken::isSimpleTypeSpecifier() (#80241)""
The change caused an asan crash when running the `QualifierFixerTest.IsQualifierType` unittest, see details: https://github.com/llvm/llvm-project/pull/80241#issuecomment-1938749844 This reverts commit 7f40c5cc4e15a0a67b031f13370afc342a5dc14b.
Diffstat (limited to 'clang/lib/Format/FormatToken.cpp')
-rw-r--r--clang/lib/Format/FormatToken.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 33bcde3..b791c5a 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -14,7 +14,9 @@
#include "FormatToken.h"
#include "ContinuationIndenter.h"
-#include "TokenAnalyzer.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Debug.h"
+#include <climits>
namespace clang {
namespace format {
@@ -32,9 +34,41 @@ 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 {
- assert(LangOpts.CPlusPlus);
- return Tok.isSimpleTypeSpecifier(LangOpts);
+ 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;
+ }
}
bool FormatToken::isTypeOrIdentifier() const {