aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-19 20:05:41 +0000
committerDaniel Jasper <djasper@google.com>2013-02-19 20:05:41 +0000
commit03628b86a9c50e066412fb0e49908686ff117378 (patch)
tree3a0a7bbc644a304fceb6d66c93084e9392ea1c2b
parent0be5e567e3a48592fd6b11f88cc77efb20c76f26 (diff)
Add missing clang-format null pointer check..
.. and a test that triggers it in valid albeit questionable code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175554 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/TokenAnnotator.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index d9368c3649..ac7301eebd 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -592,7 +592,8 @@ private:
else
Current.Type = TT_BlockComment;
} else if (Current.is(tok::r_paren)) {
- bool ParensNotExpr = Current.Parent->Type == TT_PointerOrReference ||
+ bool ParensNotExpr = !Current.Parent ||
+ Current.Parent->Type == TT_PointerOrReference ||
Current.Parent->Type == TT_TemplateCloser;
bool ParensCouldEndDecl =
!Current.Children.empty() && (Current.Children[0].is(tok::equal) ||
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 3a1e9dce95..05e5d37171 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -937,6 +937,8 @@ TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) {
getLLVMStyleWithColumns(20));
verifyFormat("#define A template <typename T>");
+ verifyFormat("#define STR(x) #x\n"
+ "f(STR(this_is_a_string_literal{));");
}
TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {