[cfe-commits] r80131 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/address-space-compound-literal.c

Eli Friedman eli.friedman at gmail.com
Wed Aug 26 13:01:39 PDT 2009


Author: efriedma
Date: Wed Aug 26 15:01:39 2009
New Revision: 80131

URL: http://llvm.org/viewvc/llvm-project?rev=80131&view=rev
Log:
Make address-space qualification work correctly for compound literals.  
Issue reported on cfe-dev.

Also fixed the code to use isConstant to determine whether to generate a 
constant global, to be consistent with CodeGenModule.  This probably 
needs to be refactored to deal with C++, though.


Added:
    cfe/trunk/test/CodeGen/address-space-compound-literal.c
Modified:
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Aug 26 15:01:39 2009
@@ -591,9 +591,10 @@
       // FIXME: "Leaked" on failure.
       if (C)
         C = new llvm::GlobalVariable(CGM.getModule(), C->getType(),
-                                     E->getType().isConstQualified(), 
+                                     E->getType().isConstant(CGM.getContext()),
                                      llvm::GlobalValue::InternalLinkage,
-                                     C, ".compoundliteral");
+                                     C, ".compoundliteral", 0, false,
+                                     E->getType().getAddressSpace());
       return C;
     }
     case Expr::DeclRefExprClass: 

Added: cfe/trunk/test/CodeGen/address-space-compound-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-space-compound-literal.c?rev=80131&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/address-space-compound-literal.c (added)
+++ cfe/trunk/test/CodeGen/address-space-compound-literal.c Wed Aug 26 15:01:39 2009
@@ -0,0 +1,5 @@
+// RUN: clang-cc -emit-llvm < %s | grep "internal addrspace(1) global i32 1"
+
+typedef int a __attribute__((address_space(1)));
+a* x = &(a){1};
+





More information about the cfe-commits mailing list