All callers of Demangler::parseTagUniqueName check 'Demangler.Error' and assume that 'Error is false' means 'return value is not null'
Diff Detail
- Repository
- rLLDB LLDB
Event Timeline
Add a test that fails without the code change and that passes with it. I don't know under which conditions this change is needed, so I apologize that I can't make a more concrete suggestion.
llvm/lib/Demangle/MicrosoftDemangle.cpp | ||
---|---|---|
737 | Why not change the return type to llvm::Expected<TagTypeNode>? Then you have one return value that is either an error (when return value evaluates to false) or the value. On top of just a boolean Error variable you then can also use the return value to store error texts if you need them. Now, I don't know if the Error member is used anywhere else. |
llvm/lib/Demangle/MicrosoftDemangle.cpp | ||
---|---|---|
737 | Error is not a parameter, it's class-level state that's used pervasively in this file. |
llvm/lib/Demangle/MicrosoftDemangle.cpp | ||
---|---|---|
737 | Okay, was just a thought. Thanks for explaining. |
Why not change the return type to llvm::Expected<TagTypeNode>? Then you have one return value that is either an error (when return value evaluates to false) or the value. On top of just a boolean Error variable you then can also use the return value to store error texts if you need them. Now, I don't know if the Error member is used anywhere else.