summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
* [preprocessor] Use MacroDirective in the preprocessor callbacks to make ↵Argyrios Kyrtzidis2013-02-246-41/+48
| | | | | | | | available the full information about the macro (e.g if it was imported and where). llvm-svn: 175978
* [libclang] Fix assertion hit when code-completing inside a function macro ↵Argyrios Kyrtzidis2013-02-221-2/+4
| | | | | | | | with more arguments than it should accept. llvm-svn: 175925
* [preprocessing record] Have the MacroDefinitions map point to the ↵Argyrios Kyrtzidis2013-02-221-9/+7
| | | | | | | | | | MacroDefinition object instead its index in the preprocessed entities vector. This is because the order of the entities in the vector can change in some (uncommon) cases. llvm-svn: 175907
* Preproceessor: fix #if skipping under -traditional-cpp.Jordan Rose2013-02-221-1/+1
| | | | | | | | | | | | When parsing directives within skipped #if blocks, we don't want to retain any whitespace. Previously we were just skipping comments, but it's not possible to skip comments and retain other whitespace. This change matches the usual behavior for parsing directives (i.e. the behavior outside of skipped #if blocks). <rdar://problem/13267695> llvm-svn: 175840
* Preprocessor: preserve whitespace in -traditional-cpp mode.Jordan Rose2013-02-212-26/+33
| | | | | | | | | Note that unlike GNU cpp we currently do not preserve whitespace in macros (even in -traditional-cpp mode). <rdar://problem/12897179> llvm-svn: 175778
* Include llvm::Optional in clang/Basic/LLVM.hDavid Blaikie2013-02-201-2/+2
| | | | | | Post-commit CR feedback from Jordan Rose regarding r175594. llvm-svn: 175679
* [preprocessor] Split the MacroInfo class into two separate concepts, ↵Argyrios Kyrtzidis2013-02-205-133/+102
| | | | | | | | | | | | | | | | | | | | | | | | | MacroInfo class for the data specific to a macro definition (e.g. what the tokens are), and MacroDirective class which encapsulates the changes to the "macro namespace" (e.g. the location where the macro name became active, the location where it was undefined, etc.) (A MacroDirective always points to a MacroInfo object.) Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but splitting the concepts allows us to better model the effect of modules to the macro namespace (also as a bonus it allows better modeling of push_macro/pop_macro #pragmas). Modules can have their own macro history, separate from the local (current translation unit) macro history; MacroDirectives will be used to model the macro history (changes to macro namespace). For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created to indicate that "FOO" became active at the import location. Module "A" itself will contain another MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives will point to the same MacroInfo object. Introducing the separation of macro concepts is the first part towards better modeling of module macros. llvm-svn: 175585
* [modules] Const'ify some functions of ModuleMap.Argyrios Kyrtzidis2013-02-191-12/+13
| | | | llvm-svn: 175552
* [preprocessing record] Add some sanity checks for the preprocessed entity indexArgyrios Kyrtzidis2013-02-121-4/+8
| | | | | | | | to make sure we don't crash on release if the index is not valid. rdar://13089714 llvm-svn: 175010
* Remove some stray uses of <ctype.h> functions.Jordan Rose2013-02-091-1/+2
| | | | | | These are causing assertions on some MSVC builds. llvm-svn: 174805
* Properly validate UCNs for C99 and C++03 (both more restrictive than C(++)11).Jordan Rose2013-02-092-89/+582
| | | | | | | | Add warnings under -Wc++11-compat, -Wc++98-compat, and -Wc99-compat when a particular UCN is incompatible with a different standard, and -Wunicode when a UCN refers to a surrogate character in C++03. llvm-svn: 174788
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-084-26/+15
| | | | | | | Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
* Simplify logic for avoiding concatenation after numeric constants.Jordan Rose2013-02-081-6/+5
| | | | | | | I threw in a couple of test cases for UD-suffixes -- already working, but it wasn't immediately obvious to me. llvm-svn: 174767
* Pull Lexer's CharInfo table out for general use throughout Clang.Jordan Rose2013-02-081-170/+5
| | | | | | | | | | | Rewriting the same predicates over and over again is bad for code size and code maintainence. Using the functions in <ctype.h> is generally unsafe unless they are specified to be locale-independent (i.e. only isdigit and isxdigit). The next commit will try to clean up uses of <ctype.h> functions within Clang. llvm-svn: 174765
* Teach subframework header lookup to suggest modules <rdar://problem/13176200>.Douglas Gregor2013-02-082-4/+26
| | | | llvm-svn: 174683
* Introduce SourceManager::PredefinesFileID, to allow each checking of whetherArgyrios Kyrtzidis2013-02-011-0/+1
| | | | | | a source location came from the predefines buffer. llvm-svn: 174190
* Lexer: Don't warn about Unicode in preprocessor directives.Jordan Rose2013-01-311-2/+4
| | | | | | | | | This allows people to use Unicode in their #pragma mark and in macros that exist only to be string-ized. <rdar://problem/13107323&13121362> llvm-svn: 174081
* Preprocessor: initialize member introduced in r173881.Jordan Rose2013-01-311-0/+1
| | | | | | | Compilation always sets this explicitly, but creating a preprocessor manually should still put the 'IsPreprocessedOutput' flag in a valid state. llvm-svn: 174077
* Micro-change: moved a brace for better readabilityAlexander Kornienko2013-01-311-2/+2
| | | | llvm-svn: 174075
* Reinstate r173952, this time limiting it to exactly the formDouglas Gregor2013-01-301-1/+4
| | | | | | | | #define X X for which there is no point warning, ever. llvm-svn: 173991
* Revert "[preprocessor] Don't warn about "disabled expansion of recursive macro""Argyrios Kyrtzidis2013-01-301-4/+1
| | | | | | This reverts commit r173952 llvm-svn: 173970
* Fix r173881 to properly skip invalid UTF-8 characters in raw lexing and -E.Jordan Rose2013-01-301-0/+1
| | | | | | | | This caused hangs as we processed the same invalid byte over and over. <rdar://problem/13115651> llvm-svn: 173959
* [preprocessor] Don't warn about "disabled expansion of recursive macro"Argyrios Kyrtzidis2013-01-301-1/+4
| | | | | | | | | for "#define X X". This is a pattern that, for example, stdbool.h uses. rdar://12435773 llvm-svn: 173952
* Move UTF conversion routines from clang/lib/Basic to llvm/lib/SupportDmitri Gribenko2013-01-303-12/+15
| | | | | | This is required to use them in TableGen. llvm-svn: 173924
* Don't warn about Unicode characters in -E mode.Jordan Rose2013-01-301-18/+20
| | | | | | | | | | | | | | | People use the C preprocessor for things other than C files. Some of them have Unicode characters. We shouldn't warn about Unicode characters appearing outside of identifiers in this case. There's not currently a way for the preprocessor to tell if it's in -E mode, so I added a new flag, derived from the PreprocessorOutputOptions. This is only used by the Unicode warnings for now, but could conceivably be used by other warnings or even behavioral differences later. <rdar://problem/13107323> llvm-svn: 173881
* [Preprocessor] When checking if we can concatenate two tokens, checkArgyrios Kyrtzidis2013-01-291-3/+4
| | | | | | | | | | | | if they were already concatenated in source using the spelling locations even if they came from a macro expansion. This fixes an issue where a GUID passed as macro argument ends up malformed after preprocessing because we added spaces inside it. rdar://13016645 llvm-svn: 173826
* PR15067 (again): Don't warn about UCNs in C90 if we're raw-lexing.Jordan Rose2013-01-281-1/+2
| | | | | | Fixes a crash. Thanks, Richard. llvm-svn: 173701
* PR15067: Don't assert when a UCN appears in a C90 file.Jordan Rose2013-01-272-4/+7
| | | | | | | Unfortunately, we can't accept the UCN as an extension because we're required to treat it as two tokens for preprocessing purposes. llvm-svn: 173622
* <limits.h> includes <linux/limits.h> on Linux, no need to special-case itDmitri Gribenko2013-01-262-6/+2
| | | | llvm-svn: 173578
* Since we're stuck with realpath for the header <-> module mapping,Douglas Gregor2013-01-262-44/+26
| | | | | | | | factor the realpath calls into FileManager::getCanonicalName() so we can cache the results of this epically slow operation. 5% speedup on my modules test, and realpath drops out of the profile. llvm-svn: 173542
* Lexer.cpp: Fix a warning with ptrdiff_t on i686. [-Wsign-compare]NAKAMURA Takumi2013-01-251-1/+1
| | | | llvm-svn: 173447
* [Lex] Remove DirectoryLookup.UserSpecified, which is unused.Daniel Dunbar2013-01-251-1/+1
| | | | llvm-svn: 173409
* Clarify comment: "diagnose" is better than "warn" when emitting an error.Jordan Rose2013-01-251-1/+1
| | | | | | Thanks, Dmitri. llvm-svn: 173400
* Add a fixit for \U1234 -> \u1234.Jordan Rose2013-01-241-1/+9
| | | | llvm-svn: 173371
* As an extension, treat Unicode whitespace characters as whitespace.Jordan Rose2013-01-241-0/+23
| | | | llvm-svn: 173370
* Handle universal character names and Unicode characters outside of literals.Jordan Rose2013-01-242-17/+331
| | | | | | | | | | | | | | | | | | | | | | | | This is a missing piece for C99 conformance. This patch handles UCNs by adding a '\\' case to LexTokenInternal and LexIdentifier -- if we see a backslash, we tentatively try to read in a UCN. If the UCN is not syntactically well-formed, we fall back to the old treatment: a backslash followed by an identifier beginning with 'u' (or 'U'). Because the spelling of an identifier with UCNs still has the UCN in it, we need to convert that to UTF-8 in Preprocessor::LookUpIdentifierInfo. Of course, valid code that does *not* use UCNs will see only a very minimal performance hit (checks after each identifier for non-ASCII characters, checks when converting raw_identifiers to identifiers that they do not contain UCNs, and checks when getting the spelling of an identifier that it does not contain a UCN). This patch also adds basic support for actual UTF-8 in the source. This is treated almost exactly the same as UCNs except that we consider stray Unicode characters to be mistakes and offer a fixit to remove them. llvm-svn: 173369
* Unify diagnostics for \x, \u, and \U without any following hex digits.Jordan Rose2013-01-241-2/+2
| | | | llvm-svn: 173368
* [PCH] Temporarily disable the "ambiguous macro" warning that is currently ↵Argyrios Kyrtzidis2013-01-231-0/+4
| | | | | | | | | | | | bogus with a PCH that redefined a macro without undef'ing it first. Proper reconstruction of the macro info history from modules will properly fix this in subsequent commits. rdar://13016031 llvm-svn: 173281
* Fix compilation on Linux, which defines PATH_MAX in a weird place,Douglas Gregor2013-01-222-0/+10
| | | | | | from Saleem Abdulrasool! llvm-svn: 173208
* [PCH/Modules] Revert r172843, it caused a module to fail building.Argyrios Kyrtzidis2013-01-191-5/+9
| | | | llvm-svn: 172884
* Adopt llvm::hexDigitValue.Jordan Rose2013-01-181-13/+4
| | | | llvm-svn: 172861
* [PCH/Modules] Re-apply r172620 and r172629, now with 100% less infinite loops!Argyrios Kyrtzidis2013-01-181-9/+5
| | | | | | | | | Makes sure that a deserialized macro is only added to the preprocessor macro definitions only once. Unfortunately I couldn't get a reduced test case. rdar://13016031 llvm-svn: 172843
* [ubsan] Add support for -fsanitize-blacklistWill Dietz2013-01-181-3/+3
| | | | llvm-svn: 172808
* Revert Clang r172620 and r172629, which caused a hang when buildingDouglas Gregor2013-01-181-5/+9
| | | | | | | complicated modules (<rdar://problem/13038265>). Unfortunately, this un-fixes <rdar://problem/13016031>. llvm-svn: 172783
* Add some semantic checks for OpenCL. Variadic macros, VLAs and bitfields are ↵Joey Gouly2013-01-171-0/+6
| | | | | | not supported. llvm-svn: 172732
* Remove unnecessary initialization i Added in r172668.David Blaikie2013-01-161-6/+5
| | | | | | | echristo already fixed this in r172649, but I'll leave the reformatting in since I'm in the blame history for it now anyway. llvm-svn: 172672
* Fix -Wreorder warning.David Blaikie2013-01-161-13/+11
| | | | | | Rewrapping courtesy of clang-format. llvm-svn: 172668
* Move initialization of ParsingIfOrElifDirective down next to the macroEric Christopher2013-01-161-4/+3
| | | | | | initializations to fix Wreorder warning. llvm-svn: 172649
* No longer crashing with an assert when __has_include or __has_include_next ↵Aaron Ballman2013-01-163-1/+11
| | | | | | is used outside of a preprocessor directive. This fixes PR14837. llvm-svn: 172639
* [preprocessor] Call the MacroUndefined callback even when the macro was not ↵Argyrios Kyrtzidis2013-01-162-5/+8
| | | | | | | | defined. Patch by Enea Zaffanella! llvm-svn: 172623
OpenPOWER on IntegriCloud