Commit Graph

3181 Commits

Author SHA1 Message Date
Fariborz Jahanian f82ec6dd2f Better diagnostic on deleted constructor when no
initializer name is available.

llvm-svn: 89885
2009-11-25 21:53:11 +00:00
Douglas Gregor 5c80a27ba2 Implement support for default template arguments of function templates.
llvm-svn: 89874
2009-11-25 18:55:14 +00:00
Douglas Gregor ed5731f68a Diagnose ill-formed uses of default template arguments in
function templates (in C++98), friend function templates, and
out-of-line definitions of members of class templates.

Also handles merging of default template arguments from previous
declarations of function templates, for C++0x. However, we don't yet
make use of those default template arguments.

llvm-svn: 89872
2009-11-25 17:50:39 +00:00
Douglas Gregor 7fdcbaf291 Fix a thinko where we weren't always performing unary conversions on the switch condition, fixing PR5612
llvm-svn: 89864
2009-11-25 15:17:36 +00:00
Douglas Gregor 3ff3af4ff9 When the condition of a switch() statement is semantically invalid,
still parse the body of the switch to try to avoid spurious
diagnostics. Fixes PR5606.

llvm-svn: 89847
2009-11-25 06:20:02 +00:00
Douglas Gregor 0681a35f5f Don't crash when we re-use a template specialization node for an explicit instantiation. lib/Support/CommandLine.cpp is our test case
llvm-svn: 89845
2009-11-25 06:01:46 +00:00
Douglas Gregor 110755548b Refactor ActOnFinishSwitchStmt to simplify it further
llvm-svn: 89843
2009-11-25 05:02:21 +00:00
Douglas Gregor 852d53e712 Refactor ActOnFinishSwitchStmt to simplify and reduce nesting
llvm-svn: 89842
2009-11-25 04:55:54 +00:00
Alexis Hunt 54a0254887 Parse C++ member check attributes - base_check, hiding, and override.
The attributes are currently ignored.

llvm-svn: 89837
2009-11-25 04:20:27 +00:00
Fariborz Jahanian 906d871e6c Some fancy footwork to move the decision on how
to build casted expression-list AST to Sema.

llvm-svn: 89827
2009-11-25 01:26:41 +00:00
Douglas Gregor 7bab5ff8e7 Eliminate CXXConditionDeclExpr with extreme prejudice.
All statements that involve conditions can now hold on to a separate
condition declaration (a VarDecl), and will use a DeclRefExpr
referring to that VarDecl for the condition expression. ForStmts now
have such a VarDecl (I'd missed those in previous commits).

Also, since this change reworks the Action interface for
if/while/switch/for, use FullExprArg for the full expressions in those
expressions, to ensure that we're emitting

Note that we are (still) not generating the right cleanups for
condition variables in for statements. That will be a follow-on
commit.

llvm-svn: 89817
2009-11-25 00:27:52 +00:00
Sebastian Redl d6f7850117 Have the parser tell sema whether a member declaration is a function definition. This allows sema to not emit spurious diagnostics in some invalid code.
llvm-svn: 89816
2009-11-24 23:38:44 +00:00
Fariborz Jahanian 4fa66ce244 Refactor argument collection of constructor calls using
the common routine.

llvm-svn: 89802
2009-11-24 21:37:28 +00:00
Douglas Gregor 680f861d74 Clean up the AST for while loops and fix several problems with
cleanups for while loops: 

1) Make sure that we destroy the condition variable of a while statement each time through the loop for, e.g.,

   while (shared_ptr<WorkInt> p = getWorkItem()) {
         // ...
         }

2) Make sure that we always enter a new cleanup scope for the body of the while loop, even when there is no compound expression, e.g.,

   while (blah)
     RAIIObject raii(blah+1);

llvm-svn: 89800
2009-11-24 21:15:44 +00:00
John McCall 45b1a47a9c Fix some major problems dealing with dependently-qualified names in implicit
member-reference contexts.  Fixes some clang-on-clang asserts.

llvm-svn: 89796
2009-11-24 20:33:45 +00:00
Fariborz Jahanian 6f2d25e441 More cleanup of argument call collection.
llvm-svn: 89789
2009-11-24 19:27:49 +00:00
John McCall e66edc18ae Rip out TemplateIdRefExpr and make UnresolvedLookupExpr and
DependentScopeDeclRefExpr support storing templateids.  Unite the common   
code paths between ActOnDeclarationNameExpr and ActOnTemplateIdExpr.

This gets us to a point where we don't need to store function templates in
the AST using TemplateNames, which is critical to ripping out OverloadedFunction.

Also resolves a few FIXMEs.

llvm-svn: 89785
2009-11-24 19:00:30 +00:00
Fariborz Jahanian 835026e9f1 Refactor collection of call arguments in common code.
Add support for variadic collection functions. More to do
here.

llvm-svn: 89781
2009-11-24 18:29:37 +00:00
Anders Carlsson 0b11a3ef71 GNUNullExpr is a valid sentinel even though it isn't of pointer type.
llvm-svn: 89778
2009-11-24 17:24:21 +00:00
Douglas Gregor dcf1962405 Explicitly store the condition variable within switch statements, and
make sure that this variable is destroyed when we exit the switch
statement.

llvm-svn: 89776
2009-11-24 17:07:59 +00:00
Anders Carlsson b7408b95ed Fix a crash when "instantiating" VarDecls that are neither type nor value dependent.
llvm-svn: 89774
2009-11-24 16:52:50 +00:00
Douglas Gregor 0156d1c8db Un-break instantiation of if statements with conditional variables
llvm-svn: 89767
2009-11-24 16:07:02 +00:00
Anders Carlsson 65e6d131f0 Set the template specialization kind before instantiating the function definition so that the function will have the right linkage.
llvm-svn: 89740
2009-11-24 05:34:41 +00:00
Douglas Gregor 633caca353 Explicitly track the condition variable within an "if" statement,
rather than burying it in a CXXConditionDeclExpr (that occassionally
hides behind implicit conversions). Similar changes for
switch, while, and do-while will follow, then the removal of
CXXConditionDeclExpr. This commit is the canary.

llvm-svn: 89717
2009-11-23 23:44:04 +00:00
Anders Carlsson 2e7bc11f11 Convert the && and || operands to bool using standard conversions. Fixes PR5593.
llvm-svn: 89704
2009-11-23 21:47:44 +00:00
Anders Carlsson 7fa434c2b8 Handle converting member pointers to bool.
llvm-svn: 89692
2009-11-23 20:04:44 +00:00
Fariborz Jahanian 3f21c159dc Fix a recent regression probably caused by addition of altivec-style
type-casts in the parser.

llvm-svn: 89691
2009-11-23 19:51:43 +00:00
Fariborz Jahanian 0afc555196 Make 'SEL' pointer to a builtin type and not an
objective-c pointer type. This was a serious mishap and
luckily, Ted's test caught that (and patch fixes the test case).

llvm-svn: 89680
2009-11-23 18:04:25 +00:00
Sebastian Redl 22e2e5c423 Intercept sizeof and alignof references before they get into ASTContext methods. This fixes a crash when writing sizeof(Incomplete&), and lets ASTContext's methods do the right thing for CodeGen, which fixes PR5590.
llvm-svn: 89668
2009-11-23 17:18:46 +00:00
Sebastian Redl a6602e9e2a Let using directives refer to namespace aliases. Fixes PR5479.
llvm-svn: 89657
2009-11-23 15:34:23 +00:00
Douglas Gregor 378e1923b6 Require a class type to be complete before probing its conversion
functions for a switch condition's conversion to integral or
enumeration type. 

llvm-svn: 89656
2009-11-23 13:53:21 +00:00
Douglas Gregor d0c22e0d10 Implement conversion from a switch condition with class type to an
integral or enumeration type (vi user-defined conversions). Fixes PR5518.

llvm-svn: 89655
2009-11-23 13:46:08 +00:00
Douglas Gregor 601f4f0b07 Improve type-checking of templates by distinguishing between members
of the current instantiation and members of an unknown specialization
when type-checking a qualified-if expression.

llvm-svn: 89653
2009-11-23 12:39:54 +00:00
Douglas Gregor 27381f3d93 Do not mark declarations as used when performing overload resolution. Fixes PR5541
llvm-svn: 89652
2009-11-23 12:27:39 +00:00
Douglas Gregor 65911498ef Tolerate extraneous "template<>" headers better, downgrading the
complaint to a warning and providing a helpful node in the case where
the "template<>" header is redundant because the corresponding
template-id refers to an explicit specialization. C++0x might still
change this behavior, and existing practice is all over the place on
the number of "template<>" headers actually needed.

llvm-svn: 89651
2009-11-23 12:11:45 +00:00
Douglas Gregor ed6c744091 Centralize and complete the computation of value- and type-dependence for DeclRefExprs
llvm-svn: 89649
2009-11-23 11:41:28 +00:00
John McCall 6b51f28e82 Encapsulate "an array of TemplateArgumentLocs and two angle bracket locations" into
a new class.  Use it pervasively throughout Sema.

My fingers hurt.

llvm-svn: 89638
2009-11-23 01:53:49 +00:00
John McCall dc7b6079eb Fix LookupResult's sanity-check to handle shadow decls.
llvm-svn: 89624
2009-11-22 20:57:36 +00:00
John McCall a9ee325d71 If a C++ qualified id is followed by a postfix suffix, it is never the direct
operand of an addressof operator, and so we should not treat it as an abstract
member-pointer expression and therefore suppress the implicit member access.

This is really a well-formedness constraint on expressions:  a DeclRefExpr of
a FieldDecl or a non-static CXXMethodDecl (or template thereof, or unresolved
collection thereof) should not be allowed in an arbitrary location in the AST.
Arguably it shouldn't be allowed anywhere and we should have a different expr
node type for this.  But unfortunately we don't have a good way of enforcing
this kind of constraint right now.

llvm-svn: 89578
2009-11-22 02:49:43 +00:00
John McCall b53bbd42c8 Reorganize the intermediate BuildDeclarationNameExpr routines again.
llvm-svn: 89575
2009-11-22 01:44:31 +00:00
John McCall 283b901cf3 Consider a FunctionTemplate to be an overload all on its lonesome. Track
this information through lookup rather than rederiving it.

llvm-svn: 89570
2009-11-22 00:44:51 +00:00
Fariborz Jahanian 252ba5fb6f This patch implements objective-c's 'SEL' type as a built-in
type and fixes a long-standing code gen. crash reported in
at least two PRs and a radar. (radar 7405040 and pr5025). 
There are couple of remaining issues that I would like for
Ted. and Doug to look at:

Ted, please look at failure in Analysis/MissingDealloc.m.
I have temporarily added an expected-warning to make the
test pass. This tests has a declaration of 'SEL' type which
may not co-exist with the new changes.

Doug, please look at a FIXME in PCHWriter.cpp/PCHReader.cpp.
I think the changes which I have ifdef'ed out are correct. They
need be considered for in a few Indexer/PCH test cases.

llvm-svn: 89561
2009-11-21 19:53:08 +00:00
John McCall 4b1f16e6f8 Overload resolution doesn't decide whether to do ADL or not anymore; stopping
threading that state.

llvm-svn: 89557
2009-11-21 09:38:42 +00:00
John McCall d14a86427f "Incremental" progress on using expressions, by which I mean totally ripping
into pretty much everything about overload resolution in order to wean
BuildDeclarationNameExpr off LookupResult::getAsSingleDecl().  Replace  
UnresolvedFunctionNameExpr with UnresolvedLookupExpr, which generalizes the
idea of a non-member lookup that we haven't totally resolved yet, whether by
overloading, argument-dependent lookup, or (eventually) the presence of   
a function template in the lookup results.  

Incidentally fixes a problem with argument-dependent lookup where we were 
still performing ADL even when the lookup results contained something from
a block scope.  

Incidentally improves a diagnostic when using an ObjC ivar from a class method.
This just fell out from rewriting BuildDeclarationNameExpr's interaction with
lookup, and I'm too apathetic to break it out.

The only remaining uses of OverloadedFunctionDecl that I know of are in
TemplateName and MemberExpr.

llvm-svn: 89544
2009-11-21 08:51:07 +00:00
Alexis Hunt 96d5c76498 Added rudimentary C++0x attribute support.
The following attributes are currently supported in C++0x attribute
lists (and in GNU ones as well):
 - align() - semantics believed to be conformant to n3000, except for
   redeclarations and what entities it may apply to
 - final - semantics believed to be conformant to CWG issue 817's proposed
   wording, except for redeclarations
 - noreturn - semantics believed to be conformant to n3000, except for
   redeclarations
 - carries_dependency - currently ignored (this is an optimization hint)

llvm-svn: 89543
2009-11-21 08:43:09 +00:00
Douglas Gregor ade9bcd72e Cope with extraneous "template" keyword when providing an out-of-line
definition of a member template (or a member thereof). Fixes PR5566.

llvm-svn: 89512
2009-11-20 23:39:24 +00:00
Douglas Gregor a25d65d1b6 Implement C++ [basic.lookup.classref]p3, which states how the type
name 'T' is looked up in the expression

  t.~T()

Previously, we weren't looking into the type of "t", and therefore
would fail when T actually referred to an injected-class-name. Fixes
PR5530.

llvm-svn: 89493
2009-11-20 22:03:38 +00:00
Douglas Gregor e4f764f013 When checking the base object of a member access expression (b.foo,
b->foo), don't look through pointers unless we have an -> operator.

llvm-svn: 89480
2009-11-20 19:58:21 +00:00
Douglas Gregor 51c538bee4 Teach FixOverloadedFunctionReference to build new expression ASTs rather
than tweaking existing ASTs, since we were (*gasp*) stomping on ASTs
within templates. I'm glad we found this little stick of TNT early...

llvm-svn: 89475
2009-11-20 19:42:02 +00:00
Douglas Gregor 3153da7154 Don't build an explicit conversion to a reference type
llvm-svn: 89441
2009-11-20 02:31:03 +00:00