[clang] 111de45 - [clang-scan-deps] Move command-line generation out of critical section (#158187)

via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 13 09:20:09 PDT 2025


Author: Naveen Seth Hanig
Date: 2025-09-13T18:20:05+02:00
New Revision: 111de45e838a7d33637da8807212284c988f7fae

URL: https://github.com/llvm/llvm-project/commit/111de45e838a7d33637da8807212284c988f7fae
DIFF: https://github.com/llvm/llvm-project/commit/111de45e838a7d33637da8807212284c988f7fae.diff

LOG: [clang-scan-deps] Move command-line generation out of critical section (#158187)

The first call to getBuildArguments() can be costly. Although the
original author’s comment (from commit 3b1a686) states that it should
be called outside the critical section, it is currently invoked within
the locked region.

This change moves it outside the critical section to match the original
intent and reduce lock contention.

Added: 
    

Modified: 
    clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index f10b73278381b..0e2758d123edc 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -429,12 +429,12 @@ class FullDeps {
         auto Res = Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
         NewMDs.push_back(&Res->second);
       }
-      // First call to \c getBuildArguments is somewhat expensive. Let's call it
-      // on the current thread (instead of the main one), and outside the
-      // critical section.
-      for (ModuleDeps *MD : NewMDs)
-        (void)MD->getBuildArguments();
     }
+    // First call to \c getBuildArguments is somewhat expensive. Let's call it
+    // on the current thread (instead of the main one), and outside the
+    // critical section.
+    for (ModuleDeps *MD : NewMDs)
+      (void)MD->getBuildArguments();
   }
 
   bool roundTripCommand(ArrayRef<std::string> ArgStrs,


        


More information about the cfe-commits mailing list