track "just a little more" location information for macro instantiations.
Now instead of just tracking the expansion history, also track the full
range of the macro that got replaced.  For object-like macros, this doesn't
change anything.  For _Pragma and function-like macros, this means we track
the locations of the ')'.

This is required for PR3579 because apparently GCC uses the line of the ')'
of a function-like macro as the location to expand __LINE__ to.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64601 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index e023a91..71bda5b 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -352,7 +352,7 @@
   
   // Use up FileID #0 as an invalid instantiation.
   NextOffset = 0;
-  createInstantiationLoc(SourceLocation(), SourceLocation(), 1);
+  createInstantiationLoc(SourceLocation(),SourceLocation(),SourceLocation(), 1);
 }
 
 /// getOrCreateContentCache - Create or return a cached ContentCache for the
@@ -418,11 +418,11 @@
 /// that a token from SpellingLoc should actually be referenced from
 /// InstantiationLoc.
 SourceLocation SourceManager::createInstantiationLoc(SourceLocation SpellingLoc,
-                                                     SourceLocation InstantLoc,
+                                                     SourceLocation ILocStart,
+                                                     SourceLocation ILocEnd,
                                                      unsigned TokLength) {
-  SLocEntryTable.push_back(SLocEntry::get(NextOffset, 
-                                          InstantiationInfo::get(InstantLoc,
-                                                                 SpellingLoc)));
+  InstantiationInfo II = InstantiationInfo::get(ILocStart,ILocEnd, SpellingLoc);
+  SLocEntryTable.push_back(SLocEntry::get(NextOffset, II));
   assert(NextOffset+TokLength+1 > NextOffset && "Ran out of source locations!");
   NextOffset += TokLength+1;
   return SourceLocation::getMacroLoc(NextOffset-(TokLength+1));
@@ -543,7 +543,8 @@
 getInstantiationLocSlowCase(SourceLocation Loc) const {
   do {
     std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
-    Loc =getSLocEntry(LocInfo.first).getInstantiation().getInstantiationLoc();
+    Loc = getSLocEntry(LocInfo.first).getInstantiation()
+                   .getInstantiationLocStart();
     Loc = Loc.getFileLocWithOffset(LocInfo.second);
   } while (!Loc.isFileID());
 
@@ -568,7 +569,7 @@
   FileID FID;
   SourceLocation Loc;
   do {
-    Loc = E->getInstantiation().getInstantiationLoc();
+    Loc = E->getInstantiation().getInstantiationLocStart();
     
     FID = getFileID(Loc);
     E = &getSLocEntry(FID);
@@ -596,6 +597,16 @@
   return std::make_pair(FID, Offset);
 }
 
+/// getImmediateInstantiationRange - Loc is required to be an instantiation
+/// location.  Return the start/end of the instantiation information.
+std::pair<SourceLocation,SourceLocation>
+SourceManager::getImmediateInstantiationRange(SourceLocation Loc) const {
+  assert(Loc.isMacroID() && "Not an instantiation loc!");
+  const InstantiationInfo &II = getSLocEntry(getFileID(Loc)).getInstantiation();
+  return II.getInstantiationLocRange();
+}
+
+
 
 //===----------------------------------------------------------------------===//
 // Queries about the code at a SourceLocation.