summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix bogus 'method is unavailable' errors with modulesBen Langmuir2015-01-121-3/+7
| | | | | | | | This just tweaks the fix from r224892 (which handled PCHs) to work with modules, where we will serialize each method individually and hence the hasMoreThanOneDecl bit needs to be updated as we add the methods. llvm-svn: 225659
* Objective-C: Serialize "more than one decl" state of ObjCMethodList.Nico Weber2014-12-271-9/+20
| | | | | | | | | | | | | | | | | This fixes PR21587, what r221933 fixed for regular programs is now also fixed for decls coming from PCH files. Use another bit from the count/bits uint16_t for storing the "more than one decl" bit. This reduces the number of bits for the count from 14 to 13. The selector with the most overloads in Cocoa.h has ~55 overloads, so 13 bits should still be plenty. Since this changes the meaning of a serialized bit pattern, also increase clang::serialization::VERSION_MAJOR. Storing the "more than one decl" state of only the first overload isn't quite correct, but Sema::AreMultipleMethodsInGlobalPool() currently only looks at the state of the first overload so it's good enough for now. llvm-svn: 224892
* Address review feedback on r221933.Nico Weber2014-12-271-7/+7
| | | | | | | | | | | Remove ObjCMethodList::Count, instead store a "has more than one decl" bit in the low bit of the ObjCMethodDecl pointer, using a PointerIntPair. Most of this patch is replacing ".Method" with ".getMethod()". No intended behavior change. llvm-svn: 224876
* [modules] If we import a module, and we've seen a module map that describes theRichard Smith2014-12-061-2/+24
| | | | | | | | | module, use the path from the module map file in preference to the path from the .pcm file when resolving relative paths in the .pcm file. This allows diagnostics (and .d output) to give relative paths if the module was found via a relative path. llvm-svn: 223577
* [modules] Instead of storing absolute paths in a .pcm file, store the path toRichard Smith2014-12-051-67/+71
| | | | | | | | | | | | | | | the root of the module and use paths relative to that directory wherever possible. This is a step towards allowing explicit modules to be relocated without being rebuilt, which is important for some kinds of distributed builds, for good paths in diagnostics, and for appropriate .d output. This is a recommit of r223443, reverted in r223465; when joining together imported file paths, we now use the system's separator rather than always using '/'. This avoids path mismatches between the original module build and the module user on Windows (at least, in some cases). A more comprehensive fix will follow. llvm-svn: 223539
* Temporarily reverting r223443 due to bot breakage.Aaron Ballman2014-12-051-71/+65
| | | | llvm-svn: 223465
* [modules] Instead of storing absolute paths in a .pcm file, store the path toRichard Smith2014-12-051-65/+71
| | | | | | | | | the root of the module and use paths relative to that directory wherever possible. This is a step towards allowing explicit modules to be relocated without being rebuilt, which is important for some kinds of distributed builds, for good paths in diagnostics, and for appropriate .d output. llvm-svn: 223443
* Try to fix the MSVC build.Hans Wennborg2014-12-021-3/+2
| | | | llvm-svn: 223105
* [modules] Track how 'header' directives were written in module map files,Richard Smith2014-12-021-1/+7
| | | | | | | | | | | | | rather than trying to extract this information from the FileEntry after the fact. This has a number of beneficial effects. For instance, diagnostic messages for failed module builds give a path relative to the "module root" rather than an absolute file path, and the contents of the module includes file is no longer dependent on what files the including TU happened to inspect prior to triggering the module build. llvm-svn: 223095
* PR21323: Fix iterator invalidation issue when looking for redeclarations of aRichard Smith2014-11-211-3/+8
| | | | | | | | | special member function. No test yet: the only testcases we have for this issue are extremely complex. Testcase will be added once I get a reasonable reduction. llvm-svn: 222506
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-2/+2
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* [ASTReader] Add a convenience function to retrieve all the input files of a ↵Argyrios Kyrtzidis2014-11-181-0/+8
| | | | | | module file. llvm-svn: 222224
* Update for llvm api change.Rafael Espindola2014-11-121-1/+1
| | | | llvm-svn: 221786
* Simplify code a bit by passing StreamFile to the BitstreamCursor constructor.Rafael Espindola2014-11-121-4/+2
| | | | llvm-svn: 221784
* Validate user headers even if -fmodules-validate-once-per-build-sessionBen Langmuir2014-11-101-3/+2
| | | | | | | | is enabled. Unlike system headers, we want to be more careful about modifications to user headers, because it's still easy to edit a header while you're building. llvm-svn: 221634
* Fix unintended fallthrough in ASTReaderBen Langmuir2014-11-081-0/+2
| | | | llvm-svn: 221567
* Introduce a SanitizerKind enum to LangOptions.Alexey Samsonov2014-11-071-1/+2
| | | | | | | | | | | | | Use the bitmask to store the set of enabled sanitizers instead of a bitfield. On the negative side, it makes syntax for querying the set of enabled sanitizers a bit more clunky. On the positive side, we will be able to use SanitizerKind to eventually implement the new semantics for -fsanitize-recover= flag, that would allow us to make some sanitizers recoverable, and some non-recoverable. No functionality change. llvm-svn: 221558
* [modules] When a .pcm file is explicitly built separately from the translationRichard Smith2014-10-311-18/+47
| | | | | | unit, allow the -O settings of the two compilations to differ. llvm-svn: 220943
* [modules] Allow -I, -D, -W flags to change between building a module andRichard Smith2014-10-281-3/+18
| | | | | | | | explicitly using the resulting .pcm file. Unlike for an implicit module build, we don't need nor want to require these flags to match between the module and its users. llvm-svn: 220780
* Remove unused variable.Richard Smith2014-10-271-2/+1
| | | | llvm-svn: 220738
* [modules] Load .pcm files specified by -fmodule-file lazily.Richard Smith2014-10-271-0/+19
| | | | llvm-svn: 220731
* Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer2014-10-261-11/+8
| | | | | | | This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
* [modules] Support combining 'textual' with 'private'.Richard Smith2014-10-241-17/+10
| | | | llvm-svn: 220589
* [modules] Simplify reading of INPUT_FILE_OFFSETS record and make it robust ↵Richard Smith2014-10-231-7/+7
| | | | | | against changes to record order. llvm-svn: 220524
* Factor out common checks from module map deserialization. No functionality ↵Richard Smith2014-10-231-110/+17
| | | | | | change. llvm-svn: 220521
* Add a "signature" to AST files to verify that they haven't changedBen Langmuir2014-10-231-2/+40
| | | | | | | | | | | | | | | | | | | | | Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs) is not stable, it is not safe to load an AST file that depends on another AST file that has been rebuilt since the importer was built, even if "nothing changed". We previously used size and modtime to check this, but I've seen cases where a module rebuilt quickly enough to foil this check and caused very hard to debug build errors. To save cycles when we're loading the AST, we just generate a random nonce value and check that it hasn't changed when we load an imported module, rather than actually hash the whole file. This is slightly complicated by the fact that we need to verify the signature inside addModule, since we might otherwise consider that a mdoule is "OutOfDate" when really it is the importer that is out of date. I didn't see any regressions in module load time after this change. llvm-svn: 220493
* [modules] Initial support for explicitly loading .pcm files.Richard Smith2014-10-221-21/+37
| | | | | | | | | | | | | | | Implicit module builds are not well-suited to a lot of build systems. In particular, they fare badly in distributed build systems, and they lead to build artifacts that are not tracked as part of the usual dependency management process. This change allows explicitly-built module files (which are already supported through the -emit-module flag) to be explicitly loaded into a build, allowing build systems to opt to manage module builds and dependencies themselves. This is only the first step in supporting such configurations, and it should be considered experimental and subject to change or removal for now. llvm-svn: 220359
* [modules] When building an injected-class-name type, we may have to insert itRichard Smith2014-10-211-6/+11
| | | | | | into multiple merged classes' TypeForDecl slots. llvm-svn: 220331
* Revert most of r215810, which is no longer neededBen Langmuir2014-10-201-24/+15
| | | | | | | | Now that we no longer add mappings when there are no local entities, there is no need to always bump the size of the tables that correspond to ContinuousRangeMaps. llvm-svn: 220208
* Don't add ID mappings for offsets with no entities in a moduleBen Langmuir2014-10-201-33/+27
| | | | | | | | | | | This is a better fix for 'duplicate key' problems in module continuous range maps (vs what I added in r215810) by not adding any mappings at all when there are no local entities. Now it also covers selectors, which were not always being bumped because the record SELECTOR_OFFSET is not always emitted. I'll back out most of r215810 in a future commit, since it should no longer be needed. llvm-svn: 220207
* PR21246: DebugInfo: Emit the appropriate type (cv qualifiers, ↵David Blaikie2014-10-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | reference-ness, etc) for non-type template parameters Plumb through the full QualType of the TemplateArgument::Declaration, as it's insufficient to only know whether the type is a reference or pointer (that was necessary for mangling, but insufficient for debug info). This shouldn't increase the size of TemplateArgument as TemplateArgument::Integer is still longer by another 32 bits. Several bits of code were testing that the reference-ness of the parameters matched, but this seemed to be insufficient (various other features of the type could've mismatched and wouldn't've been caught) and unnecessary, at least insofar as removing those tests didn't cause anything to fail. (Richard - perchaps you can hypothesize why any of these checks might need to test reference-ness of the parameters (& explain why reference-ness is part of the mangling - I would've figured that for the reference-ness to be different, a prior template argument would have to be different). I'd be happy to add them in/beef them up and add test cases if there's a reason for them) llvm-svn: 219900
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-1/+14
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Avoid a couple of assertions when preprocessing with modulesBen Langmuir2014-09-101-18/+20
| | | | | | | | | | | | | | | | 1. We were hitting the NextIsPrevious assertion because we were trying to merge decl chains that were independent of each other because we had no Sema object to allow them to find existing decls. This is fixed by delaying loading the "preloaded" decls until Sema is available. 2. We were trying to get identifier info from an annotation token, which asserts. The fix is to special-case the module annotations in the preprocessed output printer. Fixed in a single commit because when you hit 1 you almost invariably hit 2 as well. llvm-svn: 217550
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* unique_ptrify SourceManager::createFileIDDavid Blaikie2014-08-291-1/+1
| | | | llvm-svn: 216715
* [modules] When completing the redecl chain for an anonymous declaration in aRichard Smith2014-08-281-4/+14
| | | | | | | merged context, pull in the lexical decls in that context, since one of them may complete the redecl chain. llvm-svn: 216652
* [modules] Number anonymous declarations that are lexically within mergeableRichard Smith2014-08-281-1/+4
| | | | | | contexts, so that we can merge them when we merge the surrounding context. llvm-svn: 216639
* [modules] Add an assert that we properly manage the IsCompleteDefinition flagRichard Smith2014-08-271-1/+4
| | | | | | | | on CXXRecordDecls when merging definitions, and make it pass by not trying to save and restore this flag across AST serialization/deserialization. For CXXRecordDecls, we have a separate mechanism to manage this. llvm-svn: 216633
* Overload SourceManager::overrideFileContents so that unconditionally passing ↵David Blaikie2014-08-271-1/+1
| | | | | | | | | | ownership is explicitly done using unique_ptr. Only those callers who are dynamically passing ownership should need the 3 argument form. Those accepting the default ("do pass ownership") should do so explicitly with a unique_ptr now. llvm-svn: 216614
* Update for LLVM api change.Rafael Espindola2014-08-271-6/+6
| | | | llvm-svn: 216585
* Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola2014-08-261-4/+4
| | | | llvm-svn: 216476
* Update for llvm api change.Rafael Espindola2014-08-251-4/+3
| | | | llvm-svn: 216397
* Use range based for loops to avoid needing to re-mention SmallPtrSet size.Craig Topper2014-08-251-8/+6
| | | | llvm-svn: 216370
* When loading a module with no local entities, still bump the size of theBen Langmuir2014-08-161-16/+25
| | | | | | | | | | | | | | | | | 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-25/+45
| | | | | | | | | | 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-19/+22
| | | | | | | | | | 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-41/+90
| | | | | | | | | | 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
* Correctly implement -include search logic.Manuel Klimek2014-08-121-4/+2
| | | | | | | | | | | | | | | According to the gcc docs, -include uses the current working directory for the lookup instead of the main source file. This patch gets rid of NormalizeIncludePath (which relied on an implementation detail of FileManager / FileEntry for the include path logic to work), and instead hands the correct lookup information down to LookupFile. This will allow us to change the FileEntry's behavior regarding its Name caching. llvm-svn: 215433
* Refactor the module map file used for uniquing a module name out ofBen Langmuir2014-08-091-12/+12
| | | | | | | | | 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] Don't defer performing updates if we have incomplete redecl chains.Richard Smith2014-08-071-4/+1
| | | | | | Instead, perform them carefully immediately. llvm-svn: 215147
OpenPOWER on IntegriCloud