[all-commits] [llvm/llvm-project] 2183fe: [clang-format] Parse the else part of `#if 0`
eywdck2l via All-commits
all-commits at lists.llvm.org
Fri Sep 16 06:35:54 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2183fe2160fbcb754893e98829f2bff4d0fccfa3
https://github.com/llvm/llvm-project/commit/2183fe2160fbcb754893e98829f2bff4d0fccfa3
Author: sstwcw <f0gukp2nk at protonmail.com>
Date: 2022-09-16 (Fri, 16 Sep 2022)
Changed paths:
M clang/lib/Format/UnwrappedLineParser.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Parse the else part of `#if 0`
Fixes https://github.com/llvm/llvm-project/issues/57539
Previously things outside of `#if` blocks were parsed as if only the
first branch of the conditional compilation branch existed, unless the
first condition is 0. In that case the outer parts would be parsed as
if nothing inside the conditional parts existed. Now we use the second
conditional branch if the first condition is 0.
Reviewed By: owenpan
Differential Revision: https://reviews.llvm.org/D133647
Commit: e5964223d99a119e4077e3ed1f1322fa2b8cc703
https://github.com/llvm/llvm-project/commit/e5964223d99a119e4077e3ed1f1322fa2b8cc703
Author: sstwcw <f0gukp2nk at protonmail.com>
Date: 2022-09-16 (Fri, 16 Sep 2022)
Changed paths:
M clang/lib/Format/TokenAnnotator.cpp
M clang/lib/Format/TokenAnnotator.h
M clang/lib/Format/UnwrappedLineParser.cpp
M clang/lib/Format/UnwrappedLineParser.h
M clang/unittests/Format/FormatTest.cpp
M clang/unittests/Format/TokenAnnotatorTest.cpp
Log Message:
-----------
[clang-format] Fix template arguments in macros
Fixes https://github.com/llvm/llvm-project/issues/57738
old
```
#define FOO(typeName, realClass) \
{ \
#typeName, foo < FooType>(new foo <realClass>(#typeName)) \
}
```
new
```
#define FOO(typeName, realClass) \
{ #typeName, foo<FooType>(new foo<realClass>(#typeName)) }
```
Previously, when an UnwrappedLine began with a hash in a macro
definition, the program incorrectly assumed the line was a preprocessor
directive. It should be stringification.
The rule in spaceRequiredBefore was added in 8b5297117b. Its purpose is
to add a space in an include directive. It also added a space to a
template opener when the line began with a stringification hash. So we
changed it.
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D133954
Compare: https://github.com/llvm/llvm-project/compare/c9cffdde393f...e5964223d99a
More information about the All-commits
mailing list