[PATCH] D43174: [clang-move] Fix the incorrect expansion end location.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 12 04:29:12 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL324886: [clang-move] Fix the incorrect expansion end location. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43174

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp


Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -431,12 +431,16 @@
 
 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";
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===================================================================
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -280,7 +280,7 @@
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43174.133833.patch
Type: text/x-patch
Size: 1881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180212/9359917c/attachment.bin>


More information about the cfe-commits mailing list