Commit Graph

6522 Commits

Author SHA1 Message Date
Douglas Gregor f98d9b60db Improve name lookup for and template instantiation of declaration
references. There are several smallish fixes here:

  - Make sure we look through template parameter scope when
    determining whether we're parsing a nested class (or nested class
    *template*). This makes sure that we delay parsing the bodies of
    inline member functions until after we're out of the outermost
    class (template) scope.
  - Since the bodies of member functions are always parsed
    "out-of-line", even when they were declared in-line, teach
    unqualified name lookup to look into the (semantic) parents.
  - Use the new InstantiateDeclRef to handle the instantiation of a
    reference to a declaration (in DeclRefExpr), which drastically
    simplifies template instantiation for DeclRefExprs.
  - When we're instantiating a ParmVarDecl, it must be in the current
    instantiation scope, so only look there.

Also, remove the #if 0's and FIXME's from the dynarray example, which
now compiles and executes thanks to Anders and Eli.

llvm-svn: 72481
2009-05-27 17:07:49 +00:00
Anders Carlsson ddcbfe7b53 IRgen support for calls to functions that return references to aggregate exressions.
llvm-svn: 72479
2009-05-27 16:45:02 +00:00
Anders Carlsson 5063613a3b Fix another test case.
llvm-svn: 72478
2009-05-27 16:38:58 +00:00
Anders Carlsson d48a008b46 Relax an assert to an if check.
llvm-svn: 72477
2009-05-27 16:28:34 +00:00
Steve Naroff 4fc95aa0d4 Convert ObjC qualified type clients over to using iterators.
This allows me to remove some API that I don't want to carry over to ObjCObjectPointerType.

No functionality change.

llvm-svn: 72475
2009-05-27 16:21:00 +00:00
Anders Carlsson 98cee2fde0 Create CXXConstructExprs when constructing via copy initialization.
llvm-svn: 72474
2009-05-27 16:10:08 +00:00
Eli Friedman 751aa72b72 Fix up constant expression handling to deal with the address
of a reference correctly.

llvm-svn: 72463
2009-05-27 06:04:58 +00:00
Eli Friedman 55422ad068 Add IRGen support for local variables of reference type.
llvm-svn: 72462
2009-05-27 05:39:06 +00:00
Douglas Gregor 5178331379 Initial stab at a generalized operation for determining the
instantiation of a declaration from the template version (or version
that lives in a template) and a given set of template arguments. This
needs much, much more testing, but it suffices for simple examples
like

  typedef T* iterator;
  iterator begin();

llvm-svn: 72461
2009-05-27 05:35:12 +00:00
Douglas Gregor 2517f334b4 Don't drop the computed implicit conversions when building a call to
overloaded operator[] or overloaded postfix unary operator (++,
--). Thanks to Eli for finding this bug!

llvm-svn: 72460
2009-05-27 05:00:47 +00:00
Eli Friedman b909bf4937 Add IRGen support for return statements in functions with reference
type.

llvm-svn: 72459
2009-05-27 04:56:12 +00:00
Anders Carlsson 4034a95dc8 Handle operator call expressions where the callee is a member function.
llvm-svn: 72458
2009-05-27 04:18:27 +00:00
Anders Carlsson d8b7ae205e Functions that return references can be rvalues as well.
llvm-svn: 72457
2009-05-27 03:37:57 +00:00
Anders Carlsson 4ae70ff9a3 Add support for emitting calls to functions that return references (as lvalues only for now)
llvm-svn: 72449
2009-05-27 01:45:47 +00:00
Mike Stump 3e97f3b35d Fix typo. I also fixed the hard to read case differences, so that no
one else is tempted to copy the style, incorrectly.

llvm-svn: 72448
2009-05-27 01:42:21 +00:00
Anders Carlsson 3a9463bfda Rename an EmitCallExpr function to EmitCall to make it clear that it doesn't emit an expr.
llvm-svn: 72446
2009-05-27 01:22:39 +00:00
Douglas Gregor 408c619afc Template instantiation for "typeof" for both types and expressions.
llvm-svn: 72440
2009-05-26 22:09:24 +00:00
Mike Stump ec3cbfe8c6 Fixup codegen for volatile structs in the trivial cases (a a=a and a=a=a).
llvm-svn: 72439
2009-05-26 22:03:21 +00:00
Douglas Gregor 28ad4b5da1 Make sure that CodeGen sees template instantiations.
llvm-svn: 72433
2009-05-26 20:50:29 +00:00
Daniel Dunbar bee70bd1e7 Use .data() instead of &...[0].
- Just SmallVectors this time.

llvm-svn: 72432
2009-05-26 19:40:20 +00:00
Mike Stump 25306cacc6 Esnure that if we have a volatile structure as the destination, that
we actually have a destination.

llvm-svn: 72429
2009-05-26 18:57:45 +00:00
Douglas Gregor 31cf12c0a6 When evaluating a VarDecl as a constant or determining whether it is
an integral constant expression, maintain a cache of the value and the
is-an-ICE flag within the VarDecl itself. This eliminates
exponential-time behavior of the Fibonacci template metaprogram.

llvm-svn: 72428
2009-05-26 18:54:04 +00:00
Daniel Dunbar 1518b64ddc When trying to pass an argument on the stack, assume LLVM will do the right
thing for non-aggregate types.
 - Otherwise we unnecessarily pin values to the stack and currently end up
   triggering a backend bug in one case.

 - This loose cooperation with LLVM to implement the ABI is pretty ugly.

 - <rdar://problem/6918722> [irgen] clang miscompile of many pointer varargs on
   x86-64

llvm-svn: 72419
2009-05-26 16:37:37 +00:00
Anders Carlsson 09ac6f21c3 An Obj-C message send expression can never have a reference type.
llvm-svn: 72417
2009-05-26 15:22:25 +00:00
Douglas Gregor a30d046059 Simplify printing of the statistics for types.
llvm-svn: 72415
2009-05-26 14:40:08 +00:00
Eli Friedman 5cd659fd32 Fix for PR4140: Add the start of a Linux toolchain (basically, just
barely enough to get the given usage of -print-file-name working).

llvm-svn: 72412
2009-05-26 07:52:18 +00:00
Anders Carlsson 00a2759ca9 Add a new CallExpr::getCallReturnType and use it in Expr::isLvalueInternal. No intended functionality change.
llvm-svn: 72410
2009-05-26 04:57:27 +00:00
Anders Carlsson 3b70b300b0 A block that returns a reference is an lvalue.
llvm-svn: 72409
2009-05-26 02:03:20 +00:00
Eli Friedman 895771aa4b Handle the edge case of a weak function with incomplete type correctly.
Found by code inspection; I haven't seen this in real-world code.

llvm-svn: 72408
2009-05-26 01:22:57 +00:00
Eli Friedman 7ab09572c6 Extend getPreferredTypeAlign to handle _Complex double and long long
correctly.

llvm-svn: 72401
2009-05-25 21:27:19 +00:00
Eli Friedman cf7530ff43 PR4122: Tweak the ambiguity handling to handle (S())() correctly. I've
left out handling for stuff like (S())++ for the moment.

llvm-svn: 72394
2009-05-25 19:41:42 +00:00
Chris Lattner 23464b8f14 tweak non-null check to put the caret on the function, but underline the
argument.  This avoids the argument from being silenced when the argument is
the NULL macro, which is defined in a system header.  This also makes the output
a bit nicer, e.g.:

t.c:8:3: warning: null passed to a callee which requires a non-null argument
  func1(NULL, cp2, i1);
  ^     ~~~~

vs something like:

t.c:8:10: warning: argument is null where non-null is required
  func1(NULL, cp2, i1);
        ^

llvm-svn: 72393
2009-05-25 18:23:36 +00:00
Chris Lattner 83bd8281e5 Fix a couple of bugs:
1. When we accept "#garbage" in asm-with-cpp mode, change the token kind
   of the # to unknown so that the preprocessor won't try to process it as
   a real #.  This fixes a crash on the attached example
2. Fix macro definition extents processing to handle #foo at the end of a
   macro to say the definition ends with the foo, not the #.

This is a follow-on fix to r72283, and rdar://6916026

llvm-svn: 72388
2009-05-25 17:16:10 +00:00
Chris Lattner 7ce761d204 improve comment, no functionality change.
llvm-svn: 72386
2009-05-25 16:23:08 +00:00
Eli Friedman 2d49c4f98d Make sure an invalid concatentaion doesn't insert whitespace before
the RHS.  Fixes assembler-with-cpp issue reported on cfe-dev.

llvm-svn: 72370
2009-05-24 19:25:46 +00:00
Mike Stump b9f2518626 Propagate volatile for implicit property refernces.
llvm-svn: 72353
2009-05-23 23:52:31 +00:00
Mike Stump 9afc476d4a Propagate volatile around for property references.
llvm-svn: 72352
2009-05-23 23:48:13 +00:00
Mike Stump 5e9e61b8d2 Track volatile aggregate copies better. I'm hoping someone else will decide
how to get the backend to know that the operation is volatile.

llvm-svn: 72348
2009-05-23 22:29:41 +00:00
Mike Stump 332ec2ce81 Fix thinko, and implement aggregate volatile reads.
llvm-svn: 72347
2009-05-23 22:01:27 +00:00
Mike Stump 23abd46b79 More volatile fixes. Can't testcase these yet as ultimately volatile
is still ignored.

llvm-svn: 72344
2009-05-23 21:40:07 +00:00
Mike Stump ca9fc09c61 Collapse a few FIXMEs together and refactor to make fixing the code easier.
llvm-svn: 72342
2009-05-23 20:28:01 +00:00
Mike Stump 93700fc988 Add support for volatile RValues.
llvm-svn: 72341
2009-05-23 20:21:36 +00:00
Daniel Dunbar b8fb96905d Fix use after free, found by Benjamin Kramer.
llvm-svn: 72333
2009-05-23 18:55:58 +00:00
Mike Stump 8673657275 One step to fixing up codegen for a=b, where a is a volatile struct.
llvm-svn: 72315
2009-05-23 04:13:59 +00:00
Eli Friedman 57406b2783 Add IEEE quad support to DefineFloatMacros.
llvm-svn: 72314
2009-05-23 03:50:01 +00:00
Daniel Dunbar 223db1c9e5 Initialize Obj-C GC attributes when emitting BlockDeclRefExprs.
- Otherwise we may incorrectly miss generation of some write barriers.

llvm-svn: 72313
2009-05-23 02:49:02 +00:00
Eli Friedman f98fc352b8 PR4247: Widen the buffer slightly so it can hold all the definitions for
PPC double double.

(No testcase because no normal target uses the format at the moment.)

llvm-svn: 72310
2009-05-23 02:03:39 +00:00
Mike Stump a35af82429 Fix typo.
llvm-svn: 72308
2009-05-23 02:02:29 +00:00
Douglas Gregor 4a9f481db9 Template instantiation for qualified declaration reference
expressions. We are now missing template instantiation logic for only
three classes of expressions:
  - Blocks-related expressions (BlockExpr, BlockDeclRefExpr)
  - C++ default argument expressions
  - Objective-C expressions

Additionally, our handling of DeclRefExpr is still quite poor, since
it cannot handle references to many kinds of declarations.

As part of this change, converted the TemplateExprInstantiator to use
iteration through all of the expressions via clang/AST/StmtNodes.def,
ensuring that we don't forget to add template instantiation logic for
any new expression node kinds.

llvm-svn: 72303
2009-05-22 23:47:06 +00:00
Douglas Gregor 93fcf93bc6 Template instantiation for the GNU address-of-label extension.
llvm-svn: 72301
2009-05-22 23:25:52 +00:00