summaryrefslogtreecommitdiffstats
path: root/lib/Format/FormatToken.cpp
diff options
context:
space:
mode:
authorBirunthan Mohanathas <birunthan@mohanathas.com>2015-07-13 16:19:34 +0000
committerBirunthan Mohanathas <birunthan@mohanathas.com>2015-07-13 16:19:34 +0000
commit44a46fa5a5c8e9d197754e0f4c4a13704f10bcd7 (patch)
treebf3b0374da6302bedd41e25af6829e3a83c43c4f /lib/Format/FormatToken.cpp
parent5ae3c7b7de2242a63d41e3c326c3600477a8fdf0 (diff)
clang-format: Print token type name instead of number in -debug output
Differential Revision: http://reviews.llvm.org/D11125 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242039 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/FormatToken.cpp')
-rw-r--r--lib/Format/FormatToken.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Format/FormatToken.cpp b/lib/Format/FormatToken.cpp
index 316171dc18..6c244c3166 100644
--- a/lib/Format/FormatToken.cpp
+++ b/lib/Format/FormatToken.cpp
@@ -23,6 +23,20 @@
namespace clang {
namespace format {
+const char *getTokenTypeName(TokenType Type) {
+ static const char *const TokNames[] = {
+#define TYPE(X) #X,
+LIST_TOKEN_TYPES
+#undef TYPE
+ nullptr
+ };
+
+ if (Type < NUM_TOKEN_TYPES)
+ return TokNames[Type];
+ llvm_unreachable("unknown TokenType");
+ return nullptr;
+}
+
// FIXME: This is copy&pasted from Sema. Put it in a common place and remove
// duplication.
bool FormatToken::isSimpleTypeSpecifier() const {