[cfe-commits] r95474 - in /cfe/trunk: lib/CodeGen/CGCall.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/CodeGenTypes.h lib/CodeGen/GlobalDecl.h test/CodeGenCXX/virtual-bases.cpp

Anders Carlsson andersca at mac.com
Fri Feb 5 18:44:09 PST 2010


Author: andersca
Date: Fri Feb  5 20:44:09 2010
New Revision: 95474

URL: http://llvm.org/viewvc/llvm-project?rev=95474&view=rev
Log:
Use the correct function info for constructors when applying function attributes. Fixes PR6245.

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h
    cfe/trunk/lib/CodeGen/CodeGenTypes.h
    cfe/trunk/lib/CodeGen/GlobalDecl.h
    cfe/trunk/test/CodeGenCXX/virtual-bases.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=95474&r1=95473&r2=95474&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Feb  5 20:44:09 2010
@@ -167,6 +167,19 @@
                          /*NoReturn*/ false);
 }
 
+const CGFunctionInfo &CodeGenTypes::getFunctionInfo(GlobalDecl GD) {
+  // FIXME: Do we need to handle ObjCMethodDecl?
+  const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
+                                              
+  if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD))
+    return getFunctionInfo(CD, GD.getCtorType());
+
+  if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(FD))
+    return getFunctionInfo(DD, GD.getDtorType());
+  
+  return getFunctionInfo(FD);
+}
+
 const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
                                                     const CallArgList &Args,
                                                     CallingConv CC,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=95474&r1=95473&r2=95474&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Feb  5 20:44:09 2010
@@ -409,11 +409,13 @@
   SetCommonAttributes(D, F);
 }
 
-void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD,
+void CodeGenModule::SetFunctionAttributes(GlobalDecl GD,
                                           llvm::Function *F,
                                           bool IsIncompleteFunction) {
+  const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
+
   if (!IsIncompleteFunction)
-    SetLLVMFunctionAttributes(FD, getTypes().getFunctionInfo(FD), F);
+    SetLLVMFunctionAttributes(FD, getTypes().getFunctionInfo(GD), F);
 
   // Only a few attributes are set on declarations; these may later be
   // overridden by a definition.
@@ -732,8 +734,7 @@
                                              "", &getModule());
   F->setName(MangledName);
   if (D.getDecl())
-    SetFunctionAttributes(cast<FunctionDecl>(D.getDecl()), F,
-                          IsIncompleteFunction);
+    SetFunctionAttributes(D, F, IsIncompleteFunction);
   Entry = F;
 
   // This is the first use or definition of a mangled name.  If there is a

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=95474&r1=95473&r2=95474&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Feb  5 20:44:09 2010
@@ -451,7 +451,7 @@
 
   /// SetFunctionAttributes - Set function attributes for a function
   /// declaration.
-  void SetFunctionAttributes(const FunctionDecl *FD,
+  void SetFunctionAttributes(GlobalDecl GD,
                              llvm::Function *F,
                              bool IsIncompleteFunction);
 

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=95474&r1=95473&r2=95474&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Fri Feb  5 20:44:09 2010
@@ -20,7 +20,7 @@
 #include <vector>
 
 #include "CGCall.h"
-#include "CGCXX.h"
+#include "GlobalDecl.h"
 
 namespace llvm {
   class FunctionType;
@@ -190,6 +190,8 @@
 
 public:
   /// getFunctionInfo - Get the function info for the specified function decl.
+  const CGFunctionInfo &getFunctionInfo(GlobalDecl GD);
+  
   const CGFunctionInfo &getFunctionInfo(const FunctionDecl *FD);
   const CGFunctionInfo &getFunctionInfo(const CXXMethodDecl *MD);
   const CGFunctionInfo &getFunctionInfo(const ObjCMethodDecl *MD);

Modified: cfe/trunk/lib/CodeGen/GlobalDecl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/GlobalDecl.h?rev=95474&r1=95473&r2=95474&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/GlobalDecl.h (original)
+++ cfe/trunk/lib/CodeGen/GlobalDecl.h Fri Feb  5 20:44:09 2010
@@ -15,6 +15,10 @@
 #ifndef CLANG_CODEGEN_GLOBALDECL_H
 #define CLANG_CODEGEN_GLOBALDECL_H
 
+#include "CGCXX.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
+
 namespace clang {
 
 namespace CodeGen {

Modified: cfe/trunk/test/CodeGenCXX/virtual-bases.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-bases.cpp?rev=95474&r1=95473&r2=95474&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/virtual-bases.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virtual-bases.cpp Fri Feb  5 20:44:09 2010
@@ -15,3 +15,11 @@
 // CHECK: define void @_ZN1BC1Ev(%struct.B* %this)
 // CHECK: define void @_ZN1BC2Ev(%struct.B* %this, i8** %vtt)
 B::B() { }
+
+struct C : virtual A {
+  C(bool);
+};
+
+// CHECK: define void @_ZN1CC1Eb(%struct.B* %this, i1 zeroext)
+// CHECK: define void @_ZN1CC2Eb(%struct.B* %this, i8** %vtt, i1 zeroext)
+C::C(bool) { }





More information about the cfe-commits mailing list