Граф коммитов

252 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor b7a86f5c5f When we encounter a derived-to-base conversion when performing an
implicit conversion sequence, check the validity of this conversion
and then perform it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 01:02:41 +00:00
Fariborz Jahanian 4c0cea2d9e Minor cleanup of my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86209 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 00:55:14 +00:00
Fariborz Jahanian 966256afd4 This patch implements Sema for clause 13.3.3.1p4.
It has to do with vararg constructors used as conversion
functions. Code gen needs work. This is WIP.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86207 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06 00:23:08 +00:00
John McCall b13c87f0c9 Implement the conditional-operator part of -Wsign-compare. Turn
DiagnoseSignCompare into Sema::CheckSignCompare and call it from more places.

Add some enumerator tests.  These seem to expose some oddities in the
types we're converting C++ enumerators to;  in particular, they're converting
to unsigned before int, which seems to contradict 4.5 [conv.prom] p2.

Note to self: stop baiting Doug in my commit messages.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86128 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 09:23:39 +00:00
Douglas Gregor 43d8863df9 When starting a C++ member access expression, make sure to compute the
type of the object even when it is dependent. Specifically, this makes
sure that we get the right type for "this->", which is important when
performing name lookup into this scope to determine whether an
identifier or operator-function-id is a template name.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86060 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04 22:49:18 +00:00
Fariborz Jahanian 6f26920dfa Remove previous patch for pr5296 due to further clarification
of value-initialization and trivial constructors.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85935 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 20:38:53 +00:00
Douglas Gregor 2d1c214141 Replace the code that parses member access expressions after "." or
"->" with a use of ParseUnqualifiedId. Collapse
ActOnMemberReferenceExpr, ActOnDestructorReferenceExpr (both of them),
ActOnOverloadedOperatorReferenceExpr,
ActOnConversionOperatorReferenceExpr, and
ActOnMemberTemplateIdReferenceExpr into a single, new action
ActOnMemberAccessExpr that does the same thing more cleanly (and can
keep more source-location information).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85930 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 19:44:04 +00:00
Douglas Gregor 02a24ee67c Use ParseUnqualifiedId when parsing id-expressions. This eliminates
yet another copy of the unqualified-id parsing code.

Also, use UnqualifiedId to simplify the Action interface for building
id-expressions. ActOnIdentifierExpr, ActOnCXXOperatorFunctionIdExpr,
ActOnCXXConversionFunctionExpr, and ActOnTemplateIdExpr have all been
removed in favor of the new ActOnIdExpression action.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85904 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 16:56:39 +00:00
Douglas Gregor 7a34314290 Within a template, qualified name lookup can refer to a non-dependent type
that is not known to be a base class at template definition time due
to some dependent base class. Treat qualified name lookup that refers
to a non-static data member or function as implicit class member
access when the "this" type would be dependent.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85718 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-01 17:08:18 +00:00
John McCall 833ca991c1 Track source information for template arguments and template specialization
types.  Preserve it through template instantiation.  Preserve it through PCH,
although TSTs themselves aren't serializable, so that's pretty much meaningless.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 08:12:44 +00:00
Fariborz Jahanian 6c813e1cb7 Generate constructor for value-initialization cases, even if the
implementation technique doesn't call the constructor at that point.
DR302. Fixes pr5296.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85249 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 16:51:19 +00:00
Fariborz Jahanian ef78ac6013 Add 'fixit' hint on mis-use of pointer-to-member
binary operators.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85153 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 20:45:27 +00:00
Sebastian Redl 8ce35b095e Remove the Skip parameter from GetTypeForDeclarator and dependents. Take the opportunity to improve an error message and fix PR4498.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85068 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-25 21:45:37 +00:00
Douglas Gregor 3eefb1c4bd Fix overload resolution when calling a member template or taking the
address of a member template when explicit template arguments are
provided.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-24 04:59:53 +00:00
Fariborz Jahanian f071e9b173 Diagnose misuse of '.*' and '->*' operators during parse
instead of crashing in code gen.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84968 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 21:01:39 +00:00
Fariborz Jahanian 7a1f4cc8d5 Fixed a code gen bug (by fixing the AST) involving user-defined
pointer-to-member type conversion follwed by a pointer-to-member
standard conversion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84955 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-23 18:08:22 +00:00
Douglas Gregor e961afbf3f Refactor our handling of implicit member reference expressions to get most of the logic out of BuildDeclarationNameExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 07:08:30 +00:00
Douglas Gregor 573d9c3252 Don't (directly) call RequireCompleteType with an invalid source location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 23:19:44 +00:00
Anders Carlsson 96ad5337a4 Change FixOverloadedFunctionReference to return a (possibly new) expression. Substitute TemplateIdRefExprs with DeclRefExprs. Doug, plz review :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84763 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 17:16:23 +00:00
Eli Friedman 73c39abdbb Remove default argument for ImpCastExprToType. Add appropriate argument
to all callers.  Switch a few other users of CK_Unknown to proper cast 
kinds.

Note that there are still some situations where we end up with 
CK_Unknown; they're pretty easy to find with grep. There 
are still a few missing conversion kinds, specifically 
pointer/int/float->bool and the various combinations of real/complex 
float/int->real/complex float/int.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84623 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 08:27:19 +00:00
Douglas Gregor dd62b15665 Parse a simple-template-id following a '~' when calling a destructor, e.g.,
t->~T<A0, A1>()

Fixes PR5213.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84545 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 22:04:39 +00:00
Anders Carlsson 4fa26848ac When building a cast argument, make sure to bind the result to a temporary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84448 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 21:20:14 +00:00
Douglas Gregor 089407be3f When type-checking a C++ "new" expression, don't type-check the actual
initialization if any of the constructor/initialization arguments are
type-dependent. Fixes PR5224.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84365 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 21:40:42 +00:00
Sebastian Redl 759986e859 Don't add implicit casts of explicit address-taking of overloaded functions.
Taking the address of an overloaded function with an explicit address-of operator wrapped the operator in an implicit cast that added yet another pointer level, leaving us with a corrupted AST, which crashed CodeGen in the test case I've added. Fix this by making FixOverloadedFunctionReference return whether there was an address-of operator and not adding the implicit cast in that case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84362 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 20:50:27 +00:00
Fariborz Jahanian 93034ca3d0 Implement derived-to-base AST/code gen. There is a
FIXME in CGCXX.cpp that I would like Anders to
take a look at.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-16 19:20:59 +00:00
Anders Carlsson de699e5510 The operator loc points to the operator, not the function decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84048 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 22:55:59 +00:00
Anders Carlsson 15ea378083 Check the return type of binary operators and the arrow operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84043 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-13 22:43:21 +00:00
Sebastian Redl dced226e37 Test exception spec compatibility on return type and parameters.
Along the way, use RequireCompleteType when testing exception spec types.
Separate all the ugly spec stuff into its own file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83764 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-11 09:03:14 +00:00
Sebastian Redl 2c7588f126 Implement the core checking for compatible exception specifications in assignment and initialization.
The exception specification of the assignee must be the same or a subset of the target. In addition, exception specifications on arguments and return types must be equivalent, but this is not implemented yet.
This currently produces two diagnostics for every invalid assignment/initialization, due to the diagnostic produced outside PerformImplicitConversion, e.g. in CheckSingleInitializer. I don't know how to suppress this; in any case I think it is the wrong place for a diagnostic, since there are other diagnostics produced inside the function. So I'm leaving it as it is for the moment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83710 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-10 12:04:10 +00:00
John McCall f36e02d4af Refactor the LookupResult API to simplify most common operations. Require users to
pass a LookupResult reference to lookup routines.  Call out uses which assume a single
result.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83674 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-09 21:13:30 +00:00
Douglas Gregor a8f32e0965 Refactor the code that walks a C++ inheritance hierarchy, searching
for bases, members, overridden virtual methods, etc. The operations
isDerivedFrom and lookupInBases are now provided by CXXRecordDecl,
rather than by Sema, so that CodeGen and other clients can use them
directly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-06 17:59:45 +00:00
Fariborz Jahanian 7a8233a691 Note location of operators caused the circularity.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83153 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-30 17:46:20 +00:00
John McCall 432887fadd Spare the processors of those poor wretches who have no choice but to write
unbounded chains of operator-> delegations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83134 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-30 01:30:54 +00:00
John McCall c4e8321deb Detect operator-> chains of arbitrary length. Use a terrible data structure
to strike fear into the hearts of CPUs everywhere.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83133 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-30 01:01:30 +00:00
Fariborz Jahanian 4a4e345a8b self-referecing operator '->' member function was causing
infinit recursion. This patch fixes it. [13.3.1.2]-p2



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83124 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-30 00:19:41 +00:00
Douglas Gregor 5d64e5b6bc Find operators new/delete in base classes. FIXME -= 2;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83119 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-30 00:03:47 +00:00
Douglas Gregor 1070c9f7ac The C++ delete expression strips cv-qualifiers from the pointed-to type. My previous fix eliminated this behavior, so bring it back again.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83113 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-29 21:38:53 +00:00
Douglas Gregor 9091656e42 Handle C++ delete expressions when the overloaded delete operator is a
"usual deallocation function" with two arguments. CodeGen will have to
handle this case specifically, since the value for the second argument
(the size of the allocated object) may have to be computed at run
time.

Fixes the Sema part of PR4782.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83080 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-29 18:16:17 +00:00
Fariborz Jahanian b740023955 Define and use a helper method to call a type conversion
function.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-28 23:23:40 +00:00
Fariborz Jahanian b3c477415f Refixed pr5050 per Anders comment. Test case enhanced
per Doug's comment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82791 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 18:59:21 +00:00
Fariborz Jahanian 7498e50aea Fix the AST tree so ir-gen can do the conversion via copy construction.
Fixed pr5050.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82783 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 18:11:25 +00:00
Douglas Gregor ce94049b69 Fix checking for a null pointer constant when the expression itself is
value-dependent. Audit (and fixed) all calls to
Expr::isNullPointerConstant() to provide the correct behavior with
value-dependent expressions. Fixes PR5041 and a crash in libstdc++
<locale>.

In the same vein, properly compute value- and type-dependence for
ChooseExpr. Fixes PR4996.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82748 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-25 04:25:58 +00:00
John McCall 0953e767ff Refactor the representation of qualifiers to bring ExtQualType out of the
Type hierarchy.  Demote 'volatile' to extended-qualifier status.  Audit our
use of qualifiers and fix a few places that weren't dealing with qualifiers
quite right;  many more remain.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82705 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 19:53:00 +00:00
Douglas Gregor 739d828314 Improve diagnostic location information when checking the initialization of a reference
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82666 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 23:04:10 +00:00
Fariborz Jahanian 51bebc83e7 This patch addresses a few issues related to 8.5.3 [dcl.init.ref]
It uses a recent API to find inherited conversion functions to do
the initializer to reference lvalue conversion (and removes a FIXME).
It issues the ambiguity diagnostics when multiple conversions are found.
WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82649 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 20:55:32 +00:00
Anders Carlsson ac18b2e3af Cast the array size expr to a size_t
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82594 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 00:37:25 +00:00
John McCall 183700f494 Change all the Type::getAsFoo() methods to specializations of Type::getAs().
Several of the existing methods were identical to their respective
specializations, and so have been removed entirely.  Several more 'leaf'
optimizations were introduced.

The getAsFoo() methods which imposed extra conditions, like
getAsObjCInterfacePointerType(), have been left in place.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 23:43:11 +00:00
Douglas Gregor 7adb10fa31 When implicitly declaring operators new, new[], delete, and delete[],
give them the appropriate exception specifications. This,
unfortunately, requires us to maintain and/or implicitly generate
handles to namespace "std" and the class "std::bad_alloc". However,
every other approach I've come up with was more hackish, and this
standard requirement itself is quite the hack.

Fixes PR4829.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81939 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 22:30:29 +00:00
Fariborz Jahanian 8b915e7048 1) don't do overload resolution in selecting conversion
to pointer function for delete expression. 2)
Treat type conversion function and its 'const' version
as identical in building the visible conversion list.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81930 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 22:15:23 +00:00
Fariborz Jahanian f652793d4d Perform overload resolution when selecting a pointer conversion
function for delete of a class expression and issue
good diagnostic when result is ambiguous.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81870 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 17:21:47 +00:00