[cfe-commits] r173247 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Manuel Klimek
klimek at google.com
Wed Jan 23 02:09:28 PST 2013
Author: klimek
Date: Wed Jan 23 04:09:28 2013
New Revision: 173247
URL: http://llvm.org/viewvc/llvm-project?rev=173247&view=rev
Log:
Fix segfaults in the formatter.
Also: expletive deleted.
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=173247&r1=173246&r2=173247&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Jan 23 04:09:28 2013
@@ -1049,7 +1049,7 @@
break;
case tok::kw_if:
case tok::kw_while:
- if (CurrentToken->is(tok::l_paren)) {
+ if (CurrentToken != NULL && CurrentToken->is(tok::l_paren)) {
next();
if (!parseParens(/*LookForDecls=*/true))
return false;
@@ -1088,7 +1088,7 @@
Tok->Type = TT_BinaryOperator;
break;
case tok::kw_operator:
- if (CurrentToken->is(tok::l_paren)) {
+ if (CurrentToken != NULL && CurrentToken->is(tok::l_paren)) {
CurrentToken->Type = TT_OverloadedOperator;
next();
if (CurrentToken != NULL && CurrentToken->is(tok::r_paren)) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173247&r1=173246&r2=173247&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 23 04:09:28 2013
@@ -1679,11 +1679,16 @@
"/* */someCall(parameter);", getLLVMStyleWithColumns(15)));
}
-TEST_F(FormatTest, Fuck) {
+TEST_F(FormatTest, FormatStarDependingOnContext) {
verifyFormat("void f(int *a);");
verifyFormat("void f() { f(fint * b); }");
}
+TEST_F(FormatTest, SpecialTokensAtEndOfLine) {
+ verifyFormat("while");
+ verifyFormat("operator");
+}
+
//===----------------------------------------------------------------------===//
// Objective-C tests.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list