summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
...
* [modules] Further delay calling DeclMustBeEmitted until it's safe.Vassil Vassilev2017-05-192-9/+16
| | | | | | | | | | | | | | As discussed in D30793, we have some unsafe calls to isConsumerInterestedIn(). This patch implements Richard's suggestion (from the inline comment) that we should track if we just deserialized an declaration. If we just deserialized, we can skip the unsafe call because we know it's interesting. If we didn't just deserialize the declaration, calling isConsumerInterestedIn() should be safe. We tried to create a test case for this but we were not successful. Patch by Raphael Isemann (D32499)! llvm-svn: 303432
* [modules] Switch from inferring owning modules based on source location toRichard Smith2017-05-182-20/+1
| | | | | | | | | | | | | | | inferring based on the current module at the point of creation. This should result in no functional change except when building a preprocessed module (or more generally when using #pragma clang module begin/end to switch module in the middle of a file), in which case it allows us to correctly track the owning module for declarations. We can't map from FileID to module in the preprocessed module case, since all modules would have the same FileID. There are still a couple of remaining places that try to infer a module from a source location; I'll clean those up in follow-up changes. llvm-svn: 303322
* [ODRHash] Support NestedNameSpecifierRichard Trieu2017-05-171-29/+2
| | | | llvm-svn: 303233
* Remove unused tracking of owning module for MacroInfo objects.Richard Smith2017-05-122-3/+1
| | | | llvm-svn: 302966
* Silences gcc's -Wnarrowing.Daniel Jasper2017-05-031-2/+3
| | | | | | | | | I think this is a false positive in GCC's warning, but nonetheless, we should try to be warning-free. Smaller reproducer (reproduces with GCC 6.3): https://godbolt.org/g/cJuO2z llvm-svn: 302003
* [modules] Round-trip -Werror flag through explicit module build.Richard Smith2017-05-032-25/+49
| | | | | | | | | | | | | | | The intent for an explicit module build is that the diagnostics produced within the module are those that were configured when the module was built, not those that are enabled within a user of the module. This includes diagnostics that don't actually show up until the module is used (for instance, diagnostics produced during template instantiation and weird cases like -Wpadded). We serialized and restored the diagnostic state for individual warning groups, but previously did not track the state for flags like -Werror and -Weverything, which are implemented as separate bits rather than as part of the diagnostics mapping information. llvm-svn: 301992
* [ODRHash] Add support for array and decayed types, and parameter names and ↵Richard Trieu2017-05-021-0/+79
| | | | | | types. llvm-svn: 301989
* Fix initial diagnostic state setup for an explicit module with no diagnostic ↵Richard Smith2017-05-011-4/+14
| | | | | | | | | | | | pragmas. If a file has no diagnostic pragmas, we build its diagnostic state lazily, but in this case we never set up the root state to be the diagnostic state in which the module was originally built, so the diagnostic flags for files in the module with no diagnostic pragmas were incorrectly based on the user of the module rather than the diagnostic state when the module was built. llvm-svn: 301846
* [X86] Support of no_caller_saved_registers attributeOren Ben Simhon2017-04-272-4/+7
| | | | | | | | | Implements the Clang part for no_caller_saved_registers attribute as appears here: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be. Differential Revision: https://reviews.llvm.org/D31871 llvm-svn: 301535
* Placate MSVC's narrowing conversion unhappiness.Richard Smith2017-04-251-1/+1
| | | | llvm-svn: 301285
* [modules ts] Diagnose 'export' declarations outside of a module interface.Richard Smith2017-04-242-3/+7
| | | | llvm-svn: 301271
* [OpenMP] Prepare sema to support combined constructs with omp distribute and ↵Carlo Bertolli2017-04-202-0/+14
| | | | | | | | | | omp for https://reviews.llvm.org/D32237 This patch prepares sema with additional fields to support all those composite and combined constructs of OpenMP that include pragma 'distribute' and 'for', such as 'distribute parallel for'. It also extends the regression tests for 'distribute parallel for' and adds a new one. llvm-svn: 300802
* Modules: Do not serialize #pragma pack stateDuncan P. N. Exon Smith2017-04-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The modules side of r299226, which serializes #pragma pack state, doesn't work well. The main purpose was to make -include and -include-pch match semantics (the PCH side). We also started serializing #pragma pack in PCMs, in the hopes of making modules and non-modules builds more consistent. But consider: $ cat a.h $ cat b.h #pragma pack(push, 2) $ cat module.modulemap module M { module a { header "a.h" } module b { header "b.h" } } $ cat t.cpp #include "a.h" #pragma pack(show) As of r299226, the #pragma pack(show) gives "2", even though we've only included "a.h". - With -fmodules-local-submodule-visibility, this is clearly wrong. We should get the default state (8 on x86_64). - Without -fmodules-local-submodule-visibility, this kind of matches how other things work (as if include-the-whole-module), but it's still really terrible, and it doesn't actually make modules and non-modules builds more consistent. This commit disables the serialization for modules, essentially a partial revert of r299226. Going forward: 1. Having this #pragma pack stuff escape is terrible design (or, more often, a horrible bug). We should prioritize adding warnings (maybe -Werror by default?). 2. If we eventually reintroduce this for modules, it should only apply to -fmodules-local-submodule-visibility, and it should be tracked on a per-submodule basis. llvm-svn: 300380
* [modules] Delay calling DeclMustBeEmitted until it's safe.Vassil Vassilev2017-04-122-28/+32
| | | | | | | | | | | | | This patch implements the suggestion in D29753 that calling DeclMustBeEmitted in the middle of deserialization should be avoided and that the actual check should be deferred until it's safe to do so. This patch fixes a crash when accessing the invalid redecl chains while trying to evaluate the value of a const VarDecl that contains a function call. Patch by Raphael Isemann (D30793)! llvm-svn: 300110
* Modular Codegen: Separate flags for function and debug info supportDavid Blaikie2017-04-122-9/+8
| | | | | | | | | | This allows using and testing these two features separately. (noteably, debug info is, so far as I know, always a win (basically). But function modular codegen is currently a loss for highly optimized code - where most of the linkonce_odr definitions are optimized away, so providing weak_odr definitions is only overhead) llvm-svn: 300104
* Revert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"Hans Wennborg2017-04-121-103/+0
| | | | | | It caused PR32640. llvm-svn: 300074
* Serialization: Simulate -Werror settings in implicit modulesDuncan P. N. Exon Smith2017-04-122-8/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r293123 started serializing diagnostic pragma state for modules. This makes the serialization work properly for implicit modules. An implicit module build (using Clang's internal build system) uses the same PCM file location for different `-Werror` levels. E.g., if a TU has `-Werror=format` and tries to load a PCM built without `-Werror=format`, a new PCM will be built in its place (and the new PCM should have the same signature, since r297655). In the other direction, if a TU does not have `-Werror=format` and tries to load a PCM built with `-Werror=format`, it should "just work". The idea is to evolve the PCM toward the strictest -Werror flags that anyone tries. r293123 started serializing the diagnostic pragma state for each PCM. Since this encodes the -Werror settings at module-build time, it breaks the implicit build model. This commit filters the diagnostic state in order to simulate the current compilation's diagnostic settings. Firstly, it ignores the module's serialized first diagnostic state, replacing it with the state from this compilation's command-line. Secondly, if a pragma warning was upgraded to error/fatal when generating the PCM (e.g., due to `-Werror` on the command-line), it checks whether it should still be upgraded in its current context. llvm-svn: 300025
* Serialization: Emit the final diagnostic state last, almost NFCDuncan P. N. Exon Smith2017-04-122-19/+40
| | | | | | | | | | Emit the final diagnostic state last to match source order. This also prepares for a follow-up commit for implicit modules. There's no real functionaliy change, just a slightly different AST file format. llvm-svn: 300024
* Serialization: Skip check in WritePragmaDiagnosticMappings, NFCDuncan P. N. Exon Smith2017-04-121-2/+1
| | | | | | | The record is never empty, since we always serialize the initial state. Skip the check. llvm-svn: 300021
* Revert r298824 & r298816, recommit r298742 & r298754Richard Trieu2017-04-111-0/+103
| | | | | | | | | | | | | r299989 fixes the underlying issue by waiting long enough to late parsed arguments to be processed before doing an calculating the hash. r298742 [ODRHash] Add error messages for mismatched parameters in methods. r298754 [ODRHash] Add support for array and decayed types. llvm-svn: 300001
* [ODRHash] Improve handling of hash valuesRichard Trieu2017-04-112-2/+9
| | | | | | | | | | | Calculating the hash in Sema::ActOnTagFinishDefinition could happen before all sub-Decls were parsed or processed, which would produce the wrong hash value. Change to calculating the hash on the first use and storing the value instead. Also, avoid using the macros that were only for Boolean fields and use an explicit checker during the DefintionData merge. No functional change, but was this blocking other ODRHash patches. llvm-svn: 299989
* Modular Codegen: Support homing debug info for types in modular objectsDavid Blaikie2017-04-113-6/+22
| | | | | | | | | Matching the function-homing support for modular codegen. Any type implicitly (implicit template specializations) or explicitly defined in a module is attached to that module's object file and omitted elsewhere (only a declaration used if necessary for references). llvm-svn: 299987
* Modular Codegen: Add/use a bit in serialized function definitions to track ↵David Blaikie2017-04-114-22/+18
| | | | | | | | | | | | | | | | | | | | | whether they are the subject of modular codegen Some decls are created not where they are written, but in other module files/users (implicit special members and function template implicit specializations). To correctly identify them, use a bit next to the definition to track the modular codegen property. Discussed whether the module file bit could be omitted in favor of reconstituting from the modular codegen decls list - best guess today is that the efficiency improvement of not having to deserialize the whole list whenever any function is queried by a module user is worth it for the small size increase of this redundant (list + bit-on-def) representation. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D29901 llvm-svn: 299982
* [Modules][PCH] Serialize #pragma packAlex Lorenz2017-03-312-0/+65
| | | | | | | | | | | This patch serializes the state of #pragma pack. It preserves the state of the pragma from a PCH/from modules in a file that uses that PCH/those modules. rdar://21359084 Differential Revision: https://reviews.llvm.org/D31241 llvm-svn: 299226
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-1/+1
| | | | llvm-svn: 299083
* 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
OpenPOWER on IntegriCloud