summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
Commit message (Collapse)AuthorAgeFilesLines
...
* Move LocInfoType from Sema to AST.Benjamin Kramer2016-02-011-1/+0
| | | | | | | While transient and only used during parsing, LocInfoTypes are still used from ASTDumper and are part of the AST. llvm-svn: 259376
* [Parser] Update CachedTokens while parsing ObjectiveC template argument listBruno Cardoso Lopes2016-01-311-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following ObjC++ snippet: -- @protocol PA; @protocol PB; @class NSArray<ObjectType>; typedef int some_t; id<PA> FA(NSArray<id<PB>> *h, some_t group); -- This would hit an assertion in the parser after generating an annotation token while trying to update the token cache: Assertion failed: (CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc() && "The annotation should be until the most recent cached token") ... 7 clang::Preprocessor::AnnotatePreviousCachedTokens(clang::Token const&) + 494 8 clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool, bool, clang::CXXScopeSpec&, bool) + 1163 9 clang::Parser::TryAnnotateTypeOrScopeToken(bool, bool) + 361 10 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) + 598 ... The cached preprocessor token in this case is: greatergreater '>>' Loc=<testcase.mm:7:24> while the annotation ("NSArray<id<PB>>") ends at "testcase.mm:7:25", hence the assertion. Properly update the CachedTokens during template parsing to contain two greater tokens instead of a greatergreater. Differential Revision: http://reviews.llvm.org/D15173 rdar://problem/23494277 llvm-svn: 259311
* Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren2016-01-293-4/+4
| | | | | | r259192 post commit comment. llvm-svn: 259232
* [Lex] Share some common code between decimal and octal parsing in ↵Craig Topper2016-01-281-61/+47
| | | | | | | | NumericLiteralParser. There were a couple slight variations between the two copies that I don't believe were intentional. For example, only one of the paths checked for digit separations proceeding a '.', but I think the lexer itself splits the token if a digit separator proceeds a period. llvm-svn: 259022
* Remove autoconf supportChris Bieneman2016-01-261-24/+0
| | | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "This is the way [autoconf] ends Not with a bang but a whimper." -T.S. Eliot Reviewers: chandlerc, grosbach, bob.wilson, echristo Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D16472 llvm-svn: 258862
* Fix -Wnull-conversion for long macros.Richard Trieu2016-01-261-0/+25
| | | | | | | | | Move the function to get a macro name from DiagnosticRenderer.cpp to Lexer.cpp so that other files can use it. Lexer now has two functions to get the immediate macro name, the newly added one is better for diagnostic purposes. Make -Wnull-conversion use this function for better NULL macro detection. llvm-svn: 258778
* [MSVC Compat] Accept elided commas in macro function argumentsEhsan Akhgari2016-01-222-7/+17
| | | | | | | | | | | | | | | Summary: This fixes PR25875. When the trailing comma in a macro argument list is elided, we need to treat it similarly to the case where a variadic macro misses one actual argument. Reviewers: rnk, rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15670 llvm-svn: 258530
* Add -Wexpansion-to-undefined: warn when using `defined` in a macro definition.Nico Weber2016-01-191-2/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [cpp.cond]p4: Prior to evaluation, macro invocations in the list of preprocessing tokens that will become the controlling constant expression are replaced (except for those macro names modified by the 'defined' unary operator), just as in normal text. If the token 'defined' is generated as a result of this replacement process or use of the 'defined' unary operator does not match one of the two specified forms prior to macro replacement, the behavior is undefined. This isn't an idle threat, consider this program: #define FOO #define BAR defined(FOO) #if BAR ... #else ... #endif clang and gcc will pick the #if branch while Visual Studio will take the #else branch. Emit a warning about this undefined behavior. One problem is that this also applies to function-like macros. While the example above can be written like #if defined(FOO) && defined(BAR) #defined HAVE_FOO 1 #else #define HAVE_FOO 0 #endif there is no easy way to rewrite a function-like macro like `#define FOO(x) (defined __foo_##x && __foo_##x)`. Function-like macros like this are used in practice, and compilers seem to not have differing behavior in that case. So this a default-on warning only for object-like macros. For function-like macros, it is an extension warning that only shows up with `-pedantic`. (But it's undefined behavior in both cases.) llvm-svn: 258128
* When copying whitespace flags from the token naming a macro argument onto theRichard Smith2016-01-151-0/+1
| | | | | | | | first token of the expansion, don't forget to copy the "is at the start of a line" token (which is always false, as newlines cannot appear within a macro body); otherwise, stringizing the result can insert spurious whitespace. llvm-svn: 257863
* Improve AST dumping:Richard Smith2016-01-121-1/+18
| | | | | | | | 1) When dumping a declaration that declares a name for a type, also dump the named type. 2) Add a #pragma clang __debug dump X, that dumps the lookup results for X in the current context. llvm-svn: 257529
* Module debugging: Make the module format part of the module hash insteadAdrian Prantl2016-01-121-2/+1
| | | | | | | | | | of the file name. This is consistent with how other HeaderSearchOptions are handled. Due to the other inputs of the module hash (revision number) this is not really testable in a meaningful way. llvm-svn: 257520
* Properly track that a character literal is UTF-8, and pretty print the ↵Aaron Ballman2016-01-071-0/+1
| | | | | | prefix properly. llvm-svn: 257097
* Emit a -Wmicrosoft warning when treating ^Z as EOF in MS mode.Nico Weber2015-12-291-1/+4
| | | | llvm-svn: 256596
* Emit a -Wmicrosoft warning when pasting /##/ into a comment token in MS mode.Nico Weber2015-12-292-8/+10
| | | | llvm-svn: 256595
* Refactor: Simplify boolean conditional return statements in lib/LexAlexander Kornienko2015-12-282-10/+4
| | | | | | | | | | | | | | Summary: Use clang-tidy to simplify boolean conditional return statements Reviewers: dblaikie Subscribers: dblaikie, cfe-commits Patch by Richard Thomson! Differential Revision: http://reviews.llvm.org/D10017 llvm-svn: 256499
* Replace SM.getFileEntryForID(Lexer->getFileID()) with Lexer->getFileEntry().Yaron Keren2015-12-182-7/+4
| | | | llvm-svn: 255993
* In Objective-C, ignore attempts to redefine the ARC/GC qualifier macros.John McCall2015-12-101-0/+24
| | | | | | | | | | | | | | This works around existing system headers which unconditionally redefine these macros. This is reasonably safe to do because we used to warn about it anyway (outside of system headers). Continue to warn if the redefinition would have changed the expansion. Still permit redefinition if the macro is explicitly #undef'ed first. rdar://23788307 llvm-svn: 255311
* [clang] Disable Unicode in asm filesVinicius Tinti2015-11-201-2/+6
| | | | | | | | | Clang should not convert tokens to Unicode when preprocessing assembly files. Fixes PR25558. llvm-svn: 253738
* Use %select to merge similar diagnostics. NFCCraig Topper2015-11-143-14/+14
| | | | llvm-svn: 253119
* Fix auto-link for text-based dynamic library SDKs.Juergen Ributzka2015-11-131-3/+12
| | | | | | | | | | When linking against text-based dynamic library SDKs the library name of a framework has now more than one possible filename extensions. This fix tests for both possible extensions (none, and .tbd). This fixes rdar://problem/20609975 llvm-svn: 253060
* Use %select to merge two diagnostics that only differ in one word and are ↵Craig Topper2015-11-121-3/+2
| | | | | | emitted in the same place. NFC llvm-svn: 252861
* Remove spaces in empty line, NFC.Yaron Keren2015-11-071-1/+1
| | | | llvm-svn: 252405
* Improve macro dumping to preserve semantically-relevant spelling information.Richard Smith2015-11-051-5/+9
| | | | llvm-svn: 252206
* Allow use of private headers in different sub-modules.Manuel Klimek2015-11-051-10/+3
| | | | llvm-svn: 252170
* Fix build breakDavid Majnemer2015-11-051-2/+1
| | | | llvm-svn: 252120
* [Lex] Add __has_builtin support for __make_integer_seqDavid Majnemer2015-11-051-1/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D14349 llvm-svn: 252115
* Sink some PTHManager includes out of Preprocessor.hReid Kleckner2015-11-022-0/+2
| | | | | | | This reduces the number of .cpp files needed to be rebuilt after touching OnDiskHashTable from 120 to 21 for me. llvm-svn: 251810
* Support tvOS and watchOS availability attributesTim Northover2015-10-301-0/+2
| | | | llvm-svn: 251711
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
* Disable trigraph and escaped newline expansion on all types of raw string ↵Craig Topper2015-10-221-1/+1
| | | | | | literals not just ASCII type. llvm-svn: 251025
* Change MacroInfo::setArgumentList to take an ArrayRef instead of pointer and ↵Craig Topper2015-10-221-3/+3
| | | | | | size. While there use std::copy intead of a manual loop. llvm-svn: 250987
* Add back null check removed accidentally in r250554Reid Kleckner2015-10-201-0/+2
| | | | | | Fixes PR25262 llvm-svn: 250844
* Roll-back r250822.Angel Garcia Gomez2015-10-206-9/+11
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-206-11/+9
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Refactor module lookup when looking up a header file, and wire through the ↵Richard Smith2015-10-162-92/+93
| | | | | | requesting module. No functionality change. llvm-svn: 250554
* Parse and ignore #pragma runtime_checks in MS extensions mode (PR25138)Hans Wennborg2015-10-121-1/+1
| | | | | | We already silently ignore the /RTC, which controls the same functionality. llvm-svn: 250099
* SourceRanges are small and trivially copyable, don't them by reference.Craig Topper2015-10-042-3/+3
| | | | llvm-svn: 249259
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-033-3/+3
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* Fix typo.Yaron Keren2015-09-291-1/+1
| | | | llvm-svn: 248807
* [Lex] A source-file new-line in a raw string literal results in a new-lineDavid Majnemer2015-09-231-4/+17
| | | | | | | | | Our string literal parser copied any source-file new-line characters into the execution string-literal. This is incorrect if the source-file new-line character was a \r\n sequence because new-line characters are merely \n. llvm-svn: 248392
* [CUDA] Allow parsing of host and device code simultaneously.Artem Belevich2015-09-221-14/+18
| | | | | | | | | | | | * adds -aux-triple option to specify target triple * propagates aux target info to AST context and Preprocessor * pulls in target specific preprocessor macros. * pulls in target-specific builtins from aux target. * sets appropriate host or device attribute on builtins. Differential Revision: http://reviews.llvm.org/D12917 llvm-svn: 248299
* [modules] Fix a corner case in the macro override rules: properly handle ↵Richard Smith2015-09-161-2/+6
| | | | | | overridden leaf module macros. llvm-svn: 247765
* Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1Adrian Prantl2015-08-271-1/+1
| | | | | | | | | | | | | to enable the use of external type references in the debug info (a.k.a. module debugging). The driver expands -gmodules to "-g -fmodule-format=obj -dwarf-ext-refs" and passes that to cc1. All this does at the moment is set a flag codegenopts. http://reviews.llvm.org/D11958 llvm-svn: 246192
* [modules] Remove unnecessary deserialization of fully-external ↵Richard Smith2015-08-242-30/+63
| | | | | | HeaderFileInfos for all files we've seen in this compilation. llvm-svn: 245881
* [modules] Fix HeaderFileInfo serialization to store all the known owning ↵Richard Smith2015-08-182-47/+71
| | | | | | modules for a header, not just the current favourite. llvm-svn: 245390
* [modules] PR20507: Avoid silent textual inclusion.Sean Silva2015-08-172-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If a module was unavailable (either a missing requirement on the module being imported, or a missing file anywhere in the top-level module (and not dominated by an unsatisfied `requires`)), we would silently treat inclusions as textual. This would cause all manner of crazy and confusing errors (and would also silently "work" sometimes, making the problem difficult to track down). I'm really not a fan of the `M->isAvailable(getLangOpts(), getTargetInfo(), Requirement, MissingHeader)` function; it seems to do too many things at once, but for now I've done things in a sort of awkward way. The changes to test/Modules/Inputs/declare-use/module.map were necessitated because the thing that was meant to be tested there (introduced in r197805) was predicated on silently falling back to textual inclusion, which we no longer do. The changes to test/Modules/Inputs/macro-reexport/module.modulemap are just an overlooked missing header that seems to have been missing since this code was committed (r213922), which is now caught. Reviewers: rsmith, benlangmuir, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10423 llvm-svn: 245228
* [modules] Stop dropping 'module.timestamp' files into the current directoryRichard Smith2015-08-151-2/+2
| | | | | | when building with implicit modules disabled. llvm-svn: 245136
* Turn off __has_feature(cxx_rtti) when -fno-rtti-data is presentReid Kleckner2015-08-131-1/+1
| | | | | | | | | | | -fno-rtti-data makes it so that vtables emitted in the current TU lack RTTI data. This means that dynamic_cast usually fails at runtime. Users of the existing cxx_rtti feature expect all of RTTI to work, not just some of it. Chromium bug for context: http://crbug.com/518191 llvm-svn: 244922
* Attempt to fix build after r244912Ben Langmuir2015-08-131-4/+7
| | | | | | | Some compilers were less happy about converting a lambda to a comparator function for array_pod_sort. llvm-svn: 244917
* [Modules] Add Darwin-specific compatibility module map parsing hacksBen Langmuir2015-08-131-7/+91
| | | | | | | | | | | | | | | | This preserves backwards compatibility for two hacks in the Darwin system module map files: 1. The use of 'requires excluded' to make headers non-modular, which should really be mapped to 'textual' now that we have this feature. 2. Silently removes a bogus cplusplus requirement from IOKit.avc. Once we start diagnosing missing requirements and headers on auto-imports these would have broken compatibility with existing Darwin SDKs. llvm-svn: 244912
OpenPOWER on IntegriCloud