[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

Sean Callanan via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 28 10:12:36 PDT 2016


spyffe updated this revision to Diff 76213.
spyffe added a comment.

Updated the corresponding comment.


https://reviews.llvm.org/D26054

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/macro.modulemap
  test/ASTMerge/Inputs/macro1.h
  test/ASTMerge/Inputs/macro1.m
  test/ASTMerge/Inputs/macro2.m
  test/ASTMerge/macro.m


Index: test/ASTMerge/macro.m
===================================================================
--- test/ASTMerge/macro.m
+++ test/ASTMerge/macro.m
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/cache
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -fmodule-map-file=%S/Inputs/macro.modulemap -I%S/Inputs -emit-pch -o %t.1.ast %S/Inputs/macro1.m
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -fmodule-map-file=%S/Inputs/macro.modulemap -I%S/Inputs -emit-pch -o %t.2.ast %S/Inputs/macro2.m
+// RUN: %clang_cc1 -fmodules -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
Index: test/ASTMerge/Inputs/macro2.m
===================================================================
--- test/ASTMerge/Inputs/macro2.m
+++ test/ASTMerge/Inputs/macro2.m
@@ -0,0 +1,5 @@
+void foo();
+
+void bar() {
+  foo();
+}
Index: test/ASTMerge/Inputs/macro1.m
===================================================================
--- test/ASTMerge/Inputs/macro1.m
+++ test/ASTMerge/Inputs/macro1.m
@@ -0,0 +1,5 @@
+ at import macro1;
+
+void foo() {
+  maybeNull(0, 0);
+}
Index: test/ASTMerge/Inputs/macro1.h
===================================================================
--- test/ASTMerge/Inputs/macro1.h
+++ test/ASTMerge/Inputs/macro1.h
@@ -0,0 +1,5 @@
+typedef void *VoidRef;
+
+void maybeNull(
+  int i,
+  __nullable VoidRef *__nullable);
Index: test/ASTMerge/Inputs/macro.modulemap
===================================================================
--- test/ASTMerge/Inputs/macro.modulemap
+++ test/ASTMerge/Inputs/macro.modulemap
@@ -0,0 +1,4 @@
+module macro1 [extern_c] {
+  header "macro1.h"
+  export *
+}
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -6943,10 +6943,10 @@
 
   SourceManager &FromSM = FromContext.getSourceManager();
   
-  // For now, map everything down to its spelling location, so that we
+  // For now, map everything down to its file location, so that we
   // don't have to import macro expansions.
   // FIXME: Import macro expansions!
-  FromLoc = FromSM.getSpellingLoc(FromLoc);
+  FromLoc = FromSM.getFileLoc(FromLoc);
   std::pair<FileID, unsigned> Decomposed = FromSM.getDecomposedLoc(FromLoc);
   SourceManager &ToSM = ToContext.getSourceManager();
   FileID ToFileID = Import(Decomposed.first);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26054.76213.patch
Type: text/x-patch
Size: 2409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161028/6aa00a55/attachment-0001.bin>


More information about the cfe-commits mailing list