summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
...
* Encapsulate FPOptions and use it consistentlyAdam Nemet2017-03-274-6/+6
| | | | | | | | | | | | | | | | | | Sema holds the current FPOptions which is adjusted by 'pragma STDC FP_CONTRACT'. This then gets propagated into expression nodes as they are built. This encapsulates FPOptions so that this propagation happens opaquely rather than directly with the fp_contractable on/off bit. This allows controlled transitioning of fp_contractable to a ternary value (off, on, fast). It will also allow adding more fast-math flags later. This is toward moving fp-contraction=fast from an LLVM TargetOption to a FastMathFlag in order to fix PR25721. Differential Revision: https://reviews.llvm.org/D31166 llvm-svn: 298877
* Revert r298742 "[ODRHash] Add error messages for mismatched parameters in ↵Vassil Vassilev2017-03-261-83/+0
| | | | | | | | methods." I failed to revert this in r298816. llvm-svn: 298824
* Revert 298754 and 298742.Vassil Vassilev2017-03-261-27/+7
| | | | | | They broke llvm modules builds and our internal modules infrastructure. llvm-svn: 298816
* [ODRHash] Add support for array and decayed types.Richard Trieu2017-03-251-7/+27
| | | | llvm-svn: 298754
* [ODRHash] Add error messages for mismatched parameters in methods.Richard Trieu2017-03-241-0/+83
| | | | llvm-svn: 298742
* [Serialization] Serialize DependentSizedExtVectorTypeAlex Lorenz2017-03-222-2/+15
| | | | | | | | rdar://30659700 Differential Revision: https://reviews.llvm.org/D31134 llvm-svn: 298493
* [Modules] Rebuild modules on umbrella header mismatchBruno Cardoso Lopes2017-03-221-7/+3
| | | | | | | | | | | | This restores behavior pre-r230064 since after PCMCache work (r298278) we don't reload PCMs from disk within the same compiler invocation. Testcases from r230064 are still left around since they still guarantee the correct behavior we're expecting. rdar://problem/19889777 llvm-svn: 298464
* Apply clang-tidy's performance-unnecessary-value-param to parts of clang.Benjamin Kramer2017-03-212-8/+9
| | | | | | No functionality change intended. llvm-svn: 298443
* Reapply "Modules: Cache PCMs in memory and avoid a use-after-free"Duncan P. N. Exon Smith2017-03-204-30/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit r298185, effectively reapplying r298165, after fixing the new unit tests (PR32338). The memory buffer generator doesn't null-terminate the MemoryBuffer it creates; this version of the commit informs getMemBuffer about that to avoid the assert. Original commit message follows: ---- Clang's internal build system for implicit modules uses lock files to ensure that after a process writes a PCM it will read the same one back in (without contention from other -cc1 commands). Since PCMs are read from disk repeatedly while invalidating, building, and importing, the lock is not released quickly. Furthermore, the LockFileManager is not robust in every environment. Other -cc1 commands can stall until timeout (after about eight minutes). This commit changes the lock file from being necessary for correctness to a (possibly dubious) performance hack. The remaining benefit is to reduce duplicate work in competing -cc1 commands which depend on the same module. Follow-up commits will change the internal build system to continue after a timeout, and reduce the timeout. Perhaps we should reconsider blocking at all. This also fixes a use-after-free, when one part of a compilation validates a PCM and starts using it, and another tries to swap out the PCM for something new. The PCMCache is a new type called MemoryBufferCache, which saves memory buffers based on their filename. Its ownership is shared by the CompilerInstance and ModuleManager. - The ModuleManager stores PCMs there that it loads from disk, never touching the disk if the cache is hot. - When modules fail to validate, they're removed from the cache. - When a CompilerInstance is spawned to build a new module, each already-loaded PCM is assumed to be valid, and is frozen to avoid the use-after-free. - Any newly-built module is written directly to the cache to avoid the round-trip to the filesystem, making lock files unnecessary for correctness. Original patch by Manman Ren; most testcases by Adrian Prantl! llvm-svn: 298278
* Revert "Modules: Cache PCMs in memory and avoid a use-after-free"Renato Golin2017-03-184-94/+30
| | | | | | This reverts commit r298165, as it broke the ARM builds. llvm-svn: 298185
* Modules: Cache PCMs in memory and avoid a use-after-freeDuncan P. N. Exon Smith2017-03-174-30/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang's internal build system for implicit modules uses lock files to ensure that after a process writes a PCM it will read the same one back in (without contention from other -cc1 commands). Since PCMs are read from disk repeatedly while invalidating, building, and importing, the lock is not released quickly. Furthermore, the LockFileManager is not robust in every environment. Other -cc1 commands can stall until timeout (after about eight minutes). This commit changes the lock file from being necessary for correctness to a (possibly dubious) performance hack. The remaining benefit is to reduce duplicate work in competing -cc1 commands which depend on the same module. Follow-up commits will change the internal build system to continue after a timeout, and reduce the timeout. Perhaps we should reconsider blocking at all. This also fixes a use-after-free, when one part of a compilation validates a PCM and starts using it, and another tries to swap out the PCM for something new. The PCMCache is a new type called MemoryBufferCache, which saves memory buffers based on their filename. Its ownership is shared by the CompilerInstance and ModuleManager. - The ModuleManager stores PCMs there that it loads from disk, never touching the disk if the cache is hot. - When modules fail to validate, they're removed from the cache. - When a CompilerInstance is spawned to build a new module, each already-loaded PCM is assumed to be valid, and is frozen to avoid the use-after-free. - Any newly-built module is written directly to the cache to avoid the round-trip to the filesystem, making lock files unnecessary for correctness. Original patch by Manman Ren; most testcases by Adrian Prantl! llvm-svn: 298165
* [Serialization] Follow-up to r297972, deserialize name/loc in separate ↵Argyrios Kyrtzidis2017-03-171-4/+6
| | | | | | | | statements to make sure they deserialize in defined order. This should fix the windows bots. llvm-svn: 298027
* [index/AST] Add references for ObjC getter=/setter= property attributes and ↵Argyrios Kyrtzidis2017-03-162-2/+6
| | | | | | | | | | | related property getter/setter role fixes This enhances the AST to keep track of locations of the names in those ObjC property attributes, and reports them for indexing. Patch by Nathan Hawes! https://reviews.llvm.org/D30907 llvm-svn: 297972
* Modules: Optimize bitcode encoding of diagnostic stateDuncan P. N. Exon Smith2017-03-142-6/+10
| | | | | | | | | | | Since bitcode uses VBR encoding, large numbers are more expensive than small ones. Instead of emitting a UINT_MAX sentinel after each sequence of state-change pairs, emit the size of the sequence as a prefix. This should have no functionality change besides saving bits from the encoding. llvm-svn: 297770
* Modules: Use hash of PCM content for SIGNATUREDuncan P. N. Exon Smith2017-03-134-111/+316
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change ASTFileSignature from a random 32-bit number to the hash of the PCM content. - Move definition ASTFileSignature to Basic/Module.h so Module and ASTSourceDescriptor can use it. - Change the signature from uint64_t to std::array<uint32_t,5>. - Stop using (saving/reading) the size and modification time of PCM files when there is a valid SIGNATURE. - Add UNHASHED_CONTROL_BLOCK, and use it to store the SIGNATURE record and other records that shouldn't affect the hash. Because implicit modules reuses the same file for multiple levels of -Werror, this includes DIAGNOSTIC_OPTIONS and DIAG_PRAGMA_MAPPINGS. This helps to solve a PCH + implicit Modules dependency issue: PCH files are handled by the external build system, whereas implicit modules are handled by internal compiler build system. This prevents invalidating a PCH when the compiler overwrites a PCM file with the same content (modulo the diagnostic differences). Design and original patch by Manman Ren! llvm-svn: 297655
* Defensively ensure that GetExternalDeclStmt protects itself from nested ↵David Blaikie2017-03-081-0/+3
| | | | | | deserialization llvm-svn: 297322
* Take into account C++17's noexcept function types during merging -- it shouldRichard Smith2017-03-081-2/+16
| | | | | | | be possible to merge a declaration with an unresolved function type against one with a resolved function type. llvm-svn: 297316
* [AST/ObjC] Make ObjCCategoryImplDecl consistent with ObjCCategoryDecl and ↵Argyrios Kyrtzidis2017-03-072-2/+0
| | | | | | | | use the category name as its DeclName This also addresses the badness in ObjCCategoryImplDecl's API, which was hiding NamedDecl's APIs with different meaning. llvm-svn: 297131
* [coroutines] Add DependentCoawaitExpr and fix re-building CoroutineBodyStmt.Eric Fiselier2017-03-062-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The changes contained in this patch are: 1. Defines a new AST node `CoawaitDependentExpr` for representing co_await expressions while the promise type is still dependent. 2. Correctly detect and transform the 'co_await' operand to `p.await_transform(<expr>)` when possible. 3. Change the initial/final suspend points to build during the initial parse, so they have the correct operator co_await lookup results. 4. Fix transformation of the CoroutineBodyStmt so that it doesn't re-build the final/initial suspends. @rsmith: This change is a little big, but it's not trivial for me to split it up. Please let me know if you would prefer this submitted as multiple patches. Reviewers: rsmith, GorNishanov Reviewed By: rsmith Subscribers: ABataev, rsmith, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D26057 llvm-svn: 297093
* [ODRHash] Add support for detecting different method properties.Richard Trieu2017-03-041-5/+98
| | | | | | | | Now print diagnostics for static, virtual, inline, volatile, and const differences in methods. Also use DeclarationName instead of IdentifierInfo for additional robustness in diagnostic printing. llvm-svn: 296932
* Mark function as llvm dump method.Vassil Vassilev2017-03-021-7/+1
| | | | llvm-svn: 296779
* Serialization: use the PCH chain to check PCH modeSaleem Abdulrasool2017-03-021-1/+2
| | | | | | | | | | | | | | | | | | When we are deciding whether we are creating a PCH or a module, we would check if the ModuleMgr had any elements to switch into PCH mode. However, when creating a module, the size may be 1. This would result in us going down the wrong path. This was found by cross-compiling the swift standard library. Use the PCH chain length instead to identify the PCH mode. Unfortunately, I have not yet been able to create a simple test case for this, but have verified that this fixes the swift standard library construction. Thanks to Adrian Prantl for help and discussions with this change! llvm-svn: 296769
* [PCH] Avoid VarDecl emission attempt if no owning module avaiableBruno Cardoso Lopes2017-03-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a stopgap fix for PR31863, a regression introduced in r276159. Consider this snippet: struct FVector; struct FVector {}; struct FBox { FVector Min; FBox(int); }; namespace { FBox InvalidBoundingBox(0); } While parsing the DECL_VAR for 'struct FBox', clang recursively read all the dep decls until it finds the DECL_CXX_RECORD forward declaration for 'struct FVector'. Then, it resumes all the way up back to DECL_VAR handling in `ReadDeclRecord`, where it checks if `isConsumerInterestedIn` for the decl. One of the condition for `isConsumerInterestedIn` to return false is if the VarDecl is imported from a module `D->getImportedOwningModule()`, because it will get emitted when we import the relevant module. However, before checking if it comes from a module, clang checks if `Ctx.DeclMustBeEmitted(D)`, which triggers the emission of 'struct FBox'. Since one of its fields is still incomplete, it crashes. Instead, check if `D->getImportedOwningModule()` is true before calling `Ctx.DeclMustBeEmitted(D)`. Differential Revision: https://reviews.llvm.org/D29753 rdar://problem/30173654 llvm-svn: 296656
* [ODRHash] Add basic support for CXXRecordDeclRichard Trieu2017-02-281-0/+23
| | | | llvm-svn: 296521
* C++ DR1611, 1658, 2180: implement "potentially constructed subobject" rules ↵Richard Smith2017-02-252-3/+6
| | | | | | | | | | | | | | | | | | | | | | for special member functions. Essentially, as a base class constructor does not construct virtual bases, such a constructor for an abstract class does not need the corresponding base class construction to be valid, and likewise for destructors. This creates an awkward situation: clang will sometimes generate references to the complete object and deleting destructors for an abstract class (it puts them in the construction vtable for a derived class). But we can't generate a "correct" version of these because we can't generate references to base class constructors any more (if they're template specializations, say, we might not have instantiated them and can't assume any other TU will emit a copy). Fortunately, we don't need to, since no correct program can ever invoke them, so instead emit symbols that just trap. We should stop emitting references to these symbols, but still need to emit definitions for compatibility. llvm-svn: 296275
* [ODRHash] Finish FieldDecl support by handling mutable and initializers.Richard Trieu2017-02-241-1/+48
| | | | | | https://reviews.llvm.org/rL296170 llvm-svn: 296198
* [ODRHash] Add handling of bitfieldsRichard Trieu2017-02-241-0/+26
| | | | | | Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 296170
* [ODRHash] Add handling of TypedefType and DeclarationNameRichard Trieu2017-02-241-0/+47
| | | | | | Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 296078
* Represent pass_object_size attrs in ExtParameterInfoGeorge Burgess IV2017-02-241-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this is to fix a bug in modules where we'd merge FunctionDecls that differed in their pass_object_size attributes. Since we can overload on the presence of pass_object_size attributes, this behavior is incorrect. We don't represent `N` in `pass_object_size(N)` as part of ExtParameterInfo, since it's an error to overload solely on the value of N. This means that we have a bug if we have two modules that declare functions that differ only in their pass_object_size attrs, like so: // In module A, from a.h void foo(char *__attribute__((pass_object_size(0)))); // In module B, from b.h void foo(char *__attribute__((pass_object_size(1)))); // In module C, in main.c #include "a.h" #include "b.h" At the moment, we'll merge the foo decls, when we should instead emit a diagnostic about an invalid overload. We seem to have similar (silent) behavior if we overload only on the return type of `foo` instead; I'll try to find a good place to put a FIXME (or I'll just file a bug) soon. This patch also fixes a bug where we'd not output the proper extended parameter info for declarations with pass_object_size attrs. llvm-svn: 296076
* [ODRHash] Add IdentiferInfo and FieldDecl support.Richard Trieu2017-02-231-0/+22
| | | | | | | | | IdentifierInfo is hashed based on the stored string. FieldDecl versus other Decl is now detected, as well as differently named fields. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295911
* [ODRHash] static_cast and Stmt hashing.Richard Trieu2017-02-221-0/+101
| | | | | | | | | | Add support for static_cast in classes. Add pointer-independent profiling for Stmt's, sharing most of the logic with Stmt::Profile. This is the first of the deep sub-Decl diffing for error messages. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295890
* Fix 'control reaches end of non-void function' warningSimon Pilgrim2017-02-221-1/+2
| | | | llvm-svn: 295829
* [ODRHash] Avoid dereferencing end() of a SmallVector.Benjamin Kramer2017-02-221-1/+2
| | | | | | Found by MSAN. llvm-svn: 295820
* Add more ODR checking.Richard Trieu2017-02-221-12/+132
| | | | | | | | | | Add the basics for the ODRHash class, which will only process Decl's from a whitelist, which currently only has AccessSpecDecl. Different access specifiers in merged classes can now be detected. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295800
* Part of adding an improved ODR checker.Richard Trieu2017-02-182-0/+3
| | | | | | | | | Reserve a spot for ODR hash in CXXRecordDecl and in its modules storage. Default the hash value to 0 for all classes. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295533
* [modules] Load the ModuleOffsetMap from the module header lazily.Richard Smith2017-02-182-85/+113
| | | | | | | | If we never need to map any ID within the module to its global ID, we don't need the module offset map. If a compilation transitively depends on lots of unused module files, this can result in a modest performance improvement. llvm-svn: 295517
* [OpenMP] Prepare Sema for initial implementation for pragma 'distribute ↵Carlo Bertolli2017-02-172-0/+4
| | | | | | | | | | | | | | | parallel for' https://reviews.llvm.org/D29922 This patch adds two fields for use in the implementation of 'distribute parallel for': The increment expression for the distribute loop. As the chunk assigned to a team is executed by multiple threads within the 'parallel for' region, the increment expression has to correspond to the value returned by the related runtime call (for_static_init). The upper bound of the innermost loop ('for' in 'distribute parallel for') is not the globalUB expression normally used for pragma 'for' when found in isolation. It is instead the upper bound of the chunk assigned to the team ('distribute' loop). In this way, we prevent teams from executing chunks assigned to other teams. The use of these two fields can be see in a related explanatory patch: https://reviews.llvm.org/D29508 llvm-svn: 295497
* Add an explicit derived class of FunctionDecl to model deduction guides ratherRichard Smith2017-02-173-0/+15
| | | | | | | | than just treating them as FunctionDecls with a funny name. No functionality change intended. llvm-svn: 295491
* Revert r295421, new ODR checker for modules, to fix build bot.Richard Trieu2017-02-173-631/+10
| | | | llvm-svn: 295427
* Add better ODR checking for modules.Richard Trieu2017-02-173-10/+631
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A slightly weaker form of ODR checking than previous attempts, but hopefully won't break the modules build bot. Future work will be needed to catch all cases. 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 taken 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: 295421
* [OpenCL] Correct ndrange_t implementationAnastasia Stulova2017-02-162-6/+0
| | | | | | | | | | | | | | | Removed ndrange_t as Clang builtin type and added as a struct type in the OpenCL header. Use type name to do the Sema checking in enqueue_kernel and modify IR generation accordingly. Review: D28058 Patch by Dmitry Borisenkov! llvm-svn: 295311
* Revert r295284: Add better ODR checking for modules.Richard Trieu2017-02-163-633/+10
| | | | | | Fix modules build bot. llvm-svn: 295293
* Loosen a Type check ODR checking to try to fix the build bot.Richard Trieu2017-02-161-2/+4
| | | | llvm-svn: 295286
* Add better ODR checking for modules.Richard Trieu2017-02-163-10/+631
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recommit r293585 that was reverted in r293611 with new fixes. The previous issue was determined to be an overly aggressive AST visitor from forward declared objects. The visitor will now only deeply visit certain Decl's and only do a shallow information extraction from all other Decl's. 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 taken 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: 295284
* [Modules] Consider enable_if attrs in isSameEntity.George Burgess IV2017-02-151-2/+42
| | | | | | | | | | | | | | Two functions that differ only in their enable_if attributes are considered overloads, so we should check for those when we're trying to figure out if two functions are mergeable. We need to do the same thing for pass_object_size, as well. Looks like that'll be a bit less trivial, since we sometimes do these merging checks before we have pass_object_size attributes available (see the merge checks in ASTDeclReader::VisitFunctionDecl that happen before we read parameters, and merge checks in calls to ReadDeclAs<>()). llvm-svn: 295252
* Delete useless / in comment. NFC.George Burgess IV2017-02-141-1/+1
| | | | llvm-svn: 295032
* ASTReader: Refactor common code for writing function definitions, to match ↵David Blaikie2017-02-121-17/+15
| | | | | | the writing code llvm-svn: 294904
* [Concepts] Class template associated constraintsHubert Tong2017-02-101-0/+1
| | | | | | | | | | | | | | | | Summary: This adds associated constraints as a property of class templates. An error is produced if redeclarations are not similarly constrained. Reviewers: rsmith, faisalv, aaron.ballman Reviewed By: rsmith Subscribers: cfe-commits, nwilson Differential Revision: https://reviews.llvm.org/D25674 llvm-svn: 294697
* Sink IsExplicitSpecified flag from CXXConstructorDecl and CXXConversionDeclRichard Smith2017-02-102-6/+3
| | | | | | | into FunctionDecl. Makes CXXConversionDecl 8 bytes smaller. No functionality change intended. llvm-svn: 294684
* [ASTReader] Improve ReadASTBlock error message when module not availableBruno Cardoso Lopes2017-02-071-1/+4
| | | | | | | | Point to the PCM file that could not be found. rdar://problem/30381981 llvm-svn: 294362
OpenPOWER on IntegriCloud