From d00406486421143c5e4eb79f9ce97e30442b1ab2 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 18 Nov 2010 20:06:41 +0000 Subject: Refactoring of Diagnostic class. -Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class. -DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units. -The rest of the state in Diagnostic object is considered related and tied to one translation unit. -Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a SourceLocation instead of a FullSourceLoc. -Reflect the changes to various interfaces. llvm-svn: 119730 --- clang/lib/Basic/SourceManager.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'clang/lib/Basic/SourceManager.cpp') diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index e576b8dc6a2..4fa7d1d8793 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -100,7 +100,7 @@ const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag, Diag.SetDelayedDiagnostic(diag::err_cannot_open_file, Entry->getName(), ErrorStr); else - Diag.Report(FullSourceLoc(Loc, SM), diag::err_cannot_open_file) + Diag.Report(Loc, diag::err_cannot_open_file) << Entry->getName() << ErrorStr; Buffer.setInt(Buffer.getInt() | InvalidFlag); @@ -120,7 +120,7 @@ const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag, Diag.SetDelayedDiagnostic(diag::err_file_modified, Entry->getName()); else - Diag.Report(FullSourceLoc(Loc, SM), diag::err_file_modified) + Diag.Report(Loc, diag::err_file_modified) << Entry->getName(); Buffer.setInt(Buffer.getInt() | InvalidFlag); @@ -147,7 +147,7 @@ const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag, .Default(0); if (BOM) { - Diag.Report(FullSourceLoc(Loc, SM), diag::err_unsupported_bom) + Diag.Report(Loc, diag::err_unsupported_bom) << BOM << Entry->getName(); Buffer.setInt(1); } @@ -342,6 +342,15 @@ LineTableInfo &SourceManager::getLineTable() { // Private 'Create' methods. //===----------------------------------------------------------------------===// +SourceManager::SourceManager(Diagnostic &Diag, FileManager &FileMgr, + const FileSystemOptions &FSOpts) + : Diag(Diag), FileMgr(FileMgr), FileSystemOpts(FSOpts), + ExternalSLocEntries(0), LineTable(0), NumLinearScans(0), + NumBinaryProbes(0) { + clearIDTables(); + Diag.setSourceManager(this); +} + SourceManager::~SourceManager() { delete LineTable; -- cgit v1.2.3