[llvm] [llvm][DebugInfo] Fix c++20 warnings in LVOptions.h (PR #79585)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 03:58:27 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: David Spickett (DavidSpickett)

<details>
<summary>Changes</summary>

Compiling with -DCMAKE_CXX_STANDARD=20 produces 228 warnings from this file due to:
```
LVOptions.h:515:16: warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]
```

So I've changed these to explicitly list the captures, including `this`.

As llvm requires at least c++17, I think we could use `[=, *this]` instead. However when I did so I got a lot of errors about const. So on balance, explicitly listing the captures seems better than adding some kind of const cast to each one.

These and other warnings can be seen on the c++20 buildbot https://lab.llvm.org/buildbot/#/builders/249.

---
Full diff: https://github.com/llvm/llvm-project/pull/79585.diff


1 Files Affected:

- (modified) llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h (+4-4) 


``````````diff
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h
index a0a360c0a434f91..a8bf33f9ad6b290 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVOptions.h
@@ -510,14 +510,14 @@ class LVPatterns final {
   template <typename T, typename U>
   void resolveGenericPatternMatch(T *Element, const U &Requests) {
     assert(Element && "Element must not be nullptr");
-    auto CheckPattern = [=]() -> bool {
+    auto CheckPattern = [this, Element]() -> bool {
       return (Element->isNamed() &&
               (matchGenericPattern(Element->getName()) ||
                matchGenericPattern(Element->getLinkageName()))) ||
              (Element->isTyped() &&
               matchGenericPattern(Element->getTypeName()));
     };
-    auto CheckOffset = [=]() -> bool {
+    auto CheckOffset = [this, Element]() -> bool {
       return matchOffsetPattern(Element->getOffset());
     };
     if ((options().getSelectGenericPattern() && CheckPattern()) ||
@@ -530,12 +530,12 @@ class LVPatterns final {
   template <typename U>
   void resolveGenericPatternMatch(LVLine *Line, const U &Requests) {
     assert(Line && "Line must not be nullptr");
-    auto CheckPattern = [=]() -> bool {
+    auto CheckPattern = [this, Line]() -> bool {
       return matchGenericPattern(Line->lineNumberAsStringStripped()) ||
              matchGenericPattern(Line->getName()) ||
              matchGenericPattern(Line->getPathname());
     };
-    auto CheckOffset = [=]() -> bool {
+    auto CheckOffset = [this, Line]() -> bool {
       return matchOffsetPattern(Line->getAddress());
     };
     if ((options().getSelectGenericPattern() && CheckPattern()) ||

``````````

</details>


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


More information about the llvm-commits mailing list