diff options
| author | Francois Pichet <pichet2000@gmail.com> | 2010-11-21 06:08:52 +0000 | 
|---|---|---|
| committer | Francois Pichet <pichet2000@gmail.com> | 2010-11-21 06:08:52 +0000 | 
| commit | 783dd6ece4d1cacbbe9c5790c5a0b6cf9a4b7c9c (patch) | |
| tree | 835aace2ba6a248986b02e383139a1f63bfb80fa /clang/lib/AST/ASTImporter.cpp | |
| parent | e040a46eb354d1eb3d2102b416620e869a10883b (diff) | |
| download | bcm5719-llvm-783dd6ece4d1cacbbe9c5790c5a0b6cf9a4b7c9c.tar.gz bcm5719-llvm-783dd6ece4d1cacbbe9c5790c5a0b6cf9a4b7c9c.zip | |
Major anonymous union/struct redesign.
A new AST node is introduced:
   def IndirectField : DDecl<Value>;
IndirectFields are injected into the anonymous's parent scope and chain back to
the original field. Name lookup for anonymous entities now result in an
IndirectFieldDecl instead of a FieldDecl.
There is no functionality change, the code generated should be the same.
llvm-svn: 119919
Diffstat (limited to 'clang/lib/AST/ASTImporter.cpp')
| -rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 37 | 
1 files changed, 37 insertions, 0 deletions
| diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 7b16809a1f1..980e93c04d3 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -98,6 +98,7 @@ namespace {      Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D);      Decl *VisitCXXConversionDecl(CXXConversionDecl *D);      Decl *VisitFieldDecl(FieldDecl *D); +    Decl *VisitIndirectFieldDecl(IndirectFieldDecl *D);      Decl *VisitObjCIvarDecl(ObjCIvarDecl *D);      Decl *VisitVarDecl(VarDecl *D);      Decl *VisitImplicitParamDecl(ImplicitParamDecl *D); @@ -2020,6 +2021,42 @@ Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {    return ToField;  } +Decl *ASTNodeImporter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { +  // Import the major distinguishing characteristics of a variable. +  DeclContext *DC, *LexicalDC; +  DeclarationName Name; +  SourceLocation Loc; +  if (ImportDeclParts(D, DC, LexicalDC, Name, Loc)) +    return 0; + +  // Import the type. +  QualType T = Importer.Import(D->getType()); +  if (T.isNull()) +    return 0; + +  NamedDecl **NamedChain = +    new (Importer.getToContext())NamedDecl*[D->getChainingSize()]; + +  unsigned i = 0; +  for (IndirectFieldDecl::chain_iterator PI = D->chain_begin(), +       PE = D->chain_end(); PI != PE; ++PI) { +    Decl* D = Importer.Import(*PI); +    if (!D) +      return 0; +    NamedChain[i++] = cast<NamedDecl>(D); +  } + +  IndirectFieldDecl *ToIndirectField = IndirectFieldDecl::Create( +                                         Importer.getToContext(), DC, +                                         Loc, Name.getAsIdentifierInfo(), T, +                                         NamedChain, D->getChainingSize()); +  ToIndirectField->setAccess(D->getAccess()); +  ToIndirectField->setLexicalDeclContext(LexicalDC); +  Importer.Imported(D, ToIndirectField); +  LexicalDC->addDecl(ToIndirectField); +  return ToIndirectField; +} +  Decl *ASTNodeImporter::VisitObjCIvarDecl(ObjCIvarDecl *D) {    // Import the major distinguishing characteristics of an ivar.    DeclContext *DC, *LexicalDC; | 

