[PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

Richard Smith richard at metafoo.co.uk
Fri Jul 17 13:06:10 PDT 2015


rsmith added inline comments.

================
Comment at: lib/CodeGen/CodeGenModule.cpp:1674-1675
@@ +1673,4 @@
+  if (lookupRepresentativeDecl(MangledName, OldGD) &&
+      (isa<CXXMethodDecl>(GD.getDecl()) ||
+       isa<CXXMethodDecl>(OldGD.getDecl())) &&
+      GD.getCanonicalDecl().getDecl() != OldGD.getCanonicalDecl().getDecl()) {
----------------
Why do you need this check? The same mangling collisions can happen with any other kind of function declaration.

================
Comment at: lib/CodeGen/CodeGenModule.cpp:1681
@@ +1680,3 @@
+                      diag::note_previous_definition);
+    return llvm::UndefValue::get(VoidPtrTy);
+  }
----------------
Any reason not to use an undef value of the appropriate type (`Ty`)? If you did that, you presumably wouldn't need special cases elsewhere.


http://reviews.llvm.org/D11297







More information about the cfe-commits mailing list