aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseInit.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-06-01Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova1-1/+2
llvm-svn: 304477
2017-03-23Publish RAIIObjectsForParser.h for external usage.Vassil Vassilev1-1/+1
Some clients (eg the cling interpreter) need to recover their parser from errors. Patch by Axel Naumann (D31190)! llvm-svn: 298606
2017-01-07PR23135: Don't instantiate constexpr functions referenced in unevaluated ↵Richard Smith1-0/+4
operands where possible. This implements something like the current direction of DR1581: we use a narrow syntactic check to determine the set of places where a constant expression could be evaluated, and only instantiate a constexpr function or variable if it's referenced in one of those contexts, or is odr-used. It's not yet clear whether this is the right set of syntactic locations; we currently consider all contexts within templates that would result in odr-uses after instantiation, and contexts within list-initialization (narrowing conversions take another victim...), as requiring instantiation. We could in principle restrict the former cases more (only const integral / reference variable initializers, and contexts in which a constant expression is required, perhaps). However, this is sufficient to allow us to accept libstdc++ code, which relies on GCC's behavior (which appears to be somewhat similar to this approach). llvm-svn: 291318
2016-07-18[NFC] Header cleanupMehdi Amini1-2/+1
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2016-01-15OpaquePtr: Use nullptr construction for ParsedType OpaquePtr typedefDavid Blaikie1-12/+6
llvm-svn: 257958
2015-07-07Silence a -Wunused-variable warning; NFC.Aaron Ballman1-5/+3
llvm-svn: 241580
2015-07-07C++ support for Objective-C lightweight generics.Douglas Gregor1-1/+4
Teach C++'s tentative parsing to handle specializations of Objective-C class types (e.g., NSArray<NSString *>) as well as Objective-C protocol qualifiers (id<NSCopying>) by extending type-annotation tokens to handle this case. As part of this, remove Objective-C protocol qualifiers from the declaration specifiers, which never really made sense: instead, provide Sema entry points to make them part of the type annotation token. Among other things, this properly diagnoses bogus types such as "<NSCopying> id" which should have been written as "id <NSCopying>". Implements template instantiation support for, e.g., NSArray<T>* in C++. Note that parameterized classes are not templates in the C++ sense, so that cannot (for example) be used as a template argument for a template template parameter. Part of rdar://problem/6294649. llvm-svn: 241545
2015-07-07Substitute type arguments into uses of Objective-C interface members.Douglas Gregor1-6/+19
When messaging a method that was defined in an Objective-C class (or category or extension thereof) that has type parameters, substitute the type arguments for those type parameters. Similarly, substitute into property accesses, instance variables, and other references. This includes general infrastructure for substituting the type arguments associated with an ObjCObject(Pointer)Type into a type referenced within a particular context, handling all of the substitutions required to deal with (e.g.) inheritance involving parameterized classes. In cases where no type arguments are available (e.g., because we're messaging via some unspecialized type, id, etc.), we substitute in the type bounds for the type parameters instead. Example: @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying> - (T)firstObject; @end void f(NSSet<NSString *> *stringSet, NSSet *anySet) { [stringSet firstObject]; // produces NSString* [anySet firstObject]; // produces id<NSCopying> (the bound) } When substituting for the type parameters given an unspecialized context (i.e., no specific type arguments were given), substituting the type bounds unconditionally produces type signatures that are too strong compared to the pre-generics signatures. Instead, use the following rule: - In covariant positions, such as method return types, replace type parameters with “id” or “Class” (the latter only when the type parameter bound is “Class” or qualified class, e.g, “Class<NSCopying>”) - In other positions (e.g., parameter types), replace type parameters with their type bounds. - When a specialized Objective-C object or object pointer type contains a type parameter in its type arguments (e.g., NSArray<T>*, but not NSArray<NSString *> *), replace the entire object/object pointer type with its unspecialized version (e.g., NSArray *). llvm-svn: 241543
2015-03-18Remove many superfluous SmallString::str() calls.Yaron Keren1-1/+1
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
2014-11-21Enable ActOnIdExpression to use delayed typo correction for non-C++ codeKaelyn Takata1-2/+4
when calling DiagnoseEmptyLookup. llvm-svn: 222551
2014-05-29Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic1-6/+6
takeAs to getAs. llvm-svn: 209800
2014-05-21[C++11] Use 'nullptr'. Parser edition.Craig Topper1-4/+4
llvm-svn: 209275
2014-04-13PR19339: Disambiguate lambdas with init-captures from designated initializersRichard Smith1-37/+21
properly. llvm-svn: 206128
2014-03-06Remove dead return in Parser::MayBeDesignationStart().Ted Kremenek1-2/+0
llvm-svn: 203078
2013-12-24Support and use token kinds as diagnostic argumentsAlp Toker1-1/+1
Introduce proper facilities to render token spellings using the diagnostic formatter. Replaces most of the hard-coded diagnostic messages related to expected tokens, which all shared the same semantics but had to be multiply defined due to variations in token order or quote marks. The associated parser changes are largely mechanical but they expose commonality in whole chunks of the parser that can now be factored away. This commit uses C++11 typed enums along with a speculative legacy fallback until the transition is complete. Requires corresponding changes in LLVM r197895. llvm-svn: 197972
2013-11-23Generate a marker token when entering or leaving a submodule when building aRichard Smith1-1/+1
module. Use the marker to diagnose cases where we try to transition between submodules when not at the top level (most likely because a closing brace was missing at the end of a header file, but is also possible if submodule headers attempt to do something fundamentally non-modular, like our .def files). llvm-svn: 195543
2013-11-18Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev1-5/+5
llvm-svn: 194994
2013-05-05Replace 'MultiExprArg()' with 'None'Dmitri Gribenko1-1/+1
llvm-svn: 181166
2013-01-02s/CPlusPlus0x/CPlusPlus11/gRichard Smith1-1/+1
llvm-svn: 171367
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-1/+1
uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
2012-08-23Now that ASTMultiPtr is nothing more than a array reference, make it a ↵Benjamin Kramer1-2/+1
MutableArrayRef. This required changing all get() calls to data() and using the simpler constructors. llvm-svn: 162501
2012-08-23Remove ASTOwningVector, it doesn't own anything and provides no value over ↵Benjamin Kramer1-1/+1
SmallVector. llvm-svn: 162492
2012-08-23Rip out remnants of move semantic emulation and smart pointers in Sema.Benjamin Kramer1-3/+3
These were nops for quite a while and only lead to confusion. ASTMultiPtr now behaves like a proper dumb array reference. llvm-svn: 162475
2012-04-10Disambiguation of '[[':Richard Smith1-0/+5
* In C++11, '[[' is ill-formed unless it starts an attribute-specifier. Reject array sizes and array indexes which begin with a lambda-expression. Recover by parsing the lambda as a lambda. * In Objective-C++11, either '[' could be the start of a message-send. Fully disambiguate this case: it turns out that the grammars of message-sends, lambdas and attributes do not actually overlap. Accept any occurrence of '[[' where either '[' starts a message send, but reject a lambda in an array index just like in C++11 mode. Implement a couple of changes to the attribute wording which occurred after our attributes implementation landed: * In a function-declaration, the attributes go after the exception specification, not after the right paren. * A reference type can have attributes applied. * An 'identifier' in an attribute can also be a keyword. Support for alternative tokens (iso646 keywords) in attributes to follow. And some bug fixes: * Parse attributes after declarator-ids, even if they are not simple identifiers. * Do not accept attributes after a parenthesized declarator. * Accept attributes after an array size in a new-type-id. * Partially disamiguate 'delete' followed by a lambda. More work is required here for the case where the lambda-introducer is '[]'. llvm-svn: 154369
2012-03-11Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie1-6/+6
(Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
2012-02-17De-nest tentative parsing to disambiguate lambdas from designators; noDouglas Gregor1-42/+45
functionality change. llvm-svn: 150817
2012-02-17Disambiguate between C++11 lambda expressions and C99 arrayDouglas Gregor1-9/+80
designators in the parser. In the worst case, this disambiguation requires tentative parsing just past the closing ']', but for most cases we'll be able to tell by looking ahead just one token (without going into the heavyweight tentative parsing machinery). llvm-svn: 150790
2012-02-05Basic: import SmallString<> into clang namespaceDylan Noblesmith1-1/+1
(I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
2011-12-12Implement the Microsoft __if_exists/if_not_exists extension in initializer-list.Francois Pichet1-0/+74
Necessary to parse Microsoft ATL code. Example: int array[] = { 0, __if_exists(CLASS::Type) {2, } 3 }; will declare an array of 2 or 3 elements depending on if CLASS::Type exists or not. llvm-svn: 146447
2011-10-12Introduce BalancedDelimiterTracker, to better track open/closeDouglas Gregor1-8/+15
delimiter pairs and detect when we exceed the implementation limit for nesting depth, from Aaron Ballman! llvm-svn: 141782
2011-08-27Improve caret location for the GNU old-style field designator warning, from ↵Douglas Gregor1-1/+1
David Blaikie llvm-svn: 138684
2011-04-15fix a bunch of comment typos found by codespell. Patch byChris Lattner1-1/+1
Luis Felipe Strano Moraes! llvm-svn: 129559
2011-01-03Implement support for pack expansions in initializer lists andDouglas Gregor1-2/+5
expression lists. llvm-svn: 122764
2010-09-15Implement bracket insertion for Objective-C instance message sends asDouglas Gregor1-1/+7
part of parser recovery. For example, given: a method1:arg]; we detect after parsing the expression "a" that we have the start of a message send expression. We pretend we've seen a '[' prior to the a, then parse the remainder as a message send. We'll then give a diagnostic+fix-it such as: fixit-objc-message.m:17:3: error: missing '[' at start of message send expression a method1:arg]; ^ [ The algorithm here is very simple, and always assumes that the open bracket goes at the beginning of the message send. It also only works for non-super instance message sends at this time. llvm-svn: 113968
2010-08-26One who seeks knowledge learns something new every day.John McCall1-6/+6
One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
2010-08-24OwningExprResult -> ExprResult. This patch brought to you byJohn McCall1-6/+6
M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
2010-08-24Abstract out passing around types and kill off ActionBase.John McCall1-5/+7
llvm-svn: 111901
2010-08-23Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall1-5/+5
llvm-svn: 111863
2010-08-23Sundry incremental steps towards killing off Action.John McCall1-4/+4
llvm-svn: 111795
2010-08-20Another step in the process of making the parser depend on Sema:John McCall1-2/+2
- move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
2010-07-02Move the "current scope" state from the Parser into Action. ThisDouglas Gregor1-2/+2
allows Sema some limited access to the current scope, which we only use in one way: when Sema is performing some kind of declaration that is not directly driven by the parser (e.g., due to template instantiatio or lazy declaration of a member), we can find the Scope associated with a DeclContext, if that DeclContext is still in the process of being parsed. Use this to make the implicit declaration of special member functions in a C++ class more "scope-less", rather than using the NULL Scope hack. llvm-svn: 107491
2010-04-21Implement parsing for message sends in Objective-C++. Message sends inDouglas Gregor1-28/+64
Objective-C++ have a more complex grammar than in Objective-C (surprise!), because (1) The receiver of an instance message can be a qualified name such as ::I or identity<I>::type. (2) Expressions in C++ can start with a type. The receiver grammar isn't actually ambiguous; it just takes a bit of work to parse past the type before deciding whether we have a type or expression. We do this in two places within the grammar: once for message sends and once when we're determining whether a []'d clause in an initializer list is a message send or a C99 designated initializer. This implementation of Objective-C++ message sends contains one known extension beyond GCC's implementation, which is to permit a typename-specifier as the receiver type for a class message, e.g., [typename compute_receiver_type<T>::type method]; Note that the same effect can be achieved in GCC by way of a typedef, e.g., typedef typename computed_receiver_type<T>::type Computed; [Computed method]; so this is merely a convenience. Note also that message sends still cannot involve dependent types or values. llvm-svn: 102031
2010-04-21Migrate the responsibility for turning the receiver name in anDouglas Gregor1-25/+7
Objective-C class message expression into a type from the parser (which was doing so in two places) to Action::getObjCMessageKind() which, in the case of Sema, reduces the number of name lookups we need to perform. llvm-svn: 102026
2010-04-21Rework the Parser-Sema interaction for Objective-C messageDouglas Gregor1-7/+48
sends. Major changes include: - Expanded the interface from two actions (ActOnInstanceMessage, ActOnClassMessage), where ActOnClassMessage also handled sends to "super" by checking whether the identifier was "super", to three actions (ActOnInstanceMessage, ActOnClassMessage, ActOnSuperMessage). Code completion has the same changes. - The parser now resolves the type to which we are sending a class message, so ActOnClassMessage now accepts a TypeTy* (rather than an IdentifierInfo *). This opens the door to more interesting types (for Objective-C++ support). - Split ActOnInstanceMessage and ActOnClassMessage into parser action functions (with their original names) and semantic functions (BuildInstanceMessage and BuildClassMessage, respectively). At present, this split is onyl used by ActOnSuperMessage, which decides which kind of super message it has and forwards to the appropriate Build*Message. In the future, Build*Message will be used by template instantiation. - Use getObjCMessageKind() within the disambiguation of Objective-C message sends vs. array designators. Two notes about substandard bits in this patch: - There is some redundancy in the code in ParseObjCMessageExpr and ParseInitializerWithPotentialDesignator; this will be addressed shortly by centralizing the mapping from identifiers to type names for the message receiver. - There is some #if 0'd code that won't likely ever be used---it handles the use of 'super' in methods whose class does not have a superclass---but could be used to model GCC's behavior more closely. This code will die in my next check-in, but I want it in Subversion. llvm-svn: 102021
2010-04-12fix a bug I noticed by inspection, correcting two reject-valid bugs.Chris Lattner1-3/+8
llvm-svn: 101026
2010-04-11fix PR6811 by not parsing 'super' as a magic expression inChris Lattner1-17/+21
LookupInObjCMethod. Doing so allows all sorts of invalid code to slip through to codegen. This patch does not change the AST representation of super, though that would now be a natural thing to do since it can only be in the receiver position and in the base of a ObjCPropertyRefExpr. There are still several ugly areas handling super in the parser, but this is definitely a step in the right direction. llvm-svn: 100959
2010-03-31Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor1-4/+3
the C-only "optimization". llvm-svn: 100022
2010-03-31Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor1-3/+4
llvm-svn: 100018
2010-03-31Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor1-4/+3
term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
2009-10-18PR5218: Replace IdentifierInfo::getName with StringRef version, now that clientsDaniel Dunbar1-1/+1
are updated. llvm-svn: 84447