summaryrefslogtreecommitdiffstats
path: root/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
* Merging r311330:Hans Wennborg2017-08-232-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r311330 | ibiryukov | 2017-08-21 05:03:08 -0700 (Mon, 21 Aug 2017) | 16 lines Fixed a crash on replaying Preamble's PP conditional stack. Summary: The crash occurs when the first token after a preamble is a macro expansion. Fixed by moving replayPreambleConditionalStack from Parser into Preprocessor. It is now called right after the predefines file is processed. Reviewers: erikjv, bkramer, klimek, yvvan Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36872 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@311591 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r309503:Hans Wennborg2017-07-311-0/+8
| | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r309503 | rsmith | 2017-07-29 23:31:29 -0700 (Sat, 29 Jul 2017) | 6 lines PR33902: Invalidate line number cache when adding more text to existing buffer. This led to crashes as the line number cache would report a bogus line number for a line of code, and we'd try to find a nonexistent column within the line when printing diagnostics. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@309580 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC] Refactor the Preprocessor function that handles Macro definitions and ↵Faisal Vali2017-07-175-58/+75
| | | | | | | | | | | | | | | | | rename Arguments to Parameters in Macro Definitions. - Extracted the reading of the tokens out into a separate function. - Replace 'Argument' with 'Parameter' when referring to the identifiers of the macro definition (as opposed to the supplied arguments - MacroArgs - during the macro invocation). This is in preparation for submitting patches for review to implement __VA_OPT__ which will otherwise just keep lengthening the HandleDefineDirective function and making it less comprehensible. I will also directly update some extra clang tooling that is broken by the change from Argument to Parameter. Hopefully the bots will stay appeased. Thanks! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308190 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert changes from my previous refactoring - will need to fix dependencies ↵Faisal Vali2017-07-175-75/+58
| | | | | | | | | in clang's extra tooling (such as clang-tidy etc.). Sorry about that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308158 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC] Refactor the Preprocessor function that handles Macro definitions and ↵Faisal Vali2017-07-175-58/+75
| | | | | | | | | | | | | | rename Arguments to Parameters in Macro Definitions. - Extracted the reading of the tokens out into a separate function. - Replace 'Argument' with 'Parameter' when referring to the identifiers of the macro definition (as opposed to the supplied arguments - MacroArgs - during the macro invocation). This is in preparation for submitting patches for review to implement __VA_OPT__ which will otherwise just keep lengthening the HandleDefineDirective function and making it less comprehensible. Thanks! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308157 91177308-0d34-0410-b5e6-96231b3b80d8
* Keep the IdentifierInfo in the Token for alternative operator keywordOlivier Goffart2017-07-143-46/+35
| | | | | | | | | | | | | | | | | | | The goal of this commit is to fix clang-format so it does not merge tokens when using the alternative spelling keywords. (eg: "not foo" should not become "notfoo") The problem is that Preprocessor::HandleIdentifier used to drop the identifier info from the token for these keyword. This means the first condition of TokenAnnotator::spaceRequiredBefore is not met. We could add explicit check for the spelling in that condition, but I think it is better to keep the IdentifierInfo and handle the operator keyword explicitly when needed. That actually leads to simpler code, and probably slightly more efficient as well. Another side effect of this change is that __identifier(and) will now work as one would expect, removing a FIXME from the MicrosoftExtensions.cpp test Differential Revision: https://reviews.llvm.org/D35172 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308008 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix invalid warnings for header guards in preamblesErik Verbruggen2017-07-053-7/+3
| | | | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=33574 Differential Revision: https://reviews.llvm.org/D34882 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307134 91177308-0d34-0410-b5e6-96231b3b80d8
* Track the set of module maps read while building a .pcm file and reload ↵Richard Smith2017-06-291-1/+2
| | | | | | those when preprocessing from that .pcm file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306628 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Allow unmarked overloadable functions.George Burgess IV2017-06-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch extends the `overloadable` attribute to allow for one function with a given name to not be marked with the `overloadable` attribute. The overload without the `overloadable` attribute will not have its name mangled. So, the following code is now legal: void foo(void) __attribute__((overloadable)); void foo(int); void foo(float) __attribute__((overloadable)); In addition, this patch fixes a bug where we'd accept code with `__attribute__((overloadable))` inconsistently applied. In other words, we used to accept: void foo(void); void foo(void) __attribute__((overloadable)); But we will do this no longer, since it defeats the original purpose of requiring `__attribute__((overloadable))` on all redeclarations of a function. This breakage seems to not be an issue in practice, since the only code I could find that had this pattern often looked like: void foo(void); void foo(void) __attribute__((overloadable)) __asm__("foo"); void foo(int) __attribute__((overloadable)); ...Which can now be simplified by simply removing the asm label and overloadable attribute from the redeclaration of `void foo(void);` Differential Revision: https://reviews.llvm.org/D32332 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306467 91177308-0d34-0410-b5e6-96231b3b80d8
* [preprocessor] Fix assertion hit when 'SingleFileParseMode' option is ↵Argyrios Kyrtzidis2017-06-211-6/+6
| | | | | | | | enabled and #if with an undefined identifier and without #else 'HandleEndifDirective' asserts that 'WasSkipping' is false, so switch to using 'FoundNonSkip' as the hint for 'SingleFileParseMode' to keep going with parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305940 91177308-0d34-0410-b5e6-96231b3b80d8
* [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, ↵Argyrios Kyrtzidis2017-06-202-14/+53
| | | | | | | | | | parse all directive blocks if the condition uses undefined macros This is useful for being able to parse the preprocessor directive blocks even if the header, that defined the macro that is checked, hasn't been included. Differential Revision: https://reviews.llvm.org/D34263 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305797 91177308-0d34-0410-b5e6-96231b3b80d8
* Support non-identifier module names when preprocessing modules.Richard Smith2017-06-191-26/+44
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305758 91177308-0d34-0410-b5e6-96231b3b80d8
* [PR33394] Avoid lexing editor placeholders when Clang is used onlyAlex Lorenz2017-06-161-1/+2
| | | | | | | | | | | | | | | | | for preprocessing r300667 added support for editor placeholder to Clang. That commit didn’t take into account that users who use Clang for preprocessing only (-E) will get the "editor placeholder in source file" error when preprocessing their source (PR33394). This commit ensures that Clang doesn't lex editor placeholders when running a preprocessor only action. rdar://32718000 Differential Revision: https://reviews.llvm.org/D34256 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305576 91177308-0d34-0410-b5e6-96231b3b80d8
* [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, Erich Keane2017-06-141-10/+10
| | | | | | | | | | | | | | | | | | | | | | correct getNumArguments StringifiedArguments is allocated (resized) based on the size the getNumArguments function. However, this function ACTUALLY currently returns the amount of total UnexpArgTokens which is minimum the same as the new implementation of getNumMacroArguments, since empty/omitted arguments result in 1 UnexpArgToken, and included ones at minimum include 2 (1 for the arg itself, 1 for eof). This patch renames the otherwise unused getNumArguments to be more clear that it is the number of arguments that the Macro expects, and thus the maximum number that can be stringified. This patch also replaces the explicit memset (which results in value instantiation of the new tokens, PLUS clearing the memory) with brace initialization. Differential Revision: https://reviews.llvm.org/D32046 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305425 91177308-0d34-0410-b5e6-96231b3b80d8
* Support operator keywords used in Windows SDK(fix ubsan)Erich Keane2017-06-091-1/+3
| | | | | | | | | | UBSan found an issue with a nullptr being assigned to a reference. This was because a following function went back and checked the identifier in the CPPOperatorName case. This patch corrects that location with the original logic as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305128 91177308-0d34-0410-b5e6-96231b3b80d8
* Add #pragma clang module build/endbuild pragmas for performing a module buildRichard Smith2017-06-091-0/+117
| | | | | | | | | | | | | | | | as part of a compilation. This is intended for two purposes: 1) Writing self-contained test cases for modules: we can now write a single source file test that builds some number of module files on the side and imports them. 2) Debugging / test case reduction. A single-source testcase is much more amenable to reduction, compared to a VFS tarball or .pcm files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305101 91177308-0d34-0410-b5e6-96231b3b80d8
* support operator keywords used in Windows SDKErich Keane2017-06-091-1/+5
| | | | | | | | | | | | | | | | | | | | | to support operator keywords used in Windows SDK, alter token type when seen in system headers Hello, I submitted D33505 to address this problem, but the proposal was rejected as too big a hammer. This change will allow clang to parse the WindowsSDK header <query.h> which uses the operator name "or" as a field name. Treat cpp operator keywords as ordinary identifiers inside the Microsoft headers, but treat them as usual in the user's program. Original Submitter: Melanie Blower (mibintc) Differential Revision: https://reviews.llvm.org/D33782 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305087 91177308-0d34-0410-b5e6-96231b3b80d8
* [libclang] Introduce a new parsing option ↵Argyrios Kyrtzidis2017-06-091-1/+5
| | | | | | | | 'CXTranslationUnit_SingleFileParse' that puts preprocessor in a mode for parsing a single file only. This is useful for parsing a single file, as a fast/inaccurate 'mode' that can still provide declarations from the file, like the classes and their methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305044 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out and unify emission of "module is unavailable" diagnostics.Richard Smith2017-06-052-27/+25
| | | | | | | Inspired by post-commit review of r304190. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304728 91177308-0d34-0410-b5e6-96231b3b80d8
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304643 91177308-0d34-0410-b5e6-96231b3b80d8
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through + ↵Galina Kistanova2017-06-031-4/+11
| | | | | | formatted. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304642 91177308-0d34-0410-b5e6-96231b3b80d8
* Support lazy stat'ing of files referenced by module maps.Richard Smith2017-06-023-84/+254
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for a `header` declaration in a module map to specify certain `stat` information (currently, size and mtime) about that header file. This has two purposes: - It removes the need to eagerly `stat` every file referenced by a module map. Instead, we track a list of unresolved header files with each size / mtime (actually, for simplicity, we track submodules with such headers), and when attempting to look up a header file based on a `FileEntry`, we check if there are any unresolved header directives with that `FileEntry`'s size / mtime and perform deferred `stat`s if so. - It permits a preprocessed module to be compiled without the original files being present on disk. The only reason we used to need those files was to get the `stat` information in order to do header -> module lookups when using the module. If we're provided with the `stat` information in the preprocessed module, we can avoid requiring the files to exist. Unlike most `header` directives, if a `header` directive with `stat` information has no corresponding on-disk file the enclosing module is *not* marked unavailable (so that behavior is consistent regardless of whether we've resolved a header directive, and so that preprocessed modules don't get marked unavailable). We could actually do this for all `header` directives: the only reason we mark the module unavailable if headers are missing is to give a diagnostic slightly earlier (rather than waiting until we actually try to build the module / load and validate its .pcm file). Differential Revision: https://reviews.llvm.org/D33703 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304515 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] When compiling a preprocessed module map, look for headers relativeRichard Smith2017-05-311-2/+15
| | | | | | | | | | | | | to the original module map. Also use the path and name of the original module map when emitting that information into the .pcm file. The upshot of this is that the produced .pcm file will track information for headers in their original locations (where the module was preprocessed), not relative to whatever directory the preprocessed module map was in when it was built. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304346 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow for unfinished #if blocks in preamblesErik Verbruggen2017-05-303-28/+26
| | | | | | | | | | | | | | | | | | | | | Previously, a preamble only included #if blocks (and friends like ifdef) if there was a corresponding #endif before any declaration or definition. The problem is that any header file that uses include guards will not have a preamble generated, which can make code-completion very slow. To prevent errors about unbalanced preprocessor conditionals in the preamble, and unbalanced preprocessor conditionals after a preamble containing unfinished conditionals, the conditional stack is stored in the pch file. This fixes PR26045. Differential Revision: http://reviews.llvm.org/D15994 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304207 91177308-0d34-0410-b5e6-96231b3b80d8
* Diagnose attempts to build a preprocessed module that defines an unavailable ↵Richard Smith2017-05-301-0/+18
| | | | | | | | | | submodule. The errors we would otherwise get are incomprehensible, as we would enter the module but not make its contents visible to itself. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304190 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] When we #include a local submodule header that we've already built,Richard Smith2017-05-301-20/+21
| | | | | | | | | | | and it has an include guard, produce callbacks for a module import, not for a skipped non-modular header. Fixes -E output when preprocessing a module to list these cases as a module import, rather than suppressing the #include and losing the import side effect. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304183 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor resolving of header directives -> files out of module map parser.Richard Smith2017-05-261-97/+104
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303945 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Sema: allow imaginary constants via GNU extension if UDL overloads ↵Tim Northover2017-05-241-20/+24
| | | | | | | | | not present." This reverts commit r303697. It broke libc++ tests that were specifically checking incompatibility in C++14 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303813 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix 'set but not used' [-Wunused-but-set-variable] warningSimon Pilgrim2017-05-241-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303734 91177308-0d34-0410-b5e6-96231b3b80d8
* Change __has_feature(objc_diagnose_if_attr) to ↵Argyrios Kyrtzidis2017-05-241-1/+1
| | | | | | __has_feature(attribute_diagnose_if_objc) for consistency with rest of attribute checks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303713 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods ↵Argyrios Kyrtzidis2017-05-241-0/+1
| | | | | | | | and properties as well This is an initial commit to allow using it with constant expressions, a follow-up commit will enable full support for it in ObjC methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303712 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: allow imaginary constants via GNU extension if UDL overloads not present.Tim Northover2017-05-231-25/+20
| | | | | | | | | | | | | C++14 added user-defined literal support for complex numbers so that you can write something like "complex<double> val = 2i". However, there is an existing GNU extension supporting this syntax and interpreting the result as a _Complex type. This changes parsing so that such literals are interpreted in terms of C++14's operators if an overload is present but otherwise falls back to the original GNU extension. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303694 91177308-0d34-0410-b5e6-96231b3b80d8
* Give files from #line the characteristics of the current fileReid Kleckner2017-05-222-22/+24
| | | | | | | | | | This allows #line directives to appear in system headers that have code that clang would normally warn on. This is compatible with GCC, which is easy to test by running `gcc -E`. Fixes PR30752 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303582 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove last (unnecessary) use of mapping from SourceLocation to Module andRichard Smith2017-05-192-43/+3
| | | | | | | | | | remove the mechanism for doing so. This mechanism was incorrect in the presence of preprocessed modules (and #pragma clang module begin/end). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303469 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Simplify module macro handling in non-local-submodule-visibility mode.Richard Smith2017-05-191-12/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When reaching the end of a module, we used to convert its macros to ModuleMacros but also leave them in the MacroDirective chain for the identifier. This meant that every lookup of such a macro would find two (identical) definitions. It also made it difficult to determine the correct owner for a macro when reaching the end of a module: the most recent MacroDirective in the chain could be from an #included submodule rather than the current module. Simplify this: whenever we convert a MacroDirective to a ModuleMacro when leaving a module, clear out the MacroDirective chain for that identifier, and just rely on the ModuleMacro to provide the macro definition information. (We don't want to do this for local submodule visibility mode, because in that mode we maintain a distinct MacroDirective chain for each submodule, and we need to keep around the prior MacroDirective in case we re-enter the submodule -- for instance, if its header is #included more than once in a module build, we need the include guard directive to stick around. But the problem doesn't arise in this case for the same reason: each submodule has its own MacroDirective chain, so the macros don't leak out of submodules in the first place.) This reinstates r302932, reverted in r302947, with a fix for a bug that resulted in us sometimes losing macro definitions due to failing to clear out the overridden module macro list when promoting a directive to a module macro. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303468 91177308-0d34-0410-b5e6-96231b3b80d8
* [Lexer] Ensure that the token is not an annotation token whenAlex Lorenz2017-05-171-0/+4
| | | | | | | | | | | | retrieving the identifer info for an Objective-C keyword This commit fixes an assertion that's triggered in getIdentifier when the token is an annotation token. rdar://32225463 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303246 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused tracking of owning module for MacroInfo objects.Richard Smith2017-05-123-33/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302966 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r302932, as it appears to be breaking stage2 for some of our ↵Richard Smith2017-05-121-7/+12
| | | | | | modules-enabled buildbots. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302947 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Simplify module macro handling in non-local-submodule-visibility mode.Richard Smith2017-05-121-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | When reaching the end of a module, we used to convert its macros to ModuleMacros but also leave them in the MacroDirective chain for the identifier. This meant that every lookup of such a macro would find two (identical) definitions. It also made it difficult to determine the correct owner for a macro when reaching the end of a module: the most recent MacroDirective in the chain could be from an #included submodule rather than the current module. Simplify this: whenever we convert a MacroDirective to a ModuleMacro when leaving a module, clear out the MacroDirective chain for that identifier, and just rely on the ModuleMacro to provide the macro definition information. (We don't want to do this for local submodule visibility mode, because in that mode we maintain a distinct MacroDirective chain for each submodule, and we need to keep around the prior MacroDirective in case we re-enter the submodule -- for instance, if its header is #included more than once in a module build, we need the include guard directive to stick around. But the problem doesn't arise in this case for the same reason: each submodule has its own MacroDirective chain, so the macros don't leak out of submodules in the first place.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302932 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules] Allow umbrella frameworks to define private submodules for ↵Bruno Cardoso Lopes2017-05-091-2/+4
| | | | | | | | | | | | subframeworks In r298391 we fixed the umbrella framework model to work when submodules named "Private" are used. This complements the work by allowing the umbrella framework model to work in general. rdar://problem/31790067 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302491 91177308-0d34-0410-b5e6-96231b3b80d8
* If we are building a module, and we read a second description of the sameRichard Smith2017-05-081-1/+13
| | | | | | | | | module from a different module map, ignore it. This happens during builds of preprocessed modules (where it is harmless). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302463 91177308-0d34-0410-b5e6-96231b3b80d8
* Permit keywords in module names in #pragma clang module *.Richard Smith2017-05-051-1/+1
| | | | | | | | This is necessary to be able to build a libc++ module from preprocessed source (due to the submodule std.new). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302312 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for building modules from preprocessed source.Richard Smith2017-05-052-13/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support this, an optional marker "#pragma clang module contents" is recognized in module map files, and the rest of the module map file from that point onwards is treated as the source of the module. Preprocessing a module map produces the input module followed by the marker and then the preprocessed contents of the module. Ignoring line markers, a preprocessed module might look like this: module A { header "a.h" } #pragma clang module contents #pragma clang module begin A // ... a.h ... #pragma clang module end The preprocessed output generates line markers, which are not accepted by the module map parser, so -x c++-module-map-cpp-output should be used to compile such outputs. A couple of major parts do not work yet: 1) The files that are listed in the module map must exist on disk, in order to build the on-disk header -> module lookup table in the PCM file. To fix this, we need the preprocessed output to track the file size and other stat information we might use to build the lookup table. 2) Declaration ownership semantics don't work properly yet, since mapping from a source location to a module relies on mapping from FileIDs to modules, which we can't do if module transitions can occur in the middle of a file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302309 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a fix-it for -Wunguarded-availabilityAlex Lorenz2017-05-051-17/+49
| | | | | | | | | | | | | | This patch adds a fix-it for the -Wunguarded-availability warning. This fix-it is similar to the Swift one: it suggests that you wrap the statement in an `if (@available)` check. The produced fixits are indented (just like the Swift ones) to make them look nice in Xcode's fix-it preview. rdar://31680358 Differential Revision: https://reviews.llvm.org/D32424 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302253 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix whitespace before token-paste of an argument.James Y Knight2017-05-041-12/+18
| | | | | | | | | | | | | | | The whitespace should come from the argument name in the macro expansion, rather than from the token passed to the macro (same as it does when not pasting). Added a new test case for the change in behavior to stringize_space.c. FileCheck'ized macro_paste_commaext.c, tweaked the test case, and added a comment; no behavioral change to this test. Differential Revision: https://reviews.llvm.org/D30427 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302195 91177308-0d34-0410-b5e6-96231b3b80d8
* Add #pragma clang module begin/end pragmas and generate them when ↵Richard Smith2017-05-045-66/+176
| | | | | | | | | | | | | | | preprocessing a module. These pragmas are intended to simulate the effect of entering or leaving a file with an associated module. This is not completely implemented yet: declarations between the pragmas will not be attributed to the correct module, but macro visibility is already functional. Modules named by #pragma clang module begin must already be known to clang (in some module map that's either loaded or on the search path). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302098 91177308-0d34-0410-b5e6-96231b3b80d8
* Add pragma to perform module import and use it in -E output.Richard Smith2017-04-292-8/+68
| | | | | | | | | | | | | | | | | | | | | | Many of our supported configurations support modules but do not have any first-class syntax to perform a module import. This leaves us with a problem: there is no way to represent the expansion of a #include that imports a module in the -E output for such languages. (We don't want to just leave it as a #include because that requires the consumer of the preprocessed source to have the same file system layout and include paths as the creator.) This patch adds a new pragma: #pragma clang module import MODULE.NAME.HERE that imports a module, and changes -E and -frewrite-includes to use it when rewriting a #include that maps to a module import. We don't make any attempt to use a native language syntax import if one exists, to get more consistent output. (If in the future, @import and #include have different semantics in some way, the pragma will track the #include semantics.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301725 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules] Improve diagnostics for incomplete umbrellaBruno Cardoso Lopes2017-04-271-4/+17
| | | | | | | | | | | | | One of the -Wincomplete-umbrella warnings diagnoses when a header is present in the directory but it's not present in the umbrella header. Currently, this warning only happens on top level modules; any submodule using an umbrella header does not get this warning. Fix that by also considering the submodules. Differential Revision: https://reviews.llvm.org/D32576 rdar://problem/22623686 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301597 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules] Refactor logic for incomplete umbrella warnings. NFCBruno Cardoso Lopes2017-04-271-37/+36
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301596 91177308-0d34-0410-b5e6-96231b3b80d8
* Preprocessor: Suppress -Wnonportable-include-path for header mapsDuncan P. N. Exon Smith2017-04-274-21/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a file search involves a header map, suppress -Wnonportable-include-path. It's firing lots of false positives for framework authors internally, and it's not trivial to fix. Consider a framework called "Foo" with a main (installed) framework header "Foo/Foo.h". It's atypical for "Foo.h" to actually live inside a directory called "Foo" in the source repository. Instead, the build system generates a header map while building the framework. If Foo.h lives at the top-level of the source repository (common), and the git repo is called ssh://some.url/foo.git, then the header map will have something like: Foo/Foo.h -> /Users/myname/code/foo/Foo.h where "/Users/myname/code/foo" is the clone of ssh://some.url/foo.git. After #import <Foo/Foo.h>, the current implementation of -Wnonportable-include-path will falsely assume that Foo.h was found in a nonportable way, because of the name of the git clone (.../foo/Foo.h). However, that directory name was not involved in the header search at all. This commit adds an extra parameter to Preprocessor::LookupFile and HeaderSearch::LookupFile to track if the search used a header map, making it easy to suppress the warning. Longer term, once we find a way to avoid the false positive, we should turn the warning back on. rdar://problem/28863903 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301592 91177308-0d34-0410-b5e6-96231b3b80d8