diff options
author | Gabor Marton <martongabesz@gmail.com> | 2018-12-17 13:53:12 +0000 |
---|---|---|
committer | Gabor Marton <martongabesz@gmail.com> | 2018-12-17 13:53:12 +0000 |
commit | 54058b5055c16fb700854223d6453a35c3c59ea8 (patch) | |
tree | 2c0768addf033b92cf69fd42d3cabb68b378af79 /clang/lib/Frontend/ASTMerge.cpp | |
parent | 193429ea15a60cb5c17e3ce9e2c9b3521eaf5d90 (diff) | |
download | bcm5719-llvm-54058b5055c16fb700854223d6453a35c3c59ea8.tar.gz bcm5719-llvm-54058b5055c16fb700854223d6453a35c3c59ea8.zip |
[ASTImporter] Add importer specific lookup
Summary:
There are certain cases when normal C/C++ lookup (localUncachedLookup)
does not find AST nodes. E.g.:
Example 1:
template <class T>
struct X {
friend void foo(); // this is never found in the DC of the TU.
};
Example 2:
// The fwd decl to Foo is not found in the lookupPtr of the DC of the
// translation unit decl.
struct A { struct Foo *p; };
In these cases we create a new node instead of returning with the old one.
To fix it we create a new lookup table which holds every node and we are
not interested in any C++ specific visibility considerations.
Simply, we must know if there is an existing Decl in a given DC.
Reviewers: a_sidorin, a.sidorin
Subscribers: mgorny, rnkovacs, dkrupp, Szelethus, cfe-commits
Differential Revision: https://reviews.llvm.org/D53708
llvm-svn: 349351
Diffstat (limited to 'clang/lib/Frontend/ASTMerge.cpp')
-rw-r--r-- | clang/lib/Frontend/ASTMerge.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp index 2434113ab0d..4f622da118c 100644 --- a/clang/lib/Frontend/ASTMerge.cpp +++ b/clang/lib/Frontend/ASTMerge.cpp @@ -10,6 +10,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/ASTDiagnostic.h" #include "clang/AST/ASTImporter.h" +#include "clang/AST/ASTImporterLookupTable.h" #include "clang/Basic/Diagnostic.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" @@ -38,6 +39,8 @@ void ASTMergeAction::ExecuteAction() { &CI.getASTContext()); IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(CI.getDiagnostics().getDiagnosticIDs()); + ASTImporterLookupTable LookupTable( + *CI.getASTContext().getTranslationUnitDecl()); for (unsigned I = 0, N = ASTFiles.size(); I != N; ++I) { IntrusiveRefCntPtr<DiagnosticsEngine> Diags(new DiagnosticsEngine(DiagIDs, &CI.getDiagnosticOpts(), @@ -51,11 +54,9 @@ void ASTMergeAction::ExecuteAction() { if (!Unit) continue; - ASTImporter Importer(CI.getASTContext(), - CI.getFileManager(), - Unit->getASTContext(), - Unit->getFileManager(), - /*MinimalImport=*/false); + ASTImporter Importer(CI.getASTContext(), CI.getFileManager(), + Unit->getASTContext(), Unit->getFileManager(), + /*MinimalImport=*/false, &LookupTable); TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl(); for (auto *D : TU->decls()) { |