r209471 - Don't warn about undefined inline functions if they're dllexport/import

Hans Wennborg hans at hanshq.net
Thu May 22 13:45:53 PDT 2014


Author: hans
Date: Thu May 22 15:45:53 2014
New Revision: 209471

URL: http://llvm.org/viewvc/llvm-project?rev=209471&view=rev
Log:
Don't warn about undefined inline functions if they're dllexport/import

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/test/SemaCXX/undefined-inline.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=209471&r1=209470&r2=209471&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu May 22 15:45:53 2014
@@ -478,6 +478,13 @@ static void checkUndefinedButUsed(Sema &
          I = Undefined.begin(), E = Undefined.end(); I != E; ++I) {
     NamedDecl *ND = I->first;
 
+    if (ND->hasAttr<DLLImportAttr>() || ND->hasAttr<DLLExportAttr>()) {
+      // An exported function will always be emitted when defined, so even if
+      // the function is inline, it doesn't have to be emitted in this TU. An
+      // imported function implies that it has been exported somewhere else.
+      continue;
+    }
+
     if (!ND->isExternallyVisible()) {
       S.Diag(ND->getLocation(), diag::warn_undefined_internal)
         << isa<VarDecl>(ND) << ND;

Modified: cfe/trunk/test/SemaCXX/undefined-inline.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/undefined-inline.cpp?rev=209471&r1=209470&r2=209471&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/undefined-inline.cpp (original)
+++ cfe/trunk/test/SemaCXX/undefined-inline.cpp Thu May 22 15:45:53 2014
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -verify %s
 // PR14993
 
 namespace test1 {
@@ -55,3 +55,9 @@ namespace test10 {
   void test() { foo(); }
   inline void foo() __attribute__((gnu_inline));
 }
+
+namespace test11 {
+  inline void foo() __attribute__((dllexport));
+  inline void bar() __attribute__((dllimport));
+  void test() { foo(); bar(); }
+}





More information about the cfe-commits mailing list