[cfe-commits] r68300 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h test/CodeGenCXX/mangle.cpp
Anders Carlsson
andersca at mac.com
Wed Apr 1 22:55:19 PDT 2009
Author: andersca
Date: Thu Apr 2 00:55:18 2009
New Revision: 68300
URL: http://llvm.org/viewvc/llvm-project?rev=68300&view=rev
Log:
Emit code for linkage specifications.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenCXX/mangle.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=68300&r1=68299&r2=68300&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Apr 2 00:55:18 2009
@@ -1236,12 +1236,25 @@
}
}
+/// EmitNamespace - Emit all declarations in a namespace.
void CodeGenModule::EmitNamespace(const NamespaceDecl *ND) {
for (RecordDecl::decl_iterator I = ND->decls_begin(), E = ND->decls_end();
I != E; ++I)
EmitTopLevelDecl(*I);
}
+// EmitLinkageSpec - Emit all declarations in a linkage spec.
+void CodeGenModule::EmitLinkageSpec(const LinkageSpecDecl *LSD) {
+ if (LSD->getLanguage() != LinkageSpecDecl::lang_c) {
+ ErrorUnsupported(LSD, "linkage spec");
+ return;
+ }
+
+ for (RecordDecl::decl_iterator I = LSD->decls_begin(), E = LSD->decls_end();
+ I != E; ++I)
+ EmitTopLevelDecl(*I);
+}
+
/// EmitTopLevelDecl - Emit code for a single top level declaration.
void CodeGenModule::EmitTopLevelDecl(Decl *D) {
// If an error has occurred, stop code generation, but continue
@@ -1300,14 +1313,9 @@
// compatibility-alias is a directive and has no code gen.
break;
- case Decl::LinkageSpec: {
- LinkageSpecDecl *LSD = cast<LinkageSpecDecl>(D);
- if (LSD->getLanguage() == LinkageSpecDecl::lang_cxx)
- ErrorUnsupported(LSD, "linkage spec");
- // FIXME: implement C++ linkage, C linkage works mostly by C
- // language reuse already.
+ case Decl::LinkageSpec:
+ EmitLinkageSpec(cast<LinkageSpecDecl>(D));
break;
- }
case Decl::FileScopeAsm: {
FileScopeAsmDecl *AD = cast<FileScopeAsmDecl>(D);
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=68300&r1=68299&r2=68300&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Apr 2 00:55:18 2009
@@ -328,6 +328,7 @@
void EmitAliasDefinition(const ValueDecl *D);
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
void EmitNamespace(const NamespaceDecl *D);
+ void EmitLinkageSpec(const LinkageSpecDecl *D);
// FIXME: Hardcoding priority here is gross.
void AddGlobalCtor(llvm::Function * Ctor, int Priority=65535);
Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=68300&r1=68299&r2=68300&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Thu Apr 2 00:55:18 2009
@@ -20,15 +20,22 @@
typedef union { int a; } u;
void f(u) { }
-// RUN: grep _Z1f1x %t | count 1
+// RUN: grep _Z1f1x %t | count 1 &&
typedef struct { int a; } x,y;
void f(y) { }
-// RUN: grep _Z1fv %t | count 1
+// RUN: grep _Z1fv %t | count 1 &&
void f() { }
-// RUN: grep _ZN1N1fEv %t | count 1
+// RUN: grep _ZN1N1fEv %t | count 1 &&
namespace N { void f() { } }
-// RUN: grep _ZN1N1N1fEv %t | count 1
+// RUN: grep _ZN1N1N1fEv %t | count 1 &&
namespace N { namespace N { void f() { } } }
+
+// RUN: grep unmangled_function %t | count 1 &&
+extern "C" { namespace N { void unmangled_function() { } } }
+
+// RUN: grep unmangled_variable %t | count 1
+extern "C" { namespace N { int unmangled_variable; } }
+
More information about the cfe-commits
mailing list