[cfe-commits] r138375 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Aug 23 14:02:28 PDT 2011
Author: akirtzidis
Date: Tue Aug 23 16:02:28 2011
New Revision: 138375
URL: http://llvm.org/viewvc/llvm-project?rev=138375&view=rev
Log:
Move a couple of SourceManager functions out-of-line; no functionality change.
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/Basic/SourceManager.cpp
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=138375&r1=138374&r2=138375&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Aug 23 16:02:28 2011
@@ -967,23 +967,7 @@
}
/// \brief The size of the SLocEnty that \arg FID represents.
- unsigned getFileIDSize(FileID FID) const {
- bool Invalid = false;
- const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid);
- if (Invalid)
- return 0;
-
- int ID = FID.ID;
- unsigned NextOffset;
- if ((ID > 0 && unsigned(ID+1) == local_sloc_entry_size()))
- NextOffset = getNextLocalOffset();
- else if (ID+1 == -1)
- NextOffset = MaxLoadedOffset;
- else
- NextOffset = getSLocEntry(FileID::get(ID+1)).getOffset();
-
- return NextOffset - Entry.getOffset() - 1;
- }
+ unsigned getFileIDSize(FileID FID) const;
/// \brief Given a specific FileID, returns true if \arg Loc is inside that
/// FileID chunk and sets relative offset (offset of \arg Loc from beginning
@@ -998,27 +982,7 @@
/// (offset of \arg Loc from beginning of chunk) to \arg relativeOffset.
bool isInFileID(SourceLocation Loc,
FileID FID, unsigned offset, unsigned length,
- unsigned *relativeOffset = 0) const {
- assert(!FID.isInvalid());
- if (Loc.isInvalid())
- return false;
-
- unsigned FIDOffs = getSLocEntry(FID).getOffset();
- unsigned start = FIDOffs + offset;
- unsigned end = start + length;
-
- // Make sure offset/length describe a chunk inside the given FileID.
- assert(start < FIDOffs + getFileIDSize(FID));
- assert(end <= FIDOffs + getFileIDSize(FID));
-
- if (Loc.getOffset() >= start && Loc.getOffset() < end) {
- if (relativeOffset)
- *relativeOffset = Loc.getOffset() - start;
- return true;
- }
-
- return false;
- }
+ unsigned *relativeOffset = 0) const;
//===--------------------------------------------------------------------===//
// Line Table Manipulation Routines
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=138375&r1=138374&r2=138375&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Aug 23 16:02:28 2011
@@ -1280,6 +1280,49 @@
return PresumedLoc(Filename, LineNo, ColNo, IncludeLoc);
}
+/// \brief The size of the SLocEnty that \arg FID represents.
+unsigned SourceManager::getFileIDSize(FileID FID) const {
+ bool Invalid = false;
+ const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid);
+ if (Invalid)
+ return 0;
+
+ int ID = FID.ID;
+ unsigned NextOffset;
+ if ((ID > 0 && unsigned(ID+1) == local_sloc_entry_size()))
+ NextOffset = getNextLocalOffset();
+ else if (ID+1 == -1)
+ NextOffset = MaxLoadedOffset;
+ else
+ NextOffset = getSLocEntry(FileID::get(ID+1)).getOffset();
+
+ return NextOffset - Entry.getOffset() - 1;
+}
+
+bool SourceManager::isInFileID(SourceLocation Loc,
+ FileID FID, unsigned offset, unsigned length,
+ unsigned *relativeOffset) const {
+ assert(!FID.isInvalid());
+ if (Loc.isInvalid())
+ return false;
+
+ unsigned FIDOffs = getSLocEntry(FID).getOffset();
+ unsigned start = FIDOffs + offset;
+ unsigned end = start + length;
+
+ // Make sure offset/length describe a chunk inside the given FileID.
+ assert(start < FIDOffs + getFileIDSize(FID));
+ assert(end <= FIDOffs + getFileIDSize(FID));
+
+ if (Loc.getOffset() >= start && Loc.getOffset() < end) {
+ if (relativeOffset)
+ *relativeOffset = Loc.getOffset() - start;
+ return true;
+ }
+
+ return false;
+}
+
//===----------------------------------------------------------------------===//
// Other miscellaneous methods.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list