]> granicus.if.org Git - clang/commitdiff
clang-format: Fix assertion when trying to build a nullptr StringRef.
authorDaniel Jasper <djasper@google.com>
Mon, 19 Jan 2015 10:51:05 +0000 (10:51 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 19 Jan 2015 10:51:05 +0000 (10:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226448 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index 00dc1bda5382b1e6e6344166cce853d0f9267f13..23b9d550fb1d28cead1cd71a4366e3b974aad965 100644 (file)
@@ -549,6 +549,7 @@ void UnwrappedLineParser::conditionalCompilationEnd() {
 void UnwrappedLineParser::parsePPIf(bool IfDef) {
   nextToken();
   bool IsLiteralFalse = (FormatTok->Tok.isLiteral() &&
+                         FormatTok->Tok.getLiteralData() != nullptr &&
                          StringRef(FormatTok->Tok.getLiteralData(),
                                    FormatTok->Tok.getLength()) == "0") ||
                         FormatTok->Tok.is(tok::kw_false);
index 5f8fba26e5a4922e745a42e3f23558d188a5c6e7..7987e58790a737b59b40a82eee6e9a2629346ec6 100644 (file)
@@ -2600,6 +2600,7 @@ TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) {
                "    y)), // expected-warning",
                getLLVMStyleWithColumns(28));
   verifyFormat("#d, = };");
+  verifyFormat("#if \"a");
 }
 
 TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {