================
@@ -179,8 +179,15 @@ class CGObjCGNU : public CGObjCRuntime {
       (R.getVersion() >= VersionTuple(major, minor));
   }
 
-  std::string ManglePublicSymbol(StringRef Name) {
-    return (StringRef(CGM.getTriple().isOSBinFormatCOFF() ? "$_" : "._") + 
Name).str();
+  const std::string ManglePublicSymbol(StringRef Name) {
+    auto triple = CGM.getTriple();
+
+    // Exported symbols in Emscripten must be a valid Javascript identifier.
+    if (triple.isOSBinFormatCOFF() || triple.isOSBinFormatWasm()) {
+      return (StringRef("$_") + Name).str();
+    } else {
+      return (StringRef("._") + Name).str();
+    }
----------------
davidchisnall wrote:

```suggestion
    StringRef prefix = "._"

    // Exported symbols in Emscripten must be a valid Javascript identifier.
    auto triple = CGM.getTriple();
    if (triple.isOSBinFormatCOFF() || triple.isOSBinFormatWasm()) {
      prefix = "$_";
    return (prefix + Name).str();
```

https://github.com/llvm/llvm-project/pull/169043
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to