aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-24 15:23:11 +0000
committerDaniel Jasper <djasper@google.com>2013-10-24 15:23:11 +0000
commit852bce4ba3c59669a80d4755f07782a3c28c606b (patch)
tree75b0d599471cc954d85613c12108160f2086d234 /unittests
parentde2204b56096e2336d19b1feae8b1be99dfb49fa (diff)
downloadclang-852bce4ba3c59669a80d4755f07782a3c28c606b.tar.gz
clang-format: Properly reset nested AnnotatedLine structure.
This fixes llvm.org/PR17682. Without this patch, the following code leads to invalid reads/writes: DEBUG({ return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; }); #if a #else #endif Because of the #if-#else structure, the code is formatted and annotated twice and becauce of the nested block, the annotated lines form a hierarchical structure. This structure was not properly reset between runs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 9b24f040d1..431940938d 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2333,6 +2333,13 @@ TEST_F(FormatTest, LayoutStatementsAroundPreprocessorDirectives) {
"#if 1\n"
"#else\n"
"#endif\n");
+ verifyFormat("DEBUG({\n"
+ " return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;\n"
+ "});\n"
+ "#if a\n"
+ "#else\n"
+ "#endif");
}
TEST_F(FormatTest, FormatsJoinedLinesOnSubsequentRuns) {