clang/lib/Sema
Gabor Marton 2cd0afaeb3 [ASTImporter] Refactor Decl creation
Summary:
Generalize the creation of Decl nodes during Import.  With this patch we do the
same things after and before a new AST node is created (::Create) The import
logic should be really simple, we create the node, then we mark that as
imported, then we recursively import the parts for that node and then set them
on that node.  However, the AST is actually a graph, so we have to handle
circles.  If we mark something as imported (`MapImported()`) then we return with
the corresponding `To` decl whenever we want to import that node again, this way
circles are handled.  In order to make this algorithm work we must ensure
things, which are handled in the generic CreateDecl<> template:
* There are no `Import()` calls in between any node creation (::Create)
and the `MapImported()` call.
* Before actually creating an AST node (::Create), we must check if
the Node had been imported already, if yes then return with that one.
One very important case for this is connected to templates: we may
start an import both from the templated decl of a template and from
the template itself.

Now, the virtual `Imported` function is called in `ASTImporter::Impor(Decl *)`,
but only once, when the `Decl` is imported.  One point of this refactor is to
separate responsibilities. The original `Imported()` had 3 responsibilities:
- notify subclasses when an import happened
- register the decl into `ImportedDecls`
- initialise the Decl (set attributes, etc)
Now all of these are in separate functions:
- `Imported`
- `MapImported`
- `InitializeImportedDecl`
I tried to check all the clients, I executed tests for `ExternalASTMerger.cpp`
and some unittests for lldb.

Reviewers: a.sidorin, balazske, xazax.hun, r.stahl

Subscribers: rnkovacs, dkrupp, cfe-commits

Differential Revision: https://reviews.llvm.org/D47632

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336896 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-12 09:42:05 +00:00
..
AnalysisBasedWarnings.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
AttributeList.cpp [NFC] Fix AttributeList allocated_size for ParsedType. 2018-06-22 17:34:44 +00:00
CMakeLists.txt Enabling the /bigobj flag for SemaDeclAttr.cpp. 2017-05-12 14:30:49 +00:00
CodeCompleteConsumer.cpp Optionally add code completion results for arrow instead of dot 2018-05-25 12:56:26 +00:00
CoroutineStmtBuilder.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
DeclSpec.cpp [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents 2018-06-14 14:53:51 +00:00
DelayedDiagnostic.cpp [Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots. 2018-03-29 17:34:09 +00:00
IdentifierResolver.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
JumpDiagnostics.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
MultiplexExternalSemaSource.cpp [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801) 2018-06-25 13:23:49 +00:00
Scope.cpp Revert r335019 "Update NRVO logic to support early return (Attempt 2)" 2018-06-19 05:35:30 +00:00
ScopeInfo.cpp [coroutines] Pass coro func args to promise ctor 2018-01-24 22:15:42 +00:00
Sema.cpp [modules] Do not serialize / deserialize pending new/delete mismatch 2018-06-28 01:57:04 +00:00
SemaAccess.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
SemaAttr.cpp Test commit; please ignore. 2018-05-26 02:29:14 +00:00
SemaCUDA.cpp [CUDA] Check initializers of instantiated template variables. 2018-06-06 22:37:25 +00:00
SemaCXXScopeSpec.cpp Check returned type is valid before using it. 2018-07-07 00:17:25 +00:00
SemaCast.cpp DR330: look through array types when forming the cv-decomposition of a type. 2018-07-11 00:19:19 +00:00
SemaChecking.cpp [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %tu/%td on Darwin 2018-07-05 22:51:11 +00:00
SemaCodeComplete.cpp [clangd] Uprank delcarations when "using q::name" is present in the main file 2018-07-11 14:49:49 +00:00
SemaConsumer.cpp Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch 2011-12-20 02:48:34 +00:00
SemaCoroutine.cpp [Sema] isValidCoroutineContext FIXME and citations 2018-06-23 18:01:02 +00:00
SemaDecl.cpp [NFC] Replace usage of QualType.getTypePtr()-> with operator-> 2018-07-11 19:09:21 +00:00
SemaDeclAttr.cpp [Builtins][Attributes][X86] Tag all X86 builtins with their required vector width. Add a min_vector_width function attribute and tag all x86 instrinsics with it 2018-07-09 19:00:16 +00:00
SemaDeclCXX.cpp Use cast instead of dyn_cast_or_null. 2018-06-20 22:56:59 +00:00
SemaDeclObjC.cpp [Sema] Emit -Wincomplete-implementation for partial methods. 2018-07-07 01:50:20 +00:00
SemaExceptionSpec.cpp [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals 2018-06-20 17:19:40 +00:00
SemaExpr.cpp [Sema] Discarded statment should be an evaluatable context. 2018-07-03 22:15:36 +00:00
SemaExprCXX.cpp [Sema] Fix crash in getConstructorName. 2018-07-04 08:50:12 +00:00
SemaExprMember.cpp [Sema][ObjC] Do not DiagnoseUseOfDecl in LookupMemberExpr 2018-05-24 01:01:43 +00:00
SemaExprObjC.cpp DR1687: When overload resolution selects a built-in operator, implicit 2018-06-27 20:30:34 +00:00
SemaFixItUtils.cpp [Sema] Revert r329346 because of memory sanitizer failures. 2018-04-05 22:15:42 +00:00
SemaInit.cpp Per C++ [over.match.copy]p1, direct-initialization of a reference can 2018-07-02 23:25:22 +00:00
SemaLambda.cpp P0806R2 Implicit capture of this with a capture-default of [=] is 2018-07-07 05:58:48 +00:00
SemaLookup.cpp [Sema] Fix a structured binding typo correction bug 2018-07-10 02:15:07 +00:00
SemaObjCProperty.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
SemaOpenMP.cpp [OPENMP] Do not mark local variables as declare target. 2018-07-09 19:58:08 +00:00
SemaOverload.cpp DR330: look through array types when forming the cv-decomposition of a type. 2018-07-11 00:19:19 +00:00
SemaPseudoObject.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
SemaStmt.cpp Revert r335019 "Update NRVO logic to support early return (Attempt 2)" 2018-06-19 05:35:30 +00:00
SemaStmtAsm.cpp Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00
SemaStmtAttr.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
SemaTemplate.cpp Revert -r336726, which included more files than intended. 2018-07-10 20:51:41 +00:00
SemaTemplateDeduction.cpp Fix deduction for conversion function templates converting to reference 2018-07-11 23:19:41 +00:00
SemaTemplateInstantiate.cpp [Sema] Produce diagnostics for attribute 'trivial_abi' that appears 2018-06-19 05:04:44 +00:00
SemaTemplateInstantiateDecl.cpp Revert r335019 "Update NRVO logic to support early return (Attempt 2)" 2018-06-19 05:35:30 +00:00
SemaTemplateVariadic.cpp [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents 2018-06-14 14:53:51 +00:00
SemaType.cpp [ASTImporter] Refactor Decl creation 2018-07-12 09:42:05 +00:00
TreeTransform.h Revert -r336726, which included more files than intended. 2018-07-10 20:51:41 +00:00
TypeLocBuilder.cpp [Sema] Fix bug in TypeLocBuilder::pushImpl 2016-02-18 21:05:09 +00:00
TypeLocBuilder.h Remove \brief commands from doxygen comments. 2018-05-09 01:00:01 +00:00