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

1153 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor caaf29a087 Added a warning when referencing an if's condition variable in the
"else" clause, e.g.,

  if (int X = foo()) {
  } else {
    if (X) { // warning: X is always zero in this context
    }
  }

Fixes rdar://6425550 and lets me think about something other than
DeclContext.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60858 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-10 23:01:14 +00:00
Fariborz Jahanian 91b51a92f2 Prevent bogus warning on unimplemented setter/getter when user
has added declaration of these methods in its @interface.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60803 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 22:43:22 +00:00
Fariborz Jahanian fef30b5523 Support for implementation of property in the case where
the synthesis is in an implementation of s subclass of
a super class where the property has been declared.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60792 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 20:23:04 +00:00
Douglas Gregor f57172b24f Move Sema::isTemplateParameterDecl to Decl::isTemplateParameter, where it belongs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60708 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 18:40:42 +00:00
Fariborz Jahanian 1ac2bc4478 Use of properties declared in protocols in the category
via the category's protocol list1s, with appropriate
diagnsostics and a test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60634 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-06 23:03:39 +00:00
Douglas Gregor 5c37de7885 Add support for calls to dependent names within templates, e.g.,
template<typename T> void f(T x) {
    g(x); // g is a dependent name, so don't even bother to look it up
    g(); // error: g is not a dependent name
  }

Note that when we see "g(", we build a CXXDependentNameExpr. However,
if none of the call arguments are type-dependent, we will force the
resolution of the name "g" and replace the CXXDependentNameExpr with
its result.

GCC actually produces a nice error message when you make this
mistake, and even offers to compile your code with -fpermissive. I'll
do the former next, but I don't plan to do the latter.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60618 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-06 00:22:45 +00:00
Douglas Gregor 898574e749 Introduce basic support for dependent types, type-dependent
expressions, and value-dependent expressions. This permits us to parse
some template definitions.

This is not a complete solution; we're missing type- and
value-dependent computations for most of the expression types, and
we're missing checks for dependent types and type-dependent
expressions throughout Sema.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60615 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 23:32:09 +00:00
Fariborz Jahanian ae6f6fd152 This test checks for duplicate implementation of the same
property. It also checks for duplicate use of the same ivar
in two different iproperty implementations. It also caught
an error for a test case used in CodeGen :).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60610 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 22:32:48 +00:00
Douglas Gregor 72c3f314d9 Representation of template type parameters and non-type template
parameters, with some semantic analysis:
  - Template parameters are introduced into template parameter scope
  - Complain about template parameter shadowing (except in Microsoft mode)

Note that we leak template parameter declarations like crazy, a
problem we'll remedy once we actually create proper declarations for
templates. 

Next up: dependent types and value-dependent/type-dependent
expressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60597 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 18:15:24 +00:00
Chris Lattner 371f258e61 change getCurFunctionDecl to skip through Block contexts to find
the containing block.  Introduce a new getCurFunctionOrMethodDecl
method to check to see if we're in a function or objc method.
Minor cleanups to other related places.  This fixes rdar://6405429.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60564 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 23:50:19 +00:00
Steve Naroff 3fa1fff997 Fix build breakage from my previous commit.
Will discuss with Chris...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60545 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 19:10:03 +00:00
Steve Naroff c77a636688 Several things...
- Implement RewritePropertySetter(). While the routine is simple, there were some tricky changes to RewriteFunctionBodyOrGlobalInitializer(), the main rewriter loop. It also required some additional instance data to distinguish setters from getters, as well as some changes to RewritePropertyGetter().

- Implement FIXME: for pretty printing ObjCPropertyRefExpr's.

- Changed ObjCPropertyRefExpr::getSourceRange() to point to the end of the property name (not the beginning). Also made a minor name change from "Loc"->"IdLoc" (to make it clear the Loc does not point to the ".").
 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60540 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 16:24:46 +00:00
Sebastian Redl d457589fc6 Fix some type punning errors in SizeOfAlignOf and Typeid AST nodes. This should satisfy compilers and language lawyers alike.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60511 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 23:17:54 +00:00
Sebastian Redl cee63fbf0e Handle new by passing the Declaration to the Action, not a processed type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60413 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 14:43:59 +00:00
Fariborz Jahanian b85cce6498 This patch corrects problem in searching for a setter/getter method for
a property. Previous scheme of seaching in interface's list of methods
would not work because this list is not yet constructed. This is in preparation
for doing semantic check on viability of setter/getter method declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60386 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 00:19:12 +00:00
Steve Naroff d40910b581 -Add several ObjC types to Decl::getDeclKindName(), a useful debug hook.
-Start adding support for rewriting @synthesize.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60368 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 20:33:01 +00:00
Anders Carlsson d26527708b Revert change that made isNullPointerConstant start emitting warnings. We don't want that :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60333 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 06:28:23 +00:00
Anders Carlsson efa9b3877e Add a new variant of isNullConstantExpr that returns an EvalResult.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60318 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 02:13:57 +00:00
Anders Carlsson 5b45d4ef1e Add a new variant of Evaluate and reimplement the old Evaluate in terms of the new.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60298 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 16:58:53 +00:00
Anders Carlsson 94deaf675a Add Expr::EvalResult struct. (Not used just yet)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60295 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30 16:19:46 +00:00
Anders Carlsson 960525cbfb CXXFunctionalCastExpr inherits from ExplicitCastExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60249 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 19:58:11 +00:00
Douglas Gregor 2d8b273470 Implement the GNU __null extension
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60235 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29 04:51:27 +00:00
Chris Lattner 5cf243a883 Switch QualType to use llvm::PointerIntPair internally to do the pointer
bitmangling.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60226 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28 23:37:31 +00:00
Fariborz Jahanian 8cf0bb3c2a Set default property attributes on each property.
Implemented anonymous category (also know as continuation class)
used to override main class's property attribute. This is work in 
propgress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60114 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 20:01:34 +00:00
Fariborz Jahanian 31afbf02a3 Refactored checking on readonly property into a method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60050 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 21:48:26 +00:00
Chris Lattner d9d22dd9c9 Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of
uses of getName() with uses of getDeclName().  This upgrades a bunch of
diags to take DeclNames instead of std::strings.

This also tweaks a couple of diagnostics to be cleaner and changes
CheckInitializerTypes/PerformInitializationByConstructor to pass
around DeclarationNames instead of std::strings.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59947 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 05:29:24 +00:00
Anders Carlsson 85879ee8b5 __builtin_constant_p takes an argument that can have any type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59944 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 05:23:12 +00:00
Chris Lattner 8ec03f58c3 Rename NamedDecl::getIdentifierName() to ::getNameAsCString() and make it
assert if the name is not an identifier.  Update callers to do the right
thing and avoid this method in unsafe cases.  This also fixes an objc
warning that was missing a space, and migrates a couple more to taking
IdentifierInfo and QualTypes instead of std::strings.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59936 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 03:54:41 +00:00
Chris Lattner 077bf5e2f4 Rename Selector::getName() to Selector::getAsString(), and add
a new NamedDecl::getAsString() method.

Change uses of Selector::getName() to just pass in a Selector 
where possible (e.g. to diagnostics) instead of going through
an std::string.

This also adds new formatters for objcinstance and objcclass
as described in the dox.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59933 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 03:33:13 +00:00
Chris Lattner 011bb4edf7 add support for inserting a DeclarationName into a diagnostic directly
without calling getAsString().  This implicitly puts quotes around the
name, so diagnostics need to be tweaked to accommodate this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59916 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-23 20:28:15 +00:00
Chris Lattner 22caddc91d Add support for sending QualType's directly into diags and convert two
diags over to use this.  QualTypes implicitly print single quotes around 
them for uniformity and future extension.

Doing this requires a little function pointer dance to prevent libbasic
from depending on libast.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59907 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-23 09:13:29 +00:00
Anders Carlsson 6dde0d5dc0 Case values must be evaluated
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59884 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 21:50:49 +00:00
Anders Carlsson 51fe996231 Use Expr::Evaluate for case statements. Fixes PR2525
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59881 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 21:04:56 +00:00
Fariborz Jahanian ba8d2d684e Support for implicit property assignment. Error assigning to
'implicit' property with no 'setter'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59878 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 20:25:50 +00:00
Fariborz Jahanian 5daf570d0c New AST node to access "implicit" setter/getter using property dor syntax.
Issuing diagnostics when assigning to read-only properties.
This is work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59874 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 18:39:36 +00:00
Sebastian Redl 4c5d320a75 Implementation of new and delete parsing and sema.
This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59835 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 19:14:01 +00:00
Argyrios Kyrtzidis 77407b8021 Take care another assert:
struct A {
  struct B;
};

struct A::B {
  void m() {} // Assertion failed: getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."
};

Introduce DeclContext::getLexicalParent which may be different from DeclContext::getParent when nested-names are involved, e.g:

   namespace A {
      struct S;
   }
   struct A::S {}; // getParent() == namespace 'A'
                   // getLexicalParent() == translation unit


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59650 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 18:01:13 +00:00
Argyrios Kyrtzidis 20bc676228 Make the non-const DeclContext::getParent call the const version, instead of the other way around.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59646 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 17:36:39 +00:00
Douglas Gregor e94ca9e437 Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.

Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.

Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.

Extended Declarator to store overloaded operator names. 
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator. 

Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59526 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 14:39:36 +00:00
Sebastian Redl a11f42f4bc Implement effects of 'mutable', and a few comments from Chris on its parsing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59470 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 23:24:37 +00:00
Douglas Gregor 10bd368824 Eliminate all of the placeholder identifiers used for constructors,
destructors, and conversion functions. The placeholders were used to
work around the fact that the parser and some of Sema really wanted
declarators to have simple identifiers; now, the code that deals with
declarators will use DeclarationNames.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59469 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 22:58:34 +00:00
Douglas Gregor 2def48394f Updated IdentifierResolver to deal with DeclarationNames. The names of
C++ constructors, destructors, and conversion functions now have a
FETokenInfo field that IdentifierResolver can access, so that these
special names are handled just like ordinary identifiers. A few other
Sema routines now use DeclarationNames instead of IdentifierInfo*'s.

To validate this design, this code also implements parsing and
semantic analysis for id-expressions that name conversion functions,
e.g.,

  return operator bool();

The new parser action ActOnConversionFunctionExpr takes the result of
parsing "operator type-id" and turning it into an expression, using
the IdentifierResolver with the DeclarationName of the conversion
function. ActOnDeclarator pushes those conversion function names into
scope so that the IdentifierResolver can find them, of course.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59462 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 20:34:05 +00:00
Chris Lattner ca354faa7e Implement rdar://6319320: give a good diagnostic for cases where people
are trying to use the old GCC "casts as lvalue" extension.  We don't and
will hopefully never support this.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59460 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 19:51:54 +00:00
Douglas Gregor 2e1cd4264d Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of
languages. DeclarationName is used in NamedDecl to store the name of
the declaration (naturally), and ObjCMethodDecl is now a NamedDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59441 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 14:58:09 +00:00
Chris Lattner 6ee7aa154e rename Expr::tryEvaluate to Expr::Evaluate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59426 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 21:24:15 +00:00
Chris Lattner 58ace88985 Fix PR3075, __builtin_stdarg_start being misprototyped. This affects netbsd headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59419 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 18:43:46 +00:00
Chris Lattner 64c34f1c6f add dump and print methods, add operator<< for APValue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59411 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 07:46:48 +00:00
Chris Lattner a9ab5d6bcf move some APValue methods out of line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59410 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 07:35:53 +00:00
Douglas Gregor b4609806e9 Add a new expression node, CXXOperatorCallExpr, which expresses a
function call created in response to the use of operator syntax that
resolves to an overloaded operator in C++, e.g., "str1 +
str2" that resolves to std::operator+(str1, str2)". We now build a
CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But
only for binary operators, where we actually implement overloading)

I decided *not* to refactor the current CallExpr to make it abstract
(with FunctionCallExpr and CXXOperatorCallExpr as derived
classes). Doing so would allow us to make CXXOperatorCallExpr a little
bit smaller, at the cost of making the argument and callee accessors
virtual. We won't know if this is going to be a win until we can parse
lots of C++ code to determine how much memory we'll save by making
this change vs. the performance penalty due to the extra virtual
calls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 16:09:21 +00:00
Douglas Gregor f2cad8633e Don't require us to manually number the statements and expressions in StmtNodes.def. We don't need stable numbers yet, renumbering is a pain, and LAST_STMT had the wrong value anyway.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59300 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 12:46:07 +00:00
Douglas Gregor bf3af05628 Some cleanup for the implementation of built-in operator
candidates. Thanks to Chris for the review!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59260 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 20:12:29 +00:00
Douglas Gregor 7d7e6727a5 Don't build identifiers for C++ constructors, destructors, or
conversion functions. Instead, we just use a placeholder identifier
for these (e.g., "<constructor>") and override NamedDecl::getName() to
provide a human-readable name.

This is one potential solution to the problem; another solution would
be to replace the use of IdentifierInfo* in NamedDecl with a different
class that deals with identifiers better. I'm also prototyping that to
see how it compares, but this commit is better than what we had
previously.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59193 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 23:21:09 +00:00
Douglas Gregor b7c3ca8af0 Fix compilation on 64-bit targets
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59192 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 23:17:06 +00:00
Douglas Gregor b995d799e1 Slightly improve type hash
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59173 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 21:52:20 +00:00
Ted Kremenek 390e48b15a ObjCForCollectionStmts are block-level expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59160 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 21:11:49 +00:00
Douglas Gregor eb8f306325 Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin

  bool operator==(int const*, int const*)

can be used for the expression "x1 == x2" given:

  struct X {
    operator int const*();
  } x1, x2;

The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it. 

There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.

Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.

As part of this change, ImplicitCastExpr can now be an lvalue.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59148 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 17:17:38 +00:00
Sebastian Redl 0518999d3a Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof expressions, both of values and types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59057 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 17:56:53 +00:00
Sebastian Redl c42e118384 Implement C++ 'typeid' parsing and sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59042 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 11:37:55 +00:00
Douglas Gregor 904eed3f61 Basic support for taking the address of an overloaded function
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59000 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-10 20:40:00 +00:00
Argyrios Kyrtzidis 5239304ff7 Introduce ScopedDecl::getLexicalDeclContext() which is different from ScopedDecl::getDeclContext() when there are nested-names.
e.g.:
  namespace A {
    void f(); // SemanticDC (getDeclContext) == LexicalDC (getLexicalDeclContext) == 'namespace A'
  }
  void A::f(); // SemanticDC == namespace 'A'
               // LexicalDC == global namespace


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58948 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-09 23:41:00 +00:00
Argyrios Kyrtzidis ef6e647b8d Implement Sema support for C++ nested-name-specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58916 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-08 17:17:31 +00:00
Argyrios Kyrtzidis 5540a72fe4 Use only one constructor for CXXMethodDecl. Keep initialization stuff into one place.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58902 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-08 11:24:06 +00:00
Daniel Dunbar 1d75118af7 Support getTypeInfo, getTypeAlign, getTypeSize on const Type*s.
- Size/align are not effected by CVR qualifiers.

Support getCanonicalType: const Type* -> const Type*.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58891 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-08 05:48:37 +00:00
Argyrios Kyrtzidis c7ed9c60b8 Changes in preparation for nested-name-specifiers.
-When parsing declarators, don't depend on "CurScope->isCXXClassScope() == true" for constructors/destructors
-For C++ member declarations, don't depend on "Declarator.getContext() == Declarator::MemberContext"

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58866 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-07 22:02:30 +00:00
Douglas Gregor 2f1bc5285c Parsing, ASTs, and semantic analysis for the declaration of conversion
functions in C++, e.g.,

  struct X {
    operator bool() const;
  };

Note that these conversions don't actually do anything, since we don't
yet have the ability to use them for implicit or explicit conversions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58860 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-07 20:08:42 +00:00
Douglas Gregor 1cd1b1e987 Parsing, ASTs, and semantic analysis for the declaration of overloaded
operators in C++. Overloaded operators can be called directly via
their operator-function-ids, e.g., "operator+(foo, bar)", but we don't
yet implement the semantics of operator overloading to handle, e.g.,
"foo + bar".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58817 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-06 22:13:31 +00:00
Sebastian Redl d93f0ddba0 Sema-check virtual declarations. Complete dynamic_cast checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58804 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-06 15:59:35 +00:00
Douglas Gregor 42a552f820 Parsing, representation, and preliminary semantic analysis of destructors.
Implicit declaration of destructors (when necessary).

Extended Declarator to store information about parsed constructors
and destructors; this will be extended to deal with declarators that
name overloaded operators (e.g., "operator +") and user-defined
conversion operators (e.g., "operator int").



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58767 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-05 20:51:48 +00:00
Douglas Gregor 64bffa9a6f Keep track of whether a C++ class is an aggregate. Don't allow initialization of non-aggregates with initializer lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58757 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-05 16:20:31 +00:00
Douglas Gregor 7ad8390f79 Initial implementation of parsing, semantic analysis, and AST-building
for constructor initializations, e.g.,

  class A { };
  class B : public A { 
    int m;
  public:
    B() : A(), m(17) { };
  };





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58749 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-05 04:29:56 +00:00
Chris Lattner 21ef7ae45c LinkageSpecDecl is c++ specific, move it to DeclCXX
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58704 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-04 16:51:42 +00:00
Douglas Gregor cd9b46e544 Add a new expression class, ObjCSuperExpr, to handle the Objective-C 'super'. Remove ObjCThis from PredefinedExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58698 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-04 14:56:14 +00:00
Douglas Gregor 796da18402 Create a new expression class, CXXThisExpr, to handle the C++ 'this' primary expression. Remove CXXThis from PredefinedExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58695 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-04 14:32:21 +00:00
Steve Naroff b2f9e51632 Fix <rdar://problem/6339636> clang ObjC rewriter: Assertion failed: FileID-1 < FileIDs.size() && "Invalid FileID!", file c:\cygwin\home\Administrator\llvm\tools\clang\include\clang/Basic/SourceManager.h, line 513
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58654 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-03 23:29:32 +00:00
Douglas Gregor 396b7cd9f6 Add implicitly-declared default and copy constructors to C++ classes,
when appropriate.

Conversions for class types now make use of copy constructors. I've
replaced the egregious hack allowing class-to-class conversions with a
slightly less egregious hack calling these conversions standard
conversions (for overloading reasons).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58622 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-03 17:51:48 +00:00
Douglas Gregor d934112e61 Eliminate header dependency ASTContext -> TargetInfo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58613 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-03 15:57:00 +00:00
Douglas Gregor b4e66d5259 Connect ASTContext to TargetInfo when determining the size_t, ptrdiff_t, and wchar_t types. Fixes recent breakage on Linux.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58609 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-03 14:12:49 +00:00
Douglas Gregor 030ff0cdad Semantic checking of constructor declarations and classification of default/copy constructors
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58538 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 20:25:05 +00:00
Douglas Gregor 60d62c29d2 Implement basic support for converting constructors in user-defined
conversions.

Notes:
  - Overload resolution for converting constructors need to prohibit
    user-defined conversions (hence, the test isn't -verify safe yet).
  - We still use hacks for conversions from a class type to itself. 
    This will be the case until we start implicitly declaring the appropriate
    special member functions. (That's next on my list)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58513 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 16:23:19 +00:00
Douglas Gregor b48fe38120 Add support for parsing and representing C++ constructor declarations.
Notes:
  - Constructors are never found by name lookup, so they'll never get
    pushed into any scope. Instead, they are stored as an 
    OverloadedFunctionDecl in CXXRecordDecl for easy overloading.
  - There's a new action isCurrentClassName that determines whether an
    identifier is the name of the innermost class currently being defined;
    we use this to identify the declarator-id grammar rule that refers to 
    a type-name. 
  - MinimalAction does *not* support parsing constructors.
  - We now handle virtual and explicit function specifiers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58499 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 09:07:45 +00:00
Ted Kremenek 7fcfa4a9b5 Add iterator/reverse_iterator to InitListExpr for iteration over the subexpressions of an initializer list. This is basically the same as child_iterator except reverse iteration is possible (which will be used by GRExprEngine::VisitInitListExpr).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58438 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30 17:45:53 +00:00
Douglas Gregor f7c2aa0b04 Make the non-reference check in Expr work always
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58388 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29 18:00:54 +00:00
Douglas Gregor 27c8dc06f6 Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:

  - Try/Perform-ImplicitConversion now handles implicit conversions
    that don't involve references.
  - Try/Perform-CopyInitialization uses
    CheckSingleAssignmentConstraints for C. PerformCopyInitialization
    is now used for all argument passing and returning values from a
    function.
  - Diagnose errors with declaring references and const values without
    an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
  
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58353 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29 00:13:59 +00:00
Daniel Dunbar 8320aaaa01 80-col fixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58341 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 19:12:58 +00:00
Douglas Gregor 6eec8e883d Rename ExplicitCCastExpr to CStyleCastExpr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58331 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 15:36:24 +00:00
Douglas Gregor 9d293dfc0a Improve our handling of (C++) references within Clang. Specifically:
- Do not allow expressions to ever have reference type
  - Extend Expr::isLvalue to handle more cases where having written a
    reference into the source implies that the expression is an lvalue
    (e.g., function calls, C++ casts).
  - Make GRExprEngine::VisitCall treat the call arguments as lvalues when
    they are being bound to a reference parameter.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 00:22:11 +00:00
Daniel Dunbar af668b0e7d Add attribute always_inline support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58304 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 00:17:57 +00:00
Douglas Gregor 49badde06e Refactor the expression class hierarchy for casts. Most importantly:
- CastExpr is the root of all casts
  - ImplicitCastExpr is (still) used for all explicit casts
  - ExplicitCastExpr is now the root of all *explicit* casts
  - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++
  - CXXFunctionalCastExpr inherits from ExplicitCastExpr
  - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all
    of the C++ named cast expression types (static_cast, dynamic_cast, etc.)
  - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, 
    CXXReinterpretCastExpr, and CXXConstCastExpr to 

Also, fixed returned-stack-addr.cpp, which broke once when we fixed
reinterpret_cast to diagnose double->int* conversions and again when
we eliminated implicit conversions to reference types. The fix is in
both testcase and SemaChecking.cpp.

Most of this patch is simply support for the renaming. There's very
little actual change in semantics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58264 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27 19:41:14 +00:00
Ted Kremenek ce2fc3a343 - Move ExprIterator to Stmt.h so that it can be used by classes defined in Stmt.h
- Implement child_begin() and child_end() for AsmStmt.  Previously these had stub implementations that did not iterate over the input/output operands of an inline assembly statement.
- Use ExprIterator for performing iteration over input/output operands.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58261 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27 18:40:21 +00:00
Douglas Gregor 3dda64ec0f When destroying a translation unit, deallocate its owned declarations in reverse order, because there may be dependencies among the declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58244 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27 12:50:38 +00:00
Chris Lattner 418f6c7d14 Remember whether an initlist had a designator in the AST.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58218 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-26 23:43:26 +00:00
Argyrios Kyrtzidis 7fb5e48882 Don't give a default argument to ASTContext::getFunctionType for the TypeQuals parameter, it causes subtle bugs where TypeQuals, while necessary, are omitted from the call.
-Remove the default argument.
-Update all call sites of ASTContext::getFunctionType.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58187 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-26 16:43:14 +00:00
Argyrios Kyrtzidis 971c4fae60 -Add support for cv-qualifiers after function declarators.
-Add withConst/withVolatile/withRestrict methods to QualType class, that return the QualType plus the respective qualifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58120 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24 21:46:40 +00:00
Douglas Gregor 1f81230ac5 Move viewInheritance to CXXRecordDecl, and make sure it builds in Release mode, too
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58105 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24 19:53:54 +00:00
Douglas Gregor 2b9d973eb7 Make QualTypeOrdering::operator() const
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58097 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24 16:48:10 +00:00
Ted Kremenek e22d911dcf Added iterators for types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58050 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-23 23:35:43 +00:00
Douglas Gregor 57c856b96e Clean up and document the representation of C++ base classes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58040 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-23 18:13:27 +00:00
Douglas Gregor 0218936235 Added GraphViz visualization of C++ inheritance hierarchies.
Factored the QualTypeOrdering predicate into its own header
(TypeOrdering.h), now that it is used in two places.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58001 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 21:13:31 +00:00
Douglas Gregor f8268ae319 Add representation of base classes in the AST, and verify that we
don't have duplicated direct base classes.

Seriliazation of base class specifiers is not yet implemented.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57991 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 17:49:05 +00:00
Douglas Gregor ba7e210a99 QualType::isMoreQualifiedThan and isAtLeastAsQualifiedAs assert that we
aren't trying to compare with address-space qualifiers (for now).

Clean up handing of DeclRefExprs in Expr::isLvalue and refactor part
of the check into a static DeclCanBeLvalue.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57980 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 15:04:37 +00:00
Douglas Gregor e0a5d5fe8e Move Sema::GetNonReferenceType to QualType::getNonReferenceType and make it inline
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57951 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 04:14:44 +00:00
Douglas Gregor 9b6e2d209c Fix a thinko in the qualification-conversion check when the qualificaitons are disjoint, and add some overloading-based tests of qualification conversions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57942 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22 00:38:21 +00:00
Douglas Gregor 98cd599ee8 Initial step toward supporting qualification conversions (C++ 4.4).
Changes:
  - Sema::IsQualificationConversion determines whether we have a qualification
    conversion.
  - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++,
    performing an implicit conversion from the right-hand side to the type of
    the left-hand side rather than checking based on the C notion of 
    "compatibility". We now rely on the implicit-conversion code to
    determine whether the conversion can happen or
    not. Sema::TryCopyInitialization has an ugly reference-related
    hack to cope with the initialization of references, for now.
  - When building DeclRefExprs, strip away the reference type, since
    there are no expressions whose type is a reference. We'll need to
    do this throughout Sema.
  - Expr::isLvalue now permits functions to be lvalues in C++ (but not
  in C).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57935 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21 23:43:52 +00:00
Douglas Gregor 8e9bebdea6 Preliminary support for function overloading
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57909 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21 16:13:35 +00:00
Argyrios Kyrtzidis 509447e7cb Change a couple of cast<> to reinterpret_cast<>.
The casts<> require that "Decl.h" is included before "Type.h", use reinterpret_cast<> to remove that kind of dependency.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57781 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-19 12:05:48 +00:00
Mon P Wang 7ae48ee2fb Make llvm memory barrier available as an intrinsic
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57751 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18 02:49:28 +00:00
Daniel Dunbar 0d504c1da8 Remove unneeded EncodingRecordTypes argument to getObjCEncodingForType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57716 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17 20:21:44 +00:00
Mon P Wang 6d5e211fc5 Fixed vec_set_v2di signature
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57696 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17 17:39:34 +00:00
Daniel Dunbar d96b35bc6b More Obj-C type encoding improvements.
- Encode unions and bit-fields correctly.
 - Accept option to name record fields (used for NeXT runtime).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57685 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17 16:17:37 +00:00
Daniel Dunbar 82a6cfbc42 Fix bug in Obj-C type encoding for structures.
- Mechanism for detecting if a structure should be expanded wasn't
   reliable. Simplified by just keeping track of what we should be
   expanding.

 - This fixes a bug in using NSInvocation to invoke a method which
   returned a structure, which in used by Key Value Observing, which
   in the end, caused a miscompile in poor little Sketch.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57675 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17 07:30:50 +00:00
Daniel Dunbar 3b0db908eb Implement #pragma pack use in structure packing. The general approach
is to encode the state of the #pragma pack stack as an attribute when
the structure is declared. 

 - Extend PackedAttr to take an alignment (in bits), and reuse for
   both __attribute__((packed)) (which takes no argument, instead
   packing tightly (to "minimize the memory required") and for #pragma
   pack (which allows specification of the maximum alignment in
   bytes). __attribute__((packed)) is just encoded as Alignment=1.

   This conflates two related but different mechanisms, but it didn't
   seem worth another attribute.

 - I have attempted to follow the MSVC semantics as opposed to the gcc
   ones, since if I understand correctly #pragma pack originated with
   MSVC. The semantics are generally equivalent except when the stack
   is altered during the definition of a structure; its not clear if
   anyone does this in practice. See testcase if curious.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57623 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-16 02:34:03 +00:00
Daniel Dunbar 20c77e995d Use BatchEmitOwnedPtrs for writing multiple child exprs, per review.
Also added serialization support to OverloadExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57588 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-15 17:52:29 +00:00
Mon P Wang bc4f4030e2 Added pinsrd, pinsrq, and some other vector intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57563 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-15 06:18:34 +00:00
Argyrios Kyrtzidis 35bc0821c4 Simplify handling of struct/union/class tags.
Instead of using two sets of Decl kinds (Struct/Union/Class and CXXStruct/CXXUnion/CXXClass), use one 'Record' and one 'CXXRecord' Decl kind and make tag kind a property of TagDecl.
Cleans up the code a bit and better reflects that Decl class structure.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57541 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-15 00:42:39 +00:00
Daniel Dunbar d17c24ff85 Add serialization support in several missing places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57502 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-14 16:57:09 +00:00
Daniel Dunbar 708ef456a1 Move Type::EmitImpl into header, add FIXME to make abstract.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57501 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-14 16:55:17 +00:00
Argyrios Kyrtzidis e2ed203b43 More const-ness goodness.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57420 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 18:45:56 +00:00
Argyrios Kyrtzidis d2595ecce5 Improve the const-ness of a few methods.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57417 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 18:40:01 +00:00
Argyrios Kyrtzidis 42220c5432 Implement more efficient Decl <-> DeclContext conversions.
When the static type on the Decl side is a subclass of DeclContext the compiler will use a "inlinable" static_cast, instead of always using an out-of-line function call.

Note, though, that the isa<> check still uses an out-of-line function call.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57415 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 16:14:48 +00:00
Steve Naroff 090276f5e1 Final phase of converting BlockDecls over to DeclContext. This is unfortunately a largish/complex diff, however it was necessry to pass all the current block tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57337 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-10 01:28:17 +00:00
Steve Naroff 1c90bfcbd7 Instantiate the BlockDecl in ActOnBlockStart() so we can use it as a DeclContext.
This required changes to attach the compound statement later on (like we do for functions).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57304 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-08 18:44:00 +00:00
Steve Naroff 56ee6896f2 - Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.

This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?).

Still some follow-up work to finish this (forthcoming).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57298 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-08 17:01:13 +00:00
Ted Kremenek 8ffb159441 Migrate DeclStmt over to using a DeclGroup instead of a pointer to a ScopedDecl*.
This also removes the ugly hack needed in CFG.cpp for subclassing DeclStmt to create a DeclStmt with one Decl*.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57275 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 23:09:49 +00:00
Ted Kremenek 401adfad4a Add const_iterator to DeclGroup.
Serialization for OwningDeclGroupRefs now works.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57272 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 23:06:01 +00:00
Ted Kremenek 3e6d1203b3 Add StmtIterator support for DeclGroups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57271 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07 23:04:14 +00:00
Ted Kremenek c7b07c19da Added prototype serialization code for DeclGroup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57222 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 23:49:24 +00:00
Argyrios Kyrtzidis ce8e2926d8 Simplify handling of direct initializers by letting Sema::AddInitializerToDecl handle conversions, instead of using Sema::ActOnCXXTypeConstructExpr.
Additional benefit is that diagnostics are the same for both direct-initialization and copy-initialization.

In the case of "int x( expression );":
-The Init expression of VarDecl 'x' will be the expression inside the parentheses.
-VarDecl::hasCXXDirectInitializer for VarDecl 'x' will return true to let clients distinguish from "int x = expression ;".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57219 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 23:08:37 +00:00
Ted Kremenek 655137a6c1 Remove DeclStmt::getDecl(). Now clients of DeclStmt must explicitly reason about a DeclStmt referring to a collection of Decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57217 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 22:51:42 +00:00
Ted Kremenek e285a9505c Modified DeclGroupRef to always load/store the internal pointer value as Decl*. This hopefully will obviate any concerns with violating strict type-aliasing issues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57213 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 22:17:16 +00:00
Ted Kremenek 65aa3b9fda Add DeclStmt::hasSolitaryDecl() and DeclStmt::getSolitaryDecl()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57204 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 20:54:44 +00:00
Ted Kremenek 8a0d2660b6 Add const_decl_iterator to DecStmt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57186 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 18:35:55 +00:00
Argyrios Kyrtzidis 73a0d889ed Implement support for C++ direct initializers in declarations, e.g. "int x(1);".
This is how this kind of initializers appear in the AST:
-The Init expression of the VarDecl is a functional type construction (of the VarDecl's type).
-The new VarDecl::hasCXXDirectInitializer() returns true.

e.g, for "int x(1);":
-VarDecl 'x' has Init with expression "int(1)" (CXXFunctionalCastExpr).
-hasCXXDirectInitializer() of VarDecl 'x' returns true.

A major benefit is that clients that don't particularly care about which exactly form was the initializer can handle both cases without special case code.
Note that codegening works now for "int x(1);" without any changes to CodeGen.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57178 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 17:10:33 +00:00
Chris Lattner 6b47561af7 Remove the 'C' / isConstantExpr flag on builtins. Code should never
depend on the value of this flag, it should depend on whether 
tryEvaluate is able to *actually* fold a builtin.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57160 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 06:51:12 +00:00
Chris Lattner 45b6b9d080 Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExpr
which is checking for something that can be inconsistent with
what we can constant fold.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57159 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 06:49:02 +00:00
Chris Lattner a4d55d89c8 Move folding of __builtin_classify_type out of the CallExpr
interface into the constant folding interface.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57158 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 06:40:35 +00:00
Chris Lattner 019f4e858e Add a comment that describes tryEvaluate. Make tryEvaluate fold
__builtin_constant_p properly, and add some scaffolding for
FloatExprEvaluator to eventually handle huge_val and inf.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57152 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:28:25 +00:00
Chris Lattner cb88896740 add a new CallExpr::isBuiltinCall() method, and use it to simplify some existing
code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57151 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:00:53 +00:00
Anders Carlsson 232eb7d33b Implement support for the const and pure attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57142 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 23:32:53 +00:00
Chris Lattner 8223b1d05f Fix a problem reported in PR2766 that makes clang reject old versions
of GCC's headers.  This impacts people that run clang in Tiger systems.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57126 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 19:05:44 +00:00
Daniel Dunbar affc3a9bfa Fix X86 palignr[128] builtins to match LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57102 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 06:35:41 +00:00
Daniel Dunbar ec04b2622a Fix another X86 builtin definitions.
- vec_set_v4hi had "v4s" in place of "V4s"


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57099 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 05:21:00 +00:00
Daniel Dunbar 1827db7711 Fix some X86 builtin definitions.
- cmp instructions return int
 - storedqu had bad const qualifier
 - pmuldq128 used invalid type code


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57098 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 05:14:37 +00:00
Steve Naroff 83ba14e260 - Add a convenience constructor to Type.
- Many rewriter modifications.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57003 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 15:04:50 +00:00
Steve Naroff 0eb07bfde0 Add getTypeSpecStartLoc() to VarDecls and FunctionDecls.
This is a temporary solution to help with the block rewriter (though it certainly has general utility).
Once DeclGroup's are implemented, this SourceLocation should be stored with it (since it applies to all the decls).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56985 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 00:02:03 +00:00
Daniel Dunbar ae3f4919e4 Add Builtins.def attribute for "can be a constant expression".
- Enabled for builtins which are always constant expressions
   (__builtin_huge_val*, __builtin_inf*, __builtin_constant_p,
   __builtin_classify_type, __builtin___CFStringMakeConstantString).

Added Builtin::Context::isConstantExpr.
 - Currently overly simply interface which only works for builtins
   whose constantexprness does not depend on their arguments.

CallExpr::isBuiltinConstantExpr now takes an ASTContext argument.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56983 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-02 23:30:31 +00:00
Mon P Wang 946685626e Added SSE4.1 blend intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56936 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-01 23:08:39 +00:00
Mon P Wang 7f57b000f2 Added support for sse intrinsics loadlpd, loadhpd, muldq128, and mulld128
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56830 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-30 05:31:27 +00:00
Chris Lattner a09f585a7f move ExtVectorElementExpr down into the 'clang extensions' section.
Wrap line to 80 cols.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56805 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 21:30:29 +00:00
Chris Lattner bd7eb1c3b2 Replace a comparison with a static list of builtins that was wrong (it
wasn't covering checking builtins like __builtin___vsnprintf_chk) with
a check that won't get out of date. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56767 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 05:54:29 +00:00
Ted Kremenek 9da13f9ddb Internally store the body of a BlockExpr using a Stmt* instead of a CompoundStmt*, and use the getBody() method to do the appropriate checking. This both removes the type-punning warnings in Expr.cpp and also makes BlockExpr have more consistency checks against modifications to its body (via StmtIterator).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 23:24:14 +00:00
Ted Kremenek e7b8d40020 Forgot to check in header file with last commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56709 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 23:24:05 +00:00
Steve Naroff 4f6a7d7ead Tweak Expr::isModifiableLvalue() and Expr::isLvalue() to better deal with BlockDeclRef exprs.
This fixes <rdar://problem/6248392> clang: Error when using address of stack variable inside block.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56652 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 14:41:28 +00:00
Ted Kremenek d17062cc23 Added prototype implementation of the DeclGroup, DeclGroupRef, and DeclGroupOwningRef classes.
Documentation and testing are pending.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-25 17:13:40 +00:00
Steve Naroff 9eae5761c0 Finish pushing blocks attribute through the clang attribute machinery.
Also added a couple simple tests from the "gcc.apple" test suite.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56309 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-18 16:44:58 +00:00
Steve Naroff 9c3c902835 Remove BlockStmtExpr.
Block literals are now represented by the concrete BlockExpr class.
This is cleanup (removes a FIXME).
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56288 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-17 18:37:59 +00:00
Steve Naroff 17dab4f616 Remove support for BlockExprExpr. For example...
^(expression) or ^(int arg1, float arg2)(expression)
...is no longer supported. 
All block literals now require a compound statement.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56257 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-16 23:11:46 +00:00
Ted Kremenek d452758bb6 ProgramPoint now takes the space of two pointers instead of one. This change was
motivated because it became clear that the number of subclasses of ProgramPoint
would expand and we ran out of bits to represent a pointer variant. As a plus of
this change, BlockEdge program points can now be represented explicitly without
using a cache of CFGBlock* pairs in CFG.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56245 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-16 18:44:52 +00:00
Ted Kremenek a95d375044 Patch by Csaba Hruska!
"Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch
covers the AST library, but ignores Analysis lib."


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56185 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-13 05:16:45 +00:00
Daniel Dunbar df3ffb300a Round out object size checking builtins (fprintf ones disabled as we
have no mapping to FILE*). We are also missing printf format
attributes for the printf style ones.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56168 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-12 18:39:42 +00:00
Douglas Gregor 77a52233f7 Give string literals const element typesin C++, and cope with the deprecated C++ conversion from a string literal to a pointer-to-non-const-character
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56137 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-12 00:47:35 +00:00
Mon P Wang 3e877ec791 Added SSE41 pminsd, pmaxsd, roundps and a few others
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56114 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 19:22:31 +00:00
Daniel Dunbar 9776ba0d84 Add ObjCMethodDecl::getSourceRange.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56083 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 00:47:15 +00:00
Argyrios Kyrtzidis 9e922b1663 Add new 'CXXConditionDeclExpr' expression node used for a 'condition' declaration, e.g: "if (int x=0) {...}".
It is a subclass of DeclRefExpr and the main difference is that CXXConditionDeclExpr owns the declaration that it references.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56033 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 23:47:53 +00:00
Mon P Wang e01c2c9e07 Added SSE4.1 packusdw
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55978 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 02:49:09 +00:00
Mon P Wang f47be933be Added SSE41 pmovsx pmovzx intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55967 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 00:19:01 +00:00
Daniel Dunbar 6f0200e9eb Add ThreadSpecified bit to Decl.
- Patch from Kevin Tew.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55940 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-08 20:05:47 +00:00
Ted Kremenek 4b7c98378a Change struct forward declarations and definitions to use unique RecordDecls, as opposed to creating a single RecordDecl and reusing it.
This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet).

The motivation of this patch is as follows:
- Capture more source information, necessary for refactoring/rewriting clients.

- Pave the way to resolve ownership issues with RecordDecls with the forthcoming
  addition of DeclGroups.

Current caveats:
- Until DeclGroups are in place, we will leak RecordDecls not explicitly
  referenced by the AST.  For example:

    typedef struct { ... } x;  

  The RecordDecl for the struct will be leaked because the TypedefDecl doesn't
  refer to it.  This will be solved with DeclGroups.
  
- This patch also (temporarily) breaks CodeGen.  More below.

High-level changes:
- As before, TagType still refers to a TagDecl, but it doesn't own it.  When
  a struct/union/class is first referenced, a RecordType and RecordDecl are
  created for it, and the RecordType refers to that RecordDecl.  Later, if
  a new RecordDecl is created, the pointer to a RecordDecl in RecordType is
  updated to point to the RecordDecl that defines the struct/union/class.

- TagDecl and RecordDecl now how a method 'getDefinition()' to return the
  TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular
  enum/struct/class/union. This is useful from going from a RecordDecl* that
  defines a forward declaration to the RecordDecl* that provides the actual
  definition. Note that this also works for EnumDecls, except that in this case
  there is no distinction between forward declarations and definitions (yet).

- Clients should no longer assume that 'isDefinition()' returns true from a
  RecordDecl if the corresponding struct/union/class has been defined.
  isDefinition() only returns true if a particular RecordDecl is the defining
  Decl. Use 'getDefinition()' instead to determine if a struct has been defined.

- The main changes to Sema happen in ActOnTag. To make the changes more
  incremental, I split off the processing of enums and structs et al into two
  code paths. Enums use the original code path (which is in ActOnTag) and
  structs use the ActOnTagStruct. Eventually the two code paths will be merged,
  but the idea was to preserve the original logic both for comparison and not to
  change the logic for both enums and structs all at once.

- There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls
  that correspond to the same type simply have a pointer to that type. If we
  need to figure out what are all the RecordDecls for a given type we can build
  a backmap.

- The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the
  changes to RecordDecl. For some reason 'svn' marks the entire file as changed.

Why is CodeGen broken:
- Codegen assumes that there is an equivalence between RecordDecl* and
  RecordType*. This was true before because we only created one RecordDecl* for
  a given RecordType*, but it is no longer true. I believe this shouldn't be too
  hard to change, but the patch was big enough as it is.
  
I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C).  


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55839 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 17:16:31 +00:00
Daniel Dunbar 797a35d8a4 Fix placement of const on a number of X86 builtins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55827 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 05:56:16 +00:00
Ted Kremenek df042e6c2b Remove "NextDecl" from RecordDecl. This change touches many files that where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration.
The motivation behind this change is that chaining the RecordDecls is simply unnecessary.  Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55821 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 01:34:33 +00:00
Steve Naroff 39218dfef5 Touchup CheckSingleAssignmentConstraints() and CheckCompareOperands() to check for block pointers.
Added a couple FIXME's wrt PointLikeType. If the author reads this, it would be great to get some background on this class (thanks in advance).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55778 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04 16:56:14 +00:00
Steve Naroff 1c7d067550 Add type checking for blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55767 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04 15:10:53 +00:00
Daniel Dunbar d5f8a4fd4d Add __builtin_object_size support.
- Currently CodeGen always returns a conservative value for this (-1
   or 0 depending on the context).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55735 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 21:13:56 +00:00
Daniel Dunbar b0a86c21f9 Modify object size checking builtins to lower to libc calls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55721 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 20:28:50 +00:00
Steve Naroff 4eb206bebc Add semantic analysis for "blocks".
Highlights...

- 4 new AST nodes, BlockExpr, BlockStmtExpr, BlockExprExpr, BlockDeclRefExpr.
- Sema::ActOnBlockStart(), ActOnBlockError(), ActOnBlockStmtExpr(), ActOnBlockExprExpr(), ActOnBlockReturnStmt().

Next steps...

- hack Sema::ActOnIdentifierExpr() to deal with block decl refs.
- add attribute handler for byref decls.
- add test cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 18:15:37 +00:00
Daniel Dunbar e66f4e3e3a Fix ObjCPropertRefExpr to be able to encode all the information for
uses which refer to methods not properties.
 - Not yet wired in Sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55681 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 00:27:26 +00:00
Ted Kremenek 6359792ca9 RecordDecl:
- Remove method 'isForwardDecl'; this functionality is already provided by
  'isDefinition()'
- Move method definitions to be co-located with other RecordDecl methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55649 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 21:12:32 +00:00
Ted Kremenek a39da06576 RecordDecl:
- Added method 'isForwardDeclaration', a predicate method that returns true
  if a RecordDecl represents a forward declaration.
- Added method 'getDefinitionDecl', a query method that returns a pointer to
  the RecordDecl that provides the actual definition of a struct/union.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55642 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 20:25:22 +00:00
Ted Kremenek df91eca19b CXXRecordDecl and RecordDecl:
- Change constructor and create methods to accept a CXXRecordDecl* (RecordDecl*)
  instead of a ScopedDecl* for PrevDecl.  This causes the type checking
  to be more tight and doesn't break any code.
  
RecordDecl:

- Don't use the NextDeclarator field in ScopedDecl to represent the previous
  declaration. This is a conflated use of the NextDeclarator field, which will
  be removed anyway when DeclGroups are fully implemented.

- Instead, represent (a soon to be implemented) chain of RecordDecls using a
  NextDecl field.  The last RecordDecl in the chain is always the 'defining'
  RecordDecl that owns the FieldDecls.  The other RecordDecls in the chain
  are forward declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55640 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 20:13:32 +00:00
Nuno Lopes b381aac9ba codegen constant data as such. add QualType::isConstant()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55603 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-01 11:33:04 +00:00
Anders Carlsson bd4c1ada2e Add code to create the fast enumeration state type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55572 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-30 19:34:46 +00:00
Nico Weber 91c027e202 fix a comment that was forgotten in r54071
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55543 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-29 17:24:46 +00:00
Daniel Dunbar 9048891ff9 Fix double-free error with sizeof applied to VLA types.
- PR2727.

Also, fix warning in CodeGenTypes for new BlockPointer type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55479 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-28 18:02:04 +00:00
Argyrios Kyrtzidis 77a49f6b1e Fix compilation error on MSVC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55465 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-28 07:45:57 +00:00
Daniel Dunbar c56f34a1c1 NeXT: Emit mostly-correct property type encoding.
- Added ASTContext::getObjCEncodingForPropertyDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55461 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-28 04:38:10 +00:00
Steve Naroff 5618bd4a52 First wave of changes to support "blocks" (an extension to C).
This commit adds the declaration syntax (and associated type).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55417 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-27 16:04:49 +00:00
Daniel Dunbar 7b4732296b Add addPropertyMethods implementations for
ObjC{Category,Protocol}Decl.
 - No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55404 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-27 02:09:39 +00:00
Daniel Dunbar af05bb9073 Objective-C @synthesize support.
- Only supports simple assignment and atomic semantics are ignored.
 - Not quite usable yet because the methods do not actually get added
   to the class metadata.
 - Added ObjCPropertyDecl::getSetterKind (one of Assign, Copy, Retain).
 - Rearrange CodeGenFunction so synthesis can reuse function prolog /
   epilog code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55365 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 08:29:31 +00:00
Daniel Dunbar 394d33f1f6 Add ObjCPropertyDecl::isReadOnly.
Respect isReadOnly when generating synthesized method decls.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55364 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 07:16:44 +00:00
Daniel Dunbar 3216dcdebb constify ObjC*::getClassMethod,getInstanceMethod
No (intended) functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55362 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 06:53:45 +00:00
Daniel Dunbar 451318c08a Move implicit Obj-C param creation into ObjCMethodDecl.
- Add ObjCMethodDecl::createImplicitParams.
 - Remove ObjCMethodDecl::set{Self,Cmd}Decl
 - Remove Sema::CreateImplicitParameter

No (intended) functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55356 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 06:07:48 +00:00
Daniel Dunbar 9f0afd4e79 Rename ObjCPropertyImplDecl::PropertyImplKind (consistency)
- Change enum name to Kind.
 - Change enum constants to English strings.

Also, fix getPropertyImplementation (which probably should be renamed)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55354 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-26 04:47:31 +00:00
Anders Carlsson aa0d25b44e Add support for parsing the objc_gc attribute. Tests will come shortly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55269 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 23:22:21 +00:00
Argyrios Kyrtzidis cb6accb465 CXXFunctionalCastExpr is a subclass of CastExpr. Make it known to isa/dyn_cast/cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55237 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 15:36:01 +00:00
Argyrios Kyrtzidis 987a14bf58 Add support for C++'s "type-specifier ( expression-list )" expression:
-The Parser calls a new "ActOnCXXTypeConstructExpr" action.
-Sema, depending on the type and expressions number:
   -If the type is a class, it will treat it as a class constructor. [TODO]
   -If there's only one expression (i.e. "int(0.5)" ), creates a new "CXXFunctionalCastExpr" Expr node
   -If there are no expressions (i.e "int()" ), creates a new "CXXZeroInitValueExpr" Expr node.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55177 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 15:38:55 +00:00
Eli Friedman 86da77fdaf Minor const cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55160 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 00:59:49 +00:00
Eli Friedman 3d815e7eb5 Rewrite type compatibility testing to do type merging rather than just
testing compatibility.  This is necessary for some constructs, like merging
redeclarations.

Also, there are some ObjC changes to make sure that 
typesAreCompatible(a,b) == typesAreCompatible(b,a).  I don't have any 
ObjC code beyond the testsuite, so please tell me if there are any cases 
where this doesn't behave as expected.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55158 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 00:56:42 +00:00
Daniel Dunbar dbc933701d NeXT: Emit [meta]class protocol references.
Updated ObjCProtocolDecl::protocol_iterator to match that of
ObjCInterfaceDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55143 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-21 21:57:41 +00:00
Daniel Dunbar f6414927e6 Fix attributes on Obj-C interfaces & methods.
- Drop MethodAttrs parameter to ObjCMethodDecl
 - Call ProcessDeclAttributeList for interface & method decls.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55068 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-20 18:02:42 +00:00
Ted Kremenek 01e6779fac Added ObjCAtDefsFieldDecl to represent FieldDecls created by @defs.
This fixes an ownership issue where FieldDecls could be owned both by an ObjCInterfaceDecl and a RecordDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55037 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-20 03:26:33 +00:00
Argyrios Kyrtzidis 0835a3cdee Add ExplicitCastExpr to replace the current CastExpr, and have ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr):
Expr
  -> CastExpr
     -> ExplicitCastExpr
     -> ImplicitCastExpr 

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54955 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-18 23:01:59 +00:00