this massive patch introduces a simple new abstraction: it makes
"FileID" a concept that is now enforced by the compiler's type checker
instead of yet-another-random-unsigned floating around.
This is an important distinction from the "FileID" currently tracked by
SourceLocation. *That* FileID may refer to the start of a file or to a
chunk within it. The new FileID *only* refers to the file (and its
#include stack and eventually #line data), it cannot refer to a chunk.
FileID is a completely opaque datatype to all clients, only SourceManager
is allowed to poke and prod it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62407 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/PlistDiagnostics.cpp b/lib/Driver/PlistDiagnostics.cpp
index 1428028..0b2ca52 100644
--- a/lib/Driver/PlistDiagnostics.cpp
+++ b/lib/Driver/PlistDiagnostics.cpp
@@ -20,9 +20,9 @@
#include "llvm/System/Path.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
-
using namespace clang;
-typedef llvm::DenseMap<unsigned,unsigned> FIDMap;
+
+typedef llvm::DenseMap<FileID, unsigned> FIDMap;
namespace clang {
class Preprocessor;
@@ -51,27 +51,28 @@
return new PlistDiagnostics(s);
}
-static void AddFID(FIDMap& FIDs,
- llvm::SmallVectorImpl<unsigned>& V,
+static void AddFID(FIDMap &FIDs,
+ llvm::SmallVectorImpl<FileID> &V,
SourceManager& SM, SourceLocation L) {
- unsigned fid = SM.getCanonicalFileID(SM.getInstantiationLoc(L));
- FIDMap::iterator I = FIDs.find(fid);
+ FileID FID = SM.getCanonicalFileID(SM.getInstantiationLoc(L));
+ FIDMap::iterator I = FIDs.find(FID);
if (I != FIDs.end()) return;
- FIDs[fid] = V.size();
- V.push_back(fid);
+ FIDs[FID] = V.size();
+ V.push_back(FID);
}
static unsigned GetFID(const FIDMap& FIDs,
SourceManager& SM, SourceLocation L) {
- unsigned fid = SM.getCanonicalFileID(SM.getInstantiationLoc(L));
- FIDMap::const_iterator I = FIDs.find(fid);
- assert (I != FIDs.end());
+ FileID FID = SM.getCanonicalFileID(SM.getInstantiationLoc(L));
+ FIDMap::const_iterator I = FIDs.find(FID);
+ assert(I != FIDs.end());
return I->second;
}
static llvm::raw_ostream& Indent(llvm::raw_ostream& o, const unsigned indent) {
- for (unsigned i = 0; i < indent; ++i) o << ' ';
+ for (unsigned i = 0; i < indent; ++i)
+ o << ' ';
return o;
}
@@ -171,7 +172,7 @@
// Build up a set of FIDs that we use by scanning the locations and
// ranges of the diagnostics.
FIDMap FM;
- llvm::SmallVector<unsigned, 10> Fids;
+ llvm::SmallVector<FileID, 10> Fids;
for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I != E; ++I) {
AddFID(FM, Fids, SM, I->getLocation());
@@ -214,7 +215,7 @@
" <key>files</key>\n"
" <array>\n";
- for (llvm::SmallVectorImpl<unsigned>::iterator I=Fids.begin(), E=Fids.end();
+ for (llvm::SmallVectorImpl<FileID>::iterator I=Fids.begin(), E=Fids.end();
I!=E; ++I)
o << " <string>" << SM.getFileEntryForID(*I)->getName() << "</string>\n";