summaryrefslogtreecommitdiffstats
path: root/clang/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-04 23:01:03 +0000
committerChris Lattner <sabre@nondot.org>2006-07-04 23:01:03 +0000
commitd3a15f7f4e354f990c53e73587ae87027deb786b (patch)
tree42b5e97b8495dc1ec5b09e9c2995d765978d3d4c /clang/Basic/SourceManager.cpp
parentef9eae1c444ae1ecd7a5dd5d9e937d420343b3e1 (diff)
downloadbcm5719-llvm-d3a15f7f4e354f990c53e73587ae87027deb786b.tar.gz
bcm5719-llvm-d3a15f7f4e354f990c53e73587ae87027deb786b.zip
Add a fast-path in getSpelling for identifiers.
llvm-svn: 38672
Diffstat (limited to 'clang/Basic/SourceManager.cpp')
-rw-r--r--clang/Basic/SourceManager.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/Basic/SourceManager.cpp b/clang/Basic/SourceManager.cpp
index 762848f9f9c..ce5e5f776d0 100644
--- a/clang/Basic/SourceManager.cpp
+++ b/clang/Basic/SourceManager.cpp
@@ -128,12 +128,14 @@ SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc,
/// getCharacterData - Return a pointer to the start of the specified location
-/// in the appropriate SourceBuffer. This returns null if it cannot be
-/// computed (e.g. invalid SourceLocation).
+/// in the appropriate SourceBuffer.
const char *SourceManager::getCharacterData(SourceLocation SL) const {
- if (unsigned FileID = SL.getFileID())
- return getFileInfo(FileID)->Buffer->getBufferStart() + getFilePos(SL);
- return 0;
+ // Note that this is a hot function in the getSpelling() path, which is
+ // heavily used by -E mode.
+ unsigned FileID = SL.getFileID();
+ assert(FileID && "Invalid source location!");
+
+ return getFileInfo(FileID)->Buffer->getBufferStart() + getFilePos(SL);
}
/// getIncludeLoc - Return the location of the #include for the specified
OpenPOWER on IntegriCloud