summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix PCHs that import more than one moduleBen Langmuir2014-09-081-1/+4
| | | | | | | We were passing < to std::unique, but it expects ==. Since the input is sorted, we were always trimming it to one entry. llvm-svn: 217402
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor ↵Craig Topper2014-08-301-2/+2
| | | | | | and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. llvm-svn: 216824
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-0/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* [modules] Number anonymous declarations that are lexically within mergeableRichard Smith2014-08-281-0/+24
| | | | | | contexts, so that we can merge them when we merge the surrounding context. llvm-svn: 216639
* When loading a module with no local entities, still bump the size of theBen Langmuir2014-08-161-0/+3
| | | | | | | | | | | | | | | | | tables that correspond to ContinuousRangeMaps, since the keys to those maps need to be unique, or we may map to the wrong offset. This fixes a crash + malformed AST file seen when loading some modules that import Cocoa on Darwin, which is a module with no contents except imports of other modules. Unfortunately I have not been able to find a reduced test case that reproduces this problem. Also add an assert that we aren't mapping one key to multiple values in CRM. We ought to be able to say there are no duplicate keys at all, but there are a bunch of 0 -> 0 mappings that are showing up, probably coming from the source location table. llvm-svn: 215810
* [modules] When we merge together multiple class template specializationRichard Smith2014-08-141-3/+16
| | | | | | | | | | definitions (because some other declaration declares a special member that isn't present in the canonical definition), we need to search *all* of them; we can't just stop when we find the requested name in any of the definitions, because that can fail to find things (and in particular, it can fail to find the member of the canonical declaration and return a bogus ODR failure). llvm-svn: 215612
* [modules] When performing a lookup into a namespace, ensure that any laterRichard Smith2014-08-131-2/+14
| | | | | | | | | | redefinitions of that namespace have already been loaded. When writing out the names in a namespace, if we see a name that is locally declared and had imported declarations merged on top of it, export the local declaration as the lookup result, because it will be the most recent declaration of that entity in the redeclaration chain of an importer of the module. llvm-svn: 215518
* Verify all the module map files for a pcm are the same on loadBen Langmuir2014-08-121-11/+21
| | | | | | | | | | We already verified the primary module map file (either the one that defines the top-level module, or the one that allows inferring it if it is an inferred framework module). Now we also verify any other module map files that define submodules, such as when there is a module.private.modulemap file. llvm-svn: 215455
* Add some FIXMEs.Richard Smith2014-08-111-0/+2
| | | | llvm-svn: 215375
* Refactor the module map file used for uniquing a module name out ofBen Langmuir2014-08-091-2/+3
| | | | | | | | | class Module. It's almost always going to be the same as getContainingModule() for top-level modules, so just add a map to cover the remaining cases. This lets us do less bookkeeping to keep the ModuleMap fields up to date. llvm-svn: 215268
* [modules] When emitting an update record containing the body of a destructor,Richard Smith2014-08-071-12/+11
| | | | | | | | | also emit the updated 'operator delete' looked up for that destructor. Switch from UpdateDecl to an actual update record when this happens due to implicitly defining a special member function and unify this code path and the one for instantiating a function definition. llvm-svn: 215132
* Use -Rblah, not -Wblah, to control remark diagnostics. This was always theRichard Smith2014-08-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | intent when we added remark support, but was never implemented in the general case, because the first -R flags didn't need it. (-Rpass= had special handling to accomodate its argument.) -Rno-foo, -Reverything, and -Rno-everything can be used to turn off a remark, or to turn on or off all remarks. Per discussion on cfe-commits, -Weverything does not affect remarks, and -Reverything does not affect warnings or errors. The only "real" -R flag we have right now is -Rmodule-build; that flag is effectively renamed from -Wmodule-build to -Rmodule-build by this change. -Wpass and -Wno-pass (and their friends) are also renamed to -Rpass and -Rno-pass by this change; it's not completely clear whether we intended to have a -Rpass (with no =pattern), but that is unchanged by this commit, other than the flag name. The default pattern is effectively one which matches no passes. In future, we may want to make the default pattern be .*, so that -Reverything works for -Rpass properly. llvm-svn: 215046
* [modules] Add some missing record names. We really should be generating this ↵Richard Smith2014-07-271-2/+8
| | | | | | from a .def file or similar... llvm-svn: 214049
* [modules] Add abbreviation for ImplicitCastExpr. This is the most commonRichard Smith2014-07-271-3/+4
| | | | | | record type in LLVM's IR module. llvm-svn: 214048
* [modules] Improve abbreviations for C++:Richard Smith2014-07-261-34/+91
| | | | | | | | | | | | | | | | | * Add abbreviation for CXXMethodDecl and for FunctionProtoType. These come up a *lot* in C++ modules. * Allow typedef declarations to use the abbreviation if they're class members, or if they're used. In passing, add more record name records for Clang AST node kinds. The downside is that we had already used up our allotment of 12 abbreviations, so this pushes us to an extra bit on each record to support the extra abbrev kinds, which increases file size by ~1%. This patch *barely* pays for that through the other improvements, but we've got room for another 18 abbrevs, so we should be able to make it much more profitable with future changes. llvm-svn: 214024
* [modules] Substantially improve handling of #undef:Richard Smith2014-07-251-107/+140
| | | | | | | | | | * Track override set across module load and save * Track originating module to allow proper re-export of #undef * Make override set properly transitive when it picks up a #undef This fixes nearly all of the remaining macro issues with self-host. llvm-svn: 213922
* [modules] Fix some of the confusion when computing the override set for a macroRichard Smith2014-07-211-13/+12
| | | | | | | introduced by finalization. This is still not entirely correct; more fixes to follow. llvm-svn: 213498
* Reinstate r213348, reverted in r213395, with an additional bug fix and moreRichard Smith2014-07-181-1/+17
| | | | | | | | | | | | | | | | | | | | thorough tests. Original commit message: [modules] Fix macro hiding bug exposed if: * A submodule of module A is imported into module B * Another submodule of module A that is not imported into B exports a macro * Some submodule of module B also exports a definition of the macro, and happens to be the first submodule of B that imports module A. In this case, we would incorrectly determine that A's macro redefines B's macro, and so we don't need to re-export B's macro at all. This happens with the 'assert' macro in an LLVM self-host. =( llvm-svn: 213416
* Revert "[modules] Fix macro hiding bug exposed if:"Ben Langmuir2014-07-181-11/+1
| | | | | | | | | | This is breaking the system modules on Darwin, because something that was defined and re-exported no longer is. Might be this patch, or might just be a really poor interaction with an existing visibility bug. This reverts commit r213348. llvm-svn: 213395
* [modules] Fix macro hiding bug exposed if:Richard Smith2014-07-181-1/+11
| | | | | | | | | | | | | | * A submodule of module A is imported into module B * Another submodule of module A that is not imported into B exports a macro * Some submodule of module B also exports a definition of the macro, and happens to be the first submodule of B that imports module A. In this case, we would incorrectly determine that A's macro redefines B's macro, and so we don't need to re-export B's macro at all. This happens with the 'assert' macro in an LLVM self-host. =( llvm-svn: 213348
* Added the pack_elements range accessor. Refactoring some for loops to use ↵Aaron Ballman2014-07-151-3/+2
| | | | | | range-based for loops instead. No functional changes intended. llvm-svn: 213095
* Remove llvm:: from uses of ArrayRef.Craig Topper2014-06-281-1/+1
| | | | llvm-svn: 211987
* Complete the switch from mappings to declarative diagnostic severitiesAlp Toker2014-06-121-1/+1
| | | | | | | | | This begins to address cognitive dissonance caused by treating the Note diagnostic level as a severity in the diagnostic engine. No change in functionality. llvm-svn: 210758
* Improve diagnostic mapping terminologyAlp Toker2014-06-101-1/+1
| | | | | | | | | | | | Diagnostic mappings are used to calculate the final severity of diagnostic instances. Detangle the implementation to reflect the terminology used in documentation and bindings. No change in functionality. llvm-svn: 210518
* Implemented support for "pragma clang optimize on/off", based on attribute ↵Dario Domizioli2014-05-231-0/+11
| | | | | | | | | | | | | | | | 'optnone'. This patch implements support for selectively disabling optimizations on a range of function definitions through a pragma. The implementation is that all function definitions in the range are decorated with attribute 'optnone'. #pragma clang optimize off // All function definitions in here are decorated with 'optnone'. #pragma clang optimize on // Compilation resumes as normal. llvm-svn: 209510
* If a class template specialization from one module has its definitionRichard Smith2014-05-221-0/+13
| | | | | | | | | instantiated in another module, and the instantiation uses a partial specialization, include the partial specialization and its template arguments in the update record. We'll need them if someone imports the second module and tries to instantiate a member of the template. llvm-svn: 209472
* [C++11] Use 'nullptr'. Serialization edition.Craig Topper2014-05-221-25/+26
| | | | llvm-svn: 209392
* If a declaration is loaded, and then a module import adds a redeclaration, thenRichard Smith2014-05-161-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. llvm-svn: 209046
* Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.Benjamin Kramer2014-05-101-1/+2
| | | | | | | Required pulling LambdaExpr::Capture into its own header. No functionality change. llvm-svn: 208470
* [PCH/Modules] Don't tie TargetOptions::LinkerVersion to a module/PCH, it's a ↵Argyrios Kyrtzidis2014-04-291-1/+0
| | | | | | | | driver only thing and doesn't affect any language/preprocessor/etc. semantics. rdar://16714526 llvm-svn: 207570
* When a module completes the definition of a class template specialization ↵Richard Smith2014-04-191-38/+107
| | | | | | imported from another module, emit an update record, rather than using the broken decl rewriting mechanism. If multiple modules do this, merge the definitions together, much as we would if they were separate declarations. llvm-svn: 206680
* Teach users of OnDiskHashTable to define hash_value and offset typesJustin Bogner2014-04-181-5/+18
| | | | | | | | This paves the way to making OnDiskHashTable work with hashes that are not 32 bits wide and to making OnDiskHashTable work very large hash tables. The LLVM change to use these types is upcoming. llvm-svn: 206640
* Remove OnDiskHashTable.h, since it's been moved to llvmJustin Bogner2014-04-181-6/+7
| | | | llvm-svn: 206637
* Add missing serialization code for one of the CXXRecordDecl definition flags.Richard Smith2014-04-171-0/+1
| | | | llvm-svn: 206493
* Allow multiple modules with the same name to coexist in the module cacheBen Langmuir2014-04-141-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To differentiate between two modules with the same name, we will consider the path the module map file that they are defined by* part of the ‘key’ for looking up the precompiled module (pcm file). Specifically, this patch renames the precompiled module (pcm) files from cache-path/<module hash>/Foo.pcm to cache-path/<module hash>/Foo-<hash of module map path>.pcm In addition, I’ve taught the ASTReader to re-resolve the names of imported modules during module loading so that if the header search context changes between when a module was originally built and when it is loaded we can rebuild it if necessary. For example, if module A imports module B first time: clang -I /path/to/A -I /path/to/B ... second time: clang -I /path/to/A -I /different/path/to/B ... will now rebuild A as expected. * in the case of inferred modules, we use the module map file that allowed the inference, not the __inferred_module.map file, since the inferred file path is the same for every inferred module. llvm-svn: 206201
* [Preprocessor/CodeComplete] Don't add include guard macros to ↵Argyrios Kyrtzidis2014-04-091-0/+1
| | | | | | code-completion results. llvm-svn: 205917
* Reapply "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner2014-03-281-61/+93
| | | | | | | | | | | | | Committed this by accident before it was done last time. Original message: Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205061
* Revert "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner2014-03-281-93/+61
| | | | | | This reverts commit r205044. llvm-svn: 205047
* OnDiskHashTable: Use EndianStream.h to write little endian ostreamsJustin Bogner2014-03-281-61/+93
| | | | | | | | | Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205044
* Fix PR18307: Properly (de)serialize inherited constructors and their using ↵Stephan Tolksdorf2014-03-271-7/+25
| | | | | | | | declarations Reviewed in http://llvm-reviews.chandlerc.com/D3102 llvm-svn: 204951
* Save out a correct lookup table if a lookup table entry is stale (it containsRichard Smith2014-03-251-64/+76
| | | | | | | | | an out-of-date external decls list). This happens if we declare some names, force the lookup table for the decl context to be built, import a module that adds more decls for the name, then write out our module without looking up the name. llvm-svn: 204694
* Emit an update record if we instantiate the definition of a function templateRichard Smith2014-03-221-0/+27
| | | | | | | | specialization from a module. (This can also happen for function template specializations in PCHs if they're instantiated eagerly, because they're constexpr or have a deduced return type.) llvm-svn: 204547
* Fixing code that doesn't compile in MSVC 2012 (but does in MSVC 2013) from ↵Aaron Ballman2014-03-211-15/+23
| | | | | | r204417 and related commits. llvm-svn: 204471
* Serialize and deserialize mangling numbers.Richard Smith2014-03-211-3/+18
| | | | llvm-svn: 204423
* PR19215: When writing/reading a PCH that imported a module, store the locationRichard Smith2014-03-211-11/+24
| | | | | | | at which that PCH imported each visible submodule of the module. Such locations are needed when synthesizing macro directives resulting from the import. llvm-svn: 204417
* When the exception specification for a function in an imported PCH or module isRichard Smith2014-03-201-9/+30
| | | | | | resolved, emit an update record. llvm-svn: 204403
* Refactor and simplify DeclUpdates serialization.Richard Smith2014-03-201-69/+38
| | | | llvm-svn: 204397
* Refactor to move decl update emission into the decl emission loop.Richard Smith2014-03-201-15/+19
| | | | llvm-svn: 204392
* Rearrange serialization block order to put decl update emission into the sameRichard Smith2014-03-201-37/+42
| | | | | | | | block as decl and type emission. This allows decl updates include statements and expressions. No functionality change (but the generated PCM files are incompatible with earlier versions of Clang). llvm-svn: 204385
OpenPOWER on IntegriCloud