forked from OSchip/llvm-project
[clang-format] Avoid considering include directive as a template closer.
This fixes a bug [[ http://llvm.org/PR48891 | PR48891 ]] introduced in D93839 where: ``` #include <stdint.h> namespace rep {} ``` got formatted as ``` #include <stdint.h> namespace rep { } ``` Reviewed By: MyDeveloperDay, leonardchan Differential Revision: https://reviews.llvm.org/D95479
This commit is contained in:
parent
b6d87e6a92
commit
e3713f156b
|
@ -371,7 +371,7 @@ private:
|
|||
if (Previous->is(tok::comment))
|
||||
Previous = Previous->getPreviousNonComment();
|
||||
if (Previous) {
|
||||
if (Previous->is(tok::greater))
|
||||
if (Previous->is(tok::greater) && !I[-1]->InPPDirective)
|
||||
return 0;
|
||||
if (Previous->is(tok::identifier)) {
|
||||
const FormatToken *PreviousPrevious =
|
||||
|
|
|
@ -10248,6 +10248,21 @@ TEST_F(FormatTest, SplitEmptyClass) {
|
|||
"{\n"
|
||||
"};",
|
||||
Style);
|
||||
|
||||
verifyFormat("#include \"stdint.h\"\n"
|
||||
"namespace rep {}",
|
||||
Style);
|
||||
verifyFormat("#include <stdint.h>\n"
|
||||
"namespace rep {}",
|
||||
Style);
|
||||
verifyFormat("#include <stdint.h>\n"
|
||||
"namespace rep {}",
|
||||
"#include <stdint.h>\n"
|
||||
"namespace rep {\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"}",
|
||||
Style);
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, SplitEmptyStruct) {
|
||||
|
|
Loading…
Reference in New Issue