aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex
AgeCommit message (Collapse)AuthorFilesLines
2012-12-01Try to make the source location information for token pastes a bit more ↵Eli Friedman1-0/+6
consistent. Fixes a crash printing diagnostics on the gcc testsuite, and also makes diagnostic range printing print nicer results for token pastes. llvm-svn: 169068
2012-11-30Comments: no need to escape any characters in \code ... \endcode.Dmitri Gribenko1-6/+6
llvm-svn: 169030
2012-11-30Support for #pragma region/endregion for MSVC compatibility. Patch thanks ↵Aaron Ballman1-0/+25
to pravic! llvm-svn: 169028
2012-11-29Keep track of modules that have failed to build. If we encounter anDouglas Gregor1-1/+8
import of that module elsewhere, don't try to build the module again: it won't work, and the experience is quite dreadful. We track this information somewhat globally, shared among all of the related CompilerInvocations used to build modules on-the-fly, so that a particular Clang instance will only try to build a given module once. Fixes <rdar://problem/12552849>. llvm-svn: 168961
2012-11-28Remove obsolete comment missed by r162937Andy Gibbs1-4/+0
llvm-svn: 168778
2012-11-28Teach Lexer::getSpelling about raw string literals. Specifically, if a rawRichard Smith1-42/+67
string literal needs cleaning (because it contains line-splicing in the encoding prefix or in the ud-suffix), do not clean the section between the double-quotes -- that's the "raw" bit! llvm-svn: 168776
2012-11-17Clean up code according to coding standardsAndy Gibbs1-3/+2
llvm-svn: 168274
2012-11-17Fix crash on end-of-file after \ in a char literal, fixes PR14369.Nico Weber1-6/+8
This makes LexCharConstant() look more like LexStringLiteral(), which doesn't have this bug. Add tests for eof after \ for several other cases. llvm-svn: 168269
2012-11-17Prevent premature macro expansion in __has_builtin, __has_feature,Andy Gibbs1-3/+3
__has_attribute, __has_extension, making them behave more akin to conventional macros. llvm-svn: 168268
2012-11-17Made the "expected string literal" diagnostic more expressiveAndy Gibbs3-5/+12
llvm-svn: 168267
2012-11-17Refactored duplicate string literal lexing code within Preprocessor, into aAndy Gibbs3-148/+86
common LexStringLiteral function. In doing so, some consistency problems have been ironed out (e.g. where the first token in the string literal was lexed with macro expansion, but subsequent ones were not) and also an erroneous diagnostic has been corrected. LexStringLiteral is complemented by a FinishLexStringLiteral function which can be used in the situation where the first token of the string literal has already been lexed. llvm-svn: 168266
2012-11-17Fix handling of invalid uses of the __has_warning builtin macroAndy Gibbs1-2/+6
llvm-svn: 168265
2012-11-15If an excluded header does not exist, just ignore itDouglas Gregor1-1/+3
llvm-svn: 168077
2012-11-14Suppress elided variadic macro argument extension diagnostic for macros usingEli Friedman3-4/+40
the related comma pasting extension. In certain cases, we used to get two diagnostics for what is essentially one extension. This change suppresses the first diagnostic in certain cases where we know we're going to print the second diagnostic. The diagnostic is redundant, and it can't be suppressed in the definition of the macro because it points at the use of the macro, so we want to avoid printing it if possible. The implementation works by detecting constructs which look like comma pasting at the time of the definition of the macro; this information is then used when the macro is used. (We can't actually detect whether we're using the comma pasting extension until the macro is actually used, but we can detecting constructs which will be comma pasting if the varargs argument is elided.) <rdar://problem/12292192> llvm-svn: 167907
2012-11-14Fix an assertion failure printing the unused-label fixit in files using CRLF ↵Eli Friedman1-1/+8
line endings. <rdar://problem/12639047>. llvm-svn: 167900
2012-11-13Revert r167801, "[preprocessor] When #including something that contributes noDaniel Dunbar2-23/+1
tokens at all,". This change broke External/Nurbs in LLVM test-suite. llvm-svn: 167858
2012-11-13UCNs in char literals are done (in LiteralSupport), remove FIXME. Expand UCN ↵Nico Weber1-2/+1
FIXME in LexNumericConstant. llvm-svn: 167818
2012-11-13[preprocessor] When #including something that contributes no tokens at all,Argyrios Kyrtzidis2-1/+23
don't recursively continue lexing. This avoids a stack overflow with a sequence of many empty #includes. rdar://11988695 llvm-svn: 167801
2012-11-13In Lexer::LexTokenInternal, avoid code duplication; no functionality change.Argyrios Kyrtzidis1-39/+26
llvm-svn: 167800
2012-11-11s/BCPLComment/LineComment/Nico Weber1-22/+22
llvm-svn: 167690
2012-11-09Improved support for removing the comma preceding __VA_ARGS__ where __VA_ARGS__Andy Gibbs1-17/+64
is empty in a variadic macro expansion. This fixes a divergence in support for the ", ## __VA_ARGS__" GCC extension which differed in behaviour when in strict C99 mode (note: there is no change in behaviour has been made in the gnu99 mode that clang uses by default). In addition, there is improved support for the Microsoft alternative extension ", __VA_ARGS__". llvm-svn: 167613
2012-11-08LiteralSupport: Don't overflow the temporary buffer when decoding invalid ↵Benjamin Kramer1-5/+6
string parts. Instead just use a dummy buffer, we're not going to use the decoded string anyways. Fixes PR14292. llvm-svn: 167594
2012-11-08LiteralSupport: Clean up style violations. No functionality change.Benjamin Kramer1-15/+15
llvm-svn: 167593
2012-11-06Remove C++11-isms I just introduced in r167482Douglas Gregor1-3/+3
llvm-svn: 167483
2012-11-06Introduce inferred framework modules into the module map file,Douglas Gregor2-85/+263
allowing a module map to be placed one level above the '.framework' directories to specify that all .frameworks within that directory can be inferred as framework modules. One can also specifically exclude frameworks known not to work. This makes explicit (and more restricted) behavior modules have had "forever", where *any* .framework was assumed to be able to be built as a module. That's not necessarily true, so we white-list directories (with exclusions) when those directories have been audited. llvm-svn: 167482
2012-11-05Rename LangOptions members for address sanitizer and thread sanitizer fromRichard Smith1-1/+1
*Sanitizer to Sanitize* in preparation for later patches. llvm-svn: 167405
2012-11-01Make the FilenameRange of the InclusionDirective callback more accurate,Argyrios Kyrtzidis1-2/+2
preserve the macro location of the range end if the filename came from a macro. Patch by Kim Gräsman! llvm-svn: 167239
2012-10-30Handle string encoding diagnostics when there are too many invalid ranges.David Blaikie1-1/+2
llvm-svn: 167059
2012-10-28improve highlighting of invalid string encodingsSeth Cantrell1-11/+49
limit highlight to exactly the bad encoding, and highlight every bad encoding in a string. llvm-svn: 166900
2012-10-25Take into account that there may be a BOM at the beginning of the file,Argyrios Kyrtzidis1-3/+6
when computing the size of the precompiled preamble. llvm-svn: 166659
2012-10-24Teach the preprocessor to hold onto the preprocessor options.Douglas Gregor1-2/+5
llvm-svn: 166599
2012-10-24Move HeaderSearchOptions into the Lex library, make it intrusivelyDouglas Gregor1-2/+4
reference-counted, and hold a reference to it in HeaderSearch. llvm-svn: 166583
2012-10-24Removed an extra blank line.Mahesha S1-1/+0
llvm-svn: 166571
2012-10-23Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor1-1/+2
the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
2012-10-22Fix for PR13334. This prevents crashes that result from badly formedRichard Trieu1-12/+27
expressions involving __has_include llvm-svn: 166438
2012-10-15Teach TargetInfo to hold on to the TargetOptions with which it wasDouglas Gregor1-11/+9
created. llvm-svn: 165943
2012-10-15Introduce the notion of excluded headers into the module mapDouglas Gregor1-30/+46
description. Previously, one could emulate this behavior by placing the header in an always-unavailable submodule, but Argyrios guilted me into expressing this idea properly. llvm-svn: 165921
2012-10-12Sanitize the names of modules determined based on the names of headersDouglas Gregor1-6/+67
or directories, to make sure that they are identifiers that are not keywords in any dialect. Fixes <rdar://problem/12489495>. llvm-svn: 165821
2012-10-12Track which particular submodule #undef's a macro, so that the actualDouglas Gregor1-6/+12
#undef only occurs if that submodule is imported. llvm-svn: 165773
2012-10-11Diagnose the expansion of ambiguous macro definitions. This can happenDouglas Gregor2-7/+35
only with modules, when two disjoint modules #define the same identifier to different token sequences. llvm-svn: 165746
2012-10-11Introduce a simple "hint" scheme to eliminate the quadratic behaviorDouglas Gregor1-3/+3
associated with deserializing macro history for an identifier. llvm-svn: 165729
2012-10-11Remove an unused bit from the serialized IdentifierInfoDouglas Gregor1-1/+1
llvm-svn: 165683
2012-10-11Deserialize macro history when we deserialize an identifier that hasDouglas Gregor2-14/+93
macro history. When deserializing macro history, we arrange history such that the macros that have definitions (that haven't been #undef'd) and are visible come at the beginning of the list, which is what the preprocessor and other clients of Preprocessor::getMacroInfo() expect. If additional macro definitions become visible later, they'll be moved toward the front of the list. Note that it's possible to have ambiguities, but we don't diagnose them yet. There is a partially-implemented design decision here that, if a particular identifier has been defined or #undef'd within the translation unit, that definition (or #undef) hides any macro definitions that come from imported modules. There's still a little work to do to ensure that the right #undef'ing happens. Additionally, we'll need to scope the update records for #undefs, so they only kick in when the submodule containing that update record becomes visible. llvm-svn: 165682
2012-10-09Rework the (de-)serialization of macros, as stored inDouglas Gregor3-5/+19
MacroInfo*. Instead of simply dumping an offset into the current file, give each macro definition a proper ID with all of the standard modules-remapping facilities. Additionally, when a macro is modified in a subsequent AST file (e.g., #undef'ing a macro loaded from another module or from a precompiled header), provide a macro update record rather than rewriting the entire macro definition. This gives us greater consistency with the way we handle declarations, and ties together macro definitions much more cleanly. Note that we're still not actually deserializing macro history (we never were), but it's far easy to do properly now. llvm-svn: 165560
2012-10-05[Modules] Introduce Module::TopHeaders which is a set of top-level headersArgyrios Kyrtzidis1-0/+1
that are associated with a (sub)module. llvm-svn: 165279
2012-10-05[preprocessing record] Have PPEntityID be independent of the size of theArgyrios Kyrtzidis1-14/+18
loaded entities vector, otherwise its meaning will change when a module is imported and the vector size changes. llvm-svn: 165278
2012-10-02Add info in the preprocessing record whether an inclusion directiveArgyrios Kyrtzidis1-3/+5
resulted in an automatic module import. llvm-svn: 165022
2012-09-29Move the 'find macro by spelling' infrastructure to the Preprocessor class andDmitri Gribenko1-0/+33
use it to suggest appropriate macro for __attribute__((deprecated)) in -Wdocumentation-deprecated-sync. llvm-svn: 164892
2012-09-29For PPCallbacks::InclusionDirective() add a parameter for the module, wheneverArgyrios Kyrtzidis3-10/+36
an inclusion directive was automatically turned into a module import, and PPCallbacks::moduleImport() for an explicit module import. llvm-svn: 164874
2012-09-29Add an assertion to make sure the implicitly imported moduleArgyrios Kyrtzidis1-0/+2
is the same as the suggested one when looking up the include filename. llvm-svn: 164872