summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Don't do an expensive definition check where a cheap 'is this C?' check ↵Sebastian Redl2010-02-031-1/+2
| | | | | | suffices. llvm-svn: 95188
* Remove abstract expression kinds from the StmtClass enum. Update a few usersJohn McCall2010-02-031-14/+2
| | | | | | appropriately. Call out a few missing cases in the expression mangler. llvm-svn: 95176
* Simplify setting of DeclContext for @catch variableFariborz Jahanian2010-02-031-9/+1
| | | | | | (per Doug's comment). llvm-svn: 95169
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-037-24/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix DeclContext of an objective-c @catch variableFariborz Jahanian2010-02-032-0/+14
| | | | | | declaration. Fixes radar 7590273. llvm-svn: 95164
* Implement promotion for enumeration types.Douglas Gregor2010-02-022-16/+13
| | | | | | | | | | | | | | | | | | | | | | | | | WHAT!?! It turns out that Type::isPromotableIntegerType() was not considering enumeration types to be promotable, so we would never do the promotion despite having properly computed the promotion type when the enum was defined. Various operations on values of enum type just "worked" because we could still compute the integer rank of an enum type; the oddity, however, is that operations such as "add an enum and an unsigned" would often have an enum result type (!). The bug actually showed up as a spurious -Wformat diagnostic (<rdar://problem/7595366>), but in theory it could cause miscompiles. In this commit: - Enum types with a promotion type of "int" or "unsigned int" are promotable. - Tweaked the computation of promotable types for enums - For all of the ABIs, treat enum types the same way as their underlying types (*not* their promotion types) for argument passing and return values - Extend the ABI tester with support for enumeration types llvm-svn: 95117
* Fix this comment.John McCall2010-02-021-1/+1
| | | | llvm-svn: 95104
* Check for redefinitions in MergeVarDecl. This finds redefinitions of globals ↵Sebastian Redl2010-02-021-0/+11
| | | | | | without an initializer in C++ and thus fixes PR5451. llvm-svn: 95098
* Mark dtors for parameter variables and eliminate some redundant type munging.John McCall2010-02-025-20/+15
| | | | llvm-svn: 95079
* Access control for implicit destructor calls. Diagnostic could be orders ofJohn McCall2010-02-024-4/+34
| | | | | | magnitude clearer. llvm-svn: 95078
* Extract a common base class between UnresolvedLookupExpr andJohn McCall2010-02-023-93/+33
| | | | | | UnresolvedMemberExpr and employ it in a few places where it's useful. llvm-svn: 95072
* Improve the diagnostic used when an incompatible overload set is passedJohn McCall2010-02-021-0/+18
| | | | | | as an argument during overload resolution. llvm-svn: 95057
* Implement C++ [temp.deduct.call]p6, template argument deduction for overloadedJohn McCall2010-02-021-31/+111
| | | | | | | | | | arguments. Fix a bug where incomplete explicit specializations were being passed through as legitimate. Fix a bug where the absence of an explicit specialization in an overload set was causing overall deduction to fail. Fixes PR6191. llvm-svn: 95052
* Add a stop gap to Sema::CorrectTypo() to correct only up to 20 typos.Ted Kremenek2010-02-023-2/+12
| | | | | | | | | | | | | | | | | This is to address a serious performance problem observed when running 'clang -fsyntax-only' on really broken source files. In one case, repeatedly calling CorrectTypo() caused one source file to be rejected after 2 minutes instead of 1 second. This patch causes typo correction to take neglible time on that file while still providing correction results for the first 20 cases. I felt this was a reasonable number for moderately broken source files. I don't claim this is the best solution. Comments welcome. It is necessary for us to address this issue because it is a serious performance problem. llvm-svn: 95049
* Improve handling of enumerator values for C and C++, including:Douglas Gregor2010-02-011-39/+133
| | | | | | | | | | | | | | | | | - In C++, prior to the closing '}', set the type of enumerators based on the type of their initializer. Don't perform unary conversions on the enumerator values. - In C++, handle overflow when an enumerator has no initializer and its value cannot be represented in the type of the previous enumerator. - In C, handle overflow more gracefully, by complaining and then falling back to the C++ rules. - In C, if the enumerator value is representable in an int, convert the expression to the type 'int'. Fixes PR5854 and PR4515. llvm-svn: 95031
* In C++, an initializer on a variable doesn't necessarily mean it's the ↵Sebastian Redl2010-02-013-9/+8
| | | | | | definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
* Use early return as suggested by Cristian Draghici.Ted Kremenek2010-02-011-12/+9
| | | | llvm-svn: 94994
* Format string checking: selectively ignore implicit casts to 'int'Ted Kremenek2010-02-011-6/+17
| | | | | | | | when checking if the format specifier matches the type of the data argument and the length modifier indicates the data type is 'char' or 'short'. llvm-svn: 94992
* Note that an overload candidate was non-viable because template argumentJohn McCall2010-02-012-9/+77
| | | | | | | deduction failed. Right now there's a very vague diagnostic for most cases and a good diagnostic for incomplete deduction. llvm-svn: 94988
* Fix for PR5185. C99 [*] VLA notation should be disallowed in function ↵Sam Weinig2010-02-011-0/+14
| | | | | | definitions. llvm-svn: 94972
* Access checking for implicit user-defined conversions.John McCall2010-02-014-17/+60
| | | | llvm-svn: 94971
* Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the ↵Sebastian Redl2010-01-313-37/+15
| | | | | | logic for when a variable declaration is a (possibly tentativ) definition. Add a few functions building on this, and shift C tentative definition handling over to this new functionality. This shift also kills the Sema::TentativeDefinitions map and instead simply stores all declarations in the renamed list. The correct handling for multiple tentative definitions is instead shifted to the final walk of the list. llvm-svn: 94968
* Switch expressions like T() and T(1,2) over to new-style initialization. I'mEli Friedman2010-01-313-139/+12
| | | | | | | not quite sure what we want to do about the AST representation; comments welcome. llvm-svn: 94967
* Start creating CXXBindReferenceExpr nodes when binding complex types to ↵Anders Carlsson2010-01-311-3/+19
| | | | | | references. llvm-svn: 94964
* Diagnose binding a non-const reference to a vector element.Anders Carlsson2010-01-312-3/+10
| | | | llvm-svn: 94963
* Return early, reduce indentation, and simplify line breaks. No functionalityChandler Carruth2010-01-311-65/+64
| | | | | | | | | change. PS: I'm under the impression formatting-only patches don't need pre-commit review, but feel free to yell at me if I should post these first! =D llvm-svn: 94956
* 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
* Fix PR6159 and several other problems with value-dependent non-type templateChandler Carruth2010-01-311-9/+31
| | | | | | | | | | | | | arguments. This both prevents meaningless checks on these arguments and ensures that they are represented as an expression by the instantiation. Cleaned up and added standard text to the relevant test case. Also started adding tests for *rejected* cases. At least one FIXME here where (I think) we allow something we shouldn't. More to come in the area of rejecting crazy arguments with decent diagnostics. Suggestions welcome for still better diagnostics on these errors! llvm-svn: 94953
* Rework base and member initialization in constructors, with severalDouglas Gregor2010-01-315-249/+385
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (necessarily simultaneous) changes: - CXXBaseOrMemberInitializer now contains only a single initializer rather than a set of initialiation arguments + a constructor. The single initializer covers all aspects of initialization, including constructor calls as necessary but also cleanup of temporaries created by the initializer (which we never handled before!). - Rework + simplify code generation for CXXBaseOrMemberInitializers, since we can now just emit the initializer as an initializer. - Switched base and member initialization over to the new initialization code (InitializationSequence), so that it - Improved diagnostics for the new initialization code when initializing bases and members, to match the diagnostics produced by the previous (special-purpose) code. - Simplify the representation of type-checked constructor initializers in templates; instead of keeping the fully-type-checked AST, which is rather hard to undo at template instantiation time, throw away the type-checked AST and store the raw expressions in the AST. This simplifies instantiation, but loses a little but of information in the AST. - When type-checking implicit base or member initializers within a dependent context, don't add the generated initializers into the AST, because they'll look like they were explicit. - Record in CXXConstructExpr when the constructor call is to initialize a base class, so that CodeGen does not have to infer it from context. This ensures that we call the right kind of constructor. There are also a few "opportunity" fixes here that were needed to not regress, for example: - Diagnose default-initialization of a const-qualified class that does not have a user-declared default constructor. We had this diagnostic specifically for bases and members, but missed it for variables. That's fixed now. - When defining the implicit constructors, destructor, and copy-assignment operator, set the CurContext to that constructor when we're defining the body. llvm-svn: 94952
* Handle instantiation of templates with non-type arguments expressed with anChandler Carruth2010-01-311-0/+16
| | | | | | | explicit '&' by introducing an address-of operator prior to checking the argument's type. llvm-svn: 94947
* 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-303-8/+16
| | | | llvm-svn: 94925
* More asm cleanup.Anders Carlsson2010-01-301-1/+7
| | | | llvm-svn: 94920
* 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
* Eliminate yet another old-school PerformCopyInitialization.Anders Carlsson2010-01-301-1/+3
| | | | llvm-svn: 94874
* Add basic type checking of format string conversion specifiers and their ↵Ted Kremenek2010-01-301-6/+63
| | | | | | arguments. Thanks to Cristian Draghici for his help with this patch! llvm-svn: 94864
* Be a little more permissive than C99: allow 'unsigned' to be used forTed Kremenek2010-01-291-2/+6
| | | | | | | the field width and precision of a format specifier instead of just 'int'. This matches GCC, and fixes <rdar://problem/6079850>. llvm-svn: 94856
* Switch Sema over to using the new implementation of format stringTed Kremenek2010-01-292-275/+39
| | | | | | | | | checking. It passes all existing tests, and the diagnostics have been refined to provide better range information (we now highlight individual format specifiers) and more precise wording in the diagnostics. llvm-svn: 94837
* Fix reference-binding when we have a reference to const volatile type;Douglas Gregor2010-01-292-1/+3
| | | | | | | previously, we were allowing this to bind to a temporary. Now, we don't; add test-cases and improve diagnostics. llvm-svn: 94831
* Fix reference binding of const lvalue references to bit-fields, whichDouglas Gregor2010-01-292-3/+207
| | | | | | | | | | | | | | | | | requires a temporary. Previously, we were building an initialization sequence that bound to the bit-field as if it were a real lvalue. Note that we previously (and still) diagnose binding of non-const references to bit-fields, as we should. There's no real way to test that this code is correct, since reference binding does not *currently* have any representation in the AST. This fix should make it easier for that to happen, so I've verified this fix with... Added InitializationSequence::dump(), to print an initialization sequence for debugging purposes. llvm-svn: 94826
* And yet another call.Anders Carlsson2010-01-291-2/+8
| | | | llvm-svn: 94824
* Another PerformCopyInitialization call bites the dust.Anders Carlsson2010-01-291-4/+12
| | | | llvm-svn: 94823
* Get rid of another old PerformCopyInitialization call.Anders Carlsson2010-01-291-4/+12
| | | | llvm-svn: 94819
* When naming a function template via a qualified-id (or any other wayDouglas Gregor2010-01-291-1/+1
| | | | | | | | that ADL is suppressed), we need to build an UnresolvedLookupExpr. Fixes PR6063, which was hitting Boost headers pretty hard. llvm-svn: 94814
* Alternate format string checking: issue warnings for incomplete format ↵Ted Kremenek2010-01-291-12/+19
| | | | | | | | | | specifiers. In addition, move ParseFormatString() and FormatStringHandler() from the clang::analyze_printf to the clang namespace. Hopefully this will resolve some link errors on Linux. llvm-svn: 94794
* Simplify InitListChecker::CheckReferenceTypeAnders Carlsson2010-01-291-11/+10
| | | | llvm-svn: 94793
* Alternate format string checking: issue a warning for invalid conversion ↵Ted Kremenek2010-01-291-8/+27
| | | | | | specifiers. llvm-svn: 94792
* Add an CXXBindReferenceExpr (not used just yet).Anders Carlsson2010-01-291-0/+10
| | | | llvm-svn: 94791
* Alternate format string checking: check for excess data arguments.Ted Kremenek2010-01-291-0/+11
| | | | llvm-svn: 94787
OpenPOWER on IntegriCloud