[PATCH] D51314: Parse compile commands lazily in InterpolatingCompilationDatabase

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 10:07:28 PDT 2018


ilya-biryukov added inline comments.


================
Comment at: lib/Tooling/InterpolatingCompilationDatabase.cpp:201
+
+  CommandTraits computeTraits() const {
+    CommandTraits Result;
----------------
jfb wrote:
> It's not clear to me that this entire function is safe to call from multiple threads at the same time. Even if it's safe now, I'm willing to bet it won't always be that way. `getTraits` should therefore use a magic static or `call_once` and avoid the headache entirely.
Thanks, `call_once` is both simpler and more reliable.


================
Comment at: lib/Tooling/InterpolatingCompilationDatabase.cpp:258
+  /// Null before Traits were computed, non-null otherwise. All accesses to this
+  /// must be atomic.
+  mutable std::shared_ptr<CommandTraits> Traits;
----------------
jfb wrote:
> The comment should say why accesses need to be atomic. Or better yet, this should only be usable "the right way".
Clarified how it's used.


Repository:
  rC Clang

https://reviews.llvm.org/D51314





More information about the cfe-commits mailing list