summaryrefslogtreecommitdiffstats
path: root/clang
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
commit6db1b7ca16729d0f73066dcdf4dc7c2a89ea37f7 (patch)
treef8b5572d1830395d4e6cdfc7cf1833911e94b2f3 /clang
parent0186347c4c0efe83ee1683a2cb437e014ec55b68 (diff)
downloadbcm5719-llvm-6db1b7ca16729d0f73066dcdf4dc7c2a89ea37f7.tar.gz
bcm5719-llvm-6db1b7ca16729d0f73066dcdf4dc7c2a89ea37f7.zip
Add missing clang-format null pointer check..
.. and a test that triggers it in valid albeit questionable code. llvm-svn: 175554
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index d9368c36499..ac7301eebd0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 3a1e9dce95a..05e5d371711 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud