[clang-move] Fix the incorrect expansion end location.
Summary:
Before the fix, if clang-move decides to move the following macro statement, it only moves the first line `DEFINE(A,`.
```
DEFINE(A,
B);
```
Reviewers: ioeric
Reviewed By: ioeric
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D43174
llvm-svn: 324886
This commit is contained in:
@@ -280,7 +280,7 @@ SourceLocation
|
||||
getLocForEndOfDecl(const clang::Decl *D,
|
||||
const LangOptions &LangOpts = clang::LangOptions()) {
|
||||
const auto &SM = D->getASTContext().getSourceManager();
|
||||
auto EndExpansionLoc = SM.getExpansionLoc(D->getLocEnd());
|
||||
auto EndExpansionLoc = SM.getExpansionRange(D->getLocEnd()).second;
|
||||
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(EndExpansionLoc);
|
||||
// Try to load the file buffer.
|
||||
bool InvalidTemp = false;
|
||||
|
||||
@@ -431,12 +431,16 @@ TEST(ClangMove, MacroInFunction) {
|
||||
|
||||
TEST(ClangMove, DefinitionInMacro) {
|
||||
const char TestHeader[] = "#define DEF(CLASS) void CLASS##_::f() {}\n"
|
||||
"class A_ {\nvoid f();\n};\n"
|
||||
"#define DEF2(CLASS, ...) void CLASS##_::f2() {}\n"
|
||||
"class A_ {\nvoid f();\nvoid f2();\n};\n"
|
||||
"class B {};\n";
|
||||
const char TestCode[] = "#include \"foo.h\"\n"
|
||||
"DEF(A)\n";
|
||||
"DEF(A)\n\n"
|
||||
"DEF2(A,\n"
|
||||
" 123)\n";
|
||||
const char ExpectedNewCode[] = "#include \"new_foo.h\"\n\n"
|
||||
"DEF(A)\n";
|
||||
"DEF(A)\n\n"
|
||||
"DEF2(A, 123)\n";
|
||||
move::MoveDefinitionSpec Spec;
|
||||
Spec.Names.push_back("A_");
|
||||
Spec.OldHeader = "foo.h";
|
||||
|
||||
Reference in New Issue
Block a user