[MicrosoftDemangle] calls to isMemberPointer shadow previous errors
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
# Description
The function [`Demangler::isMemberPointer`](https://github.com/llvm/llvm-project/blob/b4e4616342ca4c7a3c53b99d8d082fd17bfbbb10/llvm/lib/Demangle/MicrosoftDemangle.cpp#L69) sets the internal `Error` state to `false` at the start.
This shadows previous errors and causes `llvm-undname` to accept invalid symbols.
# Example
For example: introducing an invalid qualifier is not detected as invalid
```diff
-??Aklass@@QAAAAHXZ
+??Aklass@@Q%AAAHXZ
```
```sh
> llvm-undname "??Aklass@@Q%AAAHXZ"
??Aklass@@Q%AAAHXZ
public: int & __cdecl klass::operator[](void)
```
msvc `undname` rejects this symbol.
When processing this symbol, [`Demangler::demangleQualifiers`](https://github.com/llvm/llvm-project/blob/b4e4616342ca4c7a3c53b99d8d082fd17bfbbb10/llvm/lib/Demangle/MicrosoftDemangle.cpp#L1824) correctly sets `Error = true` but this flag is not checked before [`Demangler::isMemberPointer`](https://github.com/llvm/llvm-project/blob/b4e4616342ca4c7a3c53b99d8d082fd17bfbbb10/llvm/lib/Demangle/MicrosoftDemangle.cpp#L69) is called, which sets the flag to `false` again.
# Suggested Fix
As far as I can tell there is no reason for [`Demangler::isMemberPointer`](https://github.com/llvm/llvm-project/blob/b4e4616342ca4c7a3c53b99d8d082fd17bfbbb10/llvm/lib/Demangle/MicrosoftDemangle.cpp#L69) to set `Error = false`.
This line should likely be removed.
Contributor guide
Research direction
Start in llvm/lib/Demangle/MicrosoftDemangle.cpp at Demangler::isMemberPointer, then trace the Error handling from demangleQualifiers. Verify the example invalid symbol with llvm-undname and add coverage using the project's existing Microsoft demangling tests if available. Done means the invalid qualifier is rejected rather than demangled successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100