diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-11-07 11:19:30 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-11-07 11:19:30 +0100 |
commit | 07b8711526972e120824d0fb913b01b1baf6a4cb (patch) | |
tree | b9fcff64e92c1fc497babdde187db3d277ec61dc /compilerplugins/clang/plugin.cxx | |
parent | 3a32caa141f9c16a4f3d3895381384da13acd149 (diff) |
Memoize ignoreLocation results
...which, according to callgrind, reduces instruction fetch count spent on
compiling sw/source/core/layout/paintfrm.cxx (randomly selected because it is
rather large) by 5% from 41,992,064,226 to 39,861,989,855 (function main() in
clang-6.0).
This is best done by forwarding ignoreLocation calls from Plugin to the
PluginHandler signleton, but due to the tight mutual coupling between plugin.hxx
and pluginhandler.hxx that unfortunately required some reorganization (and two
outstanding TODO clean-ups of temporarily introduced using declarations in
plugin.hxx).
Change-Id: Ia4270517d194def7db7ed80cb6894e9c473e9499
Diffstat (limited to 'compilerplugins/clang/plugin.cxx')
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 7d53e71dfd61..f8292ef661f6 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -36,48 +36,7 @@ DiagnosticBuilder Plugin::report( DiagnosticsEngine::Level level, StringRef mess return handler.report( level, name, message, compiler, loc ); } -bool Plugin::ignoreLocation( SourceLocation loc ) -{ - SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( loc ); - if( compiler.getSourceManager().isInSystemHeader( expansionLoc )) - return true; - const char* bufferName = compiler.getSourceManager().getPresumedLoc( expansionLoc ).getFilename(); - if (bufferName == NULL - || hasPathnamePrefix(bufferName, SRCDIR "/external/") - || isSamePathname(bufferName, SRCDIR "/sdext/source/pdfimport/wrapper/keyword_list") ) - // workdir/CustomTarget/sdext/pdfimport/hash.cxx is generated from - // sdext/source/pdfimport/wrapper/keyword_list by gperf, which - // inserts various #line directives denoting the latter into the - // former, but fails to add a #line directive returning back to - // hash.cxx itself before the gperf generated boilerplate, so - // compilers erroneously consider errors in the boilerplate to come - // from keyword_list instead of hash.cxx (for Clang on Linux/macOS - // this is not an issue due to the '#pragma GCC system_header' - // generated into the start of hash.cxx, #if'ed for __GNUC__, but - // for clang-cl it is an issue) - return true; - if( hasPathnamePrefix(bufferName, WORKDIR) ) - { - // workdir/CustomTarget/vcl/unx/kde4/tst_exclude_socket_notifiers.moc - // includes - // "../../../../../vcl/unx/kde4/tst_exclude_socket_notifiers.hxx", - // making the latter file erroneously match here; so strip any ".." - // segments: - if (strstr(bufferName, "/..") == nullptr) { - return true; - } - std::string s(bufferName); - normalizeDotDotInFilePath(s); - if (hasPathnamePrefix(s, WORKDIR)) - return true; - } - if( hasPathnamePrefix(bufferName, BUILDDIR) - || hasPathnamePrefix(bufferName, SRCDIR) ) - return false; // ok - return true; -} - -void Plugin::normalizeDotDotInFilePath( std::string & s ) +void normalizeDotDotInFilePath( std::string & s ) { for (std::string::size_type i = 0;;) { |