From: David Majnemer Date: Mon, 16 May 2016 20:30:03 +0000 (+0000) Subject: [Lex] inferModuleFromLocation should do no work if there are no modules X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd4a20bc9c477ee19112ea4d9440d0823bfa38b1;p=clang [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 --- 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())