[cfe-commits] r62499 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceLocation.cpp lib/CodeGen/CGDebugInfo.cpp lib/Driver/HTMLDiagnostics.cpp lib/Driver/PlistDiagnostics.cpp lib/Driver/TextDiagnosticPrinter.cpp lib/Lex/Lexer.cpp lib/Rewrite/HTMLRewrite.cpp
Chris Lattner
sabre at nondot.org
Sun Jan 18 23:46:46 PST 2009
Author: lattner
Date: Mon Jan 19 01:46:45 2009
New Revision: 62499
URL: http://llvm.org/viewvc/llvm-project?rev=62499&view=rev
Log:
Rename SourceManager::getCanonicalFileID -> getFileID. There is
no longer such thing as a non-canonical FileID.
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/Basic/SourceLocation.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Driver/HTMLDiagnostics.cpp
cfe/trunk/lib/Driver/PlistDiagnostics.cpp
cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jan 19 01:46:45 2009
@@ -409,15 +409,6 @@
return getContentCache(FID)->Entry;
}
- /// getCanonicalFileID - Return the canonical FileID for a SourceLocation.
- /// A file can have multiple FileIDs if it is large enough to be broken
- /// into multiple chunks. This method returns the unique FileID without
- /// chunk information for a given SourceLocation. Use this method when
- /// you want to compare FileIDs across SourceLocations.
- FileID getCanonicalFileID(SourceLocation SpellingLoc) const {
- return getDecomposedFileLoc(SpellingLoc).first;
- }
-
/// getDecomposedFileLoc - Decompose the specified file location into a raw
/// FileID + Offset pair. The first element is the FileID, the second is the
/// offset from the start of the buffer of the location.
@@ -437,7 +428,13 @@
return std::make_pair(FileID::Create(Loc.getChunkID()-ChunkNo), Offset);
}
-
+
+ /// getFileID - Return the FileID for a SourceLocation.
+ ///
+ FileID getFileID(SourceLocation SpellingLoc) const {
+ return getDecomposedFileLoc(SpellingLoc).first;
+ }
+
/// getFullFilePos - This (efficient) method returns the offset from the start
/// of the file that the specified spelling SourceLocation represents. This
/// returns the location of the actual character data, not the instantiation
@@ -449,13 +446,13 @@
/// isFromSameFile - Returns true if both SourceLocations correspond to
/// the same file.
bool isFromSameFile(SourceLocation Loc1, SourceLocation Loc2) const {
- return getCanonicalFileID(Loc1) == getCanonicalFileID(Loc2);
+ return getFileID(Loc1) == getFileID(Loc2);
}
/// isFromMainFile - Returns true if the file of provided SourceLocation is
/// the main file.
bool isFromMainFile(SourceLocation Loc) const {
- return getCanonicalFileID(Loc) == getMainFileID();
+ return getFileID(Loc) == getMainFileID();
}
/// isInSystemHeader - Returns if a SourceLocation is in a system header.
Modified: cfe/trunk/lib/Basic/SourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceLocation.cpp?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceLocation.cpp (original)
+++ cfe/trunk/lib/Basic/SourceLocation.cpp Mon Jan 19 01:46:45 2009
@@ -39,7 +39,7 @@
FileID FullSourceLoc::getFileID() const {
assert(isValid());
- return SrcMgr->getCanonicalFileID(*this);
+ return SrcMgr->getFileID(*this);
}
@@ -106,7 +106,7 @@
const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
assert(isValid());
- return SrcMgr->getBuffer(SrcMgr->getCanonicalFileID(*this));
+ return SrcMgr->getBuffer(SrcMgr->getFileID(*this));
}
void FullSourceLoc::dump() const {
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jan 19 01:46:45 2009
@@ -51,7 +51,7 @@
return llvm::DICompileUnit();
SourceManager &SM = M->getContext().getSourceManager();
- const FileEntry *FE = SM.getFileEntryForID(SM.getCanonicalFileID(Loc));
+ const FileEntry *FE = SM.getFileEntryForID(SM.getFileID(Loc));
if (FE == 0) return llvm::DICompileUnit();
// See if this compile unit has been used before.
Modified: cfe/trunk/lib/Driver/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HTMLDiagnostics.cpp?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/Driver/HTMLDiagnostics.cpp Mon Jan 19 01:46:45 2009
@@ -26,7 +26,6 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
#include <fstream>
-
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -132,8 +131,8 @@
FullSourceLoc L = I->getLocation().getInstantiationLoc();
if (FID.isInvalid()) {
- FID = SMgr.getCanonicalFileID(L);
- } else if (SMgr.getCanonicalFileID(L) != FID)
+ FID = SMgr.getFileID(L);
+ } else if (SMgr.getFileID(L) != FID)
return; // FIXME: Emit a warning?
// Check the source ranges.
@@ -142,19 +141,13 @@
SourceLocation L = SMgr.getInstantiationLoc(RI->getBegin());
- if (!L.isFileID())
- return; // FIXME: Emit a warning?
-
- if (SMgr.getCanonicalFileID(L) != FID)
+ if (!L.isFileID() || SMgr.getFileID(L) != FID)
return; // FIXME: Emit a warning?
L = SMgr.getInstantiationLoc(RI->getEnd());
- if (!L.isFileID())
+ if (!L.isFileID() || SMgr.getFileID(L) != FID)
return; // FIXME: Emit a warning?
-
- if (SMgr.getCanonicalFileID(L) != FID)
- return; // FIXME: Emit a warning?
}
}
@@ -336,10 +329,10 @@
SourceManager &SM = R.getSourceMgr();
FullSourceLoc LPos = Pos.getInstantiationLoc();
- FileID FID = SM.getCanonicalFileID(LPos);
+ FileID FID = SM.getFileID(LPos);
assert(&LPos.getManager() == &SM && "SourceManagers are different!");
- if (SM.getCanonicalFileID(LPos) != BugFileID)
+ if (SM.getFileID(LPos) != BugFileID)
return;
const llvm::MemoryBuffer *Buf = SM.getBuffer(FID);
@@ -469,8 +462,8 @@
if (EndLineNo < StartLineNo)
return;
- if (SM.getCanonicalFileID(InstantiationStart) != BugFileID ||
- SM.getCanonicalFileID(InstantiationEnd) != BugFileID)
+ if (SM.getFileID(InstantiationStart) != BugFileID ||
+ SM.getFileID(InstantiationEnd) != BugFileID)
return;
// Compute the column number of the end.
Modified: cfe/trunk/lib/Driver/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/PlistDiagnostics.cpp?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/Driver/PlistDiagnostics.cpp Mon Jan 19 01:46:45 2009
@@ -51,20 +51,18 @@
return new PlistDiagnostics(s);
}
-static void AddFID(FIDMap &FIDs,
- llvm::SmallVectorImpl<FileID> &V,
+static void AddFID(FIDMap &FIDs, llvm::SmallVectorImpl<FileID> &V,
SourceManager& SM, SourceLocation L) {
- FileID FID = SM.getCanonicalFileID(SM.getInstantiationLoc(L));
+ FileID FID = SM.getFileID(SM.getInstantiationLoc(L));
FIDMap::iterator I = FIDs.find(FID);
if (I != FIDs.end()) return;
FIDs[FID] = V.size();
V.push_back(FID);
}
-static unsigned GetFID(const FIDMap& FIDs,
- SourceManager& SM, SourceLocation L) {
- FileID FID = SM.getCanonicalFileID(SM.getInstantiationLoc(L));
+static unsigned GetFID(const FIDMap& FIDs, SourceManager& SM, SourceLocation L){
+ FileID FID = SM.getFileID(SM.getInstantiationLoc(L));
FIDMap::const_iterator I = FIDs.find(FID);
assert(I != FIDs.end());
return I->second;
@@ -178,7 +176,7 @@
AddFID(FM, Fids, SM, I->getLocation());
for (PathDiagnosticPiece::range_iterator RI=I->ranges_begin(),
- RE=I->ranges_end(); RI!=RE; ++RI) {
+ RE=I->ranges_end(); RI!=RE; ++RI) {
AddFID(FM, Fids, SM, RI->getBegin());
AddFID(FM, Fids, SM, RI->getEnd());
}
@@ -229,7 +227,8 @@
o << " </array>\n";
// Output the bug type and bug category.
- o << " <key>description</key>\n <string>" << D->getDescription() << "</string>\n"
+ o << " <key>description</key>\n <string>" << D->getDescription()
+ << "</string>\n"
" <key>category</key>\n <string>" << D->getCategory() << "</string>\n";
// Finish.
Modified: cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Driver/TextDiagnosticPrinter.cpp Mon Jan 19 01:46:45 2009
@@ -48,13 +48,13 @@
SourceMgr.getInstantiationLoc(R.getBegin());
unsigned StartLineNo = SourceMgr.getLineNumber(InstantiationStart);
if (StartLineNo > LineNo ||
- SourceMgr.getCanonicalFileID(InstantiationStart) != FID)
+ SourceMgr.getFileID(InstantiationStart) != FID)
return; // No intersection.
SourceLocation InstantiationEnd = SourceMgr.getInstantiationLoc(R.getEnd());
unsigned EndLineNo = SourceMgr.getLineNumber(InstantiationEnd);
if (EndLineNo < LineNo ||
- SourceMgr.getCanonicalFileID(InstantiationEnd) != FID)
+ SourceMgr.getFileID(InstantiationEnd) != FID)
return; // No intersection.
// Compute the column number of the start.
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Mon Jan 19 01:46:45 2009
@@ -156,7 +156,7 @@
SourceManager &SM = PP.getSourceManager();
// Create the lexer as if we were going to lex the file normally.
- FileID SpellingFID = SM.getCanonicalFileID(SpellingLoc);
+ FileID SpellingFID = SM.getFileID(SpellingLoc);
Lexer *L = new Lexer(SpellingFID, PP);
// Now that the lexer is created, change the start/end locations so that we
Modified: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/HTMLRewrite.cpp?rev=62499&r1=62498&r2=62499&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp (original)
+++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp Mon Jan 19 01:46:45 2009
@@ -33,8 +33,8 @@
SourceManager &SM = R.getSourceMgr();
B = SM.getInstantiationLoc(B);
E = SM.getInstantiationLoc(E);
- FileID FID = SM.getCanonicalFileID(B);
- assert(SM.getCanonicalFileID(E) == FID && "B/E not in the same file!");
+ FileID FID = SM.getFileID(B);
+ assert(SM.getFileID(E) == FID && "B/E not in the same file!");
unsigned BOffset = SM.getFullFilePos(B);
unsigned EOffset = SM.getFullFilePos(E);
More information about the cfe-commits
mailing list