diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-01-18 03:11:38 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-01-18 03:11:38 +0000 | 
| commit | 0a791672f0d62aacc29abbf802b20163ad9eb43a (patch) | |
| tree | 40a03388c093ad32d3fdba8a3ef77a31645d5ff3 /clang/lib | |
| parent | 66e91d4a581e35305418d5e7b934e1159a16c9f6 (diff) | |
| download | bcm5719-llvm-0a791672f0d62aacc29abbf802b20163ad9eb43a.tar.gz bcm5719-llvm-0a791672f0d62aacc29abbf802b20163ad9eb43a.zip  | |
Introduce the notion of a "minimal" import of ASTs, to better support LLDB.
llvm-svn: 123723
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 30 | ||||
| -rw-r--r-- | clang/lib/Frontend/ASTMerge.cpp | 3 | 
2 files changed, 28 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index eaab3d3e6c9..315f4feca67 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -83,7 +83,7 @@ namespace {                           SourceLocation &Loc);      void ImportDeclarationNameLoc(const DeclarationNameInfo &From,                                    DeclarationNameInfo& To); -    void ImportDeclContext(DeclContext *FromDC); +    void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);      bool ImportDefinition(RecordDecl *From, RecordDecl *To);      TemplateParameterList *ImportTemplateParameterList(                                                   TemplateParameterList *Params); @@ -1713,7 +1713,15 @@ ASTNodeImporter::ImportDeclarationNameLoc(const DeclarationNameInfo &From,    }  } -void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC) { +void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) { +  if (Importer.isMinimalImport() && !ForceImport) { +    if (DeclContext *ToDC = Importer.ImportContext(FromDC)) { +      ToDC->setHasExternalLexicalStorage(); +      ToDC->setHasExternalVisibleStorage(); +    } +    return; +  } +      for (DeclContext::decl_iterator From = FromDC->decls_begin(),                                 FromEnd = FromDC->decls_end();         From != FromEnd; @@ -3897,9 +3905,12 @@ Expr *ASTNodeImporter::VisitCStyleCastExpr(CStyleCastExpr *E) {  }  ASTImporter::ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, -                         ASTContext &FromContext, FileManager &FromFileManager) +                         ASTContext &FromContext, FileManager &FromFileManager, +                         bool MinimalImport)    : ToContext(ToContext), FromContext(FromContext), -    ToFileManager(ToFileManager), FromFileManager(FromFileManager) { +    ToFileManager(ToFileManager), FromFileManager(FromFileManager), +    Minimal(MinimalImport)  +{    ImportedDecls[FromContext.getTranslationUnitDecl()]      = ToContext.getTranslationUnitDecl();  } @@ -4163,6 +4174,17 @@ FileID ASTImporter::Import(FileID FromID) {    return ToID;  } +void ASTImporter::ImportDefinition(Decl *From) { +  Decl *To = Import(From); +  if (!To) +    return; +   +  if (DeclContext *FromDC = cast<DeclContext>(From)) { +    ASTNodeImporter Importer(*this); +    Importer.ImportDeclContext(FromDC, true); +  } +} +  DeclarationName ASTImporter::Import(DeclarationName FromName) {    if (!FromName)      return DeclarationName(); diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp index ec074415c1f..3905b99b02a 100644 --- a/clang/lib/Frontend/ASTMerge.cpp +++ b/clang/lib/Frontend/ASTMerge.cpp @@ -52,7 +52,8 @@ void ASTMergeAction::ExecuteAction() {      ASTImporter Importer(CI.getASTContext(),                            CI.getFileManager(),                           Unit->getASTContext(),  -                         Unit->getFileManager()); +                         Unit->getFileManager(), +                         /*MinimalImport=*/false);      TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();      for (DeclContext::decl_iterator D = TU->decls_begin(),   | 

