summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add better ODR checking for modules.Richard Trieu2017-01-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When objects are imported for modules, there is a chance that a name collision will cause an ODR violation. Previously, only a small number of such violations were detected. This patch provides a stronger check based on AST nodes. The information needed to uniquely identify an object is taked from the AST and put into a one-dimensional byte stream. This stream is then hashed to give a value to represent the object, which is stored with the other object data in the module. When modules are loaded, and Decl's are merged, the hash values of the two Decl's are compared. Only Decl's with matched hash values will be merged. Mismatch hashes will generate a module error, and if possible, point to the first difference between the two objects. The transform from AST to byte stream is a modified depth first algorithm. Due to references between some AST nodes, a pure depth first algorithm could generate loops. For Stmt nodes, a straight depth first processing occurs. For Type and Decl nodes, they are replaced with an index number and only on first visit will these nodes be processed. As an optimization, boolean values are saved and stored together in reverse order at the end of the byte stream to lower the ammount of data that needs to be hashed. Compile time impact was measured at 1.5-2.0% during module building, and negligible during builds without module building. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 293585
* [modules] When reading / writing a typedef that is a name for linkage forRichard Smith2017-01-261-0/+5
| | | | | | | | | | | | | | another declaration, ensure we actually serialize / deserialize that declaration. Before this patch, if another copy of the typedef were merged with the parsed version, we would emit type information referring to the merged version and consequently emit nothing about the parsed anonymous struct. This resulted in us losing information, particularly the visible merged module set for the parsed definition. Force that information to be emitted and to be loaded when the typedef is used. llvm-svn: 293219
* Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.David L. Jones2017-01-241-6/+5
| | | | | | | | | | | | | | | Summary: This patch changes TableGen-generated code in AttrPCHRead to call functions on ASTRecordReader, instead of passing separate parameters to ASTReader. This is a follow-up to r290217. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28007 llvm-svn: 292868
* Serialize the UsesSEH bit on FunctionDeclReid Kleckner2017-01-101-0/+1
| | | | | | Fixes PR31539 llvm-svn: 291600
* Rename several methods on ASTRecordReader to follow LLVM style (lowerCamelCase).David L. Jones2016-12-211-65/+65
| | | | | | | | | | | | | | Summary: This follows up to r290217, and makes functions on ASTRecordReader consistent and valid style. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28008 llvm-svn: 290236
* Store the "current position" index within the ASTRecordReader.David L. Jones2016-12-211-334/+326
| | | | | | | | | | | | | | | | | | Summary: For ASTDeclReader and ASTStmtReader, every parameter "unsigned &Idx" ultimately comes from a variable that is defined on the stack, next to the RecordData. This change moves that index into the ASTRecordReader. TypeLocReader cannot be transitioned, due to TableGen-generated code which calls ASTReader::GetTypeSourceInfo. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27836 llvm-svn: 290217
* [c++1z] P0195R2: Support pack-expansion of using-declarations.Richard Smith2016-12-201-0/+15
| | | | | | | | | | | | | | This change introduces UsingPackDecl as a marker for the set of UsingDecls produced by pack expansion of a single (unresolved) using declaration. This is not strictly necessary (we just need to be able to map from the original using declaration to its expansions somehow), but it's useful to maintain the invariant that each declaration reference instantiates to refer to one declaration. This is a re-commit of r290080 (reverted in r290092) with a fix for a use-after-lifetime bug. llvm-svn: 290203
* Revert "[c++1z] P0195R2: Support pack-expansion of using-declarations."Daniel Jasper2016-12-191-15/+0
| | | | | | | This reverts commit r290080 as it leads to many Clang crashes, e.g.: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814 llvm-svn: 290092
* [c++1z] P0195R2: Support pack-expansion of using-declarations.Richard Smith2016-12-191-0/+15
| | | | | | | | | | | This change introduces UsingPackDecl as a marker for the set of UsingDecls produced by pack expansion of a single (unresolved) using declaration. This is not strictly necessary (we just need to be able to map from the original using declaration to its expansions somehow), but it's useful to maintain the invariant that each declaration reference instantiates to refer to one declaration. llvm-svn: 290080
* Add a class ASTRecordReader which wraps an ASTReader, a RecordData, and ↵David L. Jones2016-12-151-349/+332
| | | | | | | | | | | | | | | | | | | | | ModuleFile. Summary: When reading an ASTRecord, each RecordData is logically contained within a single ModuleFile, and global(er) state is contained by a single ASTReader. This means that any operations that read from a RecordData and reference an ASTReader or a ModuleFile, will always reference the same ASTReader or ModuleFile. ASTRecordReader groups these together so that parameters don't need to be duplicated ad infinitum. Most uses of the Idx variable seem to be redunant aliases as well, but I'll leave that for now. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27784 llvm-svn: 289870
* [modules] Fix assert if multiple update records provide a definition for aRichard Smith2016-10-261-1/+4
| | | | | | class template specialization and that specialization has attributes. llvm-svn: 285160
* Reinstate r284008 reverted in r284081, with two fixes:Richard Smith2016-10-141-0/+24
| | | | | | | | | | | | | | | | | | | 1) Merge and demote variable definitions when we find a redefinition in MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach the second case if it's the addition of the initializer itself that converts an existing declaration into a definition). 2) When rebuilding a redeclaration chain for a variable, if we merge two definitions together, mark the definitions as merged so the retained definition is made visible whenever the demoted definition would have been. Original commit message (from r283882): [modules] PR28752: Do not instantiate variable declarations which are not visible. Original patch by Vassil Vassilev! Changes listed above are mine. llvm-svn: 284284
* Revert r284008. This is us to fail to instantiate static data members in someRichard Smith2016-10-121-24/+0
| | | | | | cases. I'm working on reducing a testcase. llvm-svn: 284081
* Reinstate r283887 and r283882.Vassil Vassilev2016-10-121-0/+24
| | | | | | | | | | | Original message: "[modules] PR28752: Do not instantiate variable declarations which are not visible. https://reviews.llvm.org/D24508 Patch developed in collaboration with Richard Smith!" llvm-svn: 284008
* Revert r283887 and r283882, until the issue is understood and fixed.Vassil Vassilev2016-10-111-29/+0
| | | | llvm-svn: 283890
* [modules] PR28752: Do not instantiate variable declarations which are not ↵Vassil Vassilev2016-10-111-0/+29
| | | | | | | | | | visible. https://reviews.llvm.org/D24508 Patch developed in collaboration with Richard Smith! llvm-svn: 283882
* Allocate after the early exit checks. NFC.Vassil Vassilev2016-10-061-2/+2
| | | | llvm-svn: 283448
* [modules] Allow VarDecls with initializers to use special var abbrev.Vassil Vassilev2016-10-061-1/+1
| | | | | | | | | Update storage sizes to fit the (past) changes in the VarDecl's data model. Update some comments. Patch partially reviewed by Richard Smith as part of https://reviews.llvm.org/D24508 llvm-svn: 283444
* Remove excessive padding from RedeclarableResultAlexander Shaposhnikov2016-09-241-7/+8
| | | | | | | | | | | This diff reorders the fields of the class RedeclarableResult to remove excessive padding. Test plan: make -j8 check-clang Differential revision: https://reviews.llvm.org/D24754 llvm-svn: 282322
* Remove excessive padding from ObjCCategoriesVisitorAlexander Shaposhnikov2016-09-241-8/+8
| | | | | | | | | | | This diff reorders the fields of ObjCCategoriesVisitor to remove excessive padding. Test plan: make -j8 check-clang Differential revision: https://reviews.llvm.org/D24753 llvm-svn: 282318
* Fix interaction between serialization and c++1z feature.Richard Trieu2016-09-131-1/+1
| | | | | | | | In c++1z, static_assert is not required to have a StringLiteral message, where previously it was required. Update the AST Reader to be able to handle a null StringLiteral. llvm-svn: 281286
* [modules] When we merge two definitions of a function, mark the retainedRichard Smith2016-09-121-23/+2
| | | | | | | definition as visible in the discarded definition's module, as we do for other kinds of definition. llvm-svn: 281258
* Modules: for ObjectiveC try to keep the definition invariant.Manman Ren2016-09-091-36/+59
| | | | | | | | | | | | When deserializing ObjCInterfaceDecl with definition data, if we already have a definition, try to keep the definition invariant; also pull in the categories even if it is not what getDefinition returns (this effectively combines categories). rdar://27926200 rdar://26708823 llvm-svn: 281119
* C++ Modules TS: Add parsing and some semantic analysis support forRichard Smith2016-09-081-0/+9
| | | | | | | export-declarations. These don't yet have an effect on name visibility; we still export everything by default. llvm-svn: 280999
* PR29166: when merging declarations with typedef names for linkage purposes,Richard Smith2016-08-301-1/+1
| | | | | | | don't assume that the anonymous struct will be part of the most recent declaration of the typedef. llvm-svn: 280136
* Lazily load the ContextDecl for a lambda's DefinitionData, to fix aRichard Smith2016-08-251-1/+1
| | | | | | | deserialization cycle caused by the ContextDecl recursively importing members of the lambda's closure type. llvm-svn: 279694
* PR29097: add an update record when we instantiate the default memberRichard Smith2016-08-241-0/+17
| | | | | | initializer of an imported field. llvm-svn: 279667
* Module: add -fprebuilt-module-path to support loading prebuilt modules.Manman Ren2016-08-181-3/+2
| | | | | | | | | | | | | In this mode, there is no need to load any module map and the programmer can simply use "@import" syntax to load the module directly from a prebuilt module path. When loading from prebuilt module path, we don't support rebuilding of the module files and we ignore compatible configuration mismatches. rdar://27290316 Differential Revision: http://reviews.llvm.org/D23125 llvm-svn: 279096
* P0217R3: serialization/deserialization support for c++17 decomposition ↵Richard Smith2016-08-121-0/+20
| | | | | | declarations. llvm-svn: 278460
* [ASTReader] Use real move semantics instead of emulating them in the copy ctor.Benjamin Kramer2016-08-061-3/+3
| | | | | | No functionality change intended. llvm-svn: 277923
* Move helpers into anonymous namespaces. NFC.Benjamin Kramer2016-08-061-2/+3
| | | | llvm-svn: 277918
* [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.Vassil Vassilev2016-07-221-9/+4
| | | | | | | | | | | | | | | Processing update records (and loading a module, in general) might trigger unexpected calls to the ASTWriter (being a mutation listener). Now we have a mechanism to suppress those calls to the ASTWriter but notify other possible mutation listeners. Fixes https://llvm.org/bugs/show_bug.cgi?id=28332 Patch by Cristina Cristescu and me. Reviewed by Richard Smith (D21800). llvm-svn: 276473
* [modules] Don't emit initializers for VarDecls within a module eagerly wheneverRichard Smith2016-07-201-4/+10
| | | | | | | | | | | | we first touch any part of that module. Instead, defer them until the first time that module is (transitively) imported. The initializer step for a module then recursively initializes modules that its own headers imported. For example, this avoids running the <iostream> global initializer in programs that don't actually use iostreams, but do use other parts of the standard library. llvm-svn: 276159
* [NFC] Header cleanupMehdi Amini2016-07-181-2/+1
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Revert r275481, r275490. This broke modules bootstrap.Richard Smith2016-07-151-9/+8
| | | | llvm-svn: 275624
* [AST] Keep track of the left brace source location of a tag decl.Argyrios Kyrtzidis2016-07-151-2/+2
| | | | | | This is useful for source modification tools. There will be a follow-up commit using it. llvm-svn: 275590
* [modules] Don't pass interesting decls to the consumer for a module file that'sRichard Smith2016-07-141-8/+9
| | | | | | | | | | | passed on the command line but never actually used. We consider a (top-level) module to be used if any part of it is imported, either by the current translation unit, or by any part of a top-level module that is itself used. (Put another way, a module is used if an implicit modules build would have loaded its .pcm file.) llvm-svn: 275481
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-031-9/+6
| | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274475
* P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:Richard Smith2016-06-281-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace inheriting constructors implementation with new approach, voted into C++ last year as a DR against C++11. Instead of synthesizing a set of derived class constructors for each inherited base class constructor, we make the constructors of the base class visible to constructor lookup in the derived class, using the normal rules for using-declarations. For constructors, UsingShadowDecl now has a ConstructorUsingShadowDecl derived class that tracks the requisite additional information. We create shadow constructors (not found by name lookup) in the derived class to model the actual initialization, and have a new expression node, CXXInheritedCtorInitExpr, to model the initialization of a base class from such a constructor. (This initialization is special because it performs real perfect forwarding of arguments.) In cases where argument forwarding is not possible (for inalloca calls, variadic calls, and calls with callee parameter cleanup), the shadow inheriting constructor is not emitted and instead we directly emit the initialization code into the caller of the inherited constructor. Note that this new model is not perfectly compatible with the old model in some corner cases. In particular: * if B inherits a private constructor from A, and C uses that constructor to construct a B, then we previously required that A befriends B and B befriends C, but the new rules require A to befriend C directly, and * if a derived class has its own constructors (and so its implicit default constructor is suppressed), it may still inherit a default constructor from a base class llvm-svn: 274049
* Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith2016-06-251-0/+2
| | | | | | | variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
* PR27754: CXXRecordDecl::data() needs to perform an update even if it's calledRichard Smith2016-05-171-10/+10
| | | | | | on a declaration that already knows the location of the DefinitionData object. llvm-svn: 269858
* Add support for derived class special members hiding functions brought in fromRichard Smith2016-05-131-0/+4
| | | | | | | | | a base class via a using-declaration. If a class has a using-declaration declaring either a constructor or an assignment operator, eagerly declare its special members in case they need to displace a shadow declaration from a using-declaration. llvm-svn: 269398
* [OpenMP] Parse+Sema for '#pragma omp declare target' syntax version 4.5Dmitry Polukhin2016-05-091-5/+1
| | | | | | | | | | | | | | | | | Support OpenMP version 4.5 syntax for #pragma omp declare target. Syntax: #pragma omp declare target (extended-list) new-line or #pragma omp declare target clause[ [,] clause ... ] new-line Where clause is one of the following: to(extended-list) link(list) Differential Revision: http://reviews.llvm.org/D20011 llvm-svn: 268925
* [modules] Attempt to improve performance for declaration merging without a SemaRichard Smith2016-05-061-5/+4
| | | | | | | | | | object in C. Rather than using the DeclContext (which is very slow because it triggers us to build a lookup table for the DeclContext), use a separate map from identifiers to decls for this case, containing only the ones we've actually deserialized. For convenience, this map is implemented as an IdentifierResolver. llvm-svn: 268817
* Reland r267691 fixing PR27535.Vassil Vassilev2016-04-281-8/+17
| | | | llvm-svn: 267882
* Revert r267691, it caused PR27535.Nico Weber2016-04-271-17/+8
| | | | llvm-svn: 267744
* [modules] Fix Decl's Used invariant.Vassil Vassilev2016-04-271-8/+17
| | | | | | | | | | | | | | | | | | | | The Decl::isUsed has a value for every decl. In non-module builds it is very difficult (but possible) to break this invariant but when we walk up the redecl chain we find the neccessary information. When deserializing the decls from a module it is much more difficult to update correctly this invariant. The patch centralizes the information whether a decl is used in the canonical decl marking the entire entity as being used. Fixes https://llvm.org/bugs/show_bug.cgi?id=27401 Patch by Cristina Cristescu and me. Thanks to Richard Smith who helped to debug and understand the issue! Reviewed by Richard Smith. llvm-svn: 267691
* [modules] Store the location of the lexical update record in a decl update asRichard Smith2016-04-141-1/+1
| | | | | | | an offset from the current record rather than as an absolute bit number. This gives a minor .pcm file size reduction. llvm-svn: 266269
* [modules] Remove CXX_BASE_SPECIFIERS_OFFSETS table. Instead of storing an ID ofRichard Smith2016-04-141-2/+2
| | | | | | | | a table entry in the corresponding decl, store an offset from the current record to the relevant CXX_BASE_SPECIFIERS record. This results in fewer indirections and a minor .pcm file size reduction. llvm-svn: 266266
* [modules] Remove CXX_CTOR_INITIALIZERS_OFFSETS table. Instead of storing an IDRichard Smith2016-04-131-5/+8
| | | | | | | | of a table entry in the corresponding decl, store an offset from the current record to the relevant CXX_CTOR_INITIALIZERS record. This results in fewer indirections and a minor .pcm file size reduction. llvm-svn: 266254
OpenPOWER on IntegriCloud