aaron.ballman added inline comments.

================
Comment at: cfe/trunk/lib/AST/Mangle.cpp:127
+    // do not add a "\01" prefix.
+    if (!ALA->getIsLiteralLabel() || ALA->getLabel().startswith("llvm.")) {
+      Out << ALA->getLabel();
----------------
Sorry to dredge up an old review, but I recently ran into a bug in this area 
and am not certain of how to fix it. What should happen if the asm label is a 
literal which is empty? e.g.,
```
void foo(void) __asm__("");
void foo(void) {}
```
Currently, that seems to get through this code path and stream an empty string 
into the output stream. However, `writeFuncOrVarName()` doesn't check that it 
actually wrote anything into the stream when calling `mangleName()` and returns 
success to the caller. This causes `writeName()` to eventually call 
`llvm::Mangler::getNameWithPrefix()`, which asserts that the passed `StringRef` 
is not an empty string and we crash. The typical LLVM code path seems to treat 
unnamed symbols as being mangled with `__unnamed_N` (where N is replaced), but 
this relies on having a `GlobalValue*` available to get the next mangling ID.

I'm not certain of where to fix the bug. Should the LLVM side be able to accept 
an empty string and try to gin up a `GlobalValue*` to mangle it properly? 
Should the FE side not generate an empty name here? Should empty asm labels be 
rejected at the source level?

Thanks for any insights you can provide!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67774/new/

https://reviews.llvm.org/D67774



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to