]> granicus.if.org Git - clang/commitdiff
change FullSourceLoc to have a *const* SourceManager&, eliminating
authorChris Lattner <sabre@nondot.org>
Tue, 20 Apr 2010 20:49:23 +0000 (20:49 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 20 Apr 2010 20:49:23 +0000 (20:49 +0000)
a const_cast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101940 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceLocation.h
include/clang/Frontend/TextDiagnosticPrinter.h
lib/Basic/SourceManager.cpp
lib/Frontend/TextDiagnosticPrinter.cpp

index 555e6f5a919a126b6fc3b0c6d2ddee3ff153d039..0bbeffefc725eff2c827892a9076066c1eb9c4e5 100644 (file)
@@ -176,19 +176,14 @@ public:
 /// FullSourceLoc - A SourceLocation and its associated SourceManager.  Useful
 /// for argument passing to functions that expect both objects.
 class FullSourceLoc : public SourceLocation {
-  SourceManager* SrcMgr;
+  const SourceManager *SrcMgr;
 public:
   /// Creates a FullSourceLoc where isValid() returns false.
-  explicit FullSourceLoc() : SrcMgr((SourceManager*) 0) {}
+  explicit FullSourceLoc() : SrcMgr(0) {}
 
-  explicit FullSourceLoc(SourceLocation Loc, SourceManager &SM)
+  explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
     : SourceLocation(Loc), SrcMgr(&SM) {}
 
-  SourceManager &getManager() {
-    assert(SrcMgr && "SourceManager is NULL.");
-    return *SrcMgr;
-  }
-
   const SourceManager &getManager() const {
     assert(SrcMgr && "SourceManager is NULL.");
     return *SrcMgr;
index 157876b59d347a096d4fcc2c0916cf50b63b8cd2..336713661a28a30f38e9ee893d726bf033658c1a 100644 (file)
@@ -68,7 +68,7 @@ public:
 
   void EmitCaretDiagnostic(SourceLocation Loc,
                            SourceRange *Ranges, unsigned NumRanges,
-                           SourceManager &SM,
+                           const SourceManager &SM,
                            const FixItHint *Hints,
                            unsigned NumHints,
                            unsigned Columns);
index 355b87a9dd7af229776fe14492cbec03573dbefb..3ecab1d8c16fceb94e06c2c769ffa922c052a259 100644 (file)
@@ -60,7 +60,7 @@ void ContentCache::replaceBuffer(const llvm::MemoryBuffer *B) {
 }
 
 const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag,
-                                                  const SourceManager &sm,
+                                                  const SourceManager &SM,
                                                   SourceLocation Loc,
                                                   bool *Invalid) const {
   if (Invalid)
@@ -68,9 +68,6 @@ const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag,
       
   // Lazily create the Buffer for ContentCaches that wrap files.
   if (!Buffer.getPointer() && Entry) {
-    // FIXME:
-    SourceManager &SM = const_cast<SourceManager &>(sm);
-    
     std::string ErrorStr;
     struct stat FileInfo;
     Buffer.setPointer(MemoryBuffer::getFile(Entry->getName(), &ErrorStr,
index f2b16a4b386966957086d4f4af22abe2a776e43b..28bb17ac3efa9ab1c196bf300ce7af04d39c91b3 100644 (file)
@@ -282,7 +282,7 @@ static void SelectInterestingSourceRegion(std::string &SourceLine,
 void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
                                                 SourceRange *Ranges,
                                                 unsigned NumRanges,
-                                                SourceManager &SM,
+                                                const SourceManager &SM,
                                                 const FixItHint *Hints,
                                                 unsigned NumHints,
                                                 unsigned Columns) {