summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPLexerChange.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-7/+7
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [clang-cl, PCH] Implement support for MS-style PCH through headersErich Keane2018-07-051-2/+25
| | | | | | | | | | | | | | | | | | | | | Implement support for MS-style PCH through headers. This enables support for /Yc and /Yu where the through header is either on the command line or included in the source. It replaces the current support the requires the header also be specified with /FI. This change adds a -cc1 option -pch-through-header that is used to either start or stop compilation during PCH create or use. When creating a PCH, the compilation ends after compilation of the through header. When using a PCH, tokens are skipped until after the through header is seen. Patch By: mikerice Differential Revision: https://reviews.llvm.org/D46652 llvm-svn: 336379
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-2/+2
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [Lex] Fix crash on code completion in comment in included file.Volodymyr Sapsai2018-01-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes PR32732 by updating CurLexerKind to reflect available lexers. We were hitting null pointer in Preprocessor::Lex because CurLexerKind was CLK_Lexer but CurLexer was null. And we set it to null in Preprocessor::HandleEndOfFile when exiting a file with code completion point. To reproduce the crash it is important for a comment to be inside a class specifier. In this case in Parser::ParseClassSpecifier we improve error recovery by pushing a semicolon token back into the preprocessor and later on try to lex a token because we haven't reached the end of file. Also clang crashes only on code completion in included file, i.e. when IncludeMacroStack is not empty. Though we reset CurLexer even if include stack is empty. The difference is that during pushing back a semicolon token, preprocessor calls EnterCachingLexMode which decides it is already in caching mode because various lexers are null and IncludeMacroStack is not empty. As the result, CurLexerKind remains CLK_Lexer instead of updating to CLK_CachingLexer. rdar://problem/34787685 Reviewers: akyrtzi, doug.gregor, arphaman Reviewed By: arphaman Subscribers: cfe-commits, kfunk, arphaman, nemanjai, kbarton Differential Revision: https://reviews.llvm.org/D41688 llvm-svn: 323008
* Another attempt to fix warning discovered by r313487. [-Wunused-lambda-capture]Vitaly Buka2017-09-181-1/+1
| | | | llvm-svn: 313521
* Revert rL313511, "Fix a warning discovered by rL313487. ↵NAKAMURA Takumi2017-09-181-1/+1
| | | | | | | | [-Wunused-lambda-capture]" It was incompatible to msc. llvm-svn: 313513
* Fix a warning discovered by rL313487. [-Wunused-lambda-capture]NAKAMURA Takumi2017-09-181-1/+1
| | | | llvm-svn: 313511
* Reformat.NAKAMURA Takumi2017-09-181-4/+3
| | | | llvm-svn: 313510
* Fixed a crash on replaying Preamble's PP conditional stack.Ilya Biryukov2017-08-211-1/+12
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 311330
* Fix invalid warnings for header guards in preamblesErik Verbruggen2017-07-051-6/+0
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=33574 Differential Revision: https://reviews.llvm.org/D34882 llvm-svn: 307134
* Allow for unfinished #if blocks in preamblesErik Verbruggen2017-05-301-0/+6
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 304207
* [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. llvm-svn: 303468
* Revert r302932, as it appears to be breaking stage2 for some of our ↵Richard Smith2017-05-121-7/+12
| | | | | | modules-enabled buildbots. llvm-svn: 302947
* [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.) llvm-svn: 302932
* Add #pragma clang module begin/end pragmas and generate them when ↵Richard Smith2017-05-041-14/+43
| | | | | | | | | | | | | | 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). llvm-svn: 302098
* [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 llvm-svn: 301597
* [Modules] Refactor logic for incomplete umbrella warnings. NFCBruno Cardoso Lopes2017-04-271-37/+36
| | | | llvm-svn: 301596
* Use setUsedForHeaderGuard() accessor function instead of direcly accessing ↵Yaron Keren2017-04-161-3/+2
| | | | | | UsedForHeaderGuard. llvm-svn: 300423
* Fix MSVC warning about missing 'this' from lambda default capture modeSimon Pilgrim2016-10-271-1/+1
| | | | llvm-svn: 285281
* [PP] Replace some index based for loops with range based onesErik Verbruggen2016-10-261-8/+6
| | | | | | | | | While in the area, also change some unsigned variables to size_t, and introduce an LLVM_FALLTHROUGH instead of a comment stating that. Differential Revision: http://reviews.llvm.org/D25982 llvm-svn: 285193
* C++ Modules TS: add frontend support for building pcm files from moduleRichard Smith2016-08-261-1/+1
| | | | | | | interface files. At the moment, all declarations (and no macros) are exported, and 'export' declarations are not supported yet. llvm-svn: 279794
* PR24667: fix quadratic runtime if textually-included modular headers define ↵Richard Smith2016-02-231-22/+45
| | | | | | large numbers of macros. llvm-svn: 261705
* [modules] Do less scanning of macro definition chains when computing the set ofRichard Smith2016-02-191-5/+20
| | | | | | | exported module macros outside local submodule visibility mode. Related to PR24667. llvm-svn: 261373
* Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.Nico Weber2015-12-291-1/+0
| | | | llvm-svn: 256595
* Replace SM.getFileEntryForID(Lexer->getFileID()) with Lexer->getFileEntry().Yaron Keren2015-12-181-2/+1
| | | | llvm-svn: 255993
* Remove spaces in empty line, NFC.Yaron Keren2015-11-071-1/+1
| | | | llvm-svn: 252405
* Sink some PTHManager includes out of Preprocessor.hReid Kleckner2015-11-021-0/+1
| | | | | | | This reduces the number of .cpp files needed to be rebuilt after touching OnDiskHashTable from 120 to 21 for me. llvm-svn: 251810
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* [modules] Make sure macros get made visible in the top-level file if we've gotRichard Smith2015-06-301-2/+15
| | | | | | | local submodule visibility enabled; that top-level file might not actually be the module includes buffer if use of prebuilt modules is disabled. llvm-svn: 241120
* Introduced pragmas for audited nullability regions.Douglas Gregor2015-06-191-0/+11
| | | | | | | | | | | | | | | | | 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
* Avoid using a C++11 library feature not present in libstdc++4.7.Richard Smith2015-05-211-2/+1
| | | | llvm-svn: 237872
* [modules] If we re-enter a submodule from within itself (when submoduleRichard Smith2015-05-211-47/+51
| | | | | | | | | | visibility is enabled) or leave and re-enter it, restore the macro and module visibility state from last time we were in that submodule. This allows mutually-#including header files to stand a chance at being modularized with local visibility enabled. llvm-svn: 237871
* [modules] Retain the name as written for umbrella headers and directories, ↵Richard Smith2015-05-161-1/+1
| | | | | | rather than converting to an absolute path. No observable change expected, but this allows us to correctly compute the module for an umbrella header, which later changes will require. llvm-svn: 237508
* [modules] Add local submodule visibility support for declarations.Richard Smith2015-05-151-3/+16
| | | | | | | | | | | | 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
* [modules] Rearrange preprocessor module visibility handling, no observable ↵Richard Smith2015-05-141-7/+10
| | | | | | change intended. llvm-svn: 237331
* [modules] Don't bother creating a ModuleMacro representing a #undef that ↵Richard Smith2015-05-021-2/+5
| | | | | | overrides nothing. llvm-svn: 236374
* [modules] If a module #includes a modular header that #undef's its macro, itRichard Smith2015-05-021-5/+4
| | | | | | | | should not export the macro. ... at least, not unless we have local submodule visibility enabled. llvm-svn: 236369
* [modules] Add -fmodules-local-submodule-visibility flag.Richard Smith2015-05-011-17/+52
| | | | | | | | | | | | | | | 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] Start moving the module visibility information off the Module itself.Richard Smith2015-05-011-7/+1
| | | | | | | 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
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-1/+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
* Refactor to make MacroState ownership and lifetime clearer.Richard Smith2015-04-281-1/+4
| | | | llvm-svn: 236032
* [modules] Incrementally compute the list of overridden module macros based onRichard Smith2015-04-271-7/+17
| | | | | | | the active module macros at the point of definition, rather than reconstructing it from the macro history. No functionality change intended. llvm-svn: 235941
* Remove unused variable to silence GCC warningDavid Majnemer2015-04-241-3/+2
| | | | llvm-svn: 235693
* [modules] Partial revert of r235669: don't create ModuleMacros for imported ↵Richard Smith2015-04-241-6/+0
| | | | | | | | local macros. The surrounding infrastructure isn't quite ready for this yet. llvm-svn: 235677
* [modules] Refactor creation of ModuleMacros and create them when importing ↵Richard Smith2015-04-231-4/+11
| | | | | | from local submodules. llvm-svn: 235669
* [modules] Properly attribute macros to modules if they're in a file ↵Richard Smith2015-04-231-1/+1
| | | | | | textually included into a file in the module. llvm-svn: 235661
* [modules] Determine the set of macros exported by a submodule at the end of ↵Richard Smith2015-04-231-0/+63
| | | | | | | | | | | 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 superceded warning warn_forgotten_module_headerBen Langmuir2014-11-051-28/+0
| | | | | | | | | | | | This DefaultIgnore warning under -Wincomplete-module was firing on any module map files that happened to be parsed (it's only supposed to fire on headers), and it has been superceded by -Wnon-modular-include-in-module anyway. For compatibility, I rewired -Wincomplete-module to imply -Wnon-modular-include-in-module. llvm-svn: 221357
* [modules] Add support for 'textual header' directives.Richard Smith2014-10-221-1/+2
| | | | | | | | This allows a module to specify that it logically contains a file, but that said file is non-modular and intended for textual inclusion. This allows layering checks to work properly in the presence of such files. llvm-svn: 220448
OpenPOWER on IntegriCloud