Skip to content

[lldb][NFC] Fix a build failure with MSVC #111231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

igorkudrin
Copy link
Collaborator

This fixes a build error with msvc for code introduced in #106442:

...\lldb\source\Expression\DiagnosticManager.cpp(37): error C2668: 'llvm::ErrorInfo<lldb_private::ExpressionError,lldb_private::ExpressionErrorBase>::ErrorInfo': ambiguous call to overloaded function
...\llvm\include\llvm/Support/Error.h(357): note: could be 'llvm::ErrorInfo<lldb_private::ExpressionError,lldb_private::ExpressionErrorBase>::ErrorInfo(std::error_code)', which inherits 'lldb_private::CloneableECError::CloneableECError(std::error_code)' via base class 'lldb_private::ExpressionErrorBase'
...\llvm\include\llvm/Support/Error.h(357): note: or       'llvm::ErrorInfo<lldb_private::ExpressionError,lldb_private::ExpressionErrorBase>::ErrorInfo(std::error_code,std::string)', which inherits 'lldb_private::ExpressionErrorBase::ExpressionErrorBase(std::error_code,std::string)' via base class 'lldb_private::ExpressionErrorBase'
...\lldb\source\Expression\DiagnosticManager.cpp(37): note: while trying to match the argument list '(std::error_code)'

Building the original code failed with an error:

```
...\lldb\source\Expression\DiagnosticManager.cpp(37): error C2668: 'llvm::ErrorInfo<lldb_private::ExpressionError,lldb_private::ExpressionErrorBase>::ErrorInfo': ambiguous call to overloaded function
...\llvm\include\llvm/Support/Error.h(357): note: could be 'llvm::ErrorInfo<lldb_private::ExpressionError,lldb_private::ExpressionErrorBase>::ErrorInfo(std::error_code)', which inherits 'lldb_private::CloneableECError::CloneableECError(std::error_code)' via base class 'lldb_private::ExpressionErrorBase'
...\llvm\include\llvm/Support/Error.h(357): note: or       'llvm::ErrorInfo<lldb_private::ExpressionError,lldb_private::ExpressionErrorBase>::ErrorInfo(std::error_code,std::string)', which inherits 'lldb_private::ExpressionErrorBase::ExpressionErrorBase(std::error_code,std::string)' via base class 'lldb_private::ExpressionErrorBase'
...\lldb\source\Expression\DiagnosticManager.cpp(37): note: while trying to match the argument list '(std::error_code)'
```
@llvmbot
Copy link
Member

llvmbot commented Oct 5, 2024

@llvm/pr-subscribers-lldb

Author: Igor Kudrin (igorkudrin)

Changes

This fixes a build error with msvc for code introduced in #106442:

...\lldb\source\Expression\DiagnosticManager.cpp(37): error C2668: 'llvm::ErrorInfo&lt;lldb_private::ExpressionError,lldb_private::ExpressionErrorBase&gt;::ErrorInfo': ambiguous call to overloaded function
...\llvm\include\llvm/Support/Error.h(357): note: could be 'llvm::ErrorInfo&lt;lldb_private::ExpressionError,lldb_private::ExpressionErrorBase&gt;::ErrorInfo(std::error_code)', which inherits 'lldb_private::CloneableECError::CloneableECError(std::error_code)' via base class 'lldb_private::ExpressionErrorBase'
...\llvm\include\llvm/Support/Error.h(357): note: or       'llvm::ErrorInfo&lt;lldb_private::ExpressionError,lldb_private::ExpressionErrorBase&gt;::ErrorInfo(std::error_code,std::string)', which inherits 'lldb_private::ExpressionErrorBase::ExpressionErrorBase(std::error_code,std::string)' via base class 'lldb_private::ExpressionErrorBase'
...\lldb\source\Expression\DiagnosticManager.cpp(37): note: while trying to match the argument list '(std::error_code)'

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

1 Files Affected:

  • (modified) lldb/include/lldb/Utility/Status.h (+1-2)
diff --git a/lldb/include/lldb/Utility/Status.h b/lldb/include/lldb/Utility/Status.h
index 3910c26d115a09..2911ffb804c6fb 100644
--- a/lldb/include/lldb/Utility/Status.h
+++ b/lldb/include/lldb/Utility/Status.h
@@ -83,8 +83,7 @@ class ExpressionErrorBase
     : public llvm::ErrorInfo<ExpressionErrorBase, CloneableECError> {
 public:
   using llvm::ErrorInfo<ExpressionErrorBase, CloneableECError>::ErrorInfo;
-  ExpressionErrorBase(std::error_code ec, std::string msg = {})
-      : ErrorInfo(ec) {}
+  ExpressionErrorBase(std::error_code ec) : ErrorInfo(ec) {}
   lldb::ErrorType GetErrorType() const override;
   static char ID;
 };

Copy link
Collaborator

@labath labath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I guess. Is that constructor even necessary, given that it just forwards the argument to the base class, and we already have the forwarding using declaration?

@igorkudrin
Copy link
Collaborator Author

Looks good, I guess. Is that constructor even necessary, given that it just forwards the argument to the base class, and we already have the forwarding using declaration?

The constructor looks redundant at the moment, perhaps it is just a legacy from the early stages of patch #106442. Maybe some other constructors can also be reduced, for example, Win32Error::Win32Error(). However, I may not fully understand the intentions of the author of the original patch, so I'd prefer @adrian-prantl to do the cleanup if necessary. My patch is only intended to fix the immediate problem.

@igorkudrin igorkudrin merged commit c80f484 into llvm:main Oct 9, 2024
10 checks passed
@igorkudrin igorkudrin deleted the lldb-fix-ExpressionErrorBase-with-msvc branch October 9, 2024 00:46
@adrian-prantl
Copy link
Collaborator

Looks good, I guess. Is that constructor even necessary, given that it just forwards the argument to the base class, and we already have the forwarding using declaration?

The constructor looks redundant at the moment, perhaps it is just a legacy from the early stages of patch #106442. Maybe some other constructors can also be reduced, for example, Win32Error::Win32Error(). However, I may not fully understand the intentions of the author of the original patch, so I'd prefer @adrian-prantl to do the cleanup if necessary. My patch is only intended to fix the immediate problem.

This constructor is more a leftover after a bunch of refactoring, your change LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants