summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
* objc-arc: enforce performSelector rules in rejecting retaining selectorsFariborz Jahanian2011-07-051-0/+28
| | | | | | | passed to it, and unknown selectors causing potential leak. // rdar://9659270 llvm-svn: 134449
* Don't overread the buffer when an %x escape in inline asm ends prematurely.Benjamin Kramer2011-07-051-0/+4
| | | | | | Tested by valgrind & Sema/asm.c. llvm-svn: 134404
* Switch the Decl and Stmt stats printing to use llvm::errs() instead ofChandler Carruth2011-07-042-15/+16
| | | | | | | fprintf, and to be more consistent in formatting with the other stats printing routines. llvm-svn: 134374
* Start switching the AST stats printing to use llvm::errs() instead ofChandler Carruth2011-07-041-26/+27
| | | | | | fprintf. There is more cleanup to be done to the AST stats printing... llvm-svn: 134373
* Rewritten fix in r134139 to conform evaluation result to original evaluation ↵Abramo Bagnara2011-07-021-11/+21
| | | | | | context. llvm-svn: 134320
* -Fix mistake in ASTContext::getInnerObjCOwnership noticed by DougArgyrios Kyrtzidis2011-07-011-1/+1
| | | | | | | | -Remove unnecessary 'return'. -Remove unnecessary 'if' check (llvm_unreachable make sure attrStr will be non-null) -Add a test of transferring ownership to a reference cast type. llvm-svn: 134285
* [ARC] When casting from a pointer to an objective-c object with known ↵Argyrios Kyrtzidis2011-07-011-0/+19
| | | | | | | | | | | | | | ownership, if the cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type to the cast type: id x; static_cast<NSString**>(&x); // Casting as (__strong NSString**). This currently only works for C++ named casts, C casts to follow. llvm-svn: 134273
* Just mangle substituted template parameter types as unresolved types.John McCall2011-07-011-10/+3
| | | | | | | This is kindof questionable but seems to do more-or-less the right thing. This is not a particularly friendly part of the ABI. llvm-svn: 134227
* Introduce the notion of instantiation dependence into Clang's AST. ADouglas Gregor2011-07-018-55/+317
| | | | | | | | | | | | | | | | | | | | | | | | | | type/expression/template argument/etc. is instantiation-dependent if it somehow involves a template parameter, even if it doesn't meet the requirements for the more common kinds of dependence (dependent type, type-dependent expression, value-dependent expression). When we see an instantiation-dependent type, we know we always need to perform substitution into that instantiation-dependent type. This keeps us from short-circuiting evaluation in places where we shouldn't, and lets us properly implement C++0x [temp.type]p2. In theory, this would also allow us to properly mangle instantiation-dependent-but-not-dependent decltype types per the Itanium C++ ABI, but we aren't quite there because we still mangle based on the canonical type in cases like, e.g., template<unsigned> struct A { }; template<typename T> void f(A<sizeof(sizeof(decltype(T() + T())))>) { } template void f<int>(A<sizeof(sizeof(int))>); and therefore get the wrong answer. llvm-svn: 134225
* Change the mangling of enclosing template template parametersJohn McCall2011-07-011-19/+73
| | | | | | | that serve as the base template name of an unresolved-name to be mangled as a substitution. llvm-svn: 134213
* No, actually, we do need to be able to mangle substituted template names.John McCall2011-06-301-3/+10
| | | | llvm-svn: 134195
* Fix off-by-one error in StringLiteral::getLocationOfByte.Hans Wennborg2011-06-301-1/+1
| | | | | | This fixes PR10223. llvm-svn: 134183
* Fixed enum constant evaluation assertions.Abramo Bagnara2011-06-301-6/+13
| | | | llvm-svn: 134139
* Preserve that a TemplateName was arrived at by substitutingJohn McCall2011-06-305-26/+125
| | | | | | | | | | | for a template template parameter. Uses to follow. I've also made the uniquing of SubstTemplateTemplateParmPacks use a ContextualFoldingSet as a minor space efficiency. llvm-svn: 134137
* Document and check tighter assumptions about the TemplateName of aJohn McCall2011-06-301-0/+3
| | | | | | TemplateSpecializationType. llvm-svn: 134120
* Eliminate most uses of ShallowCollectObjCIvars which requiresFariborz Jahanian2011-06-282-7/+10
| | | | | | | a vector for collection. Use iterators where needed instead. // rdar://6817577 llvm-svn: 134015
* Be more thorough about mangling unresolved types.John McCall2011-06-282-57/+102
| | | | llvm-svn: 134011
* Merge some calls to FoldingSetNodeID::AddInteger; assuming my measurements ↵Eli Friedman2011-06-271-4/+12
| | | | | | aren't completely off, roughly a 1% speedup on SingleSource/UnitTests/ObjC/trivial-interface.m . llvm-svn: 133968
* Don't factor in visibility for templates and template argumentsJohn McCall2011-06-271-24/+44
| | | | | | for explicit specializations with their own explicit visibility. llvm-svn: 133958
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-5/+5
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Apparently at some point in the past I forgot how 'continue'John McCall2011-06-231-6/+2
| | | | | | | | works in a 'while(false)' loop. Simplify this code; it was complicated only in anticipation of C++0x lambdas, and it can become complicated again when those happen. :) llvm-svn: 133761
* Move definition of template <typename T> void Decl::dropAttrFariborz Jahanian2011-06-231-18/+0
| | | | | | to its header to avoid an explicit instantiation. llvm-svn: 133753
* Minor tweak to my last patch per Doug's comment.Fariborz Jahanian2011-06-231-2/+4
| | | | llvm-svn: 133731
* Remove multiple use of weak_import attribute onFariborz Jahanian2011-06-231-14/+16
| | | | | | same declaration. Templatize dropAttr for general use. llvm-svn: 133724
* Remove weak_import attribute on new declaration.Fariborz Jahanian2011-06-231-0/+14
| | | | | | // rdar://9538608 llvm-svn: 133721
* Changes ParenListExpr to always require a type.Manuel Klimek2011-06-221-3/+3
| | | | | | | Removes dead code found in the process. Adds a test to verify that ParenListExprs do not have NULL types. llvm-svn: 133637
* Fix a missing space noticed by matthewbg in code review.Chandler Carruth2011-06-211-1/+1
| | | | llvm-svn: 133577
* Fix the mangling of dependent-scope decl ref expressions so that theyJohn McCall2011-06-211-20/+8
| | | | | | use the unresolved-name production correctly. llvm-svn: 133554
* A few tweaks to MaterializeTemporaryExpr suggested by John.Douglas Gregor2011-06-213-7/+2
| | | | llvm-svn: 133528
* Fix a crash when a pointer-to-member function is called in the conditionChandler Carruth2011-06-211-1/+1
| | | | | | | expression of '?:'. Add a test case for this pattern, and also test the code that led to the crash in a "working" case as well. llvm-svn: 133523
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-217-2/+85
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* Make more use of llvm::StringRef in various APIs. In particular, don'tJay Foad2011-06-211-5/+5
| | | | | | use the deprecated forms of llvm::StringMap::GetOrCreateValue(). llvm-svn: 133515
* Restructure the API in Type based on a conversation with Richard Smith.Chandler Carruth2011-06-201-26/+0
| | | | | | | | | | | This makes 'isPointerLikeType' a little less confusing, and pulls the decay check into a separate interface that is much more clear and concrete. Also, just implement these as logical wrappers around other predicates. Having a switch based implementation isn't likely to be necessary. We can try to optimize them later if they show up on a profile. llvm-svn: 133405
* Add test cases for false positives on -Wnull-arithmetic from RichardChandler Carruth2011-06-191-0/+25
| | | | | | | | | | | | | Trieu, and fix them by checking for array and function types as well as pointer types. I've added a predicate method on Type to bundle together the logic we're using here: isPointerLikeType(). I'd welcome better names for this predicate, this is the best I came up with. It's implemented as a switch to be a touch lighter weight than all the chained isa<...> casts that would result otherwise. llvm-svn: 133383
* Fix regression with @encode string. rdar://9624314.Argyrios Kyrtzidis2011-06-171-2/+6
| | | | llvm-svn: 133312
* Objective-C++ ARC: do not mangle __unsafe_unretained lifetimeDouglas Gregor2011-06-171-2/+7
| | | | | | | | | | qualifiers, so that an __unsafe_unretained-qualified type T in ARC code will have the same mangling as T in non-ARC code, improving ABI interoperability. This works now because we infer or require a lifetime qualifier everywhere one can appear in an external interface. Another part of <rdar://problem/9595486>. llvm-svn: 133306
* Objective-ARC++: infer template type arguments ofDouglas Gregor2011-06-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ownership-unqualified retainable object type as __strong. This allows us to write, e.g., std::vector<id> and we'll infer that the vector's element types have __strong ownership semantics, which is far nicer than requiring: std::vector<__strong id> Note that we allow one to override the ownership qualifier of a substituted template type parameter, e.g., given template<typename T> struct X { typedef __weak T type; }; X<id> is treated the same as X<__strong id>. At instantiation type, the __weak in "__weak T" overrides the (inferred or specified) __strong on the template argument type, so that we can still provide metaprogramming transformations. This is part of <rdar://problem/9595486>. llvm-svn: 133303
* Objective-C fast enumeration loop variables are not retained in ARC, butJohn McCall2011-06-171-3/+9
| | | | | | | | | | | | they should still be officially __strong for the purposes of errors, block capture, etc. Make a new bit on variables, isARCPseudoStrong(), and set this for 'self' and these enumeration-loop variables. Change the code that was looking for the old patterns to look for this bit, and change IR generation to find this bit and treat the resulting variable as __unsafe_unretained for the purposes of init/destroy in the two places it can come up. llvm-svn: 133243
* Move computation of __private_extern__ visibilty toFariborz Jahanian2011-06-161-0/+8
| | | | | | getLVForNamespaceScopeDecl(). // rdar://9609649 llvm-svn: 133182
* Make the Stmt::Profile method const, and the StmtProfile visitorChandler Carruth2011-06-162-140/+152
| | | | | | | | | | | | a ConstStmtVisitor. This also required adding some const iteration support for designated initializers and making some of the getters on the designators const. It also made the formatting of StmtProfile.cpp rather awkward. I'm happy to adjust any of the formatting if folks have suggestions. I've at least fitted it all within 80 columns. llvm-svn: 133152
* Automatic Reference Counting.John McCall2011-06-1513-147/+634
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Introduce a utility routine for checking whether a block's capturesJohn McCall2011-06-151-0/+10
| | | | | | include a specific variable. llvm-svn: 133102
* Eliminate a 'default' case in template argument deduction, where weDouglas Gregor2011-06-151-1/+1
| | | | | | | | | | | | | | | | | | were just punting on template argument deduction for a number of type nodes. Most of them, obviously, didn't matter. As a consequence of this, make extended vector types (via the ext_vector_type attribute) actually work properly for several important cases: - If the attribute appears in a type-id (i.e, not attached to a typedef), actually build a proper vector type - Build ExtVectorType whenever the size is constant; previously, we were building DependentSizedExtVectorType when the size was constant but the type was dependent, which makes no sense at all. - Teach template argument deduction to handle ExtVectorType/DependentSizedExtVectorType. llvm-svn: 133060
* When profiling FunctionProtoTypes, don't canonicalize the expressionDouglas Gregor2011-06-141-1/+1
| | | | | | | | | | in a noexcept exception specification because it isn't part of the canonical type. This ensures that we keep the exact expression written in the noexcept exception specification, rather than accidentally "adopting" a previously-written and canonically "equivalent" function prototype. Fixes PR10087. llvm-svn: 132998
* Added 'atomic' for objc properties.Fariborz Jahanian2011-06-111-0/+5
| | | | llvm-svn: 132879
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-117-70/+141
| | | | llvm-svn: 132878
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-113-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id llvm-svn: 132868
* PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to ↵Eli Friedman2011-06-101-2/+2
| | | | | | | | determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates. While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp. llvm-svn: 132861
* Don't add objc method name mangling to locally declared function.Fariborz Jahanian2011-06-091-0/+6
| | | | | | // rdar://9566314 llvm-svn: 132791
* Handle overloaded operators in ?: precedence warningHans Wennborg2011-06-091-1/+8
| | | | | | | | | | | | | | This is a follow-up to r132565, and should address the rest of PR9969: Warn about cases such as int foo(A a, bool b) { return a + b ? 1 : 2; // user probably meant a + (b ? 1 : 2); } also when + is an overloaded operator call. llvm-svn: 132784
OpenPOWER on IntegriCloud