summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseTentative.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [MSVC] Implementation of __unaligned as a proper type qualifierAndrey Bokhanko2016-05-061-1/+1
| | | | | | | | | | | This patch implements __unaligned (MS extension) as a proper type qualifier (before that, it was implemented as an ignored attribute). It also fixes PR27367. Differential Revision: http://reviews.llvm.org/D19654 llvm-svn: 268727
* Revert 266186 as it breaks anything that includes type_traits on some platformsNemanja Ivanovic2016-04-151-3/+0
| | | | | | | | | | Since this patch provided support for the __float128 type but disabled it on all platforms by default, some platforms can't compile type_traits with -std=gnu++11 since there is a specialization with __float128. This reverts the patch until D19125 is approved (i.e. we know which platforms need this support enabled). llvm-svn: 266460
* Revert r266415, it broke parsing SDK headers (PR27367).Nico Weber2016-04-151-1/+1
| | | | llvm-svn: 266431
* [MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifierAndrey Bokhanko2016-04-151-1/+1
| | | | | | | | | | | This patch implements __unaligned as a type qualifier; before that, it was modeled as an attribute. Proper mangling of __unaligned is implemented as well. Some OpenCL code/tests are tangenially affected, as they relied on existing number and sizes of type qualifiers. Differential Revision: http://reviews.llvm.org/D18596 llvm-svn: 266415
* Enable support for __float128 in ClangNemanja Ivanovic2016-04-131-0/+3
| | | | | | | | | | | | | | | | This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
* [OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library.Alexey Bader2016-04-131-1/+1
| | | | | | | | | | Putting OpenCLImageTypes.def to clangAST library violates layering requirement: "It's not OK for a Basic/ header to include an AST/ header". This fixes the modules build. Differential revision: http://reviews.llvm.org/D18954 Reviewers: Richard Smith, Vassil Vassilev. llvm-svn: 266180
* [OpenCL] Complete image types support.Alexey Bader2016-04-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I. Current implementation of images is not conformant to spec in the following points: 1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine: void write_image(write_only image2d_t img); kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code which is disallowed according to s6.13.14. 2. It discards access qualifier on generated code, which leads to generated code for the above example: call void @write_image(%opencl.image2d_t* %img); In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images. Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently. 3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names. 4. Default access qualifier read_only is to be added if not provided explicitly. II. This patch corrects the above points as follows: 1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type. 2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers). 3. Improves testing of images in Clang. Author: Anastasia Stulova Reviewers: bader, mgrang. Subscribers: pxli168, pekka.jaaskelainen, yaxunl. Differential Revision: http://reviews.llvm.org/D17821 llvm-svn: 265783
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* Implement the Objective-C __kindof type qualifier.Douglas Gregor2015-07-071-0/+1
| | | | | | | | | | The __kindof type qualifier can be applied to Objective-C object (pointer) types to indicate id-like behavior, which includes implicit "downcasting" of __kindof types to subclasses and id-like message-send behavior. __kindof types provide better type bounds for substitutions into unspecified generic types, which preserves more type information. llvm-svn: 241548
* Handle Objective-C type arguments.Douglas Gregor2015-07-071-1/+1
| | | | | | | | | | | | | | | | | | | | | Objective-C type arguments can be provided in angle brackets following an Objective-C interface type. Syntactically, this is the same position as one would provide protocol qualifiers (e.g., id<NSCopying>), so parse both together and let Sema sort out the ambiguous cases. This applies both when parsing types and when parsing the superclass of an Objective-C class, which can now be a specialized type (e.g., NSMutableArray<T> inherits from NSArray<T>). Check Objective-C type arguments against the type parameters of the corresponding class. Verify the length of the type argument list and that each type argument satisfies the corresponding bound. Specializations of parameterized Objective-C classes are represented in the type system as distinct types. Both specialized types (e.g., NSArray<NSString *> *) and unspecialized types (NSArray *) are represented, separately. llvm-svn: 241542
* [CONCEPTS] Parsing of concept keywordHubert Tong2015-06-301-0/+2
| | | | | | | | | | | | | | | | | | Summary: This change adds parsing for the concept keyword in a declaration and tracks the location. Diagnostic testing added for invalid use of concept keyword. Reviewers: faisalv, fraggamuffin, rsmith, hubert.reinterpretcast Reviewed By: rsmith, hubert.reinterpretcast Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10528 Patch by Nathan Wilson! llvm-svn: 241060
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-241-5/+5
| | | | | | | | | | | | | | | | _Uppercase_underscored Addresses a conflict with glibc's __nonnull macro by renaming the type nullability qualifiers as follows: __nonnull -> _Nonnull __nullable -> _Nullable __null_unspecified -> _Null_unspecified This is the major part of rdar://problem/21530726, but does not yet provide the Darwin-specific behavior for the old names. llvm-svn: 240596
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Introduce type nullability specifiers for C/C++.Douglas Gregor2015-06-191-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Introduces the type specifiers __nonnull, __nullable, and __null_unspecified that describe the nullability of the pointer type to which the specifier appertains. Nullability type specifiers improve on the existing nonnull attributes in a few ways: - They apply to types, so one can represent a pointer to a non-null pointer, use them in function pointer types, etc. - As type specifiers, they are syntactically more lightweight than __attribute__s or [[attribute]]s. - They can express both the notion of 'should never be null' and also 'it makes sense for this to be null', and therefore can more easily catch errors of omission where one forgot to annotate the nullability of a particular pointer (this will come in a subsequent patch). Nullability type specifiers are maintained as type sugar, and therefore have no effect on mangling, encoding, overloading, etc. Nonetheless, they will be used for warnings about, e.g., passing 'null' to a method that does not accept it. This is the C/C++ part of rdar://problem/18868820. llvm-svn: 240146
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-181-40/+26
| | | | | | is(). llvm-svn: 240008
* Revert "Improve declaration / expression disambiguation around ↵Justin Bogner2015-02-231-44/+22
| | | | | | | | | | | ptr-operators, and use" This seems to break mixing function-style and c-style casts, and is breaking bootstrapping llvm. This reverts r230261. llvm-svn: 230274
* Improve declaration / expression disambiguation around ptr-operators, and useRichard Smith2015-02-231-22/+44
| | | | | | | | the presence of an abstract declarator with a ptr-operator as proof that a construct cannot parse as an expression to improve diagnostics along error recovery paths. llvm-svn: 230261
* [PowerPC]To provide better compatibility with gcc I added the __bool keyword ↵Bill Seurer2015-01-121-0/+1
| | | | | | | | | | | | | | | | | to the Alitivec support in clang. __bool is functionally identical to using bool when declaring vector types. For example: vector bool char v_bc; vector __bool char v___bc; clang already supported vector/__vector and pixel/__pixel but was missing __bool. http://llvm.org/bugs/show_bug.cgi?id=19220 For reference: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html http://reviews.llvm.org/D6882 llvm-svn: 225664
* Don't crash on surprising tokens in default parameter template lists.Nico Weber2014-12-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | Fixes this snippet from SLi's afl fuzzer output: class { i (x = <, enum This parsed i as a function, x as a paramter, and the stuff after < as a template list. This then called TryConsumeDeclarationSpecifier() which called TryAnnotateCXXScopeToken() without checking the preconditions of this function. Check them before calling, like all other callers of TryAnnotateCXXScopeToken() do. A more readable reproducer that causes the same crash is class { void i(int x = MyTemplateClass<int, union int>::foo()); }; The reduced version used an eof token as surprising token, but kw_int works just as well to repro and is easier to insert into a test file. llvm-svn: 224906
* [c++1z] Support for u8 character literals.Richard Smith2014-11-081-0/+1
| | | | llvm-svn: 221576
* Filter out non-static class members when correcting non-member-references.Kaelyn Takata2014-11-051-7/+23
| | | | llvm-svn: 221319
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-4/+4
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* Add frontend support for __vectorcallReid Kleckner2014-10-241-0/+3
| | | | | | | | | | | | | Wire it through everywhere we have support for fastcall, essentially. This allows us to parse the MSVC "14" CTP headers, but we will miscompile them because LLVM doesn't support __vectorcall yet. Reviewed By: Aaron Ballman Differential Revision: http://reviews.llvm.org/D5808 llvm-svn: 220573
* Be smarter when parsing variable declarations with unknown types.Kaelyn Takata2014-10-141-1/+4
| | | | | | | | | Specifically, avoid typo-correcting the variable name into a type before typo-correcting the actual type name in the declaration. Doing so results in a very unpleasant cascade of errors, with the typo correction of the actual type name being buried in the middle. llvm-svn: 219732
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-0/+1
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Replace a fake enum class with the real thing.Richard Smith2014-05-161-174/+174
| | | | llvm-svn: 208943
* Add support for MSVC's __FUNCSIG__Reid Kleckner2014-04-081-0/+1
| | | | | | | | | | | It is very similar to GCC's __PRETTY_FUNCTION__, except it prints the calling convention. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D3311 llvm-svn: 205780
* TryConsume parser cleanupsAlp Toker2014-01-101-9/+4
| | | | | | Also move some comments into the block they were meant to describe. llvm-svn: 198935
* Remove OpenCL-specific type keywords and specifiersAlp Toker2013-12-181-8/+0
| | | | | | | | | | | | | | | This commit kills off custom type specifier and keyword handling of OpenCL C data types. Although the OpenCL spec describes them as keywords, we can handle them more elegantly as predefined types. This should provide better error correction and code completion as well as simplifying the implementation. The primary intention is however to simplify the C/C++ parser and save some packed bits on AST structures that had been extended in r170432 just for OpenCL. llvm-svn: 197578
* Unify type trait parsingAlp Toker2013-12-121-27/+3
| | | | | | | | | | | | | | | | | Type trait parsing is all over the place at the moment with unary, binary and n-ary C++11 type traits that were developed independently at different points in clang's history. There's no good reason to handle them separately -- there are three parsers, three AST nodes and lots of duplicated handling code with slightly different implementations and diags for each kind. This commit unifies parsing of type traits and sets the stage for further consolidation. No change in behaviour other than more consistent error recovery. llvm-svn: 197179
* Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev2013-11-181-13/+12
| | | | llvm-svn: 194994
* [-fms-extensions] Add support for __FUNCDNAME__David Majnemer2013-11-061-0/+1
| | | | | | | | | | | | | | | | Summary: Similar to __FUNCTION__, MSVC exposes the name of the enclosing mangled function name via __FUNCDNAME__. This implementation is very naive and unoptimized, it is expected that __FUNCDNAME__ would be used rarely in practice. Reviewers: rnk, rsmith, thakis CC: cfe-commits, silvas Differential Revision: http://llvm-reviews.chandlerc.com/D2109 llvm-svn: 194181
* [-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
* PR13657 (and duplicates):Richard Smith2013-09-121-82/+313
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a comma occurs in a default argument or default initializer within a class, disambiguate whether it is part of the initializer or whether it ends the initializer. The way this works (which I will be proposing for standardization) is to treat the comma as ending the default argument or default initializer if the following token sequence matches the syntactic constraints of a parameter-declaration-clause or init-declarator-list (respectively). This is both consistent with the disambiguation rules elsewhere (where entities are treated as declarations if they can be), and should have no regressions over our old behavior. I think it might also disambiguate all cases correctly, but I don't have a proof of that. There is an annoyance here: because we're performing a tentative parse in a situation where we may not have seen declarations of all relevant entities (if the comma is part of the initializer, lookup may find entites declared later in the class), we need to turn off typo-correction and diagnostics during the tentative parse, and in the rare case that we decide the comma is part of the initializer, we need to revert all token annotations we performed while disambiguating. Any diagnostics that occur outside of the immediate context of the tentative parse (for instance, if we trigger the implicit instantiation of a class template) are *not* suppressed, mirroring the usual rules for a SFINAE context. llvm-svn: 190639
* Adding in parsing and the start of semantic support for __sptr and __uptr ↵Aaron Ballman2013-05-221-0/+2
| | | | | | | | | | pointer type qualifiers. This patch also fixes the correlated __ptr32 and __ptr64 pointer qualifiers so that they are truly type attributes instead of declaration attributes. For more information about __sptr and __uptr, see MSDN: http://msdn.microsoft.com/en-us/library/aa983399.aspx Patch reviewed by Richard Smith. llvm-svn: 182535
* Implement C++1y decltype(auto).Richard Smith2013-04-261-0/+1
| | | | llvm-svn: 180610
* Parsing support for thread_local and _Thread_local. We give them the sameRichard Smith2013-04-121-4/+9
| | | | | | semantics as __thread for now. llvm-svn: 179424
* Give the default CorrectionCandidateCallback::ValidateCandidate someKaelyn Uhrain2013-04-031-0/+1
| | | | | | | | smarts so that it doesn't approve of keywords and/or type names when it knows (based on its flags) that those kinds of corrections are not wanted. llvm-svn: 178668
* Teach statement / declaration disambiguation about C++11-style generalized ↵Richard Smith2013-03-201-7/+21
| | | | | | initializers. llvm-svn: 177480
* Add OpenCL samplers as Clang builtin types and check sampler related ↵Guy Benyei2013-02-071-0/+1
| | | | | | restrictions. llvm-svn: 174601
* Implement OpenCL event_t as Clang builtin type, including event_t related ↵Guy Benyei2013-01-201-0/+1
| | | | | | OpenCL restrictions (OpenCL 1.2 spec 6.9) llvm-svn: 172973
* s/CXX0X/CXX11/g, except for __GNU_EXPERIMENTAL_CXX0X__, and update a few ↵Richard Smith2013-01-021-1/+1
| | | | | | nearby 'C++0x' comments. llvm-svn: 171372
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-5/+5
| | | | llvm-svn: 171367
* Re-commit r170428 changes with Linux style file endings.Guy Benyei2012-12-181-0/+6
| | | | | | Add OpenCL images as clang builtin types. llvm-svn: 170432
* Revert changes from r170428, as I accidentally changed the line endings of ↵Guy Benyei2012-12-181-1580/+1574
| | | | | | these files to Windows style. llvm-svn: 170431
* Add OpenCL images as clang builtin types.Guy Benyei2012-12-181-1574/+1580
| | | | llvm-svn: 170428
* Accept and pass arguments to __unknown_anytype in argumentJohn McCall2012-11-141-0/+4
| | | | | | | | | | | | | | | | | | | | | positions of Objective-C methods. It is possible to recover a lot of type information about Objective-C methods from the reflective metadata for their implementations. This information is not rich when it comes to struct types, however, and it is not possible to produce a type in the debugger's round-tripped AST which will really do anything useful during type-checking. Therefore we allow __unknown_anytype in these positions, which essentially disables type-checking for that argument. We infer the parameter type to be the unqualified type of the argument expression unless that expression is an explicit cast, in which case it becomes the type-as-written of that cast. rdar://problem/12565338 llvm-svn: 167896
* Add the Microsoft __is_interface_class type trait.John McCall2012-09-251-0/+1
| | | | | | Patch by Andy Gibbs! llvm-svn: 164591
* When disambiguating an expression-statement from a declaraton-statement, if theRichard Smith2012-08-231-10/+29
| | | | | | | statement starts with an identifier for which name lookup will fail either way, look at later tokens to disambiguate in order to improve error recovery. llvm-svn: 162464
OpenPOWER on IntegriCloud