summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-05-16 20:30:03 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-05-16 20:30:03 +0000
commitbd4a20bc9c477ee19112ea4d9440d0823bfa38b1 (patch)
tree521631812642a59b73fb895ce42347ec577c6c3e /lib
parent5de27450d6ed6c0461ac4865dd194eb55c2057f0 (diff)
downloadclang-bd4a20bc9c477ee19112ea4d9440d0823bfa38b1.tar.gz
[Lex] inferModuleFromLocation should do no work if there are no modules
getModuleContainingLocation ends up on the hot-path for typical C code which can lead to calls to getFileIDSlow. To speed this up, short circuit inferModuleFromLocation when there aren't any modules, implicit or otherwise. This shaves 4-5% build time when building the linux kernel. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269687 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Lex/ModuleMap.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp
index 51477185ae..3e3215dee8 100644
--- a/lib/Lex/ModuleMap.cpp
+++ b/lib/Lex/ModuleMap.cpp
@@ -917,6 +917,9 @@ Module *ModuleMap::inferModuleFromLocation(FullSourceLoc Loc) {
if (Loc.isInvalid())
return nullptr;
+ if (UmbrellaDirs.empty() && Headers.empty())
+ return nullptr;
+
// Use the expansion location to determine which module we're in.
FullSourceLoc ExpansionLoc = Loc.getExpansionLoc();
if (!ExpansionLoc.isFileID())