diff options
author | Daniel Jasper <djasper@google.com> | 2013-10-24 15:23:11 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-10-24 15:23:11 +0000 |
commit | 472da8644eaaef5911f29f8bff308e2f99c1df81 (patch) | |
tree | 2482492bf14ba86732bdef8a7d3170e3427830dc /clang/unittests/Format/FormatTest.cpp | |
parent | e865d706782d296b4b546d6970d591569716e4da (diff) | |
download | bcm5719-llvm-472da8644eaaef5911f29f8bff308e2f99c1df81.tar.gz bcm5719-llvm-472da8644eaaef5911f29f8bff308e2f99c1df81.zip |
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.
llvm-svn: 193352
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 9b24f040d16..431940938dc 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) { |