TargetInfo no longer includes a reference to SourceManager.

Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation.
Added many utility methods to FullSourceLoc to provide shorthand for:

    FullLoc.getManager().someMethod(FullLoc.getLocation());
    
instead we have:

    FullLoc.someMethod();
    
Modified TextDiagnostics (and related classes) to use this short-hand.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44957 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Basic/Diagnostic.cpp b/Basic/Diagnostic.cpp
index 36da1e2..2d99814 100644
--- a/Basic/Diagnostic.cpp
+++ b/Basic/Diagnostic.cpp
@@ -197,8 +197,7 @@
 /// Report - Issue the message to the client. If the client wants us to stop
 /// compilation, return true, otherwise return false.  DiagID is a member of
 /// the diag::kind enum.  
-void Diagnostic::Report(SourceLocation Pos, unsigned DiagID,
-                        SourceManager* SrcMgr,
+void Diagnostic::Report(FullSourceLoc Pos, unsigned DiagID,
                         const std::string *Strs, unsigned NumStrs,
                         const SourceRange *Ranges, unsigned NumRanges) {
   // Figure out the diagnostic level of this message.
@@ -214,11 +213,11 @@
   }
 
   // Are we going to ignore this diagnosic?
-  if (Client.IgnoreDiagnostic(DiagLevel, Pos, SrcMgr))
+  if (Client.IgnoreDiagnostic(DiagLevel, Pos))
     return;
 
   // Finally, report it.
-  Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID, SrcMgr,
+  Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID,
                           Strs, NumStrs, Ranges, NumRanges);
   ++NumDiagnostics;
 }
diff --git a/Basic/SourceLocation.cpp b/Basic/SourceLocation.cpp
index 75b4a99..d7f3456 100644
--- a/Basic/SourceLocation.cpp
+++ b/Basic/SourceLocation.cpp
@@ -8,10 +8,12 @@
 //===----------------------------------------------------------------------===//
 //
 //  This file defines serialization methods for the SourceLocation class.
+//  This file defines accessor methods for the FullSourceLoc class.
 //
 //===----------------------------------------------------------------------===//
 
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "llvm/Bitcode/Serialize.h"
 #include "llvm/Bitcode/Deserialize.h"
 
@@ -35,3 +37,43 @@
   SourceLocation B = SourceLocation::ReadVal(D);
   return SourceRange(A,B);
 }
+
+FullSourceLoc FullSourceLoc::getLogicalLoc() {
+  assert (isValid());
+  return FullSourceLoc(SrcMgr->getLogicalLoc(Loc),*SrcMgr);
+}
+
+FullSourceLoc FullSourceLoc::getIncludeLoc() {
+  assert (isValid());
+  return FullSourceLoc(SrcMgr->getIncludeLoc(Loc),*SrcMgr);
+}
+
+unsigned FullSourceLoc::getLineNumber() {
+  assert (isValid());
+  return SrcMgr->getLineNumber(Loc);
+}
+
+unsigned FullSourceLoc::getColumnNumber() {
+  assert (isValid());
+  return SrcMgr->getColumnNumber(Loc);
+}
+
+const char* FullSourceLoc::getSourceName() const {
+  assert (isValid());
+  return SrcMgr->getSourceName(Loc);
+}
+
+const FileEntry* FullSourceLoc::getFileEntryForLoc() const { 
+  assert (isValid());
+  return SrcMgr->getFileEntryForLoc(Loc);
+}
+
+const char * FullSourceLoc::getCharacterData() const {
+  assert (isValid());
+  return SrcMgr->getCharacterData(Loc);
+}
+
+const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
+  assert (isValid());
+  return SrcMgr->getBuffer(Loc.getFileID());
+}
diff --git a/Basic/TargetInfo.cpp b/Basic/TargetInfo.cpp
index 63b3cf8..4c9d1c8 100644
--- a/Basic/TargetInfo.cpp
+++ b/Basic/TargetInfo.cpp
@@ -29,20 +29,20 @@
 
 void TargetInfo::getFloatInfo(uint64_t &Size, unsigned &Align,
                               const llvm::fltSemantics *&Format,
-                              SourceLocation Loc) {
+                              FullSourceLoc Loc) {
   Align = 32;  // FIXME: implement correctly.
   Size = 32;
   Format = &llvm::APFloat::IEEEsingle;
 }
 void TargetInfo::getDoubleInfo(uint64_t &Size, unsigned &Align,
                                const llvm::fltSemantics *&Format,
-                               SourceLocation Loc) {
+                               FullSourceLoc Loc) {
   Size = Align = 64;  // FIXME: implement correctly.
   Format = &llvm::APFloat::IEEEdouble;
 }
 void TargetInfo::getLongDoubleInfo(uint64_t &Size, unsigned &Align,
                                    const llvm::fltSemantics *&Format,
-                                   SourceLocation Loc) {
+                                   FullSourceLoc Loc) {
   Size = Align = 64;  // FIXME: implement correctly.
   Format = &llvm::APFloat::IEEEdouble;
   //Size = 80; Align = 32;  // FIXME: implement correctly.
@@ -63,9 +63,10 @@
 /// DiagnoseNonPortability - When a use of a non-portable target feature is
 /// used, this method emits the diagnostic and marks the translation unit as
 /// non-portable.
-void TargetInfo::DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind) {
+void TargetInfo::DiagnoseNonPortability(FullSourceLoc Loc,
+                                        unsigned DiagKind) {
   NonPortable = true;
-  if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind, SrcMgr);
+  if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind);
 }
 
 /// GetTargetDefineMap - Get the set of target #defines in an associative
@@ -196,7 +197,7 @@
 /// ComputeWCharWidth - Determine the width of the wchar_t type for the primary
 /// target, diagnosing whether this is non-portable across the secondary
 /// targets.
-void TargetInfo::ComputeWCharInfo(SourceLocation Loc) {
+void TargetInfo::ComputeWCharInfo(FullSourceLoc Loc) {
   PrimaryTarget->getWCharInfo(WCharWidth, WCharAlign);
   
   // Check whether this is portable across the secondary targets if the T-U is
diff --git a/Basic/Targets.cpp b/Basic/Targets.cpp
index ed29c90..9b18290 100644
--- a/Basic/Targets.cpp
+++ b/Basic/Targets.cpp
@@ -699,8 +699,7 @@
 
 /// CreateTargetInfo - Return the set of target info objects as specified by
 /// the -arch command line option.
-TargetInfo* TargetInfo::CreateTargetInfo(SourceManager& SrcMgr,
-                                         const std::string* TriplesStart,
+TargetInfo* TargetInfo::CreateTargetInfo(const std::string* TriplesStart,
                                          const std::string* TriplesEnd,
                                          Diagnostic *Diags) {
 
@@ -710,7 +709,7 @@
   if (!PrimaryTarget)
     return NULL;
   
-  TargetInfo *TI = new TargetInfo(SrcMgr, PrimaryTarget, Diags);
+  TargetInfo *TI = new TargetInfo(PrimaryTarget, Diags);
   
   // Add all secondary targets.
   for (const std::string* I=TriplesStart+1; I != TriplesEnd; ++I) {