Introduce support for "transparent" DeclContexts, which are
DeclContexts whose members are visible from enclosing DeclContexts up
to (and including) the innermost enclosing non-transparent
DeclContexts. Transparent DeclContexts unify the mechanism to be used
for various language features, including C enumerations, anonymous
unions, C++0x inline namespaces, and C++ linkage
specifications. Please refer to the documentation in the Clang
internals manual for more information.

Only enumerations and linkage specifications currently use transparent
DeclContexts.

Still to do: use transparent DeclContexts to implement anonymous
unions and GCC's anonymous structs extension, and, later, the C++0x
features. We also need to tighten up the DeclContext/ScopedDecl link
to ensure that every ScopedDecl is in a single DeclContext, which
will ensure that we can then enforce ownership and reduce the memory
footprint of DeclContext.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61735 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 3236763..0b06006 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -108,27 +108,28 @@
   unsigned StrSize = PP.getSpelling(Tok, LangBufPtr);
 
   SourceLocation Loc = ConsumeStringToken();
-  DeclTy *D = 0;
-  
-  if (Tok.isNot(tok::l_brace)) {
-    D = ParseDeclarationOrFunctionDefinition();
-    if (D)
-      return Actions.ActOnLinkageSpec(Loc, LangBufPtr, StrSize, D);
 
-    return 0;
+  ParseScope LinkageScope(this, Scope::DeclScope);
+  DeclTy *LinkageSpec 
+    = Actions.ActOnStartLinkageSpecification(CurScope, 
+                                             /*FIXME: */SourceLocation(),
+                                             Loc, LangBufPtr, StrSize,
+                                       Tok.is(tok::l_brace)? Tok.getLocation() 
+                                                           : SourceLocation());
+
+  if (Tok.isNot(tok::l_brace)) {
+    ParseDeclarationOrFunctionDefinition();
+    return Actions.ActOnFinishLinkageSpecification(CurScope, LinkageSpec, 
+                                                   SourceLocation());
   } 
 
   SourceLocation LBrace = ConsumeBrace();
-  llvm::SmallVector<DeclTy *, 8> InnerDecls;
   while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
-    D = ParseExternalDeclaration();
-    if (D)
-      InnerDecls.push_back(D);
+    ParseExternalDeclaration();
   }
 
   SourceLocation RBrace = MatchRHSPunctuation(tok::r_brace, LBrace);
-  return Actions.ActOnLinkageSpec(Loc, LBrace, RBrace, LangBufPtr, StrSize,
-                                  &InnerDecls.front(), InnerDecls.size());
+  return Actions.ActOnFinishLinkageSpecification(CurScope, LinkageSpec, RBrace);
 }
 
 /// ParseUsingDirectiveOrDeclaration - Parse C++ using using-declaration or