aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-20 20:49:23 +0000
committerChris Lattner <sabre@nondot.org>2010-04-20 20:49:23 +0000
commit5c5db4e94bd1243ba92563acba51ba66afa94917 (patch)
treef81f78094f722bbea043f73353d8c15717eaadd1
parente127a0d80155b45dafe77f2b4380e5fa111a3345 (diff)
change FullSourceLoc to have a *const* SourceManager&, eliminating
a const_cast. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101940 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/SourceLocation.h11
-rw-r--r--include/clang/Frontend/TextDiagnosticPrinter.h2
-rw-r--r--lib/Basic/SourceManager.cpp5
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp2
4 files changed, 6 insertions, 14 deletions
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h
index 555e6f5a91..0bbeffefc7 100644
--- a/include/clang/Basic/SourceLocation.h
+++ b/include/clang/Basic/SourceLocation.h
@@ -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;
diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h
index 157876b59d..336713661a 100644
--- a/include/clang/Frontend/TextDiagnosticPrinter.h
+++ b/include/clang/Frontend/TextDiagnosticPrinter.h
@@ -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);
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 355b87a9dd..3ecab1d8c1 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -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,
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index f2b16a4b38..28bb17ac3e 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -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) {