aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization
AgeCommit message (Collapse)AuthorFilesLines
2017-07-06[modules ts] Do not emit strong function definitions from the module ↵Richard Smith1-2/+12
interface unit in every user. llvm-svn: 307232
2017-07-05[modules ts] Improve merging of module-private declarations.Richard Smith2-1/+3
These cases occur frequently for declarations in the global module (above the module-declaration) in a Modules TS module interface. When we merge a definition from another module into such a module-private definition, ensure that we transitively make everything lexically within that definition visible to that translation unit. llvm-svn: 307129
2017-07-01fix trivial typos; NFCHiroshi Inoue1-1/+1
llvm-svn: 306954
2017-06-30Reinstate "Load lazily the template specialization in multi-module setups."Vassil Vassilev1-38/+47
It was reverted in r305460 but the issue appears to only break our self-host libcxx modules bot. Reapplying it will give us a chance to get a reproducer and fix the issue. llvm-svn: 306903
2017-06-29Teach ASTReader how to read only the Preprocessor state from an AST file, ↵Richard Smith3-53/+112
not the ASTContext state. We use this when running a preprocessor-only action on an AST file in order to avoid paying the runtime cost of loading the extra information. llvm-svn: 306760
2017-06-29Track the set of module maps read while building a .pcm file and reload ↵Richard Smith2-11/+30
those when preprocessing from that .pcm file. llvm-svn: 306628
2017-06-28[ASTReader] Treat multiple defns of ObjC protocols the same as interfaces.Graydon Hoare1-14/+35
Summary: In change 2ba19793512, the ASTReader logic for ObjC interfaces was modified to preserve the first definition-data read, "merging" later definitions into it rather than overwriting it (though this "merging" is, in practice, a no-op that discards the later definition-data). Unfortunately this change was only made to ObjC interfaces, not protocols; this means that when (for example) loading a protocol that references an interface, if both the protocol and interface are multiply defined (as can easily happen if the same header is read from multiple contexts), an _inconsistent_ pair of definitions is loaded: first-read for the interface and last-read for the protocol. This in turn causes very subtle downstream bugs in the Swift ClangImporter, which filters the results of name lookups based on the owning module of a definition; inconsistency between a pair of related definitions causes name lookup failures at various stages of compilation. To fix these downstream issues, this change replicates the logic applied to interfaces in change 2ba19793512, but for ObjC protocols. rdar://30851899 Reviewers: doug.gregor, rsmith Reviewed By: doug.gregor Subscribers: jordan_rose, cfe-commits Differential Revision: https://reviews.llvm.org/D34741 llvm-svn: 306583
2017-06-27Remove redundant check.Richard Smith1-6/+0
llvm-svn: 306350
2017-06-23PR33552: Distinguish between declarations that are owned by no module andRichard Smith2-18/+16
declarations that are owned but unconditionally visible. This allows us to set declarations as visible even if they have a local owning module, without losing information. In turn, that means that our Objective-C support can keep on incorrectly assuming the "hidden" bit on the declaration is the whole story with regard to name visibility. This will also be useful once we support the C++ Modules TS export semantics. Objective-C name visibility is still incorrect in any case where the "hidden" bit is not the complete story: for instance, in Objective-C++ the set of visible categories will be wrong during template instantiation, and with local submodule visibility enabled it will be wrong when building modules. Fixing that will require a major overhaul of how visibility is handled for Objective-C (and particularly for categories). llvm-svn: 306075
2017-06-22PR33002: When we instantiate the definition of a static data member, we mightRichard Smith2-3/+23
have attached an initializer to the in-class declaration. If so, include the initializer in the update record for the instantiation. llvm-svn: 306065
2017-06-21[ODRHash] Supply more information when generic error message is emitted.Richard Trieu1-0/+11
llvm-svn: 305872
2017-06-16[ODRHash] Hash VarDecl members.Richard Trieu1-0/+113
These VarDecl's are static data members of classes. Since the initializers are also hashed, this also provides checking for default arguments to methods. llvm-svn: 305543
2017-06-15Revert "Load lazily the template specialization in multi-module setups."Vassil Vassilev1-47/+38
This broke our libcxx modules builds. llvm-svn: 305460
2017-06-12[ODRHash] Add diagnostic messages for typedef and type alias.Richard Trieu1-0/+41
llvm-svn: 305238
2017-06-09[modules] D29951: Load lazily the template specialization in multi-module ↵Vassil Vassilev1-38/+47
setups. Currently, we load all template specialization if we have more than one module attached and we touch anything around the template definition. This patch registers the template specializations as lazily-loadable entities. In some TUs it reduces the amount of deserializations by 1%. llvm-svn: 305120
2017-06-09[DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.Alexey Bataev2-0/+6
Summary: If the first parameter of the function is the ImplicitParamDecl, codegen automatically marks it as an implicit argument with `this` or `self` pointer. Added internal kind of the ImplicitParamDecl to separate 'this', 'self', 'vtt' and other implicit parameters from other kind of parameters. Reviewers: rjmccall, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33735 llvm-svn: 305075
2017-06-08[ODRHash] Change the fall-back diagnostic error.Richard Trieu1-7/+7
Provide a little more information when a ODR violation is detected, but the specific error could not be diagnosed. llvm-svn: 304956
2017-06-06Retain header search and preprocessing options from AST file when emittingRichard Smith2-0/+4
preprocessed text for an AST file. llvm-svn: 304756
2017-06-05Rather than rejecting attempts to run preprocessor-only actions on AST files,Richard Smith1-0/+1
replay the steps taken to create the AST file with the preprocessor-only action installed to produce preprocessed output. This can be used to produce the preprocessed text for an existing .pch or .pcm file. llvm-svn: 304726
2017-06-02[Modules] Fix use after scope.Benjamin Kramer1-1/+2
Found by asan. llvm-svn: 304568
2017-06-02Avoid calling report_fatal_error in the destructor of raw_fd_ostreamAlex Lorenz1-0/+2
when saving a module timestamp file This commit doesn't include a test as it requires a test that reproduces a file write/close error that couldn't really be constructed artificially. rdar://31860650 Differential Revision: https://reviews.llvm.org/D33357 llvm-svn: 304538
2017-06-02Support lazy stat'ing of files referenced by module maps.Richard Smith1-42/+114
This patch adds support for a `header` declaration in a module map to specify certain `stat` information (currently, size and mtime) about that header file. This has two purposes: - It removes the need to eagerly `stat` every file referenced by a module map. Instead, we track a list of unresolved header files with each size / mtime (actually, for simplicity, we track submodules with such headers), and when attempting to look up a header file based on a `FileEntry`, we check if there are any unresolved header directives with that `FileEntry`'s size / mtime and perform deferred `stat`s if so. - It permits a preprocessed module to be compiled without the original files being present on disk. The only reason we used to need those files was to get the `stat` information in order to do header -> module lookups when using the module. If we're provided with the `stat` information in the preprocessed module, we can avoid requiring the files to exist. Unlike most `header` directives, if a `header` directive with `stat` information has no corresponding on-disk file the enclosing module is *not* marked unavailable (so that behavior is consistent regardless of whether we've resolved a header directive, and so that preprocessed modules don't get marked unavailable). We could actually do this for all `header` directives: the only reason we mark the module unavailable if headers are missing is to give a diagnostic slightly earlier (rather than waiting until we actually try to build the module / load and validate its .pcm file). Differential Revision: https://reviews.llvm.org/D33703 llvm-svn: 304515
2017-06-01[Modules] Handle sanitizer feature mismatches when importing modulesVedant Kumar1-0/+27
This patch makes it an error to have a mismatch between the enabled sanitizers in a CU, and in any module being imported into the CU. Only mismatches between non-modular sanitizers are treated as errors. This patch also includes non-modular sanitizers in module hashes, in order to ensure module rebuilds occur when -fsanitize=X is toggled on and off for non-modular sanitizers, and to cut down on module rebuilds when the option is toggled for modular sanitizers. This fixes a longstanding issue with implicit modules and sanitizers, which Duncan originally diagnosed. When building with implicit modules it's possible to hit a scenario where modules are built without -fsanitize=address, and are subsequently imported into CUs with -fsanitize=address enabled. This causes strange failures at runtime. The case Duncan found affects libcxx, since its vector implementation behaves differently when ASan is enabled. Implicit module builds should "just work" when -fsanitize=X is toggled on and off across multiple compiler invocations, which is what this patch does. Differential Revision: https://reviews.llvm.org/D32724 llvm-svn: 304463
2017-05-31[modules] When compiling a preprocessed module map, look for headers relativeRichard Smith1-4/+5
to the original module map. Also use the path and name of the original module map when emitting that information into the .pcm file. The upshot of this is that the produced .pcm file will track information for headers in their original locations (where the module was preprocessed), not relative to whatever directory the preprocessed module map was in when it was built. llvm-svn: 304346
2017-05-30Allow for unfinished #if blocks in preamblesErik Verbruggen2-0/+28
Previously, a preamble only included #if blocks (and friends like ifdef) if there was a corresponding #endif before any declaration or definition. The problem is that any header file that uses include guards will not have a preamble generated, which can make code-completion very slow. To prevent errors about unbalanced preprocessor conditionals in the preamble, and unbalanced preprocessor conditionals after a preamble containing unfinished conditionals, the conditional stack is stored in the pch file. This fixes PR26045. Differential Revision: http://reviews.llvm.org/D15994 llvm-svn: 304207
2017-05-19[modules] Further delay calling DeclMustBeEmitted until it's safe.Vassil Vassilev2-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
2017-05-18[modules] Switch from inferring owning modules based on source location toRichard Smith2-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
2017-05-17[ODRHash] Support NestedNameSpecifierRichard Trieu1-29/+2
llvm-svn: 303233
2017-05-12Remove unused tracking of owning module for MacroInfo objects.Richard Smith2-3/+1
llvm-svn: 302966
2017-05-03Silences gcc's -Wnarrowing.Daniel Jasper1-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
2017-05-03[modules] Round-trip -Werror flag through explicit module build.Richard Smith2-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
2017-05-02[ODRHash] Add support for array and decayed types, and parameter names and ↵Richard Trieu1-0/+79
types. llvm-svn: 301989
2017-05-01Fix initial diagnostic state setup for an explicit module with no diagnostic ↵Richard Smith1-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
2017-04-27[X86] Support of no_caller_saved_registers attributeOren Ben Simhon2-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
2017-04-25Placate MSVC's narrowing conversion unhappiness.Richard Smith1-1/+1
llvm-svn: 301285
2017-04-24[modules ts] Diagnose 'export' declarations outside of a module interface.Richard Smith2-3/+7
llvm-svn: 301271
2017-04-20[OpenMP] Prepare sema to support combined constructs with omp distribute and ↵Carlo Bertolli2-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
2017-04-15Modules: Do not serialize #pragma pack stateDuncan P. N. Exon Smith1-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
2017-04-12[modules] Delay calling DeclMustBeEmitted until it's safe.Vassil Vassilev2-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
2017-04-12Modular Codegen: Separate flags for function and debug info supportDavid Blaikie2-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
2017-04-12Revert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"Hans Wennborg1-103/+0
It caused PR32640. llvm-svn: 300074
2017-04-12Serialization: Simulate -Werror settings in implicit modulesDuncan P. N. Exon Smith2-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
2017-04-12Serialization: Emit the final diagnostic state last, almost NFCDuncan P. N. Exon Smith2-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
2017-04-12Serialization: Skip check in WritePragmaDiagnosticMappings, NFCDuncan P. N. Exon Smith1-2/+1
The record is never empty, since we always serialize the initial state. Skip the check. llvm-svn: 300021
2017-04-11Revert r298824 & r298816, recommit r298742 & r298754Richard Trieu1-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
2017-04-11[ODRHash] Improve handling of hash valuesRichard Trieu2-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
2017-04-11Modular Codegen: Support homing debug info for types in modular objectsDavid Blaikie3-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
2017-04-11Modular Codegen: Add/use a bit in serialized function definitions to track ↵David Blaikie4-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
2017-03-31[Modules][PCH] Serialize #pragma packAlex Lorenz2-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
2017-03-30Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim1-1/+1
llvm-svn: 299083