[llvm] Workaround -Wglobal-constructor warning. (PR #94699)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 8 13:55:48 PDT 2024


================
@@ -79,7 +82,7 @@ bool CodeGenCoverage::parse(MemoryBuffer &Buffer, StringRef BackendName) {
 bool CodeGenCoverage::emit(StringRef CoveragePrefix,
                            StringRef BackendName) const {
   if (!CoveragePrefix.empty() && !RuleCoverage.empty()) {
-    sys::SmartScopedLock<true> Lock(OutputMutex);
+    sys::SmartScopedLock<true> Lock(OutputMutex());
----------------
joker-eph wrote:

If this is the only place it is used, you can do simpler I believe:
```suggestion
    static sys::SmartMutex<true> OutputMutex;
    sys::SmartScopedLock<true> Lock(OutputMutex);
```

The global is only useful if used in multiple places.

https://github.com/llvm/llvm-project/pull/94699


More information about the llvm-commits mailing list