summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorEnea Zaffanella <zaffanella@cs.unipr.it>2013-05-16 11:27:56 +0000
committerEnea Zaffanella <zaffanella@cs.unipr.it>2013-05-16 11:27:56 +0000
commit713e3f25636736fe798c8603ebca56ae8d5372e8 (patch)
treeced56de46dab137dfde201f99e9d9ee7a9744442 /lib/CodeGen/CGDecl.cpp
parent8a99945769aa83270bda4ae4890f519800aa19eb (diff)
downloadclang-713e3f25636736fe798c8603ebca56ae8d5372e8.tar.gz
clang-713e3f25636736fe798c8603ebca56ae8d5372e8.tar.bz2
clang-713e3f25636736fe798c8603ebca56ae8d5372e8.tar.xz
Let CodeGenFunction::EmitVarDecl query the semantic storage class info.
Added testcase corresponding to PR15991. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 3ce6dec6a5..eb2b0e7e01 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -114,12 +114,7 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
/// 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 VarDecl &D) {
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,