[PATCH] D33493: Speed up preamble loading

Ivan Donchevskii via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 7 10:54:25 PDT 2017


yvvan added inline comments.


================
Comment at: include/clang/Frontend/ASTUnit.h:192
+  /// of that loading
+  std::map<const std::string, SourceLocation> SrcLocCache;
+
----------------
arphaman wrote:
> You can use an `llvm::StringMap` instead.
I will change that


================
Comment at: lib/Frontend/ASTUnit.cpp:1152
+  else
+    SrcLocCache.clear();
 
----------------
arphaman wrote:
> Why is `clear` in an `else` here? We always create a new `SourceManager` in this function, so the previously cached locations will be invalid, so shouldn't we always clear the cache before `TranslateStoredDiagnostics`?
When we load diagnostics that means that preamble has not changed. Doesn't that mean that source locations can be reused? What can cause them to become invalid?
When preamble is invalidated - cache is cleared.

I can keep cache only during TranslateStoredDiagnostics calls but in that case performance improvement is way less.

But if you say that current solution is invalid I will do that


https://reviews.llvm.org/D33493





More information about the cfe-commits mailing list