[cfe-commits] r39624 - in /cfe/cfe/trunk/CodeGen: CGDecl.cpp CGStmt.cpp CodeGenFunction.h

clattner at cs.uiuc.edu clattner at cs.uiuc.edu
Wed Jul 11 09:46:22 PDT 2007


Author: clattner
Date: Wed Jul 11 11:46:22 2007
New Revision: 39624

URL: http://llvm.org/viewvc/llvm-project?rev=39624&view=rev
Log:
codegen all declarators in a declstmt, allowing  us to successfully codegen
stuff like:

void test() {
  int *X, Y, *Z[14];

  X[Y] = 4;
}

Modified:
    cfe/cfe/trunk/CodeGen/CGDecl.cpp
    cfe/cfe/trunk/CodeGen/CGStmt.cpp
    cfe/cfe/trunk/CodeGen/CodeGenFunction.h

Modified: cfe/cfe/trunk/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CGDecl.cpp?rev=39624&r1=39623&r2=39624&view=diff

==============================================================================
--- cfe/cfe/trunk/CodeGen/CGDecl.cpp (original)
+++ cfe/cfe/trunk/CodeGen/CGDecl.cpp Wed Jul 11 11:46:22 2007
@@ -21,10 +21,9 @@
 using namespace CodeGen;
 
 
-void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
-  const Decl *Decl = S.getDecl();
+void CodeGenFunction::EmitDecl(const Decl &D) {
 
-  switch (Decl->getKind()) {
+  switch (D.getKind()) {
   default: assert(0 && "Unknown decl kind!");
   case Decl::FileVariable:
     assert(0 && "Should not see file-scope variables inside a function!");
@@ -40,9 +39,9 @@
     return;
     
   case Decl::BlockVariable:
-    return EmitBlockVarDecl(cast<BlockVarDecl>(*Decl));
+    return EmitBlockVarDecl(cast<BlockVarDecl>(D));
   case Decl::EnumConstant:
-    return EmitEnumConstantDecl(cast<EnumConstantDecl>(*Decl));
+    return EmitEnumConstantDecl(cast<EnumConstantDecl>(D));
   }
 }
 

Modified: cfe/cfe/trunk/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CGStmt.cpp?rev=39624&r1=39623&r2=39624&view=diff

==============================================================================
--- cfe/cfe/trunk/CodeGen/CGStmt.cpp (original)
+++ cfe/cfe/trunk/CodeGen/CGStmt.cpp Wed Jul 11 11:46:22 2007
@@ -271,3 +271,7 @@
   EmitBlock(new BasicBlock());
 }
 
+void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
+  for (const Decl *Decl = S.getDecl(); Decl; Decl = Decl->getNextDeclarator())
+    EmitDecl(*Decl);
+}
\ No newline at end of file

Modified: cfe/cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CodeGenFunction.h?rev=39624&r1=39623&r2=39624&view=diff

==============================================================================
--- cfe/cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/cfe/trunk/CodeGen/CodeGenFunction.h Wed Jul 11 11:46:22 2007
@@ -175,7 +175,7 @@
   //                        Local Declaration Emission
   //===--------------------------------------------------------------------===//
   
-  void EmitDeclStmt(const DeclStmt &S);
+  void EmitDecl(const Decl &D);
   void EmitEnumConstantDecl(const EnumConstantDecl &D);
   void EmitBlockVarDecl(const BlockVarDecl &D);
   void EmitLocalBlockVarDecl(const BlockVarDecl &D);
@@ -193,7 +193,8 @@
   void EmitDoStmt(const DoStmt &S);
   void EmitForStmt(const ForStmt &S);
   void EmitReturnStmt(const ReturnStmt &S);
-  
+  void EmitDeclStmt(const DeclStmt &S);
+
   //===--------------------------------------------------------------------===//
   //                         LValue Expression Emission
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list