summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
...
* Modules: Make missing headers in a module.map a warning not an error.Daniel Jasper2013-12-162-18/+11
| | | | | | | | | | | | | | | | Instead, mark the module as unavailable so that clang errors as soon as someone tries to build this module. A better long-term strategy might be to not stat the header files at all while reading the module map and instead read them only when the module is being built (there is a corresponding FIXME in parseHeaderDecl()). However, it seems non-trivial to get there and this would be a temporary solution to unblock us. Also changed the implementation to reuse the same DiagnosticsEngine as otherwise warnings can't be enabled or disabled with command-line flags. llvm-svn: 197388
* Lexer: Issue -Wbackslash-newline-escape for line commentsAlp Toker2013-12-141-1/+8
| | | | | | | | | | | | The warning for backslash and newline separated by whitespace was missed in this code path. backslash<whitespace><newline> is handled differently from compiler to compiler so it's important to warn consistently where there's ambiguity. Matches similar handling of block comments and non-comment lines. llvm-svn: 197331
* Fix raw lex crash and -frewrite-includes noeol-at-eof failureAlp Toker2013-12-131-1/+2
| | | | | | Raw lexers don't have a preprocessor so we need to null check. llvm-svn: 197245
* [Modules] Don't parse any module map if modules are disabled.Argyrios Kyrtzidis2013-12-121-0/+5
| | | | | | Fixes rdar://15644663. llvm-svn: 197165
* Modules: Let -fmodules-decluse ignore headers that aren't in a moduleDaniel Jasper2013-12-112-18/+28
| | | | | | | | | | | Includes might always pull in arbitrary header or data files outside of modules. Among others, this includes builtin includes, which do not have a module (story) yet. Also cleanup implementation of ModuleMap::findModuleForHeader() to be non-recursive. llvm-svn: 197034
* Revert r196859, "Use llvm::sys::path::append to concatenate paths", to ↵NAKAMURA Takumi2013-12-101-2/+5
| | | | | | appease FileManager. llvm-svn: 196865
* Use llvm::sys::path::append to concatenate pathsDmitri Gribenko2013-12-101-5/+2
| | | | llvm-svn: 196859
* Changed ConditionValue argument to PPCallbacks If and Elif callbacks to be a ↵John Thompson2013-12-072-5/+5
| | | | | | 3-state enum. llvm-svn: 196648
* Tweak the ordering of a conditional to possibly avoid a few strcmps.Aaron Ballman2013-12-061-1/+1
| | | | llvm-svn: 196584
* Allow string literals as module names.Daniel Jasper2013-12-062-21/+3
| | | | | | | | | | | | | | | | | | In order to make the migration to modules easier, it seems to be helpful to allow a 1:1 mapping between target names of a current build system and the corresponding C++ modules. As such targets commonly contain characters like "-". ":" and "/", allowing arbitrary quote-escaped strings seems to be a straightforward option. After several offline discussions, the precise mechanisms for C++ module names especially regarding submodules and import statements has yet to be determined. Thus, this patch only enables string literals as names inside the module map files which can be used by automatic module import (through #include). Also improve the error message on missing use-declarations. llvm-svn: 196573
* [libclang] Record ranges skipped by the preprocessor and expose them with ↵Argyrios Kyrtzidis2013-12-051-0/+4
| | | | | | | | libclang. Patch by Erik Verbruggen! llvm-svn: 196487
* Enea Zaffanella's fix for the PPCallbacks Elif callback, with a slight ↵John Thompson2013-12-041-17/+15
| | | | | | re-org, and an update of the new PPCallbacks test (soon to be moved to clang from extra), rather the unittest. llvm-svn: 196407
* Revert r196372, "do not warn about unknown pragmas in modes that do not ↵NAKAMURA Takumi2013-12-041-11/+0
| | | | | | | | handle them (pr9537)" It broke clang tests on some hosts with +Asserts. Seems "STDC" clashes. llvm-svn: 196376
* do not warn about unknown pragmas in modes that do not handle them (pr9537)Lubos Lunak2013-12-041-0/+11
| | | | | | | And refactor to have just one place in code that sets up the empty pragma handlers. llvm-svn: 196372
* Fix corner case in module-based layering warning.Daniel Jasper2013-12-031-1/+2
| | | | | | | | | | | Before, there SourceManager would not return a FileEntry for a SourceLocation of a macro expansion (if the header name itself is defined in a macro). We'd then fallback to assume that the module currently being built is the including module. However, in this case we are actually interested in the spelling location of the filename loc in order to derive the including module. llvm-svn: 196311
* Fix a typo in a comment: expasion -> expansionJames Dennett2013-12-021-1/+1
| | | | llvm-svn: 196123
* Fix the build break introduced by r195799 by restoring two closeChandler Carruth2013-11-271-1/+2
| | | | | | curlies. llvm-svn: 195802
* Documentation cleanup: Doxygen-ification, typo fixes, and changing some ofJames Dennett2013-11-272-28/+26
| | | | | | | the duplicated documentation from .cpp files so that it's not processed by Doxygen and hence doesn't generate duplicate output. llvm-svn: 195799
* Generate a marker token when entering or leaving a submodule when building aRichard Smith2013-11-233-36/+85
| | | | | | | | | module. Use the marker to diagnose cases where we try to transition between submodules when not at the top level (most likely because a closing brace was missing at the end of a header file, but is also possible if submodule headers attempt to do something fundamentally non-modular, like our .def files). llvm-svn: 195543
* Corrected comment about MS prgama warning.John Thompson2013-11-161-1/+1
| | | | llvm-svn: 194897
* When we hit a #include directive that maps to a module import, emit a tokenRichard Smith2013-11-151-5/+18
| | | | | | | | | | | | representing the module import rather than making the module immediately visible. This serves two goals: * It avoids making declarations in the module visible prematurely, if we walk past the #include during a tentative parse, for instance, and * It gives a diagnostic (although, admittedly, not a very nice one) if a header with a corresponding module is included anywhere other than at the top level. llvm-svn: 194782
* Modules: Teach the preprocessor to recognize 'import' only after an '@'.Douglas Gregor2013-11-071-3/+7
| | | | | | | | | | | | The preprocessor currently recognizes module declarations to load a module based on seeing the 'import' keyword followed by an identifier. This sequence is fairly unlikely in C (one would need a type named 'import'), but is more common in Objective-C (where a variable named 'import' can cause problems). Since import declarations currently require a leading '@', recognize that in the preprocessor as well. Fixes <rdar://problem/15084587>. llvm-svn: 194225
* Lex: Require that '#' be followed by a macro parameter name when preceded by ↵David Majnemer2013-11-051-6/+1
| | | | | | | | | | | | | | | | | | '##' After lexing a '##', we would look ahead and check to see if it was followed by '__VA_ARGS__'. After doing so, we would then go ahead and lex the token. However we would fail in the case where the '##' was followed by a '#' followed by an identifier because we would have lexed the '#' separately from the identifier, bypassing our parameter validation logic. Instead, lex the tokens coming after the '##' later. This fixes PR17804. llvm-svn: 194059
* Preload module maps in normal user directories, too.Douglas Gregor2013-11-011-3/+2
| | | | | | ... in case someone decides to -I/usr/include <rdar://problem/15235948>. llvm-svn: 193893
* Allow a new syntax in a module requires-declaration:Richard Smith2013-10-281-3/+19
| | | | | | | | | | | | requires ! feature The purpose of this is to allow (for instance) the module map for /usr/include to exclude <tgmath.h> and <complex.h> when building in C++ (these headers are instead provided by the C++ standard library in this case, and the glibc C <tgmath.h> header would otherwise try to include <complex.h>, resulting in a module cycle). llvm-svn: 193549
* Use the same SourceManager for ModuleMaps and compilations.Manuel Klimek2013-10-242-22/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows using virtual file mappings on the original SourceManager to map in virtual module.map files. Without this patch, the ModuleMap search will find a module.map file (as the FileEntry exists in the FileManager), but will be unable to get the content from the SourceManager (as ModuleMap previously created its own SourceManager). Two problems needed to be fixed which this patch exposed: 1. Storing the inferred module map When writing out a module, the ASTWriter stores the names of the files in the main source manager; when loading the AST again, the ASTReader errs out if such a file is found missing, unless it is overridden. Previously CompilerInstance's compileModule method would store the inferred module map to a temporary file; the problem with this approach is that now that the module map is handled by the main source manager, the ASTWriter stores the name of the temporary module map as source to the compilation; later, when the module is loaded, the temporary file has already been deleted, which leads to a compilation error. This patch changes the inferred module map to instead inject a virtual file into the source manager. This both saves some disk IO, and works with how the ASTWriter/ASTReader handle overridden source files. 2. Changing test input in test/Modules/Inputs/* Now that the module map file is handled by the main source manager, the VerifyDiagnosticConsumer will not ignore diagnostics created while parsing the module map file. The module test test/Modules/renamed.m uses -I test/Modules/Inputs and triggers recursive loading of all module maps in test/Modules/Inputs, some of which had conflicting names, thus leading errors while parsing the module maps. Those diagnostics already occur on trunk, but before this patch they would not break the test, as they were ignored by the VerifyDiagnosticConsumer. This patch thus changes the module maps that have been recently introduced which broke the invariant of compatible modules maps in test/Modules/Inputs. llvm-svn: 193314
* Allow a header to be part of multiple modules.Daniel Jasper2013-10-223-73/+102
| | | | | | | | | | | | | | | | | | | | This patch changes two things: a) Allow a header to be part of multiple modules. The reasoning is that in existing codebases that have a module-like build system, the same headers might be used in several build targets. Simple reasons might be that they defined different classes that are declared in the same header. Supporting a header as a part of multiple modules will make the transistion easier for those cases. A later step in clang can then determine whether the two modules are actually compatible and can be merged and error out appropriately. The later check is similar to what needs to be done for template specializations anyway. b) Allow modules to be stored in a directory tree separate from the headers they describe. Review: http://llvm-reviews.chandlerc.com/D1951 llvm-svn: 193151
* Lex: Don't restrict legal UCNs when preprocessing assemblyJustin Bogner2013-10-211-0/+4
| | | | | | | | | | | | | | | The C and C++ standards disallow using universal character names to refer to some characters, such as basic ascii and control characters, so we reject these sequences in the lexer. However, when the preprocessor isn't being used on C or C++, it doesn't make sense to apply these restrictions. Notably, accepting these characters avoids issues with unicode escapes when GHC uses the compiler as a preprocessor on haskell sources. Fixes rdar://problem/14742289 llvm-svn: 193067
* [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for ↵David Majnemer2013-10-181-0/+1
| | | | | | | | | | | | | | 'final' Summary: Some MS headers use these features. Reviewers: rnk, rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1948 llvm-svn: 192936
* Add has_feature support for reflecting the presence of refined Objective-C ↵Ted Kremenek2013-10-141-0/+1
| | | | | | ABI mangling for qualified id<...>. Fixes <rdar://problem/14799110>. llvm-svn: 192643
* Relax header guard mismatch warning with edit distance heuristic.Ismail Pazarbasi2013-10-121-13/+26
| | | | | | If the edit distance between the two macros is more than 50%, DefinedMacro may not be header guard or can be header guard of another header file or it might be defining something completely different set by the build environment. llvm-svn: 192547
* Accept #pragma warning(push, 0) without warningReid Kleckner2013-10-021-11/+11
| | | | | | | | This partially addresses PR17435, but it doesn't actually implement the pragma. If we implement it, we should map levels 1-4 to something like -Wall and level 0 to something like -w. llvm-svn: 191833
* Mark lambda init-captures as complete.Richard Smith2013-09-281-4/+5
| | | | llvm-svn: 191607
* Mark variable template implementation as complete. Nearly all of the creditRichard Smith2013-09-271-1/+2
| | | | | | here goes to Larisse Voufo. llvm-svn: 191549
* NumericLiteralParser::ParseNumberStartingWithZero(): Try to appease MSC16's ↵NAKAMURA Takumi2013-09-271-2/+5
| | | | | | | | miscompilation. Investigating yet. It seems msc16 miscompiles s[1] to be folded. llvm-svn: 191485
* Per updates to D3781, allow underscore under ' in a pp-number, and allow ' ↵Richard Smith2013-09-262-1/+6
| | | | | | in a #line directive. llvm-svn: 191443
* Fix buildbot breakage.Richard Smith2013-09-261-4/+4
| | | | llvm-svn: 191424
* Replace a bool with an enum for clarity, based on review comment from James ↵Richard Smith2013-09-261-7/+8
| | | | | | Dennett. llvm-svn: 191420
* Implement C++1y digit separator proposal (' as a digit separator). This is notRichard Smith2013-09-262-4/+51
| | | | | | yet approved by full committee, but was unanimously supported by EWG. llvm-svn: 191417
* PR17359: Fix off-by-one OOB on _Pragma("") and an unescaping bugReid Kleckner2013-09-251-7/+7
| | | | | | | Previously the code would reduce a run of backslashes to a single backslash, and now it will properly leave behind every other backslash. llvm-svn: 191382
* Avoid a signed/unsigned comparison warning with compilers that don't know howRichard Smith2013-09-241-1/+1
| | | | | | to handle constant expressions. llvm-svn: 191336
* Fix uninitialized value bug discovered buy msan buildbot.Daniel Jasper2013-09-241-1/+1
| | | | llvm-svn: 191292
* Add -fmodule-map-file option.Daniel Jasper2013-09-241-7/+29
| | | | | | | | | | | | | | | With this option, arbitrarily named module map files can be specified to be loaded as required for headers in the respective (sub)directories. This, together with the extern module declaration allows for specifying module maps in a modular fashion without the need for files called "module.map". Among other things, this allows a directory to contain two modules that are completely independent of one another. Review: http://llvm-reviews.chandlerc.com/D1697. llvm-svn: 191284
* Module use declarations (II)Daniel Jasper2013-09-243-24/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Review: http://llvm-reviews.chandlerc.com/D1546. I have picked up this patch form Lawrence (http://llvm-reviews.chandlerc.com/D1063) and did a few changes. From the original change description (updated as appropriate): This patch adds a check that ensures that modules only use modules they have so declared. To this end, it adds a statement on intended module use to the module.map grammar: use module-id A module can then only use headers from other modules if it 'uses' them. This enforcement is off by default, but may be turned on with the new option -fmodules-decluse. When enforcing the module semantics, we also need to consider a source file part of a module. This is achieved with a compiler option -fmodule-name=<module-id>. The compiler at present only applies restrictions to the module directly being built. llvm-svn: 191283
* Handle standard libraries that miss out the space when defining the standardRichard Smith2013-09-242-6/+33
| | | | | | | | literal operators. Also, for now, allow the proposed C++1y "il", "i", and "if" suffixes too. (Will revert the latter if LWG decides not to go ahead with that change after all.) llvm-svn: 191274
* Fix use-after-free in r190980.Eli Friedman2013-09-191-3/+6
| | | | llvm-svn: 190984
* Make Preprocessor::Lex non-recursive.Eli Friedman2013-09-197-151/+247
| | | | | | | | | | | | | | | Before this patch, Lex() would recurse whenever the current lexer changed (e.g. upon entry into a macro). This patch turns the recursion into a loop: the various lex routines now don't return a token when the current lexer changes, and at the top level Preprocessor::Lex() now loops until it finds a token. Normally, the recursion wouldn't end up being very deep, but the recursion depth can explode in edge cases like a bunch of consecutive macros which expand to nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this patch). <rdar://problem/14569770> llvm-svn: 190980
* Fix CharByteWidth assertion in LiteralSupport.Eli Friedman2013-09-181-1/+1
| | | | | | Patch by Eelis van der Weegen. llvm-svn: 190971
* Add a define for the ObjFW runtime ABI version.Benjamin Kramer2013-09-161-1/+0
| | | | | | | | | This removes __has_feature(objc_msg_lookup_stret), as it is not required anymore after this patch. Patch by Jonathan Schleifer! llvm-svn: 190791
* Make __has_extension(c_thread_local) work.Ed Schouten2013-09-141-0/+1
| | | | | | | | | | | Unlike C++11's "thread_local" keyword, C11's "_Thread_local" is in the reserved namespace, meaning we provide it unconditionally; it is marked as KEYALL in TokenKinds.def. This means that like all the other C11 keywords, we can expose its presence through __has_extension(). llvm-svn: 190755
OpenPOWER on IntegriCloud