r181998 - Let CodeGenFunction::EmitVarDecl query the semantic storage class info.
Enea Zaffanella
zaffanella at cs.unipr.it
Thu May 16 04:27:57 PDT 2013
Author: enea
Date: Thu May 16 06:27:56 2013
New Revision: 181998
URL: http://llvm.org/viewvc/llvm-project?rev=181998&view=rev
Log:
Let CodeGenFunction::EmitVarDecl query the semantic storage class info.
Added testcase corresponding to PR15991.
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=181998&r1=181997&r2=181998&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Thu May 16 06:27:56 2013
@@ -114,12 +114,7 @@ void CodeGenFunction::EmitDecl(const Dec
/// EmitVarDecl - This method handles emission of any variable declaration
/// inside a function, including static vars etc.
void CodeGenFunction::EmitVarDecl(const VarDecl &D) {
- switch (D.getStorageClass()) {
- case SC_None:
- case SC_Auto:
- case SC_Register:
- return EmitAutoVarDecl(D);
- case SC_Static: {
+ if (D.isStaticLocal()) {
llvm::GlobalValue::LinkageTypes Linkage =
llvm::GlobalValue::InternalLinkage;
@@ -134,15 +129,16 @@ void CodeGenFunction::EmitVarDecl(const
return EmitStaticVarDecl(D, Linkage);
}
- case SC_Extern:
- case SC_PrivateExtern:
+
+ if (D.hasExternalStorage())
// Don't emit it now, allow it to be emitted lazily on its first use.
return;
- case SC_OpenCLWorkGroupLocal:
+
+ if (D.getStorageClass() == SC_OpenCLWorkGroupLocal)
return CGM.getOpenCLRuntime().EmitWorkGroupLocalVarDecl(*this, D);
- }
- llvm_unreachable("Unknown storage class");
+ assert(D.hasLocalStorage());
+ return EmitAutoVarDecl(D);
}
static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
Modified: cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp?rev=181998&r1=181997&r2=181998&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp Thu May 16 06:27:56 2013
@@ -66,3 +66,12 @@ namespace test2 {
// CHECK-2: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv()
}
+
+namespace {
+
+int bar() {
+ extern int a;
+ return a;
+}
+
+} // namespace
More information about the cfe-commits
mailing list