[PATCH] D47698: [ASTImporter] import macro source locations

Rafael Stahl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 20 04:24:41 PDT 2018


r.stahl added inline comments.


================
Comment at: lib/AST/ASTImporter.cpp:7058
+    const SrcMgr::ExpansionInfo &FromEx = FromSLoc.getExpansion();
+    SourceLocation ToSpLoc = Import(FromEx.getSpellingLoc());
+    SourceLocation ToExLocS = Import(FromEx.getExpansionLocStart());
----------------
martong wrote:
> Let's say we import a `SourceLocation` with `ASTImporter::Import(SourceLocation FromLoc)`.
> That calls into `ASTImporter::Import(FileID FromID)` where we again import other source locations.
> Could the initial `FromLoc` be equal with any of these locations (`FromEx.getSpellingLoc()`, `FromEx.getExpansionLocStart()`) ?
> My understanding is that this is not possible because we cannot have recursive macros, but please confirm.
Yes, that was my understanding as well. If some compiler error is a macro expansion it eventually stops at some point while walking this chain.


================
Comment at: unittests/AST/ASTImporterTest.cpp:1521
 
+static void CompareSourceLocs(SourceLocation Loc1, SourceLocation Loc2,
+                              SourceManager &SM1, SourceManager &SM2) {
----------------
martong wrote:
> Perhaps it would be more concise and less error prone to use a `FullSourceLoc` which wraps one simple `SourceLocation` and a `SourceManager`.
Will do, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47698





More information about the cfe-commits mailing list