aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex
AgeCommit message (Collapse)AuthorFilesLines
2016-12-11[CrashReproducer] Collect headermap filesBruno Cardoso Lopes1-0/+7
Include headermaps (.hmap files) in the .cache directory and add VFS entries. All headermaps are known after HeaderSearch setup, collect them right after. rdar://problem/27913709 llvm-svn: 289360
2016-12-09Don't assert when redefining a built-in macro in a PCH, PR29119Nico Weber1-3/+26
PCH files store the macro history for a given macro, and the whole history list for one identifier is given to the Preprocessor at once via Preprocessor::setLoadedMacroDirective(). This contained an assert that no macro history exists yet for that identifier. That's usually true, but it's not true for builtin macros, which are created in Preprocessor() before flags and pchs are processed. Luckily, ASTWriter stops writing macro history lists at builtins (see shouldIgnoreMacro() in ASTWriter.cpp), so the head of the history list was missing for builtin macros. So make the assert weaker, and splice the history list to the existing single define for builtins. https://reviews.llvm.org/D27545 llvm-svn: 289228
2016-12-06Revert r288626, which reverts r288449. Original commit message:Richard Smith1-5/+5
Recover better from an incompatible .pcm file being provided by -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually. llvm-svn: 288741
2016-12-04Revert "Recover better from an incompatible .pcm file being provided by ↵Daniel Jasper1-5/+5
-fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually." This reverts commit r288449. I believe that this is currently faulty wrt. modules being imported inside namespaces. Adding these lines to the new test: namespace n { #include "foo.h" } Makes it break with fatal error: import of module 'M' appears within namespace 'n' However, I believe it should fail with error: redundant #include of module 'M' appears within namespace 'n' I have tracked this down to us now inserting a tok::annot_module_begin instead of a tok::annot_module_include in Preprocessor::HandleIncludeDirective() and then later in Parser::parseMisplacedModuleImport(), we hit the code path for tok::annot_module_begin, which doesn't set FromInclude of checkModuleImportContext to true (thus leading to the "wrong" diagnostic). llvm-svn: 288626
2016-12-02Recover better from an incompatible .pcm file being provided by -fmodule-file=.Richard Smith1-5/+5
We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually. llvm-svn: 288449
2016-11-15[Modules] Replace arrays with init lists.Benjamin Kramer1-9/+5
Thi way the compiler can pick the optimal storage duration. It's also more readable. No functional change intended. llvm-svn: 287005
2016-11-10Accept nullability qualifiers on array parameters.Jordan Rose1-0/+1
Since array parameters decay to pointers, '_Nullable' and friends should be available for use there as well. This is especially important for parameters that are typedefs of arrays. The unsugared syntax for this follows the syntax for 'static'-sized arrays in C: void test(int values[_Nullable]); This syntax was previously accepted but the '_Nullable' (and any other attributes) were silently discarded. However, applying '_Nullable' to a typedef was previously rejected and is now accepted; therefore, it may be necessary to test for the presence of this feature: #if __has_feature(nullability_on_arrays) One important change here is that DecayedTypes don't always immediately contain PointerTypes anymore; they may contain an AttributedType instead. This only affected one place in-tree, so I would guess it's not likely to cause problems elsewhere. This commit does not change -Wnullability-completeness just yet. I want to think about whether it's worth doing something special to avoid breaking existing clients that compile with -Werror. It also doesn't change '#pragma clang assume_nonnull' behavior, which currently treats the following two declarations as equivalent: #pragma clang assume_nonnull begin void test(void *pointers[]); #pragma clang assume_nonnull end void test(void * _Nonnull pointers[]); This is not the desired behavior, but changing it would break backwards-compatibility. Most likely the best answer is going to be adding a new warning. Part of rdar://problem/25846421 llvm-svn: 286519
2016-11-04Add some more asserts to clearly indicate that there are special casesChandler Carruth1-1/+4
which guarantee pointers are not null. These all seem to have useful properties and correlations to document, in one case we even had it in a comment but now it will also be an assert. This should prevent PVS-Studio from incorrectly claiming that there are a bunch of potential bugs here. But I feel really strongly that the PVS-Studio warnings that pointed at this code have a far too high false-positive rate to be entirely useful. These are just places where there did seem to be a useful invariant to document and verify with an assert. Several other places in the code were already correct and already have perfectly clear code documenting and validating their invariants, but still ran afoul of PVS-Studio. llvm-svn: 285985
2016-10-27Do not print include_next/pragma once warnings when input is a header.Erik Verbruggen3-4/+14
r276653 suppressed the pragma once warning when generating a PCH file. This patch extends that to any main file for which clang is told (with the -x option) that it's a header file. It will also suppress the warning "#include_next in primary source file". Differential Revision: http://reviews.llvm.org/D25989 llvm-svn: 285295
2016-10-27Fix MSVC warning about missing 'this' from lambda default capture modeSimon Pilgrim1-1/+1
llvm-svn: 285281
2016-10-26[PP] Replace some index based for loops with range based onesErik Verbruggen6-25/+19
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
2016-10-26[PP] Remove another unused parameterErik Verbruggen1-2/+2
Differential Revision: http://reviews.llvm.org/D25981 llvm-svn: 285188
2016-10-26[PP] Replace some uses of unsigned with size_tErik Verbruggen1-7/+5
All values are returned by a method as size_t, and subsequently passed to functions taking a size_t, or used where a size_t is also valid. Better still, two loops (which had an unsigned), can be replaced by a range-based for loop. Differential Revision: http://reviews.llvm.org/D25939 llvm-svn: 285182
2016-10-26PP: Remove unused parameters from methodsErik Verbruggen1-6/+6
NFC Differential Revision: http://reviews.llvm.org/D25938 llvm-svn: 285180
2016-10-26Treat module headers wrapped by our builtin headers as implicitly being textualRichard Smith1-5/+9
headers. We previously got this check backwards and treated the wrapper header as being textual. This is important because our wrapper headers sometimes inject macros into the system headers that they #include_next, and sometimes replace them entirely. llvm-svn: 285152
2016-10-25Include full filename range for missing includesErik Verbruggen1-1/+2
For the purpose of highlighting in an IDE. llvm-svn: 285057
2016-10-21Module: improve the diagnostic message for include of non-modular header.Manman Ren1-1/+2
Emit the actual path to the non-modular include. rdar://28897010 llvm-svn: 284897
2016-10-21[Modules] Add 'no_undeclared_includes' module map attributeBruno Cardoso Lopes2-21/+59
The 'no_undeclared_includes' attribute should be used in a module to tell that only non-modular headers and headers from used modules are accepted. The main motivation behind this is to prevent dep cycles between system libraries (such as darwin) and libc++. Patch by Richard Smith! llvm-svn: 284797
2016-10-20Fix off-by-one error in PPCaching.cpp token annotation assertionReid Kleckner1-1/+1
This assert is intended to defend against backtracking into the middle of a sequence of tokens that is being replaced with an annotation, but it's OK if we backtrack to the exact position of the start of the annotation sequence. Use a <= comparison instead of <. Fixes PR25946 llvm-svn: 284777
2016-10-20Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer3-12/+7
No functionality change intended. llvm-svn: 284730
2016-10-11Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)Mehdi Amini2-4/+4
llvm-svn: 283856
2016-10-10Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)Mehdi Amini2-11/+13
llvm-svn: 283815
2016-10-01Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini3-4/+4
llvm-svn: 283043
2016-09-30Move UTF functions into namespace llvm.Justin Lebar2-25/+25
Summary: This lets people link against LLVM and their own version of the UTF library. I determined this only affects llvm, clang, lld, and lldb by running $ git grep -wl 'UTF[0-9]\+\|\bConvertUTF\bisLegalUTF\|getNumBytesFor' | cut -f 1 -d '/' | sort | uniq clang lld lldb llvm Tested with ninja lldb ninja check-clang check-llvm check-lld (ninja check-lldb doesn't complete for me with or without this patch.) Reviewers: rnk Subscribers: klimek, beanz, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D24996 llvm-svn: 282822
2016-09-29Mark P0127R3 as done, and replace its __has_feature check with the ↵Richard Smith1-4/+5
corresponding SD-6 macro. llvm-svn: 282652
2016-09-28P0127R2: Support type deduction for types of non-type template parameters inRichard Smith1-0/+2
C++1z. Patch by James Touton! Some bugfixes and rebasing by me. llvm-svn: 282651
2016-09-07Fix some Clang-tidy modernize-use-using and Include What You Use warnings; ↵Eugene Zelenko7-64/+164
other minor fixes. Differential revision: https://reviews.llvm.org/D24115 llvm-svn: 280870
2016-08-26Don't diagnose non-modular includes when we are not compiling a module.Manman Ren1-1/+3
This is triggered when we are compiling an implementation of a module, it has relative includes to a VFS-mapped module with umbrella headers. Currently we will find the real path to headers under the umbrella directory, but the umbrella directories are using virtual path. rdar://27951255 Thanks Ben and Richard for reviewing the patch! Differential Revision: http://reviews.llvm.org/D23858 llvm-svn: 279838
2016-08-26C++ Modules TS: add frontend support for building pcm files from moduleRichard Smith4-4/+40
interface files. At the moment, all declarations (and no macros) are exported, and 'export' declarations are not supported yet. llvm-svn: 279794
2016-08-24Remove excessive padding from PTHStatData (NFC)Mehdi Amini1-2/+2
This diff reorders the fields and removes excessive padding. This fixes the following warning: PTHLexer.cpp:629:7: warning: Excessive padding in 'class (anonymous namespace)::PTHStatData' (14 padding bytes, where 6 is optimal). Optimal fields order: Size, ModTime, UniqueID, HasData, IsDirectory, consider reordering the fields or adding explicit padding members. Patch by: Alexander Shaposhnikov <shal1t712@gmail.com> Differential Revision: https://reviews.llvm.org/D23826 llvm-svn: 279607
2016-08-18C++ Modules TS: Add parsing support for module import declaration.Richard Smith1-4/+8
llvm-svn: 279163
2016-08-18Module: add -fprebuilt-module-path to support loading prebuilt modules.Manman Ren1-2/+20
In this mode, there is no need to load any module map and the programmer can simply use "@import" syntax to load the module directly from a prebuilt module path. When loading from prebuilt module path, we don't support rebuilding of the module files and we ignore compatible configuration mismatches. rdar://27290316 Differential Revision: http://reviews.llvm.org/D23125 llvm-svn: 279096
2016-08-18PR28438: Update the information on an identifier with local definitions beforeRichard Smith1-1/+6
trying to write out its macro graph, in case we imported a module that added another module macro between the most recent local definition and the end of the module. llvm-svn: 279024
2016-08-05Reapply r276973 "Adjust Registry interface to not require plugins to export ↵John Brawn1-1/+1
a registry" This differs from the previous version by being more careful about template instantiation/specialization in order to prevent errors when building with clang -Werror. Specifically: * begin is not defined in the template and is instead instantiated when Head is. I think the warning when we don't do that is wrong (PR28815) but for now at least do it this way to avoid the warning. * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY instead provide a template definition then do explicit instantiation. No compiler I've tried has problems with doing it the other way, but strictly speaking it's not permitted by the C++ standard so better safe than sorry. Original commit message: Currently the Registry class contains the vestiges of a previous attempt to allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a plugin would have its own copy of a registry and export it to be imported by the tool that's loading the plugin. This only works if the plugin is entirely self-contained with the only interface between the plugin and tool being the registry, and in particular this conflicts with how IR pass plugins work. This patch changes things so that instead the add_node function of the registry is exported by the tool and then imported by the plugin, which solves this problem and also means that instead of every plugin having to export every registry they use instead LLVM only has to export the add_node functions. This allows plugins that use a registry to work on Windows if LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used. llvm-svn: 277806
2016-07-28Revert r276973 "Adjust Registry interface to not require plugins to export a ↵John Brawn1-1/+1
registry" Buildbot failures when building with clang -Werror. Reverting while I try to figure this out. llvm-svn: 277008
2016-07-28Reapply r276856 "Adjust Registry interface to not require plugins to export ↵John Brawn1-1/+1
a registry" This version has two fixes compared to the original: * In Registry.h the template static members are instantiated before they are used, as clang gives an error if you do it the other way around. * The use of the Registry template in clang-tidy is updated in the same way as has been done everywhere else. Original commit message: Currently the Registry class contains the vestiges of a previous attempt to allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a plugin would have its own copy of a registry and export it to be imported by the tool that's loading the plugin. This only works if the plugin is entirely self-contained with the only interface between the plugin and tool being the registry, and in particular this conflicts with how IR pass plugins work. This patch changes things so that instead the add_node function of the registry is exported by the tool and then imported by the plugin, which solves this problem and also means that instead of every plugin having to export every registry they use instead LLVM only has to export the add_node functions. This allows plugins that use a registry to work on Windows if LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used. llvm-svn: 276973
2016-07-27Implement filtering for code completion of identifiers.Vassil Vassilev2-2/+13
Patch by Cristina Cristescu and Axel Naumann! Agreed on post commit review (D17820). llvm-svn: 276878
2016-07-27Revert r276856 "Adjust Registry interface to not require plugins to export a ↵John Brawn1-1/+1
registry" This is causing a huge pile of buildbot failures. llvm-svn: 276857
2016-07-27Adjust Registry interface to not require plugins to export a registryJohn Brawn1-1/+1
Currently the Registry class contains the vestiges of a previous attempt to allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a plugin would have its own copy of a registry and export it to be imported by the tool that's loading the plugin. This only works if the plugin is entirely self-contained with the only interface between the plugin and tool being the registry, and in particular this conflicts with how IR pass plugins work. This patch changes things so that instead the add_node function of the registry is exported by the tool and then imported by the plugin, which solves this problem and also means that instead of every plugin having to export every registry they use instead LLVM only has to export the add_node functions. This allows plugins that use a registry to work on Windows if LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used. Differential Revision: http://reviews.llvm.org/D21385 llvm-svn: 276856
2016-07-25Support '#pragma once' in headers when using PCHSunil Srivastava1-1/+3
The '#pragma once' directive was erroneously ignored when encountered in the header-file specified in generate-PCH-mode. This resulted in compile-time errors in some cases with legal code, and also a misleading warning being produced. Patch by Warren Ristow! Differential Revision: http://reviews.llvm.org/D19815 llvm-svn: 276653
2016-07-18[NFC] Header cleanupMehdi Amini7-10/+5
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2016-07-07[Lex] Speed up updateConsecutiveMacroArgTokens (NFC)Vedant Kumar1-3/+4
SM.isWrittenInSameFile() calls getFileID(), which can be expensive. Move this check behind some cheaper filters. llvm-svn: 274800
2016-07-01[Feature] Add a builtin for indexing into parameter packs. Patch by Louis ↵Eric Fiselier1-0/+1
Dionne. This patch adds a __nth_element builtin that allows fetching the n-th type of a parameter pack with very little compile-time overhead. The patch was inspired by r252036 and r252115 by David Majnemer, which add a similar __make_integer_seq builtin for efficiently creating a std::integer_sequence. Reviewed as D15421. http://reviews.llvm.org/D15421 llvm-svn: 274316
2016-06-16[Lex] Try to fix a 'comparison is always false' warning. NFC.George Burgess IV1-1/+1
llvm-svn: 272867
2016-06-13Patch for r272584 (http://reviews.llvm.org/rL272584) to address ↵Taewook Oh1-41/+41
clang-x64-ninja-win7 buildbot failure. Patch by Eric Niebler llvm-svn: 272592
2016-06-13Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2-6/+156
non-portable #include and #import paths. Differential Revision: http://reviews.llvm.org/D19843 Corresponding LLVM change: http://reviews.llvm.org/D19842 Re-commit of r272562 after addressing clang-x86-win2008-selfhost failure. llvm-svn: 272584
2016-06-13Revert r272562 for build bot failure (clang-x86-win2008-selfhost)Taewook Oh2-156/+6
llvm-svn: 272572
2016-06-13Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2-6/+156
non-portable #include and #import paths. Differential Revision: http://reviews.llvm.org/D19843 Corresponding LLVM change: http://reviews.llvm.org/D19842 Re-commit after addressing issues with of generating too many warnings for Windows and asan test failures. Patch by Eric Niebler llvm-svn: 272562
2016-06-04Revert commit r271708Taewook Oh2-75/+6
llvm-svn: 271761
2016-06-03Use the name of the file on disk to issue a new diagnostic about ↵Taewook Oh2-6/+75
non-portable #include and #import paths. Differential Revision: http://reviews.llvm.org/D19843 Corresponding LLVM change: http://reviews.llvm.org/D19842 Patch by Eric Niebler llvm-svn: 271708