aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-03-18 12:50:26 +0000
committerDaniel Jasper <djasper@google.com>2013-03-18 12:50:26 +0000
commitcf6d76af806f7e1ba97be7b72b31bc78b919e0f0 (patch)
tree172dbf476793ffd92656ff07ffee9a625c7efe0b /lib/Format/TokenAnnotator.cpp
parent74c8b794be93e73ffca42b1dcf70f26c92d9ccfd (diff)
Fix clang-format segfault.
When annotating "lines" starting with ":", clang-format would segfault. This could actually happen in valid code, e.g. #define A : git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177283 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/TokenAnnotator.cpp')
-rw-r--r--lib/Format/TokenAnnotator.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 8267a25d03..4ac4c9b1b8 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -319,6 +319,8 @@ private:
Tok->Type = TT_ObjCMethodSpecifier;
break;
case tok::colon:
+ if (Tok->Parent == NULL)
+ return false;
// Colons from ?: are handled in parseConditional().
if (Tok->Parent->is(tok::r_paren) && Contexts.size() == 1) {
Tok->Type = TT_CtorInitializerColon;