summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Switch Sema::FindCompositePointerType() over to InitializationSequence. Douglas Gregor2010-04-161-2/+2
| | | | | | | This is the last of the uses of TryImplicitConversion outside of overload resolution and InitializationSequence itself. llvm-svn: 101569
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-18/+3
| | | | | | | | | | | | | | | | | | TryStaticImplicitCast (for references, class types, and everything else, respectively) into a single invocation of InitializationSequence. One of the paths (for class types) was the only client of Sema::TryInitializationByConstructor, which I have eliminated. This also simplified the interface for much of the cast-checking logic, eliminating yet more code. I've kept the representation of C++ functional casts with <> 1 arguments the same, despite the fact that I hate it. That fix will come soon. To satisfy my paranoia, I've bootstrapped + tested Clang with these changes. llvm-svn: 101549
* Expand the argument diagnostics for too many arguments and giveEric Christopher2010-04-161-1/+2
| | | | | | | | both number seen and number expected. Finishes fixing PR6501. llvm-svn: 101442
* Expand argument diagnostic for too few arguments to give the numberEric Christopher2010-04-161-1/+2
| | | | | | | | of arguments both seen and expected. Fixes PR6501. llvm-svn: 101441
* Thread a Scope pointer into BuildRecoveryCallExpr to help typoDouglas Gregor2010-04-141-1/+1
| | | | | | | correction find names when a call failed. Fixes <rdar://problem/7853795>. llvm-svn: 101278
* Teach typo correction about various language keywords. We can'tDouglas Gregor2010-04-141-33/+46
| | | | | | | | | | | | | generally recover from typos in keywords (since we would effectively have to mangle the token stream). However, there are still benefits to typo-correcting with keywords: - We don't make stupid suggestions when the user typed something that is similar to a keyword. - We can suggest the keyword in a diagnostic (did you mean "static_cast"?), even if we can't recover and therefore don't have a fix-it. llvm-svn: 101274
* When diagnosing suspicious precedence or assignments, move the fix-itDouglas Gregor2010-04-141-20/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | that adds parentheses from the main diagnostic down to a new note. This way, when the fix-it represents a choice between two options, each of the options is associted with a note. There is no default option in such cases. For example: /Users/dgregor/t.c:2:9: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses] if (x & y == 0) { ^~~~~~~~ /Users/dgregor/t.c:2:9: note: place parentheses around the & expression to evaluate it first if (x & y == 0) { ^ ( ) /Users/dgregor/t.c:2:9: note: place parentheses around the == expression to silence this warning if (x & y == 0) { ^ ( ) llvm-svn: 101249
* Use ASTVector instead of std::vector for the Exprs in InitListExpr. PerformanceTed Kremenek2010-04-131-4/+5
| | | | | | | measurements of '-fsyntax-only' on combine.c (403.gcc) shows no real performance change, but now the vector isn't leaked. llvm-svn: 101195
* Implement C++ [temp.local]p4, which specifies how we eliminateDouglas Gregor2010-04-121-2/+4
| | | | | | | | | name-lookup ambiguities when there are multiple base classes that are all specializations of the same class template. This is part of a general cleanup for ambiguities in template-name lookup. Fixes PR6717. llvm-svn: 101065
* change Scope::WithinElse to be a normal scope flag, widen theChris Lattner2010-04-121-4/+3
| | | | | | fields to two 16-bit values instead of using bitfields. llvm-svn: 101020
* fix a fixme, stop evaluating getCurMethodDecl() repeatedly Chris Lattner2010-04-121-6/+5
| | | | | | in "LookupInObjCMethod". llvm-svn: 101014
* fix PR6811 by not parsing 'super' as a magic expression inChris Lattner2010-04-111-16/+4
| | | | | | | | | | | | | 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
* actually the interface grossness in the previous patch was due toChris Lattner2010-04-111-3/+1
| | | | | | | | typo correction. However, now that the code has been factored out of LookupMemberExpr, it can recurse to itself instead of to LookupMemberExpr! Remove grossness. llvm-svn: 100958
* factor the code that handles "expr.field" when expr is aChris Lattner2010-04-111-99/+6
| | | | | | | | pointer to an objc interface out to a method in SemaExprObjC. This is *much* uglier than it should be due to grossness in LookupMemberExpr :( llvm-svn: 100957
* Remove fixit for string literal comparison. Telling the user to use ↵Ted Kremenek2010-04-091-5/+1
| | | | | | | | | 'strcmp' is bad, and we don't have enough information to tell them how to use 'strncmp'. Instead, change the diagnostic to indicate they should use 'strncmp'. llvm-svn: 100890
* Improve diagnostics when we fail to convert from a source type to aDouglas Gregor2010-04-091-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | destination type for initialization, assignment, parameter-passing, etc. The main issue fixed here is that we used rather confusing wording for diagnostics such as t.c:2:9: warning: initializing 'char const [2]' discards qualifiers, expected 'char *' [-pedantic] char *name = __func__; ^ ~~~~~~~~ We're not initializing a 'char const [2]', we're initializing a 'char *' with an expression of type 'char const [2]'. Similar problems existed for other diagnostics in this area, so I've normalized them all with more precise descriptive text to say what we're initializing/converting/assigning/etc. from and to. The warning for the code above is now: t.c:2:9: warning: initializing 'char *' from an expression of type 'char const [2]' discards qualifiers [-pedantic] char *name = __func__; ^ ~~~~~~~~ Fixes <rdar://problem/7447179>. llvm-svn: 100832
* Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin2010-04-081-7/+7
| | | | | | | Declarator that depends on it. This fixes several redundant errors and bad recoveries. llvm-svn: 100779
* Return early from Sema::MarkDeclarationReferenced when we know thereDouglas Gregor2010-04-071-2/+7
| | | | | | | | | isn't any extra work to perform. Also, don't check for unused parameters when the warnings will be suppressed anyway. Improves performance of -fsyntax-only on 403.gcc's combine.c by ~2.5%. <rdar://problem/7836787> llvm-svn: 100686
* Implement the protected access restriction ([class.protected]), which requiresJohn McCall2010-04-061-25/+8
| | | | | | | | that protected members be used on objects of types which derive from the naming class of the lookup. My first N attempts at this were poorly-founded, largely because the standard is very badly worded here. llvm-svn: 100562
* Diagnose invalid code with -fobjc-nonfragile-abi2 whenFariborz Jahanian2010-04-021-5/+0
| | | | | | | property is being accessed without the dot-syntax notation. (radar 7822344). llvm-svn: 100212
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-37/+31
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-31/+37
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-37/+31
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Remove silly temporary comment.John McCall2010-03-301-2/+0
| | | | llvm-svn: 99964
* Introduce a new kind of derived-to-base cast which bypasses the need forJohn McCall2010-03-301-4/+4
| | | | | | | null checks, and make sure we elide null checks when accessing base class members. llvm-svn: 99963
* Remember the regparm attribute in FunctionType::ExtInfo.Rafael Espindola2010-03-301-2/+2
| | | | | | Fixes PR3782. llvm-svn: 99940
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-35/+95
| | | | | | | | | | | | | the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. llvm-svn: 99936
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-4/+4
| | | | | | | | This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. llvm-svn: 99920
* Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor2010-03-291-8/+8
| | | | | | | | | | | | | | cache of PartialDiagnostic::Storage objects into an allocator within the ASTContext. This eliminates a significant amount of malloc traffic, for a 10% performance improvement in -fsyntax-only wall-clock time with 403.gcc's combine.c. Also, eliminate the RequireNonAbstractType hack I put in earlier, which was but a symptom of this larger problem. Fixes <rdar://problem/7806091>. llvm-svn: 99849
* Allow conversion of qualified Class type to unqualifiedFariborz Jahanian2010-03-241-2/+4
| | | | | | Class type to match gcc's. Fixes radar 7789113. llvm-svn: 99425
* Only perform CFG-based warnings on 'static inline' functions thatTed Kremenek2010-03-231-2/+3
| | | | | | | are called (transitively) by regular functions/blocks within a translation untion. llvm-svn: 99233
* -Wshadow should only warn about parameter declarations when we'reJohn McCall2010-03-221-1/+9
| | | | | | | | | entering a function or block definition, not on every single declaration. Unfortunately we don't have previous-lookup results around when it's time to make this decision, so we have to redo the lookup. The alternative is to use delayed diagnostics. llvm-svn: 99172
* Refactor CFG-based warnings in Sema to be run by a worked object called ↵Ted Kremenek2010-03-201-4/+5
| | | | | | | | | | | | | | | AnalysisBasedWarnings. This object controls when the warnings are executed, allowing the client code in Sema to selectively disable warnings as needed. Centralizing the logic for analysis-based warnings allows us to optimize when and how they are run. Along the way, remove the redundant logic for the 'check fall-through' warning for blocks; now the same logic is used for both blocks and functions. llvm-svn: 99085
* Diagnose conversion of 'Class' to/from objective-c Fariborz Jahanian2010-03-191-1/+11
| | | | | | | object pointer types. Fixes radar 7634850. llvm-svn: 98970
* Some cleanup, change diagnostic when assigning toFariborz Jahanian2010-03-181-3/+0
| | | | | | a property which is not lvalue. llvm-svn: 98848
* objective-c patch to provide type safty when blocks are passing orFariborz Jahanian2010-03-171-1/+5
| | | | | | | returning objc objects. There will be a corresponding objective-c++ patch soon. llvm-svn: 98696
* Issue error when a byref array is accessed in a blockFariborz Jahanian2010-03-161-1/+1
| | | | | | literal. Fixes radar 7760213. llvm-svn: 98693
* Audit all Preprocessor::getSpelling() callers, improving failureDouglas Gregor2010-03-161-2/+8
| | | | | | recovery for those that need it. llvm-svn: 98689
* Add support for -Wwrite-strings. Patch by Mike M! Fixes PR 4804.John McCall2010-03-151-1/+1
| | | | llvm-svn: 98541
* Use SmallString instead of SmallVectorKovarththanan Rajaratnam2010-03-131-173/+173
| | | | llvm-svn: 98436
* Warn about comparing an unsigned expression with 0 in tautological ways.John McCall2010-03-111-3/+2
| | | | | | Patch by mikem! llvm-svn: 98279
* Statement expressions can be used in global- or namespace-scoped blocksDouglas Gregor2010-03-101-1/+2
| | | | llvm-svn: 98135
* Allow use of byref (__block attributed) arrays insideFariborz Jahanian2010-03-061-1/+1
| | | | | | the block. Fixes radar 7671883. llvm-svn: 97863
* Reinstate r97674 with a fix for the assertion that was firing in <list>Douglas Gregor2010-03-031-25/+107
| | | | llvm-svn: 97686
* Revert r97674; it's causing failuresDouglas Gregor2010-03-031-107/+25
| | | | llvm-svn: 97677
* Implement disambiguation of base class members via aDouglas Gregor2010-03-031-25/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | nested-name-specifier. For example, this allows member access in diamond-shaped hierarchies like: struct Base { void Foo(); int Member; }; struct D1 : public Base {}; struct D2 : public Base {}; struct Derived : public D1, public D2 { } void Test(Derived d) { d.Member = 17; // error: ambiguous cast from Derived to Base d.D1::Member = 17; // error: okay, modify D1's Base's Member } Fixes PR5820 and <rdar://problem/7535045>. Also, eliminate some redundancy between Sema::PerformObjectMemberConversion() and Sema::PerformObjectArgumentInitialization() -- the latter now calls the former. llvm-svn: 97674
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-46/+26
| | | | | | | | | | | | | | | | | | | | which has the label map, switch statement stack, etc. Previously, we had a single set of maps in Sema (for the function) along with a stack of block scopes. However, this lead to funky behavior with nested functions, e.g., in the member functions of local classes. The explicit-stack approach is far cleaner, and we retain a 1-element cache so that we're not malloc/free'ing every time we enter a function. Fixes PR6382. Also, tweaked the unused-variable warning suppression logic to look at errors within a given Scope rather than within a given function. The prior code wasn't looking at the right number-of-errors count when dealing with blocks, since the block's count would be deallocated before we got to ActOnPopScope. This approach works with nested blocks/functions, and gives tighter error recovery. llvm-svn: 97518
* Implement jump checking for initialized c++ variables, implementingChris Lattner2010-03-011-2/+8
| | | | | | | | | | | | | | | | | | a fixme and PR6451. Only perform jump checking if the containing function has no errors, and add the infrastructure needed to do this. On the testcase in the PR, we produce: t.cc:6:3: error: illegal goto into protected scope goto later; ^ t.cc:7:5: note: jump bypasses variable initialization X x; ^ llvm-svn: 97497
* Start detangling the BlockSemaInfo/Sema mess. No functionality change.Douglas Gregor2010-03-011-6/+6
| | | | llvm-svn: 97494
* Add an overload of Preprocessor::getSpelling which takes a SmallVector andBenjamin Kramer2010-02-271-5/+3
| | | | | | returns a StringRef. Use it to simplify some repetitive code. llvm-svn: 97322
OpenPOWER on IntegriCloud