aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-10-14Reinstate r284008 reverted in r284081, with two fixes:Richard Smith1-0/+4
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
2016-10-12Revert r284008. This is us to fail to instantiate static data members in someRichard Smith1-4/+0
cases. I'm working on reducing a testcase. llvm-svn: 284081
2016-10-12Reinstate r283887 and r283882.Vassil Vassilev1-0/+4
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
2016-10-11Revert r283887 and r283882, until the issue is understood and fixed.Vassil Vassilev1-4/+0
llvm-svn: 283890
2016-10-11[modules] PR28752: Do not instantiate variable declarations which are not ↵Vassil Vassilev1-0/+4
visible. https://reviews.llvm.org/D24508 Patch developed in collaboration with Richard Smith! llvm-svn: 283882
2016-10-06[modules] Allow VarDecls with initializers to use special var abbrev.Vassil Vassilev1-10/+8
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
2016-09-08C++ Modules TS: Add parsing and some semantic analysis support forRichard Smith1-0/+7
export-declarations. These don't yet have an effect on name visibility; we still export everything by default. llvm-svn: 280999
2016-08-12P0217R3: serialization/deserialization support for c++17 decomposition ↵Richard Smith1-2/+19
declarations. llvm-svn: 278460
2016-07-20[modules] Don't emit initializers for VarDecls within a module eagerly wheneverRichard Smith1-5/+5
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
2016-07-18[NFC] Header cleanupMehdi Amini1-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
2016-07-15Revert r275481, r275490. This broke modules bootstrap.Richard Smith1-1/+1
llvm-svn: 275624
2016-07-15[AST] Keep track of the left brace source location of a tag decl.Argyrios Kyrtzidis1-1/+3
This is useful for source modification tools. There will be a follow-up commit using it. llvm-svn: 275590
2016-07-14[modules] Don't pass interesting decls to the consumer for a module file that'sRichard Smith1-1/+1
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
2016-06-28P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:Richard Smith1-2/+21
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
2016-06-25Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith1-0/+5
variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
2016-06-24Use even more ArrayRefsDavid Majnemer1-3/+2
No functional change is intended, just a small refactoring. llvm-svn: 273650
2016-06-24Use more ArrayRefsDavid Majnemer1-2/+2
No functional change is intended, just a small refactoring. llvm-svn: 273647
2016-04-28Reland r267691 fixing PR27535.Vassil Vassilev1-10/+0
llvm-svn: 267882
2016-04-27Revert r267691, it caused PR27535.Nico Weber1-0/+10
llvm-svn: 267744
2016-04-27[modules] Fix Decl's Used invariant.Vassil Vassilev1-10/+0
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
2016-04-14[modules] Remove CXX_BASE_SPECIFIERS_OFFSETS table. Instead of storing an ID ofRichard Smith1-8/+1
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
2016-04-13[modules] Remove CXX_CTOR_INITIALIZERS_OFFSETS table. Instead of storing an IDRichard Smith1-2/+2
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
2016-04-13ASTWriterDecl.cpp: Prune a couple of \param(s), corresponding to r266160. ↵NAKAMURA Takumi1-10/+0
[-Wdocumentation] llvm-svn: 266177
2016-04-13[modules] Refactor handling of cases where we write an offset to a prior ↵Richard Smith1-29/+12
record into the bitstream and simplify a little, in preparation for doing this in more cases. llvm-svn: 266160
2016-04-06Minor simplifications.Richard Smith1-1/+1
llvm-svn: 265594
2016-04-06Re-commit r265518 ("[modules] Continue factoring encoding of AST records out ofRichard Smith1-36/+28
ASTWriter."), reverted in r265526, with a fix for an iterator invalidation bug (thanks, MSan!). llvm-svn: 265564
2016-04-06[OPENMP] Parsing and Sema support for 'omp declare target' directiveDmitry Polukhin1-2/+4
Add parsing, sema analysis for 'declare target' construct for OpenMP 4.0 (4.5 support will be added in separate patch). The declare target directive specifies that variables, functions (C, C++ and Fortran), and subroutines (Fortran) are mapped to a device. The declare target directive is a declarative directive. In Clang declare target is implemented as implicit attribute for the declaration. The syntax of the declare target directive is as follows: #pragma omp declare target declarations-definition-seq #pragma omp end declare target Based on patch from Michael Wong http://reviews.llvm.org/D15321 llvm-svn: 265530
2016-04-06Revert "[modules] Continue factoring encoding of AST records out of ASTWriter."Dmitry Polukhin1-28/+36
This reverts commit r265518. llvm-svn: 265526
2016-04-06[modules] Continue factoring encoding of AST records out of ASTWriter.Richard Smith1-36/+28
llvm-svn: 265518
2016-04-01[modules] Start moving the code for encoding AST records out of ASTWriter intoRichard Smith1-240/+237
a separate class. The goal is for this class to have a separate lifetime from the AST writer so that it can meaningfully track pending statement nodes and context for more compact encoding of various types. llvm-svn: 265195
2016-03-27Remove unused support for replacing declarations from chained AST files.Richard Smith1-28/+14
llvm-svn: 264533
2016-03-25[modules] Store a local offset to DeclContext lexical and visible contents. ↵Richard Smith1-3/+9
Saves a few bytes for each primary DeclContext. llvm-svn: 264377
2016-03-24[modules] Store offset to LOCAL_REDECLARATIONS record relative to the currentRichard Smith1-1/+2
record rather than relative to the start of the bitcode file. Saves a couple of bytes per LOCAL_REDECLARATIONS record (also makes diffs of llvm-bcanalyzer output more useful when tracking down nondeterminism...). llvm-svn: 264359
2016-03-04[OPENMP 4.0] Codegen for 'declare reduction' construct.Alexey Bataev1-2/+1
Emit function for 'combiner' part of 'declare reduction' construct and 'initialilzer' part, if any. llvm-svn: 262699
2016-03-03[OPENMP 4.0] Initial support for 'omp declare reduction' construct.Alexey Bataev1-0/+11
Add parsing, sema analysis and serialization/deserialization for 'declare reduction' construct. User-defined reductions are defined as #pragma omp declare reduction( reduction-identifier : typename-list : combiner ) [initializer ( initializer-expr )] These custom reductions may be used in 'reduction' clauses of OpenMP constructs. The combiner specifies how partial results can be combined into a single value. The combiner can use the special variable identifiers omp_in and omp_out that are of the type of the variables being reduced with this reduction-identifier. Each of them will denote one of the values to be combined before executing the combiner. It is assumed that the special omp_out identifier will refer to the storage that holds the resulting combined value after executing the combiner. As the initializer-expr value of a user-defined reduction is not known a priori the initializer-clause can be used to specify one. Then the contents of the initializer-clause will be used as the initializer for private copies of reduction list items where the omp_priv identifier will refer to the storage to be initialized. The special identifier omp_orig can also appear in the initializer-clause and it will refer to the storage of the original variable to be reduced. Differential Revision: http://reviews.llvm.org/D11182 llvm-svn: 262582
2016-03-02Serialize `#pragma detect_mismatch`.Nico Weber1-0/+13
This is like r262493, but for pragma detect_mismatch instead of pragma comment. The two pragmas have similar behavior, so use the same approach for both. llvm-svn: 262506
2016-03-02Serialize `#pragma comment`.Nico Weber1-0/+11
`#pragma comment` was handled by Sema calling a function on ASTConsumer, and CodeGen then implementing this function and writing things to its output. Instead, introduce a PragmaCommentDecl AST node and hang one off the TranslationUnitDecl for every `#pragma comment` line, and then use the regular serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's eagerly deserialized.) http://reviews.llvm.org/D17799 llvm-svn: 262493
2016-02-24PR26237: Fix iterator invalidation bug that occurs if serializingRichard Smith1-11/+11
specializations of a template manages to trigger deserialization of more specializations of the same template. No test case provided: this is hard to reliably test due to standard library differences. Patch by Vassil Vassilev! llvm-svn: 261781
2016-02-11[OPENMP] Rename OMPCapturedFieldDecl to OMPCapturedExprDecl, NFC.Alexey Bataev1-3/+3
OMPCapturedExprDecl allows caopturing not only of fielddecls, but also other expressions. It also allows to simplify codegen for several clauses. llvm-svn: 260492
2016-02-08[OPENMP 4.5] Ccapture/codegen of private non-static data members.Alexey Bataev1-0/+6
OpenMP 4.5 introduces privatization of non-static data members of current class in non-static member functions. To correctly handle such kind of privatization a new (pseudo)declaration VarDecl-based node is added. It allows to reuse an existing code for capturing variables in Lambdas/Block/Captured blocks of code for correct privatization and codegen. llvm-svn: 260077
2016-01-07Properly track that a character literal is UTF-8, and pretty print the ↵Aaron Ballman1-1/+1
prefix properly. llvm-svn: 257097
2015-12-11[modules] If the semantic and lexical DC of a decl are the same, write out theRichard Smith1-17/+28
second one as 0 instead of writing the same bits to the module file twice. This typically reduces PCM file size by about 1%. llvm-svn: 255384
2015-11-03Eliminate "rewritten decls" from the AST writer. NFCDouglas Gregor1-9/+5
llvm-svn: 251877
2015-10-18No functionality change, just fix whitespace, a typo and remove an unnecessaryNick Lewycky1-2/+2
emacs mode marker. (Changes left behind from another patch that ended up not working out.) llvm-svn: 250666
2015-09-29Simplify or remove calls to makeArrayRef based on feedback from David ↵Craig Topper1-1/+1
Blaikie. NFC. llvm-svn: 248776
2015-09-27Use llvm::makeArrayRef. NFC.Craig Topper1-1/+1
llvm-svn: 248678
2015-09-11[modules] Slightly defang an assert that produces false-positives on the ↵Richard Smith1-12/+13
selfhost bot. llvm-svn: 247375
2015-09-01Re-commit r246497 (and dependent changes r246524 and r246521), reverted inRichard Smith1-1/+0
r246546, with a workaround for an MSVC 2013 miscompile and an MSVC 2015 rejects-valid. Original commit message: [modules] Rework serialized DeclContext lookup table management. Instead of walking the loaded ModuleFiles looking for lookup tables for the context, store them all in one place, and merge them together if we find we have too many (currently, more than 4). If we do merge, include the merged form in our serialized lookup table, so that downstream readers never need to look at our imports' tables. This gives a huge performance improvement to builds with very large numbers of modules (in some cases, more than a 2x speedup was observed). llvm-svn: 246582
2015-09-01Reverting r246497 (which requires also reverting r246524 and r246521 to ↵Aaron Ballman1-0/+1
avoid merge conflicts). It broke the build on MSVC 2015. It also broke an MSVC 2013 bot with testing issues. llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117): error C2065: 'Files': undeclared identifier http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2917 llvm-svn: 246546
2015-08-31[modules] Rework serialized DeclContext lookup table management. Instead ofRichard Smith1-1/+0
walking the loaded ModuleFiles looking for lookup tables for the context, store them all in one place, and merge them together if we find we have too many (currently, more than 4). If we do merge, include the merged form in our serialized lookup table, so that downstream readers never need to look at our imports' tables. This gives a huge performance improvement to builds with very large numbers of modules (in some cases, more than a 2x speedup was observed). llvm-svn: 246497