summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement semantic analysis and an AST representation for the namedDouglas Gregor2010-05-151-76/+105
| | | | | | | | | | | | return value optimization. Sema marks return statements with their NRVO candidates (which may or may not end up using the NRVO), then, at the end of a function body, computes and marks those variables that can be allocated into the return slot. I've checked this locally with some debugging statements (not committed), but there won't be any tests until CodeGen comes along. llvm-svn: 103865
* Recognize when the named return value optimization applies in aDouglas Gregor2010-05-151-45/+37
| | | | | | | | | | "return" statement and mark the corresponding CXXConstructExpr as elidable. Teach CodeGen that eliding a temporary is different from eliding an object construction. This is just a baby step toward NRVO. llvm-svn: 103849
* Fixed DISABLE_SMART_POINTERS breakageDouglas Gregor2010-05-061-2/+4
| | | | llvm-svn: 103198
* Rework our handling of temporary objects within the conditions ofDouglas Gregor2010-05-061-49/+37
| | | | | | | | | | | | | | | | | | | if/switch/while/do/for statements. Previously, we would end up either: (1) Forgetting to destroy temporaries created in the condition (!), (2) Destroying the temporaries created in the condition *before* converting the condition to a boolean value (or, in the case of a switch statement, to an integral or enumeral value), or (3) In a for statement, destroying the condition's temporaries at the end of the increment expression (!). We now destroy temporaries in conditions at the right times. This required some tweaking of the Parse/Sema interaction, since the parser was building full expressions too early in many places. Fixes PR7067. llvm-svn: 103187
* Refactor Objective-C @catch parameter checking by detangling it fromDouglas Gregor2010-04-261-17/+5
| | | | | | | | function-parameter checking and splitting it into the normal ActOn*/Build* pair in Sema. We now use VarDecl to represent the @catch parameter rather than the ill-fitting ParmVarDecl. llvm-svn: 102347
* Improve the AST representation of Objective-C @try/@catch/@finallyDouglas Gregor2010-04-231-10/+10
| | | | | | | | | | statements. Instead of the @try having a single @catch, where all of the @catch's were chained (using an O(n^2) algorithm nonetheless), @try just holds an array of its @catch blocks. The resulting AST is slightly more compact (not important) and better represents the actual language semantics (good). llvm-svn: 102221
* Implement PR6845. We allow matching constraints to have differentChris Lattner2010-04-231-41/+60
| | | | | | | | input and output types when the smaller value isn't mentioned in the asm string. Extend this support from integers to also allowing fp values to be mismatched (if not mentioned in the asm string). llvm-svn: 102188
* Template instantiation for the Objective-C "fast enumeration"Douglas Gregor2010-04-221-3/+6
| | | | | | | | | | statement, i.e., for (element in collection) { // do something } llvm-svn: 102138
* Template instantiation for Objective-C++ @synchronized statements.Douglas Gregor2010-04-221-1/+2
| | | | llvm-svn: 102134
* Implement template instantiation for Objective-C++ @throw statements.Douglas Gregor2010-04-221-14/+24
| | | | llvm-svn: 102133
* make our existing "switch on bool" warning work for C. SinceChris Lattner2010-04-161-1/+1
| | | | | | | the result of comparisons are 'int' in C, it doesn't work to test just the result type of the expression. llvm-svn: 101576
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-1/+5
| | | | | | | | | | | | | | | | | | 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
* Devote a special diagnostic to the typoJohn McCall2010-04-061-0/+17
| | | | | | | (void*) someFunction(5, 10, 15, 20); where the cast is presumably meant to be to 'void'. llvm-svn: 100574
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-3/+3
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-3/+3
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-3/+3
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-16/+25
| | | | | | | | | | | | | 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
* Add Support for 'warn_unused_result" attribute onFariborz Jahanian2010-03-301-1/+7
| | | | | | objective-c methods. (radar 7418262). llvm-svn: 99903
* Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor2010-03-291-1/+1
| | | | | | | | | | | | | | 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
* Improve the unused-value check to look into comma expressions and filter outJohn McCall2010-03-121-4/+3
| | | | | | | | voids in sub-expressions. Patch by Mike M! Fixes PR4806. llvm-svn: 98335
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-4/+5
| | | | | | | | | | | | | | | | | | | | 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
* Don't warn about case-value conversions from a negative value to aDouglas Gregor2010-03-011-7/+5
| | | | | | | | larger unsigned value, since this is implementation-defined behavior. (We previously suppressed this warning when converting from a signed value to an unsigned value of the same size). llvm-svn: 97430
* Don't diagnose overflow in case statements when the conversion is aDouglas Gregor2010-02-181-3/+3
| | | | | | | signed<->unsigned conversion with the same bit width. Fixes <rdar://problem/7658121>. llvm-svn: 96545
* For -Wswitch-enum warnings, be sure to look through typedefs of enumDouglas Gregor2010-02-171-1/+1
| | | | | | types. Fixes <rdar://problem/7643909>. llvm-svn: 96531
* When we have a dependent direct initializer but not a dependentDouglas Gregor2010-02-111-0/+9
| | | | | | | | variable type, we can (and should) still check for completeness of the variable's type. Do so, to work around an assertion that shows up in Boost's shared_ptr. llvm-svn: 95934
* Warn when cases are missing from a switch on a value of enumerationDouglas Gregor2010-02-081-1/+87
| | | | | | type (-Wswitch), from Michal! llvm-svn: 95592
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-1/+2
| | | | | | | | | | | | follows (as conservatively as possible) gcc's current behavior: attributes written on return types that don't apply there are applied to the function instead, etc. Only parse CC attributes as type attributes, not as decl attributes; don't accepet noreturn as a decl attribute on ValueDecls, either (it still needs to apply to other decls, like blocks). Consistently consume CC/noreturn information throughout codegen; enforce this by removing their default values in CodeGenTypes::getFunctionInfo(). llvm-svn: 95436
* Implement Doug's suggestion. Eliminate the Stmts pointer from CXXTryStmt and ↵Sam Weinig2010-02-031-3/+3
| | | | | | instead allocate the statements after the object. llvm-svn: 95199
* Remove the SmallVector from CXXTryStmt.Sam Weinig2010-02-031-1/+1
| | | | llvm-svn: 95190
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class type to rvalue expressions of the unqualified variant of that type. For example, given: const int i; (void)(i + 17); the lvalue-to-rvalue conversion for the subexpression "i" will turn it from an lvalue expression (a DeclRefExpr) with type 'const int' into an rvalue expression with type 'int'. Both C and C++ mandate this conversion, and somehow we've slid through without implementing it. We now have both DefaultFunctionArrayConversion and DefaultFunctionArrayLvalueConversion, and which gets used depends on whether we do the lvalue-to-rvalue conversion or not. Generally, we do the lvalue-to-rvalue conversion, but there are a few notable exceptions: - the left-hand side of a '.' operator - the left-hand side of an assignment - a C++ throw expression - a subscript expression that's subscripting a vector Making this change exposed two issues with blocks: - we were deducing const-qualified return types of non-class type from a block return, which doesn't fit well - we weren't always setting the known return type of a block when it was provided with the ^return-type syntax Fixes the current Clang-on-Clang compile failure and PR6076. llvm-svn: 95167
* Really trivial patch to accept pointer to const void in indirect goto. DespiteChandler Carruth2010-01-311-3/+3
| | | | | | the lack of documentation, this matches the behavior of GCC. llvm-svn: 94954
* Remove the SmallVectors from AsmStmt. Fixes PR6105.Anders Carlsson2010-01-301-3/+3
| | | | llvm-svn: 94926
* Use IdentifierInfo * instead of std::string for the AsmStmt names.Anders Carlsson2010-01-301-3/+11
| | | | llvm-svn: 94925
* Combine AsmStmt::setOutputsAndInputs and AsmStmt::setClobbers.Anders Carlsson2010-01-301-6/+3
| | | | llvm-svn: 94918
* StringRef-ize the TargetInfo::ConstraintInfo constructor.Anders Carlsson2010-01-301-5/+2
| | | | llvm-svn: 94916
* Get rid of another old PerformCopyInitialization call.Anders Carlsson2010-01-291-4/+12
| | | | llvm-svn: 94819
* Implement instantiation of AsmStmts (Crazy, I know)Anders Carlsson2010-01-241-1/+5
| | | | llvm-svn: 94361
* fix PR6034, a crash on invalid where the switch stack would get Chris Lattner2010-01-241-0/+10
| | | | | | unbalanced. llvm-svn: 94347
* Give UnresolvedSet the ability to store access specifiers for each declaration.John McCall2010-01-201-2/+2
| | | | | | | Change LookupResult to use UnresolvedSet. Also extract UnresolvedSet into its own header and make it templated over an inline capacity. llvm-svn: 93959
* Implement goto inside of blocks.Mike Stump2010-01-191-4/+0
| | | | llvm-svn: 93945
* Remember if the AsmStmt came from Microsoft-style inline assembly code.Mike Stump2010-01-041-4/+5
| | | | llvm-svn: 92526
* Remove some dead variables clang-analyzer found.Benjamin Kramer2009-12-251-1/+0
| | | | llvm-svn: 92162
* Switch InitializedEntity from TypeLoc down to just QualTypes, since we don't ↵Douglas Gregor2009-12-221-29/+1
| | | | | | use the location information but we did spend a bunch of time building faked-up TypeLocs llvm-svn: 91905
* fix PR4010: add support for the warn_unused_result for function pointersNuno Lopes2009-12-201-1/+1
| | | | llvm-svn: 91803
* Try to de-bork DISABLE_SMART_POINTERS buildDouglas Gregor2009-12-181-7/+7
| | | | llvm-svn: 91696
* Switch the initialization required by return statements over to theDouglas Gregor2009-12-181-6/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | new InitializationSequence. This fixes some bugs (e.g., PR5808), changed some diagnostics, and caused more churn than expected. What's new: - InitializationSequence now has a "C conversion sequence" category and step kind, which falls back to - Changed the diagnostics for returns to always have the result type of the function first and the type of the expression second. CheckSingleAssignmentConstraints to peform checking in C. - Improved ASTs for initialization of return values. The ASTs now capture all of the temporaries we need to create, but intentionally do not bind the tempoary that is actually returned, so that it won't get destroyed twice. - Make sure to perform an (elidable!) copy of the class object that is returned from a class. - Fix copy elision in CodeGen to properly see through the subexpressions that occur with elidable copies. - Give "new" its own entity kind; as with return values and thrown objects, we don't bind the expression so we don't call a destructor for it. Note that, with this patch, I've broken returning move-only types in C++0x. We'll fix it later, when we tackle NRVO. llvm-svn: 91669
* Fix semantic diagnostics that embed English works, from Nicola Gigante!Douglas Gregor2009-12-161-3/+3
| | | | llvm-svn: 91503
* ShouldDestroyTemporaries? I don't think so.Anders Carlsson2009-12-151-3/+3
| | | | llvm-svn: 91450
* Fix a thinko where we weren't always performing unary conversions on the ↵Douglas Gregor2009-11-251-4/+4
| | | | | | switch condition, fixing PR5612 llvm-svn: 89864
* When the condition of a switch() statement is semantically invalid,Douglas Gregor2009-11-251-6/+7
| | | | | | | still parse the body of the switch to try to avoid spurious diagnostics. Fixes PR5606. llvm-svn: 89847
OpenPOWER on IntegriCloud