]> granicus.if.org Git - clang/commitdiff
Implement code generation of namespaces and add mangling tests.
authorAnders Carlsson <andersca@mac.com>
Wed, 1 Apr 2009 00:58:25 +0000 (00:58 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 1 Apr 2009 00:58:25 +0000 (00:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68170 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h
test/CodeGenCXX/mangle.cpp

index 6419e27e63e9e2552d32af398445717821b780f4..4cee5c8f37343dd5b0a74bfc68db71fc8972979d 100644 (file)
@@ -1218,6 +1218,12 @@ void CodeGenModule::EmitObjCPropertyImplementations(const
   }
 }
 
+void CodeGenModule::EmitNamespace(const NamespaceDecl *ND) {
+  for (RecordDecl::decl_iterator I = ND->decls_begin(), E = ND->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
@@ -1233,7 +1239,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     break;
 
   case Decl::Namespace:
-    ErrorUnsupported(D, "namespace");
+    EmitNamespace(cast<NamespaceDecl>(D));
     break;
 
     // Objective-C Decls
index 01b8d02fb8e1c77dac3fbb1e389575c8d5c3be37..4fbacdc25c9c7b1a404c649fc47d73222a88d032 100644 (file)
@@ -324,7 +324,8 @@ private:
   void EmitGlobalVarDefinition(const VarDecl *D);
   void EmitAliasDefinition(const ValueDecl *D);
   void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
-
+  void EmitNamespace(const NamespaceDecl *D);
+  
   // FIXME: Hardcoding priority here is gross.
   void AddGlobalCtor(llvm::Function * Ctor, int Priority=65535);
   void AddGlobalDtor(llvm::Function * Dtor, int Priority=65535);
index 7acb31cc69efc4cf22e0abde3c50f20d8571675d..0a76dddaff9f33c505b6e4267c563512f14203c0 100644 (file)
@@ -26,3 +26,9 @@ void f(y) { }
 
 // RUN: grep _Z1fv %t | count 1
 void f() { }
+
+// RUN: grep _ZN1N1fEv %t | count 1
+namespace N { void f() { } }
+
+// RUN: grep _ZN1N1N1fEv %t | count 1
+namespace N { namespace N { void f() { } } }