[PATCH] [-cxx-abi microsoft] Correctly identify Win32 entry points

Reid Kleckner rnk at google.com
Fri Sep 13 16:35:43 PDT 2013


  OK, now I see Richard's comments, and I said all the same things.  :)

  LGTM if DllMain is fixed.  I think you can special case it simply with something like

    if (isWin32EntryPoint() && FD->getName().equals("DllMain"))


================
Comment at: lib/AST/Decl.cpp:2213
@@ +2212,3 @@
+
+  // Even though ee aren't really targeting Win32 if we are freestanding,
+  // semantic analysis for these functions remain the same.
----------------
Richard Smith wrote:
> s/ ee / we /
s/ee/we/

================
Comment at: lib/AST/Decl.cpp:2214
@@ +2213,3 @@
+  // Even though ee aren't really targeting Win32 if we are freestanding,
+  // semantic analysis for these functions remain the same.
+
----------------
Richard Smith wrote:
> *remains
"remains"

================
Comment at: lib/Sema/SemaDecl.cpp:6881-6886
@@ -6880,5 +6880,8 @@
     bool isExplicitSpecialization=false;
     if (!NewFD->isInvalidDecl() && NewFD->isMain())
-      CheckMain(NewFD, D.getDeclSpec());
+        CheckMain(NewFD, D.getDeclSpec());
+
+    if (!NewFD->isInvalidDecl() && NewFD->isWin32EntryPoint())
+        CheckWin32EntryPoint(NewFD);
 
     if (!NewFD->isInvalidDecl())
----------------
Indentation here is off in the original code and the new code.

================
Comment at: lib/Sema/SemaDecl.cpp:7694
@@ +7693,3 @@
+      FT->getResultType()->isNullPtrType())
+    FD->setHasImplicitReturnZero(true);
+
----------------
MSVC doesn't do this for DllMain, which returns BOOL (typedefed to int =/).

================
Comment at: lib/Sema/SemaOverload.cpp:985
@@ +984,3 @@
+  if (New->isWin32EntryPoint())
+        return false;
+
----------------
Richard Smith wrote:
> Overindented.
phab shows funny indentation?

================
Comment at: test/SemaCXX/ms-overload-entry-point.cpp:15
@@ +14,3 @@
+void wWinMain(int) {} // expected-error{{conflicting types for 'wWinMain'}}
+
+int foo() {
----------------
Test that DllMain must return a value and doesn't implicitly return 0.  I get this from cl.exe:
error C4716: 'DllMain' : must return a value



http://llvm-reviews.chandlerc.com/D1683



More information about the cfe-commits mailing list