summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-031-1/+1
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* [modules] PR20507: Avoid silent textual inclusion.Sean Silva2015-08-171-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If a module was unavailable (either a missing requirement on the module being imported, or a missing file anywhere in the top-level module (and not dominated by an unsatisfied `requires`)), we would silently treat inclusions as textual. This would cause all manner of crazy and confusing errors (and would also silently "work" sometimes, making the problem difficult to track down). I'm really not a fan of the `M->isAvailable(getLangOpts(), getTargetInfo(), Requirement, MissingHeader)` function; it seems to do too many things at once, but for now I've done things in a sort of awkward way. The changes to test/Modules/Inputs/declare-use/module.map were necessitated because the thing that was meant to be tested there (introduced in r197805) was predicated on silently falling back to textual inclusion, which we no longer do. The changes to test/Modules/Inputs/macro-reexport/module.modulemap are just an overlooked missing header that seems to have been missing since this code was committed (r213922), which is now caught. Reviewers: rsmith, benlangmuir, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10423 llvm-svn: 245228
* [modules] Make the include guard optimization fire a bit more when consideringRichard Smith2015-07-011-1/+2
| | | | | | | | | | | re-entering a modular header. When we do the include guard check, we're in the visibility state for the file with the #include; the include guard may not be visible there, but we don't actually need it to be: if we've already parsed the submodule we're considering entering, it's always safe to skip it. llvm-svn: 241135
* Introduced pragmas for audited nullability regions.Douglas Gregor2015-06-191-0/+9
| | | | | | | | | | | | | | | | | Introduce the clang pragmas "assume_nonnull begin" and "assume_nonnull end" in which we make default assumptions about the nullability of many unannotated pointers: - Single-level pointers are inferred to __nonnull - NSError** in a (function or method) parameter list is inferred to NSError * __nullable * __nullable. - CFErrorRef * in a (function or method) parameter list is inferred to CFErrorRef __nullable * __nullable. - Other multi-level pointers are never inferred to anything. Implements rdar://problem/19191042. llvm-svn: 240156
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-181-2/+2
| | | | | | is(). llvm-svn: 240008
* [modules] Simplify -cc1 interface for enabling implicit module maps.Richard Smith2015-06-161-6/+3
| | | | | | | | | | | | | 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
* Revert r237609 for now.Richard Smith2015-05-191-4/+5
| | | | | | | | | | | | glibc's headers use __need_* macros to selectively export parts of themselves to each other. This requires us to enter those files repeatedly when building a glibc module. This can be unreverted once we have a better mechanism to deal with that non-modular aspect of glibc (possibly some way to mark a header as "textual if this macro is defined"). llvm-svn: 237718
* [modules] When a file is listed as a non-textual header in a module map, don'tRichard Smith2015-05-181-5/+4
| | | | | | | | | | enter it more than once, even if it doesn't have #include guards -- we already know that it is intended to have the same effect every time it's included, and it's already had that effect. This particularly helps with local submodule visibility builds, where the include guard macro may not be visible in the includer, but will become visible the moment we enter the included file. llvm-svn: 237609
* [modules] Refactor and simplify #include handling.Richard Smith2015-05-181-115/+102
| | | | | | | Fix a tiny bug where we'd try to load a module file for the module we're in the middle of building. llvm-svn: 237552
* [modules] If we see a #include that maps to a module, but use of precompiled ↵Richard Smith2015-05-181-22/+17
| | | | | | modules is disabled, track submodule visibility anyway if -fmodules-local-submodule-visibility is enabled. This, in effect, gives modules semantics but without precompilation. llvm-svn: 237550
* [modules] Rearrange preprocessor module visibility handling, no observable ↵Richard Smith2015-05-141-23/+40
| | | | | | change intended. llvm-svn: 237331
* Switch PPCallbacks to take the new MacroDefinition instead of ↵Richard Smith2015-05-041-8/+5
| | | | | | MacroDirective*, in order to preserve full information on module macro expansion. llvm-svn: 236404
* [modules] Remove dead code from Module for tracking macro import locations.Richard Smith2015-05-021-5/+4
| | | | llvm-svn: 236376
* [modules] Start moving the module visibility information off the Module itself.Richard Smith2015-05-011-1/+5
| | | | | | | It has no place there; it's not a property of the Module, and it makes restoring the visibility set when we leave a submodule more difficult. llvm-svn: 236300
* Remove dead code: a MacroDirective can't be imported or ambiguous any more.Richard Smith2015-04-301-9/+0
| | | | llvm-svn: 236197
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-14/+20
| | | | | | | | | | | | | | 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] Incrementally compute the list of overridden module macros based onRichard Smith2015-04-271-0/+1
| | | | | | | the active module macros at the point of definition, rather than reconstructing it from the macro history. No functionality change intended. llvm-svn: 235941
* [modules] Refactor creation of ModuleMacros and create them when importing ↵Richard Smith2015-04-231-8/+13
| | | | | | from local submodules. llvm-svn: 235669
* [modules] Properly attribute macros to modules if they're in a file ↵Richard Smith2015-04-231-3/+8
| | | | | | textually included into a file in the module. llvm-svn: 235661
* [modules] Store a ModuleMacro* on an imported macro directive rather than ↵Richard Smith2015-04-231-14/+6
| | | | | | duplicating the info within it. llvm-svn: 235644
* [modules] Determine the set of macros exported by a submodule at the end of ↵Richard Smith2015-04-231-0/+2
| | | | | | | | | | | that submodule. Previously we'd defer this determination until writing the AST, which doesn't allow us to use this information when building other submodules of the same module. This change also allows us to use a uniform mechanism for writing module macro records, independent of whether they are local or imported. llvm-svn: 235614
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-5/+5
| | | | | | | | | | | | | | | Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
* Lex: Don't let annotation tokens get into macro expansionDavid Majnemer2014-12-281-1/+2
| | | | | | | | | | We'd let annotation tokens from '#pragma pack' and the like get inside a function-like macro. This would lead to terror and mayhem; stop the madness early. This fixes PR22037. llvm-svn: 224896
* Fixed warnings on redefine keywords and reserved ids.Serge Pavlov2014-12-181-14/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | Repared support for warnings -Wkeyword-macro and -Wreserved-id-macro. The warning -Wkeyword-macro now is not issued in patterns that are used in configuration scripts: #define inline also for 'const', 'extern' and 'static'. If macro repalcement is identical to macro name, the warning also is not issued: #define volatile volatile And finally if macro replacement is also a keyword identical to the replaced one but decorated with leading/trailing underscores: #define inline __inline #define inline __inline__ #define inline _inline // in MSVC compatibility mode Warning -Wreserved-id-macro is off by default, it could help catching things like: #undef __cplusplus llvm-svn: 224512
* Move -Wkeyword-macro into -pedantic, remove -Wreserved-id-macro.Nico Weber2014-12-161-50/+5
| | | | | | | | | | | | | | | | | | | As discussed on the post-commit review thread for r224012, -Wkeyword-macro fires mostly on headers trying to set up portable defines and doesn't find much bad stuff in practice. But [macro.names]p2 does disallow defining or undefining keywords, override and final, and alignas, so keep the warning but move it into -pedantic. -Wreserved-id-macro warns on #define __need_size_t which is more or less public api for glibc headers. Since this warning isn't motivated by a standard, remove it. (See also r223114 for a previous follow-up to r224012.) llvm-svn: 224371
* Do not warn on keyword undefSerge Pavlov2014-12-121-11/+6
| | | | | | | #undef a keyword is generally harmless but used often in configuration scripts. Also added tests that I forgot to include to commit in r223114. llvm-svn: 224100
* Emit warning if define or undef reserved identifier or keyword.Serge Pavlov2014-12-111-0/+69
| | | | | | Recommit of r223114, reverted in r223120. llvm-svn: 224012
* Reverted r223114, it caused failure on on clang-native-arm-cortex-a9.Serge Pavlov2014-12-021-69/+0
| | | | llvm-svn: 223120
* Emit warning if define or undef reserved identifier or keyword.Serge Pavlov2014-12-021-0/+69
| | | | | | | | | | | | | | | | | | | | | Summary: This change implements warnings if macro name is identical to a keyword or reserved identifier. The warnings are different depending on the "danger" of the operation. Defining macro that replaces a keyword is on by default. Other cases produce warning that is off by default but can be turned on using option -Wreserved-id-macro. This change fixes PR11488. Reviewers: rnk Reviewed By: rnk Subscribers: rnk, cfe-commits Differential Revision: http://reviews.llvm.org/D6194 llvm-svn: 223114
* [modules] Track how 'header' directives were written in module map files,Richard Smith2014-12-021-7/+15
| | | | | | | | | | | | | 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
* Use enumerators instead of hardcoded integers when processing macro names.Serge Pavlov2014-10-241-13/+14
| | | | llvm-svn: 220572
* [modules] Add support for #include_next.Richard Smith2014-10-201-17/+50
| | | | | | | | | | | | #include_next interacts poorly with modules: it depends on where in the list of include paths the current file was found. Files covered by module maps are not found in include search paths when building the module (and are not found in include search paths when @importing the module either), so this isn't really meaningful. Instead, we fake up the result that #include_next *should* have given: find the first path that would have resulted in the given file being picked, and search from there onwards. llvm-svn: 220177
* Correctly implement -include search logic.Manuel Klimek2014-08-121-8/+11
| | | | | | | | | | | | | | | 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
* Fix six tests are failing on Windows after r215241-r215243.Yaron Keren2014-08-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang :: Frontend/iframework.c Clang :: Frontend/system-header-prefix.c Clang :: Index/annotate-comments-objc.m Clang :: Index/annotate-module.m Clang :: Index/index-module.m Clang :: Index/index-pch-with-module.m Clang :: PCH/case-insensitive-include.c Suprisingly the normalize_separators() was no-op when LLVM_ON_WIN32. Its replacement native() does change path separators into \ as expected, breaking these tests. I had fixed the tests by #ifndef LLVM_ON_WIN32 on the native call, to match the previous behaviour. If this logic is not used on Windows host, it might be completely deleted as there should not be windows path seperators on Linux hosts. I can't test on Linux but if someone can run tests on Linux after commenting out the line llvm::sys::path::native(NormalizedPath); and the tests pass, the whole if (LangOpts.MSVCCompat) could be deleted. llvm-svn: 215290
* Use llvm::sys::path::native instead of llvm::sys::fs::normalize_separators.Rafael Espindola2014-08-081-2/+2
| | | | | | | llvm::sys::path::native has a superset of the functionality and this was the only use of llvm::sys::fs::normalize_separators. llvm-svn: 215242
* Don't destroy MacroInfos if we find the macro definition is invalid; it'll getRichard Smith2014-08-031-12/+0
| | | | | | destroyed on shutdown regardless. Fixes a double-delete. llvm-svn: 214675
* [modules] Substantially improve handling of #undef:Richard Smith2014-07-251-11/+16
| | | | | | | | | | * 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
* Simplify MacroInfo lifetime management. We don't need three different functionsRichard Smith2014-07-241-3/+4
| | | | | | to destroy one of these. llvm-svn: 213837
* Remove unused Prev pointer from MacroInfo chain.Richard Smith2014-07-241-29/+2
| | | | | | | | Remove pointless MICache: it only ever contained up to 1 object, and was only non-empty when recovering from an error. There's no performance or memory win from maintaining this cache. llvm-svn: 213825
* Add stopgap option -fmodule-implementation-of <name>Ben Langmuir2014-07-231-1/+3
| | | | | | | | | | | | | | | | | | 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
* Convert StringLiteralParser constructor to use ArrayRef instead of a pointer ↵Craig Topper2014-06-261-2/+2
| | | | | | and count. llvm-svn: 211763
* Fixed formatting.Yaron Keren2014-06-191-3/+2
| | | | llvm-svn: 211295
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-2/+1
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* Preprocessor: make C++ operator names as macro identifiers a compatible ↵Alp Toker2014-05-311-5/+6
| | | | | | | | | | | extension With recent changes, this is now a compatible language extension and can be safely enabled with -ms-extensions instead of requiring the full -ms-compatibility MSVC drop-in mode. As such we can now also emit an extension warning under -Wmicrosoft to help users port their code. llvm-svn: 209978
* Preprocessor: recover gracefully when C++ operator names are used as macro ↵Alp Toker2014-05-311-3/+4
| | | | | | | | | | identifiers This failure mode shows up occasionally when users try to include C headers in C++ projects or when porting from Windows. We might as well recover in the way the user expected, thus avoiding confusing diagnostic messages at point of use. llvm-svn: 209963
* Preprocessor: don't exit early in CheckMacroName()Alp Toker2014-05-311-10/+7
| | | | | | | | | | The checks below can hypothetically apply to converted operator name identifiers. In practice there are no builtin macros etc. with those names so there's no behavioural change to test. llvm-svn: 209962
* Provide an aka for the C++ operator name macro diagnosticAlp Toker2014-05-211-1/+1
| | | | llvm-svn: 209322
* Preprocessor: support defined() with operator names for MS compatibilityAlp Toker2014-05-211-40/+48
| | | | | | | | | Also flesh out missing tests, improve diagnostic QOI and fix a couple of corner cases found in the process. Fixes PR10606. llvm-svn: 209276
* [C++11] Use 'nullptr'. Lex edition.Craig Topper2014-05-171-33/+35
| | | | llvm-svn: 209083
* Provide and use a safe Token::getRawIdentifier() accessorAlp Toker2014-05-171-4/+4
| | | | llvm-svn: 209061
OpenPOWER on IntegriCloud