Commit Graph

463 Commits

Author SHA1 Message Date
Benjamin Kramer b11416d061 Add raw_ostream operators to NamedDecl for convenience. Switch over all users of getNameAsString on a stream.
The next step is to print the name directly into the stream, avoiding a temporary std::string copy.

llvm-svn: 101632
2010-04-17 09:33:03 +00:00
Chris Lattner 4ebae65d6a make our existing "switch on bool" warning work for C. Since
the result of comparisons are 'int' in C, it doesn't work to
test just the result type of the expression.

llvm-svn: 101576
2010-04-16 23:34:13 +00:00
Ted Kremenek ac034616f1 Use ASTVector instead of std::vector for the Exprs in InitListExpr. Performance
measurements of '-fsyntax-only' on combine.c (403.gcc) shows no real performance
change, but now the vector isn't leaked.

llvm-svn: 101195
2010-04-13 23:39:13 +00:00
Ted Kremenek 43a9c9626f Don't emit an 'unused expression' warning for '||' and '&&' expressions that contain assignments
or similar side-effects.

llvm-svn: 100676
2010-04-07 18:49:21 +00:00
John McCall a8ae222d0e Implement the protected access restriction ([class.protected]), which requires
that protected members be used on objects of types which derive from the
naming class of the lookup.  My first N attempts at this were poorly-founded,
largely because the standard is very badly worded here.

llvm-svn: 100562
2010-04-06 21:38:20 +00:00
Douglas Gregor 45cf7e3d2a Rework our handling of copy construction of temporaries, which was a
poor (and wrong) approximation of the actual rules governing when to
build a copy and when it can be elided.

The correct implementation is actually simpler than the
approximation. When we only enumerate constructors as part of
initialization (e.g., for direct initialization or when we're copying
from a class type or one of its derived classes), we don't create a
copy. When we enumerate all conversion functions, we do create a
copy. Before, we created some extra copies and missed some
others. The new test copy-initialization.cpp shows a case where we
missed creating a (required, non-elidable) copy as part of a
user-defined conversion, which resulted in a miscompile. This commit
also fixes PR6757, where the missing copy made us reject well-formed
code in the ternary operator.

This commit also cleans up our handling of copy elision in the case
where we create an extra copy of a temporary object, which became
necessary now that we produce the right copies. The code that seeks to
find the temporary object being copied has moved into
Expr::getTemporaryObject(); it used to have two different
not-quite-the-same implementations, one in Sema and one in CodeGen.

Note that we still do not attempt to perform the named return value
optimization, so we miss copy elisions for return values and throw
expressions.

llvm-svn: 100196
2010-04-02 18:24:57 +00:00
Douglas Gregor d7d70e4788 Remove the AST statistics tracking I added yesterday; it didn't pan out.
llvm-svn: 100027
2010-03-31 18:21:31 +00:00
John McCall d9c7c6568e Introduce a new kind of derived-to-base cast which bypasses the need for
null checks, and make sure we elide null checks when accessing base class
members.

llvm-svn: 99963
2010-03-30 23:58:03 +00:00
John McCall 16df1e59f2 Propagate the "found declaration" (i.e. the using declaration instead of
the underlying/instantiated decl) through a lot of API, including "intermediate"
MemberExprs required for (e.g.) template instantiation.  This is necessary
because of the access semantics of member accesses to using declarations:
only the base class *containing the using decl* need be accessible from the
naming class.

This allows us to complete an access-controlled selfhost, if there are no
recent regressions.

llvm-svn: 99936
2010-03-30 21:47:33 +00:00
Douglas Gregor ad2c6988a2 Introduce new AST statistics that keep track of the number of isa (or
dyn_cast) invocations for C++ and Objective-C types, declarations,
expressions, and statements. The statistics will be printed when
-print-stats is provided to Clang -cc1, with results such as:

277073 clang - Number of checks for C++ declaration nodes
 13311 clang - Number of checks for C++ expression nodes
    18 clang - Number of checks for C++ statement nodes
174182 clang - Number of checks for C++ type nodes
 92300 clang - Number of checks for Objective-C declaration nodes
  9800 clang - Number of checks for Objective-C expression nodes
     7 clang - Number of checks for Objective-C statement nodes
 65733 clang - Number of checks for Objective-C type nodes

The statistics are only gathered when NDEBUG is not defined, since
they introduce potentially-expensive operations into very low-level
routines (isa).

llvm-svn: 99912
2010-03-30 18:56:13 +00:00
Fariborz Jahanian 5cab26d058 Add Support for 'warn_unused_result" attribute on
objective-c methods. (radar 7418262).

llvm-svn: 99903
2010-03-30 18:22:15 +00:00
Ted Kremenek 361ffd947c Make PredefinedExpr::ComputeName() more robust to incorrect
code when we are printing the name of an Objective-C method
whose class has not been declared.  Fixes <rdar://problem/7495713>.

llvm-svn: 98874
2010-03-18 21:23:08 +00:00
Fariborz Jahanian 8342e5776e Some cleanup, change diagnostic when assigning to
a property which is not lvalue.

llvm-svn: 98848
2010-03-18 18:50:41 +00:00
John McCall c493a73240 Improve the unused-value check to look into comma expressions and filter out
voids in sub-expressions.  Patch by Mike M!

Fixes PR4806.

llvm-svn: 98335
2010-03-12 07:11:26 +00:00
John McCall 85f9055955 When pretty-printing tag types, only print the tag if we're in C (and
therefore not creating ElaboratedTypes, which are still pretty-printed
with the written tag).

Most of these testcase changes were done by script, so don't feel too
sorry for my fingers.

llvm-svn: 98149
2010-03-10 11:27:22 +00:00
Douglas Gregor de4827dd34 Extend ObjCMessageExpr for class method sends with the source location
of the class name.

llvm-svn: 97943
2010-03-08 16:40:19 +00:00
John McCall 6dee473780 References to const int parameters with ICE default arguments are not ICEs.
Fixes PR6373.

llvm-svn: 97037
2010-02-24 09:03:18 +00:00
Ted Kremenek 013041eef0 Revert: "Change InitListExpr to allocate the array for holding references"
This was causing buildbot breakage.

This reverts commit d46e952cc8cb8d9eed8657d9a0b267910a0f745a.

llvm-svn: 96652
2010-02-19 01:50:18 +00:00
Ted Kremenek 445a603c78 Change InitListExpr to allocate the array for holding references
to initializer expressions in an array allocated using ASTContext.

This plugs a memory leak when ASTContext uses a BumpPtrAllocator to
allocate memory for AST nodes.

In my mind this isn't an ideal solution; it would be nice to have
a general "vector"-like class that allocates memory using ASTContext,
but whose guts could be separated from the methods of InitListExpr
itself.  I haven't gone and taken this approach yet because it isn't
clear yet if we'll eventually want an alternate solution for recylcing
memory using by InitListExprs as we are constructing the ASTs.

llvm-svn: 96642
2010-02-19 00:42:33 +00:00
Douglas Gregor b154fdc974 Introduce a new kind of failed result for isLvalue/isModifiableLvalue
which describes temporary objects of class type in C++. Use this to
provide a more-specific, remappable diagnostic when takin the address
of such a temporary.

llvm-svn: 96396
2010-02-16 21:39:57 +00:00
John McCall 1e3715acc3 White-list comma expressions with the literal 0 as their RHS against
unused-value warnings.  This is a common macro idiom.

llvm-svn: 96326
2010-02-16 04:10:53 +00:00
Fariborz Jahanian e5c118f60d Don't error when setting a sub-structure variable via objc properties
in objective-c++ mode (do it for objective-c only).

llvm-svn: 96012
2010-02-12 21:02:28 +00:00
Ted Kremenek 2c809308ca Allocate the SubExprs array in ObjCMessageExpr using the allocator associated with ASTContext. This fixes yet another leak (<rdar://problem/7639260>).
llvm-svn: 95930
2010-02-11 22:41:21 +00:00
Anders Carlsson 5bd8d19291 More vtable layout dumper improvements. Handle destructors, dump the complete function type of the member functions (using PredefinedExpr::ComputeName.
llvm-svn: 95887
2010-02-11 18:20:28 +00:00
Fariborz Jahanian 13b9782cc0 Diagnose when user provided getter is being used as lvalue
using property dot-syntax. Fixes radar 7628953.

llvm-svn: 95838
2010-02-11 01:11:34 +00:00
John McCall 52cc0897f3 Per discussion, remove the explicit restriction on static const data members with
out-of-line initializers as integer constant expressions.  Fixes PR6206.

llvm-svn: 95463
2010-02-06 01:07:37 +00:00
Daniel Dunbar 45858d2d59 Revert "Numerous changes to selector handling:", this breaks a whole bunch of
working code, for no apparent reason.

llvm-svn: 95244
2010-02-03 20:11:42 +00:00
David Chisnall 92b762e256 Numerous changes to selector handling:
- 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
2010-02-03 02:09:30 +00:00
John McCall 2adddcae7e Remove abstract expression kinds from the StmtClass enum. Update a few users
appropriately.  Call out a few missing cases in the expression mangler.

llvm-svn: 95176
2010-02-03 00:55:45 +00:00
Sebastian Redl 5ca7984bb4 In C++, an initializer on a variable doesn't necessarily mean it's the 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
2010-02-01 20:16:42 +00:00
Anders Carlsson 8abde4b447 Diagnose binding a non-const reference to a vector element.
llvm-svn: 94963
2010-01-31 17:18:49 +00:00
Douglas Gregor 65eb86e912 Fix reference binding of const lvalue references to bit-fields, which
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
2010-01-29 19:14:02 +00:00
Anders Carlsson ba6c437d52 Add an CXXBindReferenceExpr (not used just yet).
llvm-svn: 94791
2010-01-29 02:39:32 +00:00
Douglas Gregor 5fcb51c09c When determining whether a DeclRefExpr is value-dependent when it
references a const variable of integral type, the initializer may be
in a different declaration than the one that name-lookup saw. Find the
initializer anyway. Fixes PR6045.

llvm-svn: 93514
2010-01-15 16:21:02 +00:00
Douglas Gregor 03e8bdc07e Move the allocation of designators in DesignatedInitExpr to the
ASTContext. Fixes <rdar://problem/7495428>.

llvm-svn: 92867
2010-01-06 23:17:19 +00:00
Eli Friedman 84341cd668 Make sure to explicitly pass type/value dependence to Expr constructor. This
caught several cases where we were not doing the right thing. I'm
not completely sure all cases are being handled correctly, but this should
be an improvement.

llvm-svn: 92281
2009-12-30 00:13:48 +00:00
Sam Weinig 4e83bd2795 Fix for PR5872. Add static specifier and const/volatile qualifiers to member functions in __PRETTY_FUNCTION__ predefined expressions.
llvm-svn: 92171
2009-12-27 01:38:20 +00:00
Nuno Lopes c095b5361a support the warn_unused_result in C++ class methods
llvm-svn: 92095
2009-12-24 00:28:18 +00:00
Chris Lattner 3a6af3de6c indentation fix
llvm-svn: 91807
2009-12-21 01:10:56 +00:00
Nuno Lopes 518e370719 fix PR4010: add support for the warn_unused_result for function pointers
llvm-svn: 91803
2009-12-20 23:11:08 +00:00
Douglas Gregor 5103effb1d A CXXExprWithTemporaries expression is an lvalue if its subexpression
is an lvalue. Fixes PR5787.

llvm-svn: 91765
2009-12-19 07:07:47 +00:00
Fariborz Jahanian e8d28904b0 Diagnose attempting to assign to a sub-structure of an ivar
using objective-c property. (fixes radar 7449707)

llvm-svn: 91474
2009-12-15 23:59:41 +00:00
Douglas Gregor d196a58b55 Improve template instantiation for object constructions in several ways:
- During instantiation, drop default arguments from constructor and
    call expressions; they'll be recomputed anyway, and we don't want
    to instantiate them twice.
  - Rewrote the instantiation of variable initializers to cope with
    non-dependent forms properly.

Together, these fix a handful of problems I introduced with the switch
to always rebuild expressions from the source code "as written."

llvm-svn: 91315
2009-12-14 19:27:10 +00:00
Jeffrey Yasskin 1615d45daa Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gave
no extra safety anyway.

llvm-svn: 91207
2009-12-12 05:05:38 +00:00
Fariborz Jahanian ffe912c647 Patch to allow C-style cast from 'void *' to block pointer type.
(fixes radar 7465023).

llvm-svn: 91171
2009-12-11 22:40:48 +00:00
Fariborz Jahanian 531c16f9fb Code gen for ObjCIsaExpr AST used as lvalue.
(fixes radar 7457534).

llvm-svn: 90995
2009-12-09 23:35:29 +00:00
Fariborz Jahanian e19122ff01 Added a missing case to a switch statement.
llvm-svn: 90902
2009-12-08 23:46:15 +00:00
John McCall ce54657e95 DeclRefExpr stores a ValueDecl internally.
Template instantiation can re-use DeclRefExprs.

llvm-svn: 90848
2009-12-08 09:08:17 +00:00
Sam Weinig d060ed4d70 Don't print a void return type for C++ constructors and destructors when generating a predefined expr for them.
llvm-svn: 90725
2009-12-06 23:55:13 +00:00
Eli Friedman 2cfcef65b7 Make the type of the Decl referred to by a MemberExpr a bit more precise.
llvm-svn: 90549
2009-12-04 06:40:45 +00:00
Eli Friedman 1d6fb1669c Add recursion guards to ice-checking and evaluation for declrefs, so we
don't infinitely recurse for cases we can't evaluate.

llvm-svn: 90480
2009-12-03 20:31:57 +00:00
John McCall 3d988d9042 r90313, in which OverloadedFunctionDecl is removed and never spoken of again.
llvm-svn: 90313
2009-12-02 08:47:38 +00:00
John McCall 10eae1851d Eliminate the use of OverloadedFunctionDecl in member expressions.
Create a new UnresolvedMemberExpr for these lookups.  Assorted hackery
around qualified member expressions;  this will all go away when we
implement the correct (i.e. extremely delayed) implicit-member semantics.

llvm-svn: 90161
2009-11-30 22:42:35 +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
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
Anders Carlsson 7fa434c2b8 Handle converting member pointers to bool.
llvm-svn: 89692
2009-11-23 20:04:44 +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 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
Douglas Gregor deebf6efab Deduce a ConstantArrayType from a value-dependent initializer list
rather than punting to a DependentSizedArrayType, tightening up our
type checking for template definitions. Thanks, John!

llvm-svn: 89407
2009-11-19 23:25:22 +00:00
John McCall 8cd7813ca3 Draw a brighter line between "unresolved" expressions, where we have done the
appropriate lookup and simply can't resolve the referrent yet, and
"dependent scope" expressions, where we can't do the lookup yet because the
entity we need to look into is a dependent type.

llvm-svn: 89402
2009-11-19 22:55:06 +00:00
Anders Carlsson 6aa503900f Fix PR5531.
llvm-svn: 89106
2009-11-17 17:11:23 +00:00
Anders Carlsson a70ad93f8a Add a CK_BaseToDerived cast kind.
llvm-svn: 86994
2009-11-12 16:43:42 +00:00
Mike Stump 53f9ded62b Refine volatile handling, specifically, we must have the canonical
type to look at the volatile specifier.  I found these all from just
hand auditing the code.

llvm-svn: 85967
2009-11-03 23:25:48 +00:00
Douglas Gregor 0840cc02ce When determining whether a reference to a static data member is an
integral constant expression, make sure to find where the initializer
was provided---inside or outside the class definition---since that can
affect whether we have an integral constant expression (and, we need
to see the initializer itself).

llvm-svn: 85741
2009-11-01 20:32:48 +00:00
Anders Carlsson 3f0db2beb1 Add a CK_DerivedToBaseMemberPointer cast kind and use it in Sema (Still no codegen).
llvm-svn: 85552
2009-10-30 00:46:35 +00:00
John McCall 0ad166672f 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.

llvm-svn: 85500
2009-10-29 08:12:44 +00:00
Douglas Gregor d33198420d Fix overload resolution when calling a member template or taking the
address of a member template when explicit template arguments are
provided.

llvm-svn: 84991
2009-10-24 04:59:53 +00:00
Douglas Gregor 4bd90e53c2 Eliminate QualifiedDeclRefExpr, which captured the notion of a
qualified reference to a declaration that is not a non-static data
member or non-static member function, e.g., 

  namespace N { int i; }
  int j = N::i;

Instead, extend DeclRefExpr to optionally store the qualifier. Most
clients won't see or care about the difference (since
QualifierDeclRefExpr inherited DeclRefExpr). However, this reduces the
number of top-level expression types that clients need to cope with,
brings the implementation of DeclRefExpr into line with MemberExpr,
and simplifies and unifies our handling of declaration references.

Extended DeclRefExpr to (optionally) store explicitly-specified
template arguments. This occurs when naming a declaration via a
template-id (which will be stored in a TemplateIdRefExpr) that,
following template argument deduction and (possibly) overload
resolution, is replaced with a DeclRefExpr that refers to a template
specialization but maintains the template arguments as written.

llvm-svn: 84962
2009-10-23 18:54:35 +00:00
Daniel Dunbar 07d0785dbb PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients
are updated.

llvm-svn: 84447
2009-10-18 21:17:35 +00:00
Benjamin Kramer beb873d84a Add FloatingCast to getCastKindName's list.
llvm-svn: 84427
2009-10-18 19:02:15 +00:00
Anders Carlsson 094c459525 Add some more cast kinds.
llvm-svn: 84423
2009-10-18 18:12:03 +00:00
Daniel Dunbar ce5a0b3deb Switch ExtVectorElementExpr::getEncodedElementAccess to use StringRef.
- Really this should be simplified by the FIXME above, but I'm too deep in DFS.

llvm-svn: 84392
2009-10-18 02:09:31 +00:00
Daniel Dunbar cb2a056980 Add FIXME... maybe Nate will get bored? :)
llvm-svn: 84389
2009-10-18 02:09:09 +00:00
Daniel Dunbar 125c9c98f7 Simplify ExtVectorElementExpr::containsDuplicateElements().
llvm-svn: 84380
2009-10-17 23:53:04 +00:00
Anders Carlsson 43d70f874d Add CK_VectorSplat and use it for casting non-pointer scalars to ExtVectors.
llvm-svn: 84245
2009-10-16 05:23:41 +00:00
Anders Carlsson ef918ac840 Add a ToVoid cast kind and start using it.
llvm-svn: 84241
2009-10-16 02:35:04 +00:00
Chris Lattner a2f9bd5339 fix test/CodeGen/statements.c on 32-bit hosts.
llvm-svn: 84039
2009-10-13 22:12:09 +00:00
Chris Lattner 3eb172a02b Teach sema and codegen about the difference between address of labels,
which is a common idiom to improve PIC'ness of code using the addr of
label extension.  This implementation is a gross hack, but the only other
alternative would be to teach evalutate about this horrid combination.
While GCC allows things like "&&foo - &&bar + 1", people don't use this
in practice.  This implements PR5131.

llvm-svn: 83957
2009-10-13 07:14:16 +00:00
Chris Lattner 1a6babf1f4 make the diagnostic in the 'unused result' warning more precise
about the reason, rdar://7186119.

llvm-svn: 83940
2009-10-13 04:53:48 +00:00
Fariborz Jahanian 03b4f666ed Implement [expr.mptr.oper]p6 for '->*' operator.
llvm-svn: 83562
2009-10-08 18:00:39 +00:00
Fariborz Jahanian 333bb733a5 Refixed pr5086 by letting Expr::isNullPointerConstant
handle checking for a null pointer for a zero-valued
enumerator; moving the test case from CodeGen to Sema.

llvm-svn: 83350
2009-10-06 00:09:31 +00:00
Douglas Gregor 56751b5981 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.

llvm-svn: 82748
2009-09-25 04:25:58 +00:00
John McCall 8ccfcb51ee 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.

llvm-svn: 82705
2009-09-24 19:53:00 +00:00
Daniel Dunbar 362178883c Add StringLiteral::getString -> StringRef.
llvm-svn: 82514
2009-09-22 03:27:33 +00:00
John McCall 9dd450bb78 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.

llvm-svn: 82501
2009-09-21 23:43:11 +00:00
Daniel Dunbar ebc5140e22 Disable questionable code for handling isNullPointerConstant on value dependent
expression.

llvm-svn: 82217
2009-09-18 08:46:16 +00:00
Daniel Dunbar 687fa86a30 Fix two crashes on value dependent expressions (shift and null-pointer check).
- Doug, please check.

 - PR4940.

llvm-svn: 82129
2009-09-17 06:31:27 +00:00
Daniel Dunbar 4782a6ead5 Remove trailing whitespace.
llvm-svn: 82128
2009-09-17 06:31:17 +00:00
Fariborz Jahanian cceedbff27 Do not generate write-barrier in indirect assignment to
a weak object.

llvm-svn: 82061
2009-09-16 18:09:18 +00:00
Anders Carlsson 7cd39e0721 Handle reinterpret_cast between integral types and pointer types.
llvm-svn: 81837
2009-09-15 04:48:33 +00:00
Fariborz Jahanian cb1c19147f Using the property dot-syntax to invoke a non-eixsting
structure-valued setter should cause a user error instead of
crash.

llvm-svn: 81769
2009-09-14 16:40:48 +00:00
Douglas Gregor 15fc956ca0 Remove unnecessary ASTContext parameter from FunctionDecl::isBuiltinID
llvm-svn: 81590
2009-09-12 00:22:50 +00:00
Douglas Gregor 73341c4e63 Diagnose VLAs as an error in C++.
Also, treat the GNU __null as an integral constant expression to match
GCC's behavior.

llvm-svn: 81490
2009-09-11 00:18:58 +00:00
Douglas Gregor 8ef65fbd49 Eliminate some "default"s in CheckICE.
llvm-svn: 81477
2009-09-10 23:31:45 +00:00
Douglas Gregor 7736e2ad98 static_cast, reinterpret_cast, and const_cast can all be used in C++
integral constant expressions (for conversions to integer types,
naturally). I don't *think* that const_casts will ever get to this
point, but I also can't convince myself that they won't... so I've
taken the safe route and allowed the ICE checking code to look at
const_cast.

llvm-svn: 81453
2009-09-10 17:44:23 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Fariborz Jahanian 063c7720f4 More objc GC's API work for array of pointers declared
as __strong.

llvm-svn: 81283
2009-09-08 23:38:54 +00:00
Anders Carlsson 2fb0824197 Vastly improve PredefinedExpr output, both in Sema and CodeGen. Patch by Sam Weinig!
llvm-svn: 81237
2009-09-08 18:24:21 +00:00
Anders Carlsson 496335ea1a Add CastExpr::getCastKindName and use it in the StmtDumper.
llvm-svn: 80862
2009-09-03 00:59:21 +00:00
Douglas Gregor 84f14dd674 Preliminary AST representation and semantic analysis for
explicitly-specified template argument lists in member reference
expressions, e.g.,

  x->f<int>()

llvm-svn: 80646
2009-09-01 00:37:14 +00:00
Douglas Gregor f405d7e6f1 Eliminate CXXAdornedMemberExpr entirely. Instead, optionally allocate
space within the MemberExpr for the nested-name-specifier and its
source range. We'll do the same thing with explicitly-specified
template arguments, assuming I don't flip-flop again.

llvm-svn: 80642
2009-08-31 23:41:50 +00:00
Douglas Gregor 96ee789d33 Rename CXXQualifiedMemberExpr -> CXXAdornedMemberExpr, since we will
also be adding explicit template arguments as an additional
"adornment". No functionality change.

llvm-svn: 80628
2009-08-31 21:41:48 +00:00
Eli Friedman 9ab0319b2b Get rid of mostly-unused, buggy method.
llvm-svn: 80432
2009-08-29 19:09:59 +00:00
Douglas Gregor c190523d7a When a member reference expression includes a qualifier on the member
name, e.g.,
  
  x->Base::f()

retain the qualifier (and its source range information) in a new
subclass of MemberExpr called CXXQualifiedMemberExpr. Provide
construction, transformation, profiling, printing, etc., for this new
expression type.

When a virtual function is called via a qualified name, don't emit a
virtual call. Instead, call that function directly. Mike, could you
add a CodeGen test for this, too?

llvm-svn: 80167
2009-08-26 22:36:53 +00:00
Fariborz Jahanian 9a84665921 Using "ObjCImplicitSetterGetterRefExpr" instead of "ObjCImplctSetterGetterRefExpr".
A field rename and more comments.

llvm-svn: 79537
2009-08-20 17:02:02 +00:00
Fariborz Jahanian 88cc2340de Renamed ObjCKVCRefExpr to ObjCImplctSetterGetterRefExpr.
Removed an unnecessary loop to get to setters incoming
argument. Added DoxyGen comments. Still more work
to do in this area (WIP).

llvm-svn: 79365
2009-08-18 20:50:23 +00:00
Chris Lattner d37f61c1c6 fix my previous commit.
llvm-svn: 79191
2009-08-16 16:51:50 +00:00
Chris Lattner d8b800ad31 This is an attempt to improve loc info for 'unused result' expression
warnings, but it fails because we don't have the location of the .
and I don't understand ObjCKVCRefExpr.  I'll revisit this later.

llvm-svn: 79190
2009-08-16 16:45:18 +00:00
Anders Carlsson e80ccac2cb Call MaybeBindToTemporary for overloaded binary and unary operators.
llvm-svn: 79173
2009-08-16 04:11:06 +00:00
Anders Carlsson 8c84c206d9 Add MaybeBindToTemporary calls for member call expressions.
llvm-svn: 79171
2009-08-16 03:42:12 +00:00
Nate Begeman 4874592208 Transition the PCH support for ShuffleVectorExpr over to ASTContext allocation
llvm-svn: 78783
2009-08-12 02:28:50 +00:00
Fariborz Jahanian 853d21a18a Warn on use of property dot syntax when unused.
llvm-svn: 78760
2009-08-12 00:45:33 +00:00
Chris Lattner f1c9797ffa Fix rdar://7126285: don't warn on unused ObjC property access
that uses "dot syntax" since it might have a side effect.

llvm-svn: 78704
2009-08-11 20:08:03 +00:00
Nate Begeman 5ec4b318e3 Take 2 on AltiVec-style vector initializers.
Fixes PR4704 problems

Addresses Eli's patch feedback re: ugly cast code

Updates all postfix operators to remove ParenListExprs.  While this is awful,
no better solution (say, in the parser) is obvious to me.  Better solutions
welcome.

llvm-svn: 78621
2009-08-10 23:49:36 +00:00
Daniel Dunbar 481fe50903 Revert r78535, it is causing a number of failures to build projects.
--- Reverse-merging r78535 into '.':
D    test/Sema/altivec-init.c
U    include/clang/Basic/DiagnosticSemaKinds.td
U    include/clang/AST/Expr.h
U    include/clang/AST/StmtNodes.def
U    include/clang/Parse/Parser.h
U    include/clang/Parse/Action.h
U    tools/clang-cc/clang-cc.cpp
U    lib/Frontend/PrintParserCallbacks.cpp
U    lib/CodeGen/CGExprScalar.cpp
U    lib/Sema/SemaInit.cpp
U    lib/Sema/Sema.h
U    lib/Sema/SemaExpr.cpp
U    lib/Sema/SemaTemplateInstantiateExpr.cpp
U    lib/AST/StmtProfile.cpp
U    lib/AST/Expr.cpp
U    lib/AST/StmtPrinter.cpp
U    lib/Parse/ParseExpr.cpp
U    lib/Parse/ParseExprCXX.cpp

llvm-svn: 78551
2009-08-10 03:01:36 +00:00
Nate Begeman a96114ed08 AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);
In addition to being defined by the AltiVec PIM, this is also the vector
initializer syntax used by OpenCL, so that vector literals are compatible
with macro arguments.

llvm-svn: 78535
2009-08-09 17:55:44 +00:00
Anders Carlsson c5c57c3b86 Get rid of Stmt::Clone now that we can reference count statements instead.
llvm-svn: 78452
2009-08-08 02:50:17 +00:00
Douglas Gregor e26a285c8f Separate Stmt::Destroy into the entrypoint for destroying a statement
or expression (Destroy) from the virtual function used to actually
destroy a given expression (DoDestroy). 

llvm-svn: 78375
2009-08-07 06:08:38 +00:00
Ted Kremenek c23c7e6a51 Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.

llvm-svn: 77510
2009-07-29 21:53:49 +00:00
Chris Lattner 2706a55071 fix PR4633: cast to void should silence the 'unused expression' warning.
llvm-svn: 77344
2009-07-28 18:25:28 +00:00
Daniel Dunbar ec5ae3d75a CallExpr's SubExprs sometimes were allocated in the wrong place.
llvm-svn: 77302
2009-07-28 06:29:46 +00:00
Steve Naroff e87026a08f Allow front-end 'isa' access on object's of type 'id'.
Enhance test case to cover 'isa' access on interface types (clang produces an error, GCC produces a warning).

Still need back-end CodeGen for ObjCIsaExpr.

llvm-svn: 76979
2009-07-24 17:54:45 +00:00
Anders Carlsson 15b73deeea Revert r75641.
llvm-svn: 76327
2009-07-18 19:43:29 +00:00
Ted Kremenek 8a286fbdb9 Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.

llvm-svn: 76193
2009-07-17 17:50:17 +00:00
Chris Lattner 5230191e37 objc methods can't be an operand to callexpr.
llvm-svn: 76179
2009-07-17 15:46:27 +00:00
Zhongxing Xu 3c8fa978ad Refactor code into a new CallExpr::getDirectCallee() method. Simplify some
code with the new method.

llvm-svn: 76164
2009-07-17 07:29:51 +00:00
Ted Kremenek b825c0ddc5 Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
llvm-svn: 76139
2009-07-17 01:20:38 +00:00
Ted Kremenek e3fb4b6524 Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.

The motivation behind this change is twofold:

1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.

2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.

Along with this patch:

a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.

llvm-svn: 76098
2009-07-16 19:58:26 +00:00
Steve Naroff 79d1215d83 Remove ASTContext::isObjCObjectPointerType().
Convert all clients to use the new predicate on Type.

llvm-svn: 76076
2009-07-16 15:41:00 +00:00
Anders Carlsson 466fd0a16d Rename RecordLayout.h to ASTRecordLayout.h
llvm-svn: 75641
2009-07-14 17:29:11 +00:00
Argyrios Kyrtzidis eeaaead736 Read/write a CXXOperatorCallExpr from/to PCH files.
llvm-svn: 75598
2009-07-14 03:19:21 +00:00
Steve Naroff 7cae42b07a This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.

llvm-svn: 75314
2009-07-10 23:34:53 +00:00
Douglas Gregor 9b14658713 Implement template argument deduction when taking the address of a
function template. Most of the change here is in factoring out the
common bits used for template argument deduction from a function call
and when taking the address of a function template.

llvm-svn: 75044
2009-07-08 20:55:45 +00:00
Douglas Gregor 19623dc075 Fix bitfield promotion in the presence of explicit casts, from Abrama Bagnara.
llvm-svn: 74830
2009-07-06 15:38:40 +00:00
Argyrios Kyrtzidis b4b64ca752 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

llvm-svn: 74501
2009-06-30 02:34:44 +00:00
Chris Lattner e4edb8e818 Fix the FloatingLiteral API to take the isexact flag by value instead of
by pointer.

llvm-svn: 74432
2009-06-29 17:34:55 +00:00
Nate Begeman 0359e12208 OpenCL 1.0 Support, patch 1/N: upper case swizzle operator and hex element index.
llvm-svn: 74202
2009-06-25 21:06:09 +00:00
Fariborz Jahanian 99b57fb987 Renamed Protocol as TheProtocol so people can use clang header for
building obj-c++ clients. "Protocol" is a class name in Cocoa.h

llvm-svn: 73854
2009-06-21 18:26:03 +00:00
Douglas Gregor 78bd61f661 Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
llvm-svn: 73702
2009-06-18 16:11:24 +00:00
Chris Lattner 15ba94987a Sink the BuiltinInfo object from ASTContext into the
preprocessor and initialize it early in clang-cc.  This
ensures that __has_builtin works in all modes, not just
when ASTContext is around.

llvm-svn: 73319
2009-06-14 01:54:56 +00:00
Anders Carlsson 0880e9f58d Instantiation support for more Obj-C expressions, string literals, @selector and @protocol expressions.
llvm-svn: 73036
2009-06-07 19:51:47 +00:00
Fariborz Jahanian c6d9800564 A corner case of objc2 gc's write-barrier generation
for the Next runtime.

llvm-svn: 72703
2009-06-01 21:29:32 +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
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
Douglas Gregor ca1aeecd37 Template instantiation for C99 designated initializers, because we
can. Also, delay semantic analysis of initialization for
value-dependent as well as type-dependent expressions, since we can't
always properly type-check a value-dependent expression.

llvm-svn: 72233
2009-05-21 23:17:49 +00:00
Douglas Gregor 115652db4a Fix handling of the GNU "t ? : f" extension to the conditional
operator in C++, and verify that template instantiation for the
condition operator does the right thing.

llvm-svn: 72127
2009-05-19 20:13:50 +00:00
Douglas Gregor 38e7f8bd6d Template instantiation for imaginary literals, because they were next in Expr.h
llvm-svn: 72058
2009-05-18 22:38:38 +00:00
Anders Carlsson 24824e5009 Make ActOnExprStmt take a FullExprArg.
llvm-svn: 71989
2009-05-17 21:11:30 +00:00