Skip to content

Commit 973ace6

Browse files
committed
code review
1 parent f7e79ed commit 973ace6

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

clang/unittests/Tooling/HeaderIncludesTest.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,67 @@ int main() {
675675
EXPECT_EQ(Expected, insert(Code, "<vector>"));
676676
}
677677

678+
TEST_F(HeaderIncludesTest, InsertInGlobalModuleFragmentWithPPIncludes) {
679+
// Ensure header insertions go only in the global module fragment
680+
std::string Code = R"cpp(// comments
681+
682+
// more comments
683+
684+
// some more comments
685+
686+
module;
687+
688+
#include "header.h"
689+
690+
#include <string>
691+
692+
#ifndef MACRO_NAME
693+
#define MACRO_NAME
694+
#endif
695+
696+
// comment
697+
698+
#ifndef MACRO_NAME
699+
#define MACRO_NAME
700+
#endif
701+
702+
// more comment
703+
704+
int main() {
705+
std::vector<int> ints {};
706+
})cpp";
707+
std::string Expected = R"cpp(// comments
708+
709+
// more comments
710+
711+
// some more comments
712+
713+
module;
714+
715+
#include "header.h"
716+
717+
#include <string>
718+
#include <vector>
719+
720+
#ifndef MACRO_NAME
721+
#define MACRO_NAME
722+
#endif
723+
724+
// comment
725+
726+
#ifndef MACRO_NAME
727+
#define MACRO_NAME
728+
#endif
729+
730+
// more comment
731+
732+
int main() {
733+
std::vector<int> ints {};
734+
})cpp";
735+
736+
EXPECT_EQ(Expected, insert(Code, "<vector>"));
737+
}
738+
678739
} // namespace
679740
} // namespace tooling
680741
} // namespace clang

0 commit comments

Comments
 (0)