summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* A dependent initializer with zero arguments should return a NULLDouglas Gregor2010-02-052-1/+5
| | | | | | | initializer (for no initialization) rather than a ParenListExpr with zero arguments in it. llvm-svn: 95382
* Default function arguments for function template specializationsDouglas Gregor2010-02-053-5/+16
| | | | | | | always come from the primary template, so gather the instantiation template arguments from the primary template. llvm-svn: 95380
* Teach C++ name lookup that it's okay to look in a scope without aDouglas Gregor2010-02-051-8/+10
| | | | | | | | context. This happens fairly rarely (which is why we got away with this bug). Fixes PR6184, where we skipped over the template parameter scope while tentatively parsing. llvm-svn: 95376
* A function declarator with a non-identifier name in an anonymous classDouglas Gregor2010-02-052-2/+3
| | | | | | is a constructor for that class, right? Fixes PR6238. llvm-svn: 95367
* When adding ADL candidates for overloadedDouglas Gregor2010-02-051-1/+1
| | | | | | | post-increment/post-decrement operators, be sure to consider both arguments. Fixes PR6237. llvm-svn: 95361
* When determining whether a scope specifier is complete, consider aDouglas Gregor2010-02-051-0/+4
| | | | | | dependent DeclContext to be "complete". Fixes PR6236. llvm-svn: 95359
* First stage of adding AltiVec supportJohn Thompson2010-02-052-5/+14
| | | | llvm-svn: 95335
* Fix a crash with ill-formed code within a method in an ill-formedDouglas Gregor2010-02-041-3/+6
| | | | | | | category implementation, which showed up during (attempted) typo correction. Fixes <rdar://problem/7605289>. llvm-svn: 95334
* Extract a common structure for holding information about the definitionJohn McCall2010-02-045-21/+54
| | | | | | | | of a C++ record. Exposed a lot of problems where various routines were silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order) when presented with a non-definition. Also cuts down on memory usage. llvm-svn: 95330
* Move ParseFormatString() and FormatStringHandler back into the ↵Ted Kremenek2010-02-041-8/+9
| | | | | | analyze_printf namespace. llvm-svn: 95324
* When substituting the template argument for a pointer non-typeDouglas Gregor2010-02-041-10/+41
| | | | | | | | | template parameter, perform array/function decay (if needed), take the address of the argument (if needed), perform qualification conversions (if needed), and remove any top-level cv-qualifiers from the resulting expression. Fixes PR6226. llvm-svn: 95309
* Allow calling convention attributes to apply to types. Patch by Chip Davis!John McCall2010-02-044-8/+130
| | | | llvm-svn: 95291
* Patch to allow reinterpret_cast on objective-c pointers.Fariborz Jahanian2010-02-031-7/+28
| | | | | | (partial fix for radar 7591784). llvm-svn: 95245
* Revert "Numerous changes to selector handling:", this breaks a whole bunch ofDaniel Dunbar2010-02-031-14/+1
| | | | | | working code, for no apparent reason. llvm-svn: 95244
* Top-level const changes do not make a qualification conversion. Fixes PR6089.Sebastian Redl2010-02-031-1/+1
| | | | llvm-svn: 95239
* Fix for PR6220: compute the correct type for multicharacter literals.Eli Friedman2010-02-031-0/+2
| | | | llvm-svn: 95228
* Revert the new reference binding code; I came up with a way simpler solution ↵Anders Carlsson2010-02-031-17/+2
| | | | | | for the reference binding bug that is preventing self-hosting. llvm-svn: 95223
* Teach the allocation function overload handling to deal with templates, andChandler Carruth2010-02-031-12/+21
| | | | | | | | | | | prevent a crash on templates when looking for an existing declaration of the predefined global operators. This fixes PR5918. Added an easy test case for the overload handling, but testing the crash is a bit trickier. Created a new test that can use multiple runs with a define to trigger which test case is used so we can test this type of issue. llvm-svn: 95220
* Fix PR6149 by looking at the qualifiers on the referred to type for non-typeChandler Carruth2010-02-031-2/+3
| | | | | | | reference template arguments. Adds test cases for the cv-quals of reference arguments. llvm-svn: 95217
* When a function or variable somehow depends on a type or declarationDouglas Gregor2010-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is in an anonymous namespace, give that function or variable internal linkage. This change models an oddity of the C++ standard, where names declared in an anonymous namespace have external linkage but, because anonymous namespace are really "uniquely-named" namespaces, the names cannot be referenced from other translation units. That means that they have external linkage for semantic analysis, but the only sensible implementation for code generation is to give them internal linkage. We now model this notion via the UniqueExternalLinkage linkage type. There are several changes here: - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage when the declaration is in an anonymous namespace. - Added Type::getLinkage() to determine the linkage of a type, which is defined as the minimum linkage of the types (when we're dealing with a compound type that is not a struct/class/union). - Extended NamedDecl::getLinkage() to consider the linkage of the template arguments and template parameters of function template specializations and class template specializations. - Taught code generation to rely on NamedDecl::getLinkage() when determining the linkage of variables and functions, also considering the linkage of the types of those variables and functions (C++ only). Map UniqueExternalLinkage to internal linkage, taking out the explicit checks for isInAnonymousNamespace(). This fixes much of PR5792, which, as discovered by Anders Carlsson, is actually the reason behind the pass-manager assertion that causes the majority of clang-on-clang regression test failures. With this fix, Clang-built-Clang+LLVM passes 88% of its regression tests (up from 67%). The specific numbers are: LLVM: Expected Passes : 4006 Expected Failures : 32 Unsupported Tests : 40 Unexpected Failures: 736 Clang: Expected Passes : 1903 Expected Failures : 14 Unexpected Failures: 75 Overall: Expected Passes : 5909 Expected Failures : 46 Unsupported Tests : 40 Unexpected Failures: 811 Still to do: - Improve testing - Check whether we should allow the presence of types with InternalLinkage (in addition to UniqueExternalLinkage) given variables/functions internal linkage in C++, as mentioned in PR5792. - Determine how expensive the getLinkage() calls are in practice; consider caching the result in NamedDecl. - Assess the feasibility of Chris's idea in comment #1 of PR5792. llvm-svn: 95216
* Look through CXXExprWithTemporaries when digging out the originalDouglas Gregor2010-02-031-0/+3
| | | | | | initializer. Grrr.... llvm-svn: 95211
* 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
* Provide a real fix for PR6199, reverting the old workaround. Here, weDouglas Gregor2010-02-031-0/+6
| | | | | | | | realize that CXXConstructExpr is always implicit, so we should just return its argument (if there is only one) rather than directly invoking the constructor. llvm-svn: 95192
* Remove the SmallVector from CXXTryStmt.Sam Weinig2010-02-031-1/+1
| | | | llvm-svn: 95190
* Numerous changes to selector handling:David Chisnall2010-02-031-1/+14
| | | | | | | | | | | | | | | | | | | | | | | - Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon. This also simplifies the code generated by the GNU runtime a bit. - Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant. - Recognise @selector() expressions as valid static initialisers (as GCC does). - Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants. These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load. - Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector. This is needed for generating typed selectors from @selector() expressions (as GCC does). Ideally, this information should be stored in the Selector, but that would be an invasive change. We should eventually add checks for common uses of @selector() expressions. Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this: - (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL) withObject: (id)object; Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature. We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes. - Made @selector() expressions emit type info if available and the runtime supports it. Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac. This currently just assert()s. llvm-svn: 95189
* 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
OpenPOWER on IntegriCloud