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/Driver/clang.cpp b/Driver/clang.cpp
index b7aea67..094d360 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -919,14 +919,14 @@
if (InFile != "-") {
const FileEntry *File = FileMgr.getFile(InFile);
if (File) SourceMgr.createMainFileID(File, SourceLocation());
- if (SourceMgr.getMainFileID() == 0) {
+ if (SourceMgr.getMainFileID().isInvalid()) {
fprintf(stderr, "Error reading '%s'!\n",InFile.c_str());
return true;
}
} else {
llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN();
if (SB) SourceMgr.createMainFileIDForMemBuffer(SB);
- if (SourceMgr.getMainFileID() == 0) {
+ if (SourceMgr.getMainFileID().isInvalid()) {
fprintf(stderr, "Error reading standard input! Empty?\n");
return true;
}
@@ -1335,7 +1335,7 @@
std::pair<const char*,const char*> File =
SM.getBufferData(SM.getMainFileID());
// Start lexing the specified input file.
- Lexer RawLex(SourceLocation::getFileLoc(SM.getMainFileID(), 0),
+ Lexer RawLex(SM.getLocForStartOfFile(SM.getMainFileID()),
PP.getLangOptions(), File.first, File.second);
RawLex.SetKeepWhitespaceMode(true);