summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix PCHs that import more than one moduleBen Langmuir2014-09-082-0/+2
| | | | | | | 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
* Fix test to not write output to the test directory, as it may not be writable.David Blaikie2014-09-071-2/+2
| | | | llvm-svn: 217337
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-063-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix r217275 to work without the need for standard headers being includedDavid Blaikie2014-09-052-4/+0
| | | | | | | | It seems (I guess) in ObjC that va_list is provided without the need for inclusions. I verified that with this change the test still crashes in the absence of the fix committed in r217275. llvm-svn: 217290
* Move the initialization of VAListTagName after InitializeSema()Ben Langmuir2014-09-054-0/+36
| | | | | | | | | | | | | | | | | | | | This innocuous statement to get the identifier info for __va_list_tag was causing an assertion failure: NextIsPrevious() && "decl became non-canonical unexpectedly" if the __va_list_tag identifier was found in a PCH in some circumstances, because it was looked up before the ASTReader had a Sema object to use to find existing decls to merge with. We could possibly move getting the identifier info even later, or make it lazy if we wanted to, but this seemed like the minimal change. Now why a PCH would have this identifier in the first place is a bit mysterious. This seems to be related to the global module index in some way, because when the test case is built without the global module index it will not emit an identifier for __va_list_tag into the PCH, but with the global module index it does. llvm-svn: 217275
* [modules] Make NamespaceAliasDecl redeclarable, as it should be. This fixesRichard Smith2014-09-033-0/+8
| | | | | | | merging of namespace aliases across modules and improves source fidelity. Incidentally also fixes PR20816. llvm-svn: 217103
* [modules] Use DeclContext::equals rather than == on DeclContext* whenRichard Smith2014-09-034-4/+31
| | | | | | | | | | determining whether a declaration is out of line, instead of assuming that the semantic and lexical DeclContext will be the same declaration whenever they're the same entity. This fixes behavior of declarations within merged classes and enums. llvm-svn: 217008
* [modules] Fix deserialization cycle when loading a tag declaration with a ↵Richard Smith2014-08-303-0/+19
| | | | | | typedef name for linkage purposes. When loading the type, delay loading its typedef until we've finished loading and merging the type. In its place, save out the name of the typedef, which we need for merging purposes. llvm-svn: 216806
* Add some missing test coverage for merging 'extern "C"' functions with modules.Richard Smith2014-08-295-0/+15
| | | | llvm-svn: 216796
* Oops, use correct RUN: line for test.Richard Smith2014-08-281-2/+2
| | | | llvm-svn: 216685
* [modules] PR20786: add (already passing) regression test from the bug report.Richard Smith2014-08-286-0/+21
| | | | llvm-svn: 216683
* [modules] When completing the redecl chain for an anonymous declaration in aRichard Smith2014-08-286-4/+19
| | | | | | | 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-284-0/+16
| | | | | | contexts, so that we can merge them when we merge the surrounding context. llvm-svn: 216639
* [modules] Don't assert when merging virtual functions that override otherRichard Smith2014-08-263-0/+18
| | | | | | | functions. Also don't needlessly pull in non-canonical declarations of the overridden virtual functions. llvm-svn: 216503
* [modules] Track the described template in an alias declaration that is theRichard Smith2014-08-264-0/+10
| | | | | | | pattern of an alias template declaration. Use this to merge alias templates properly when they're members of class template specializations. llvm-svn: 216437
* Fix typo.Richard Smith2014-08-253-0/+6
| | | | llvm-svn: 216417
* [modules] Fix false report of an ODR violation when merging friendRichard Smith2014-08-253-1/+16
| | | | | | | | | | declarations. We can't expect to find them in the canonical definition of the class, because that's not where they live. This means we no longer reject real ODR violations with friend declarations, but we weren't consistently doing so anyway. llvm-svn: 216369
* [modules] When merging a tag declaration that has a typedef name for linkageRichard Smith2014-08-233-0/+17
| | | | | | | purposes, look for other typedefs with that same name and merge into their named tag declaration if there is one. llvm-svn: 216312
* [modules] Put class template declarations into the scope in which they'reRichard Smith2014-08-233-0/+20
| | | | | | | | | | | declared, rather than putting them into the template parameter scope. We previously had *no record* in the scope for class template declarations, once those declarations completed and their template parameter scopes were popped. This in turn caused us to be unable to merge class template declarations that were declared in the global scope (where we use scope lookup rather than DeclContext lookup for merging), when loading a module. llvm-svn: 216311
* [modules] Turn off a broken optimization: we need to pick up implicit specialRichard Smith2014-08-143-0/+55
| | | | | | | members from all redefinitions of a class that have them, in case the special member is defined in one module but only declared in another. llvm-svn: 215675
* [modules] Don't assert if the same imported class template specializationRichard Smith2014-08-143-0/+6
| | | | | | | declaration has its definition instantiated in two sibling modules and they use a partial specialization. llvm-svn: 215616
* [modules] When we merge together multiple class template specializationRichard Smith2014-08-144-0/+8
| | | | | | | | | | 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
* clang/test/Modules/cxx-irgen.cpp: Let it tolerant of x86_thiscallcc.NAKAMURA Takumi2014-08-141-4/+4
| | | | llvm-svn: 215607
* [modules] Fix a rejects-valid resulting from emitting an inline functionRichard Smith2014-08-132-0/+28
| | | | | | | | recursively within the emission of another inline function. This ultimately led to us emitting the same inline function definition twice, which we then rejected because we believed we had a mangled name conflict. llvm-svn: 215579
* Default getFile() to use the last accessed name in the FileEntry.Manuel Klimek2014-08-133-0/+13
| | | | | | | | | | | | With modules we start accessing headers for the first time while reading the module map, which often has very different paths from the include scanning logic. Using the name by which the file was accessed gets us one step closer to the right solution, which is using a FileName abstraction that decouples the name by which a file was accessed from the FileEntry. llvm-svn: 215541
* [modules] When performing a lookup into a namespace, ensure that any laterRichard Smith2014-08-139-2/+33
| | | | | | | | | | 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-124-0/+32
| | | | | | | | | | 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
* Modify behavior of -ast-dump-lookups: if -ast-dump is not also provided, dumpRichard Smith2014-08-111-2/+2
| | | | | | | | anyway. If -ast-dump *is* also provided, then dump the AST declarations as well as the lookup results. This is invaluable for cross-correlating the lookup information with the declarations actually found. llvm-svn: 215393
* [modules] When considering merging a newly-declared typedef into an importedRichard Smith2014-08-106-0/+41
| | | | | | | | | one, perform the import if the types match even if the imported declaration is hidden. Otherwise, NamedDecl::declarationReplaces will drop one of the name lookup entries, making the typedef effectively inaccessible from one of the modules that declared it. llvm-svn: 215306
* [modules] Weaken an out-of-date assertion: an #undef can have no location if weRichard Smith2014-08-095-0/+15
| | | | | | | imported it from a module when performing finalization before writing out an AST file. llvm-svn: 215272
* [modules] When emitting an update record containing the body of a destructor,Richard Smith2014-08-073-0/+21
| | | | | | | | | 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
* test/Modules: Use FileCheck's -allow-empty instead of "count 0"Justin Bogner2014-08-071-2/+5
| | | | | | | | | | Piping stderr into "count 0" in tests doesn't work - things like guard malloc write to stderr and mess up the count. This comes up all the time, so I've added a feature to FileCheck to fix it this time. Fixes test failures caused by r215046 under guard malloc. llvm-svn: 215129
* Use -Rblah, not -Wblah, to control remark diagnostics. This was always theRichard Smith2014-08-073-7/+19
| | | | | | | | | | | | | | | | | | | | | | 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] Remove IRGen special case for emitting implicit special members ifRichard Smith2014-08-011-1/+1
| | | | | | | | | | | they're somehow missing a body. Looks like this was left behind when the loop was generalized, and it's not been problematic before because without modules, a used, implicit special member function declaration must be a definition. This was resulting in us trying to emit a constructor declaration rather than a definition, and producing a constructor missing its member initializers. llvm-svn: 214473
* [modules] Maintain an AST invariant across module load/save: if any declarationRichard Smith2014-07-314-1/+66
| | | | | | | | | | | | | | | of a function has a resolved exception specification, then all declarations of the function do. We should probably improve the AST representation to make this implicit (perhaps only store the exception specification on the canonical declaration), but this fixes things for now. The testcase for this (which used to assert) also exposes the actual bug I was trying to reduce here: we sometimes fail to emit the body of an imported special member function definition. Fix for that to follow. llvm-svn: 214458
* [modules] Add testcase for a bug reduced from a selfhost issue. This bug wasRichard Smith2014-07-293-0/+9
| | | | | | | never present in Clang trunk, but was present in some of my development work, and it seems like a useful test to have. llvm-svn: 214154
* Revert accidentally-committed files in r214151.Richard Smith2014-07-293-9/+0
| | | | llvm-svn: 214152
* [modules] Add missing #include, found by modules build. We need a classRichard Smith2014-07-293-0/+9
| | | | | | definition in order to apply isa<...>. llvm-svn: 214151
* [modules] PR20475: merging support for alias template declarations.Richard Smith2014-07-282-0/+4
| | | | llvm-svn: 214124
* [modules] Substantially improve handling of #undef:Richard Smith2014-07-257-4/+41
| | | | | | | | | | * 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
* Add stopgap option -fmodule-implementation-of <name>Ben Langmuir2014-07-231-0/+29
| | | | | | | | | | | | | | | | | | This flag specifies that we are building an implementation file of the module <name>, preventing importing <name> as a module. This does not consider this to be the 'current module' for the purposes of doing modular checks like decluse or non-modular-include warnings, unlike -fmodule-name. This is needed as a stopgap until: 1) we can resolve relative includes to a VFS-mapped module (or can safely import a header textually and as part of a module) and ideally 2) we can safely do incremental rebuilding when implementation files import submodules. llvm-svn: 213767
* [modules] Fix some of the confusion when computing the override set for a macroRichard Smith2014-07-2113-1/+54
| | | | | | | 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-188-0/+115
| | | | | | | | | | | | | | | | | | | | 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-187-22/+0
| | | | | | | | | | 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
* Mark C++ reference parameters as dereferenceableHal Finkel2014-07-181-2/+2
| | | | | | | | | | | | | | Because references must be initialized using some evaluated expression, they must point to something, and a callee can assume the reference parameter is dereferenceable. Taking advantage of a new attribute just added to LLVM, mark them as such. Because dereferenceability in addrspace(0) implies nonnull in the backend, we don't need both attributes. However, we need to know the size of the object to use the dereferenceable attribute, so for incomplete types we still emit only nonnull. llvm-svn: 213386
* [modules] Fix macro hiding bug exposed if:Richard Smith2014-07-187-0/+22
| | | | | | | | | | | | | | * 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
* Try harder to supress the test from r212975 on WindowsBen Langmuir2014-07-141-2/+2
| | | | | | | | The attempt in r212980 was broken because we might not fail if LLVM_ON_UNIX is enabled for cross compiling to Windows, and it didn't consider mingw either. llvm-svn: 212989
* XFAIL test that doesn't work on Windows yetBen Langmuir2014-07-141-0/+2
| | | | llvm-svn: 212980
* Fix case-sensitivity of inferred framework modulesBen Langmuir2014-07-141-0/+5
| | | | | | | Just because we can open a directory named "COcoa.framework" doesn't mean we should provide a "COcoa" module on a case-insensitive filesystem. llvm-svn: 212975
* [modules] When merging a class template, also merge the definition of its ↵Richard Smith2014-07-113-0/+15
| | | | | | pattern. llvm-svn: 212836
OpenPOWER on IntegriCloud