summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules/macros.c
Commit message (Collapse)AuthorAgeFilesLines
* [modules] Fix a corner case in the macro override rules: properly handle ↵Richard Smith2015-09-161-1/+5
| | | | | | overridden leaf module macros. llvm-svn: 247765
* [modules] Stop updating all identifiers when writing a module. This isRichard Smith2015-08-241-1/+7
| | | | | | | unnecessary in C++ modules (where we don't need the identifiers for their Decls) and expensive. llvm-svn: 245821
* [modules] Change module manager visitation order to be a bit more stable whenRichard Smith2015-07-221-3/+8
| | | | | | | | | | | more modules are added: visit modules depth-first rather than breadth-first. The visitation is still (approximately) oldest-to-newest, and still guarantees that a module is visited before anything it imports, so modules that are imported by others sometimes need to jump to a later position in the visitation order when more modules are loaded, but independent module trees don't interfere with each other any more. llvm-svn: 242863
* [modules] Simplify -cc1 interface for enabling implicit module maps.Richard Smith2015-06-161-4/+4
| | | | | | | | | | | | | We used to have a flag to enable module maps, and two more flags to enable implicit module maps. This is all redundant; we don't need any flag for enabling module maps in the abstract, and we don't usually have -fno- flags for -cc1. We now have just a single flag, -fimplicit-module-maps, that enables implicitly searching the file system for module map files and loading them. The driver interface is unchanged for now. We should probably rename -fmodule-maps to -fimplicit-module-maps at some point. llvm-svn: 239789
* [modules] Add local submodule visibility support for declarations.Richard Smith2015-05-151-1/+1
| | | | | | | | | | | | With this change, enabling -fmodules-local-submodule-visibility results in name visibility rules being applied to submodules of the current module in addition to imported modules (that is, names no longer "leak" between submodules of the same top-level module). This also makes it much safer to textually include a non-modular library into a module: each submodule that textually includes that library will get its own "copy" of that library, and so the library becomes visible no matter which including submodule you import. llvm-svn: 237473
* Switch PPCallbacks to take the new MacroDefinition instead of ↵Richard Smith2015-05-041-0/+1
| | | | | | MacroDirective*, in order to preserve full information on module macro expansion. llvm-svn: 236404
* [modules] Add -fmodules-local-submodule-visibility flag.Richard Smith2015-05-011-9/+15
| | | | | | | | | | | | | | | This flag specifies that the normal visibility rules should be used even for local submodules (submodules of the currently-being-built module). Thus names will only be visible if a header / module that declares them has actually been included / imported, and not merely because a submodule that happened to be built earlier declared those names. This also removes the need to modularize bottom-up: textually-included headers will be included into every submodule that includes them, since their include guards will not leak between modules. So far, this only governs visibility of macros, not of declarations, so is not ready for real use yet. llvm-svn: 236350
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-0/+1
| | | | | | | | | | | | | | Modules builds fundamentally have a non-linear macro history. In the interest of better source fidelity, represent the macro definition information faithfully: we have a linear macro directive history within each module, and at any point we have a unique "latest" local macro directive and a collection of visible imported directives. This also removes the attendent complexity of attempting to create a correct MacroDirective history (which we got wrong in the general case). No functionality change intended. llvm-svn: 236176
* [modules] Properly attribute macros to modules if they're in a file ↵Richard Smith2015-04-231-0/+4
| | | | | | textually included into a file in the module. llvm-svn: 235661
* [modules] Weaken an out-of-date assertion: an #undef can have no location if weRichard Smith2014-08-091-0/+6
| | | | | | | imported it from a module when performing finalization before writing out an AST file. llvm-svn: 215272
* If a module A exports a macro M, and a module B imports that macro and #undef'sRichard Smith2014-03-011-7/+32
| | | | | | | | | | | | | | it, importers of B should not see the macro. This is complicated by the fact that A's macro could also be visible through a different path. The rules (as hashed out on cfe-commits) are included as a documentation update in this change. With this, the number of regressions in libc++'s testsuite when modules are enabled drops from 47 to 7. Those remaining 7 are also macro-related, and are due to remaining bugs in this change (in particular, the handling of submodules is imperfect). llvm-svn: 202560
* Require a module.map file to load a moduleBen Langmuir2014-01-221-2/+2
| | | | | | | | Removes some old code that allowed a module to be loaded from a pcm file even if the module.map could not be found. Also update a number of tests that relied on the old behavior. llvm-svn: 199852
* Add 'not' to commands that are expected to fail.Rafael Espindola2013-07-041-1/+1
| | | | | | | This is at least good documentation, but also opens the possibility of using pipefail. llvm-svn: 185652
* Extended VerifyDiagnosticConsumer to also verify source file for diagnostic.Andy Gibbs2013-04-171-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VerifyDiagnosticConsumer previously would not check that the diagnostic and its matching directive referenced the same source file. Common practice was to create directives that referenced other files but only by line number, and this led to problems such as when the file containing the directive didn't have enough lines to match the location of the diagnostic in the other file, leading to bizarre file formatting and other oddities. This patch causes VerifyDiagnosticConsumer to match source files as well as line numbers. Therefore, a new syntax is made available for directives, for example: // expected-error@file:line {{diagnostic message}} This extends the @line feature where "file" is the file where the diagnostic is generated. The @line syntax is still available and uses the current file for the diagnostic. "file" can be specified either as a relative or absolute path - although the latter has less usefulness, I think! The #include search paths will be used to locate the file and if it is not found an error will be generated. The new check is not optional: if the directive is in a different file to the diagnostic, the file must be specified. Therefore, a number of test-cases have been updated with regard to this. This closes out PR15613. llvm-svn: 179677
* [preprocessor] Allow comparing two macro definitions syntactically instead ↵Argyrios Kyrtzidis2013-04-031-0/+1
| | | | | | | | | | | | | | of only lexically. Syntactically means the function macro parameter names do not need to use the same identifiers in order for the definitions to be considered identical. Syntactic equivalence is a microsoft extension for macro redefinitions and we'll also use this kind of comparison to check for ambiguous macros coming from modules. rdar://13562254 llvm-svn: 178671
* [modules] Re-enable the "ambiguous expansion of macro" warning.Argyrios Kyrtzidis2013-03-271-14/+14
| | | | | | | | | | Also update "test/Modules/macros.c" to test modified semantics: -When there is an ambiguous macro, expand using the latest introduced version, not the first one. -#undefs in submodules cause the macro to not be exported by that submodule, it doesn't cause undefining of macros in the translation unit that imported that submodule. This reduces macro namespace interference across modules. llvm-svn: 178105
* Rename -fmodule-cache-path <blah> to -fmodules-cache-path=<blah> for ↵Douglas Gregor2013-02-071-6/+6
| | | | | | consistency. llvm-svn: 174645
* [PCH] Temporarily disable the "ambiguous macro" warning that is currently ↵Argyrios Kyrtzidis2013-01-231-0/+1
| | | | | | | | | | | | bogus with a PCH that redefined a macro without undef'ing it first. Proper reconstruction of the macro info history from modules will properly fix this in subsequent commits. rdar://13016031 llvm-svn: 173281
* Use @import rather than @__experimental_modules_import, since theDouglas Gregor2012-12-111-4/+4
| | | | | | latter is rather a mess to type. llvm-svn: 169919
* Track which particular submodule #undef's a macro, so that the actualDouglas Gregor2012-10-121-4/+10
| | | | | | #undef only occurs if that submodule is imported. llvm-svn: 165773
* Diagnose the expansion of ambiguous macro definitions. This can happenDouglas Gregor2012-10-111-4/+10
| | | | | | | only with modules, when two disjoint modules #define the same identifier to different token sequences. llvm-svn: 165746
* Deserialize macro history when we deserialize an identifier that hasDouglas Gregor2012-10-111-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | macro history. When deserializing macro history, we arrange history such that the macros that have definitions (that haven't been #undef'd) and are visible come at the beginning of the list, which is what the preprocessor and other clients of Preprocessor::getMacroInfo() expect. If additional macro definitions become visible later, they'll be moved toward the front of the list. Note that it's possible to have ambiguities, but we don't diagnose them yet. There is a partially-implemented design decision here that, if a particular identifier has been defined or #undef'd within the translation unit, that definition (or #undef) hides any macro definitions that come from imported modules. There's still a little work to do to ensure that the right #undef'ing happens. Additionally, we'll need to scope the update records for #undefs, so they only kick in when the submodule containing that update record becomes visible. llvm-svn: 165682
* Introduce builtin macros to determine whether we're building aDouglas Gregor2012-09-251-0/+9
| | | | | | | | | | specific module (__building_module(modulename)) and to get the name of the current module as an identifier (__MODULE__). Used to help headers behave differently when they're being included as part of building a module. Oh, the irony. llvm-svn: 164605
* Change @import to @__experimental_modules_import. We are not ready to ↵Ted Kremenek2012-03-011-1/+1
| | | | | | | | commit to a particular syntax for modules, and don't have time to push it forward in the near future. llvm-svn: 151841
* Re-uglify #public and #private to #__public_macro and #__private_macro.Douglas Gregor2012-01-031-1/+1
| | | | llvm-svn: 147469
* Eliminate the uglified keyword __import_module__ for importingDouglas Gregor2012-01-031-4/+5
| | | | | | | | | | | | | modules. This leaves us without an explicit syntax for importing modules in C/C++, because such a syntax needs to be discussed first. In Objective-C/Objective-C++, the @import syntax is used to import modules. Note that, under -fmodules, C/C++ programs can import modules via the #include mechanism when a module map is in place for that header. This allows us to work with modules in C/C++ without committing to a syntax. llvm-svn: 147467
* Under -fmodules, accept #public <macroname> and #private <macroname>Douglas Gregor2012-01-031-4/+4
| | | | | | | to make a macro public (the default for headers) or private, respectively. llvm-svn: 147455
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* Eliminate the -emit-module option, which emitted a module by parsing aDouglas Gregor2011-11-291-1/+1
| | | | | | | source file (e.g., a header). Immediately steal this useful option name for building modules from a module map file. llvm-svn: 145444
* Migrate a few more modules tests over to -emit-module-from-map.Douglas Gregor2011-11-161-17/+4
| | | | llvm-svn: 144779
* For modules, all macros that aren't include guards are implicitlyDouglas Gregor2011-10-171-1/+2
| | | | | | | public. Add a __private_macro__ directive to hide a macro, similar to the __module_private__ declaration specifier. llvm-svn: 142188
* Make -E work with module importsDouglas Gregor2011-09-141-0/+3
| | | | llvm-svn: 139750
* Don't try to write a macro offset for an identifier that names a ↵Douglas Gregor2011-09-141-0/+5
| | | | | | non-exported macro, for real this time llvm-svn: 139745
* Revert my exported-macro hackery. Something is amissDouglas Gregor2011-09-141-5/+0
| | | | llvm-svn: 139734
* Don't try to write a macro offset for an identifier that names a ↵Douglas Gregor2011-09-141-0/+5
| | | | | | non-exported macro llvm-svn: 139728
* For modules, use a hash of the compiler version, language options, andDouglas Gregor2011-09-131-1/+1
| | | | | | | | | target triple to separate modules built under different conditions. The hash is used to create a subdirectory in the module cache path where other invocations of the compiler (with the same version, language options, etc.) can find the precompiled modules. llvm-svn: 139662
* Introduce a cc1-level option to provide the path to the module cache,Douglas Gregor2011-09-121-1/+1
| | | | | | | | where the compiler will look for module files. Eliminates the egregious hack where we looked into the header search paths for modules. llvm-svn: 139538
* Modules hide macro definitions by default, so that silly things likeDouglas Gregor2011-09-011-0/+33
include guards don't show up as macro definitions in every translation unit that imports a module. Macro definitions can, however, be exported with the intentionally-ugly #__export_macro__ directive. Implement this feature by not even bothering to serialize non-exported macros to a module, because clients of that module need not (should not) know that these macros even exist. llvm-svn: 138943
OpenPOWER on IntegriCloud