summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Lex and ignore Microsoft's #pragma warning(...)Reid Kleckner2013-09-131-1/+131
| | | | | | | | | | | | | | | | | Summary: This fixes PR17145 and avoids unknown pragma warnings. This change does not attempt to map MSVC warning numbers to clang warning flags. Perhaps in the future we will implement a mapping for some common subset of Microsoft warnings, but for now we don't. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1652 llvm-svn: 190726
* Simplify code with the in place path::native. No functionality change.Benjamin Kramer2013-09-111-4/+2
| | | | llvm-svn: 190515
* Support for modular module-map-filesDaniel Jasper2013-09-111-2/+57
| | | | | | | | | | | | | | | | | | | This patch is the first step to make module-map-files modular (instead of requiring a single "module.map"-file per include directory). This step adds a new "extern module" declaration that enables module-map-files to reference one another along with a very basic implementation. The next steps are: * Combine this with the use-declaration (from http://llvm-reviews.chandlerc.com/D1546) in order to only load module map files required for a specific compilation. * Add an additional flag to start with a specific module-map-file (instead of requiring there to be at least one "module.map"). Review: http://llvm-reviews.chandlerc.com/D1637 llvm-svn: 190497
* Use new UnicodeCharSet interface.Alexander Kornienko2013-08-292-21/+41
| | | | | | | | | | | | | | Summary: This is a Clang part of http://llvm-reviews.chandlerc.com/D1534 Reviewers: jordan_rose, klimek, rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1535 llvm-svn: 189583
* Fix "//" comments with -traditional-cpp in C++.Eli Friedman2013-08-281-2/+4
| | | | | | | | | Apparently, gcc's -traditional-cpp behaves slightly differently in C++ mode; specifically, it discards "//" comments. Match gcc's behavior. <rdar://problem/14808126> llvm-svn: 189515
* Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm2013-08-231-4/+2
| | | | | | No functionality change intended. llvm-svn: 189112
* Respect -Wnewline-eof even in C++11 mode.Jordan Rose2013-08-231-4/+22
| | | | | | | | | | | If the user has requested this warning, we should emit it, even if it's not an extension in the current language mode. However, being an extension is more important, so prefer the pedantic warning or the pedantic-compatibility warning if those are enabled. <rdar://problem/12922063> llvm-svn: 189110
* Split isFromMainFile into two functions.Eli Friedman2013-08-221-1/+1
| | | | | | | | | Basically, isInMainFile considers line markers, and isWrittenInMainFile doesn't. Distinguishing between the two is useful when dealing with files which are preprocessed files or rewritten with -frewrite-includes (so we don't, for example, print useless warnings). llvm-svn: 188968
* Revert r188863 which could propose wrong fixits for multibyte character ↵Nick Lewycky2013-08-211-9/+3
| | | | | | literals. llvm-svn: 188918
* Issue fixits replacing invalid character literals with the equivalent \xNNNick Lewycky2013-08-211-3/+9
| | | | | | escape code. llvm-svn: 188863
* No functionality change. Adjust a bunch of formatting issues in this code andNick Lewycky2013-08-211-20/+20
| | | | | | fix a typo in a comment. llvm-svn: 188857
* ObjectiveC migrator: More work towardsFariborz Jahanian2013-08-201-2/+3
| | | | | | insertion of ObjC audit pragmas. llvm-svn: 188733
* Use isCharInSet from llvm/Support/UnicodeCharRanges.h, added a test for ↵Alexander Kornienko2013-08-091-89/+1
| | | | | | | | | | | | | | | | double-width characters in FixIt-hints. Summary: This is a follow-up to r187837. Reviewers: gribozavr, jordan_rose Reviewed By: jordan_rose CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1306 llvm-svn: 188056
* DataFlowSanitizer; Clang changes.Peter Collingbourne2013-08-071-0/+1
| | | | | | | | | | | | | DataFlowSanitizer is a generalised dynamic data flow analysis. Unlike other Sanitizer tools, this tool is not designed to detect a specific class of bugs on its own. Instead, it provides a generic dynamic data flow analysis framework to be used by clients to help detect application-specific issues within their own code. Differential Revision: http://llvm-reviews.chandlerc.com/D966 llvm-svn: 187925
* Add option to disable module loading.Daniel Jasper2013-08-052-10/+13
| | | | | | | This patch was created by Lawrence Crowl and reviewed in: http://llvm-reviews.chandlerc.com/D963 llvm-svn: 187738
* Use llvm::sys::fs::UniqueID for windows and unix.Rafael Espindola2013-08-011-28/+36
| | | | | | | | | | | | | | | | | | | This unifies the unix and windows versions of FileManager::UniqueDirContainer and FileManager::UniqueFileContainer by using UniqueID. We cannot just replace "struct stat" with llvm::sys::fs::file_status, since we want to be able to construct fake ones, and file_status has different members on unix and windows. What the patch does is: * Record only the information that clang is actually using. * Use llvm::sys::fs::status instead of stat and fstat. * Use llvm::sys::fs::UniqueID * Delete the old windows versions of UniqueDirContainer and UniqueFileContainer since the "unix" one now works on windows too. llvm-svn: 187619
* Support for Thread Safety Analysis in CDavid Blaikie2013-07-291-0/+1
| | | | | | Patch by Ethan Jackson. llvm-svn: 187365
* Reduce stack frame size by avoiding a large token vector on an error path.Bob Wilson2013-07-271-1/+1
| | | | | | | | | | | | | | | | | Beginning with svn r186971, we noticed an internal test started to fail when using clang built with LTO. After much investigation, it turns out that there are no blatant bugs here, we are just running out of stack space and crashing. Preprocessor::ReadFunctionLikeMacroArgs already has one vector of 64 Tokens, and r186971 added another. When built with LTO, that function is inlined into Preprocessor::HandleMacroExpandedIdentifier, which for our internal test is invoked in a deep recursive cycle. I'm leaving the original 64 Token vector alone on the assumption that it is important for performance, but the new FixedArgTokens vector is only used on an error path, so it should be OK if it requires additional heap storage. It would be even better if we could avoid the deep recursion, but I think this change is a good thing to do regardless. <rdar://problem/14540345> llvm-svn: 187315
* Fix GNU ObjC ABI for a message returning a struct.Eli Friedman2013-07-261-0/+1
| | | | | | | | | This allows the ObjFW runtime to correctly implement message forwarding for messages which return a struct. Patch by Jonathan Schleifer. llvm-svn: 187174
OpenPOWER on IntegriCloud