Commit Graph

2189 Commits

Author SHA1 Message Date
Ted Kremenek 6c90efb923 Move LexIncludeFilename from Lexer to PreprocessorLexer.
PreprocessorLexer now has a virtual method "IndirectLex" which allows it to call the lex method of its subclasses.  This is not for performance intensive operations.

llvm-svn: 59185
2008-11-12 22:43:05 +00:00
Daniel Dunbar f32443cdcd Quick fix for crash in IRgen when we can tryEvaluate a condition to
something that is not an int.

 - Ignore these cases for now, added FIXME that we should also boolize
   them.

llvm-svn: 59184
2008-11-12 22:37:10 +00:00
Ted Kremenek 50b4f48225 Use PushIncludeMacroStack() instead of manually manipulating the include stack.
llvm-svn: 59181
2008-11-12 22:21:57 +00:00
Ted Kremenek 65dd30fdea Update CFGStmtVisitor to recognize that ObjCForCollectionStmts are special block-level "expressions".
llvm-svn: 59176
2008-11-12 21:58:46 +00:00
Daniel Dunbar a461e6d124 Disable some debug prints.
llvm-svn: 59174
2008-11-12 21:52:46 +00:00
Ted Kremenek 7cd62457c4 Add skeleton for PTH lexer.
llvm-svn: 59169
2008-11-12 21:37:15 +00:00
Chris Lattner 6515bcc3c6 Fix a FIXME by improving a diagnostic, add a testcase for PR3048
llvm-svn: 59167
2008-11-12 21:25:45 +00:00
Chris Lattner ffb31a23a5 make TryFixInvalidVariablyModifiedType a static function.
llvm-svn: 59163
2008-11-12 21:17:48 +00:00
Ted Kremenek df31792a66 Shore up transfer function for ObjCForCollectionStmt.
llvm-svn: 59162
2008-11-12 21:12:46 +00:00
Ted Kremenek 97450fe0a1 Use Stmt* instead of Expr* for block-level expression.
llvm-svn: 59161
2008-11-12 21:12:18 +00:00
Ted Kremenek 6d8b46e71d ObjCForCollectionStmts are block-level expressions.
llvm-svn: 59160
2008-11-12 21:11:49 +00:00
Chris Lattner b5da7a342c Restructure code to encourage fallthrough, no functionality change.
llvm-svn: 59157
2008-11-12 19:48:13 +00:00
Chris Lattner e7d1cdb6fd fix PR3048. I'm going to do some more work before closing it off and
adding a testcase.

llvm-svn: 59156
2008-11-12 19:45:49 +00:00
Ted Kremenek 1781080c34 Add (preliminary) transfer function support for ObjCForCollectionStmt. Still need to flesh out some logic.
When processing DeclStmt, use the new interface to StateManager::BindDecl.  Conjuring of symbols is now done in VisitDeclStmt.

llvm-svn: 59155
2008-11-12 19:24:17 +00:00
Ted Kremenek 9999d72fe2 Conjured symbols now bind to Stmt* instead of Expr*.
llvm-svn: 59154
2008-11-12 19:22:47 +00:00
Ted Kremenek 60d46414f4 Update method names involving GRStateRef. No functionality change.
llvm-svn: 59153
2008-11-12 19:22:09 +00:00
Ted Kremenek b94d72a0e3 GRStateRef:
- Rename SetSVal to BindLoc
- Add BindDecl
- Add BindExpr

GRState:
- Environment now binds to Stmt* instead of Expr*.  This is needed for processing ObjCForCollectionStmt (essentially the declaration of the the 'element' variable can have an SVal attached to it).
- BindDecl no longer accepts Expr* for the initialization value; use SVal* instead.

llvm-svn: 59152
2008-11-12 19:21:30 +00:00
Ted Kremenek cd639218e4 StoreManager::BindDecl now takes an SVal* for the initialization value instead of an Expr* (which can be null). Lazy symbolication of conjured symbols is now the sole responsibility of GRExprEngine.
llvm-svn: 59151
2008-11-12 19:18:35 +00:00
Douglas Gregor a11693bc37 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.

llvm-svn: 59148
2008-11-12 17:17:38 +00:00
Daniel Dunbar 2889780436 Start a README.txt of possible optimizations to do in IRgen.
llvm-svn: 59130
2008-11-12 12:31:28 +00:00
Daniel Dunbar bf3c22e51d Handle ?: in EmitBranchOnBoolExpr.
llvm-svn: 59129
2008-11-12 10:30:32 +00:00
Daniel Dunbar d2a53a7b77 Rename ?: operator blocks to cond.true and cond.false (I don't know
what "cond.?" means, and this avoids quoting).

llvm-svn: 59128
2008-11-12 10:13:37 +00:00
Daniel Dunbar 682712cda0 Comment/indentation fix.
llvm-svn: 59127
2008-11-12 10:12:14 +00:00
Eli Friedman 9a156e5c1e Some additions to tryEvaluate I've had sitting around for a while.
This pushes it a lot closer to being able to deal with most of the stuff 
CodeGen's constant expression evaluator knows how to deal with.  This 
also fixes PR3003.

The test could possibly use some improvement, but this'll work for now.  
Test 6 is inspired by PR3003; the other tests are mostly just designed
to exercise the new code.  The reason for the funny structure of the 
tests is that type fixing for arrays inside of structs is the only place 
in Sema that calls tryEvaluate, at least for the moment.

llvm-svn: 59125
2008-11-12 09:44:48 +00:00
Chris Lattner 3fd91f83fd Lower ?: into select when the selected values are cheap and side-effect-free.
This cuts another 200 lines off expr.ll, forming 23 selects.

llvm-svn: 59124
2008-11-12 08:55:54 +00:00
Chris Lattner 35710d18fe emit better codegen for ||/&&, shrinking expr.ll by another 240 lines.
This happens for stuff like this:

x = cond1 || cond2 || cond3 || cond4;

llvm-svn: 59123
2008-11-12 08:38:24 +00:00
Chris Lattner 8b0845822d use ConstantFoldsToSimpleInteger instead of code emission to do
constant folding.

llvm-svn: 59121
2008-11-12 08:26:50 +00:00
Daniel Dunbar 5fc2871820 IRgen improvements on unreachable code:
- Split out "simple" statements which can easily handle IR generation
   when there is no insert point. These are generally statements which
   start by emitting a new block or are only containers for other
   statements.

 - This fixes a regression in emitting dummy blocks, notably for case
   statements.

 - This also fixes spurious emission of a number of debug stoppoint
   intrinsic instructions.

Remove unneeded sw.body block, just clear the insertion point.

Lift out CodeGenFunction::EmitStopPoint which calls into the
CGDebugInfo class when generating debug info.

Normalize definitions of Emit{Break,Continue}Stmt and usage of
ErrorUnsupported.

llvm-svn: 59118
2008-11-12 08:21:33 +00:00
Chris Lattner d95377341b Handle Unary ! in EmitBranchOnBoolExpr, so that we can efficiently
codegen stuff like "if (!(X && Y))"

llvm-svn: 59115
2008-11-12 08:13:36 +00:00
Chris Lattner 51e7118c30 Use EmitBranchOnBoolExpr in VisitConditionalOperator. This
shrinks code yet again by a bit.

llvm-svn: 59114
2008-11-12 08:08:13 +00:00
Chris Lattner cd439299b0 Move EmitBranchOnBoolExpr and ConstantFoldsToSimpleInteger to
CodeGenFunction.cpp.  Change VisitConditionalOperator to use
constant fold instead of codegen'ing a constant conditional.

Change ForStmt to use EmitBranchOnBoolExpr, this shrinks
expr.c very slightly to 40239 lines.

llvm-svn: 59113
2008-11-12 08:04:58 +00:00
Chris Lattner b7a9e16486 Make emission of 'if' conditions much more sophisticated when we
have a condition that is an &&/||.  Before we used to compile things like this:

int test() {
  if (x && y) foo(); else bar();
}

into:

	%0 = load i32* @x		; <i32> [#uses=1]
	%1 = icmp ne i32 %0, 0		; <i1> [#uses=1]
	br i1 %1, label %land_rhs, label %land_cont

land_rhs:		; preds = %entry
	%2 = load i32* @y		; <i32> [#uses=1]
	%3 = icmp ne i32 %2, 0		; <i1> [#uses=1]
	br label %land_cont

land_cont:		; preds = %land_rhs, %entry
	%4 = phi i1 [ false, %entry ], [ %3, %land_rhs ]		; <i1> [#uses=1]
	br i1 %4, label %ifthen, label %ifelse

ifthen:		; preds = %land_cont
	%call = call i32 (...)* @foo()		; <i32> [#uses=0]
	br label %ifend

ifelse:		; preds = %land_cont
	%call1 = call i32 (...)* @bar()		; <i32> [#uses=0]
	br label %ifend

ifend:		; preds = %ifelse, %ifthen


Now we turn it into the much more svelte code:

        %0 = load i32* @x               ; <i32> [#uses=1]
        %1 = icmp ne i32 %0, 0          ; <i1> [#uses=1]
        br i1 %1, label %land_lhs_true, label %ifelse

land_lhs_true:          ; preds = %entry
        %2 = load i32* @y               ; <i32> [#uses=1]
        %3 = icmp ne i32 %2, 0          ; <i1> [#uses=1]
        br i1 %3, label %ifthen, label %ifelse

ifthen:         ; preds = %land_lhs_true
        %call = call i32 (...)* @foo()          ; <i32> [#uses=0]
        br label %ifend

ifelse:         ; preds = %land_lhs_true, %entry
        %call1 = call i32 (...)* @bar()         ; <i32> [#uses=0]
        br label %ifend

ifend:          ; preds = %ifelse, %ifthen

Note the lack of a phi node.

This shrinks the -O0 .ll file for 176.gcc/expr.c from 43176 to 40267 lines.

llvm-svn: 59111
2008-11-12 07:46:33 +00:00
Chris Lattner fac05aeae5 fix a crash analyzing constants in 176.gcc/expr.c with my next patch. It was
crashing because we errors are ignored in subexpressions that are not evaluated,
but we still evaluate the result of parents.  This would cause an assertion 
because the erroneous subexpr didn't have its result value set to the right type.

llvm-svn: 59110
2008-11-12 07:43:42 +00:00
Chris Lattner aa3f951efc Teach the aggressive constant folder to fold X && 0 -> 0 and X || 1 -> 1
llvm-svn: 59105
2008-11-12 07:04:29 +00:00
Chris Lattner 4ad31fcc43 Clean up some code to use isZero instead of calling getZExtValue.
llvm-svn: 59103
2008-11-12 04:54:14 +00:00
Daniel Dunbar 8307290f35 Use createBasicBlock here too.
llvm-svn: 59095
2008-11-12 00:02:07 +00:00
Daniel Dunbar 851eec11a7 Disable generation of basic block names in NDEBUG mode.
Revert to enabling generation of instruction names when not in NDEBUG
mode.

llvm-svn: 59094
2008-11-12 00:01:12 +00:00
Daniel Dunbar 5c7e3935f1 Rework IRgen invariant w.r.t. current insert point.
- EmitStmt is no longer required to finish with a current insertion
   point defined (i.e. it does not need to make dummy
   blocks). Instead, it can clear the insertion point in the builder
   which indicates that the current insertion point is unreachable.
 - CodeGenFunction provides HaveInsertPoint and EnsureInsertPoint
   which respectively test if there is an insert point and ensure an
   insertion point exists (by making a dummy block).
 - Clearly mark functions in CodeGenFunction which can be called with
   no insertion point defined. Currently this is a limited set, and
   EmitStmt simply EnsureInsertPoint()s before emitting subsequent IR.

Remove EmitDummyBlock, which is no longer needed. Clients who haven't
already cleared the insertion point (typically via EmitBranch) can do
so by hand.

Remove isDummyBlock, which has effectively been renamed to
HaveInsertPoint.

The main thrust of this change is that we no longer have create dummy
blocks just to destroy them a short time later in EmitBlock in the
common case that there is no unreachable code following something like
a goto. 

Additionally, this means that we are not using the hokey condition in
isDummyBlock that a block without a name is a dummy block. Guess how
well that works when we never emit block names!

llvm-svn: 59089
2008-11-11 23:11:34 +00:00
Daniel Dunbar ab197ebb1a Change EmitBranch to always clear the insert point to clarify irgen
invariants.

llvm-svn: 59085
2008-11-11 22:06:59 +00:00
Daniel Dunbar fab3f936dd Emit debug region end in unified return block.
llvm-svn: 59081
2008-11-11 20:59:54 +00:00
Anton Korobeynikov fdf389b9e4 Codegen support for fastcall & stdcall CC.
Patch by Ilya Okonsky!

llvm-svn: 59080
2008-11-11 20:21:14 +00:00
Ted Kremenek 7a18858bcf Flow-sensitive uninitialized values analysis:
- Added support for ObjCForCollectionStmt
- Fixed bug where expression values would be always set to uninitialized when loops were involved

llvm-svn: 59076
2008-11-11 19:41:42 +00:00
Ted Kremenek 3b4e1d5cc6 Accesses to a collection within a fast enumeration 'for' statement constitute a 'use'.
llvm-svn: 59075
2008-11-11 19:40:47 +00:00
Chris Lattner d53e23328e Try to not emit the dead side of ?: if the condition is a constant.
llvm-svn: 59061
2008-11-11 18:56:45 +00:00
Sebastian Redl 6f28289aca Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof expressions, both of values and types.
llvm-svn: 59057
2008-11-11 17:56:53 +00:00
Ted Kremenek fbd2f4006b Add transfer function support for ObjCForCollectionStmt to LiveVariables.
llvm-svn: 59053
2008-11-11 17:42:10 +00:00
Ted Kremenek 9d56e64543 Add CFG support for Objective-C 2.0 fast enumeration 'for' statement:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_7_section_2.html#//apple_ref/doc/uid/TP30001163-CH18-SW3

Need to modify GRExprEngine, LiveVariables, and UninitializedValues to understand this construct.

llvm-svn: 59049
2008-11-11 17:10:00 +00:00
Sebastian Redl c470476420 Implement C++ 'typeid' parsing and sema.
llvm-svn: 59042
2008-11-11 11:37:55 +00:00
Daniel Dunbar c56e67644f Add CodeGenFunction::EmitBranch.
- Emits an unconditional branch, with extra logic to avoid generating
   spurious branches out of dummy blocks.

llvm-svn: 59037
2008-11-11 09:41:28 +00:00
Daniel Dunbar a0821bf8a2 Fix cmake build, patch from Jjgod Jiang.
llvm-svn: 59036
2008-11-11 08:29:24 +00:00
Chris Lattner 5b1964b5f9 short circuit && and || when possible. This substantially reduces
the size of the -O0 output on some cases.  For example, on expr.c from
176.gcc, it shrinks the .ll file from 43164 to 42835 lines, and removed
references to two external symbols.

llvm-svn: 59034
2008-11-11 07:41:27 +00:00
Chris Lattner aaaa199ad1 Make codegen smart enough to not emit the dead side of an if whose
condition is a constant.  This shrinks -O0 codegen by quite a bit
on some cases.

llvm-svn: 59033
2008-11-11 07:24:28 +00:00
Chris Lattner cd2523b41c implement debug info for typeof()
llvm-svn: 59032
2008-11-11 07:01:36 +00:00
Chris Lattner 8c5dd730ce Fix PR3031 by silencing follow-on errors in invalid declarations.
llvm-svn: 59027
2008-11-11 06:13:16 +00:00
Daniel Dunbar 29ac59f25c Add CodeGenFunction::EmitDummyBlock for marking places where we make
"dummy" blocks (blocks just used to make sure we have a place to dump
code to).

llvm-svn: 59022
2008-11-11 04:34:23 +00:00
Daniel Dunbar 05e629aec6 Remove CodeGenFunction::StartBlock.
- Was confusing and only used in one small part of the code.

llvm-svn: 59020
2008-11-11 04:12:31 +00:00
Daniel Dunbar 75283ff38a Centralize basic block creation in CodeGenFunction::createBasicBlock.
- No functionality change.

llvm-svn: 59017
2008-11-11 02:29:29 +00:00
Zhongxing Xu deb7cac332 Fix StringLiteral print bug.
llvm-svn: 59015
2008-11-11 01:36:32 +00:00
Daniel Dunbar e27d7b5530 Fix Release-Asserts warning.
llvm-svn: 59013
2008-11-11 01:16:00 +00:00
Douglas Gregor cd695e500d Basic support for taking the address of an overloaded function
llvm-svn: 59000
2008-11-10 20:40:00 +00:00
Douglas Gregor d36ed56c52 Remove an out-of-date FIXME
llvm-svn: 58990
2008-11-10 17:01:38 +00:00
Douglas Gregor 49de5340c0 Improve parser error recovery after a constructor initializer
llvm-svn: 58989
2008-11-10 16:59:40 +00:00
Douglas Gregor f52cdd0124 Allow user-defined conversions during reference binding
llvm-svn: 58988
2008-11-10 16:14:15 +00:00
Douglas Gregor 1cd48f1645 Don't create a typedef for the injected-class-name
llvm-svn: 58987
2008-11-10 14:41:22 +00:00
Douglas Gregor 6cf0806e75 Some cleanups to the declaration/checking of overloaded operators in C++. Thanks to Sebastian for the review
llvm-svn: 58986
2008-11-10 13:38:07 +00:00
Zhongxing Xu bba5c7c629 Add pretty printing to StringRegion.
llvm-svn: 58985
2008-11-10 13:05:26 +00:00
Zhongxing Xu 18d6fd45de Implement RegionStoreManager::RemoveDeadBindings(). This prunes several false warning caused by removal of symbolic constraints. Currently we just mark all symbols live. Further optimization for dead binding removal needed.
llvm-svn: 58982
2008-11-10 09:39:04 +00:00
Chris Lattner b5d21a4d03 don't preserve names on IR instructions. This matches llvm-gcc's behavior and
speeds up the compiler by ~8% at -emit-llvm -O0.

llvm-svn: 58977
2008-11-10 06:31:46 +00:00
Chris Lattner f61801403d Fix even more bugs in debug info support:
1. emit proper debug info for forward decls of structs.
2. emit DW_TAG_member nodes around members of a field like llvm-gcc does.

This slows down debug info generation, but is required for correctness.

llvm-svn: 58973
2008-11-10 06:10:01 +00:00
Chris Lattner affb37337f reimplement debug info generation in terms of DebugInfo.h instead of
using MachineModuleInfo.  This runs at about the same speed as the old
code, but fixes a bunch of bugs and is simpler and shorter.

llvm-svn: 58971
2008-11-10 06:08:34 +00:00
Zhongxing Xu 1c31dbe417 Print integer value instead of raw pointer. This is a hack to be fixed by migrating the output in analyzer to llvm::raw_ostream.
llvm-svn: 58965
2008-11-10 05:00:06 +00:00
Chris Lattner 231f7bbdbe silence a warning from gcc.
llvm-svn: 58956
2008-11-10 03:00:37 +00:00
Argyrios Kyrtzidis 9e59b577d8 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

llvm-svn: 58948
2008-11-09 23:41:00 +00:00
Argyrios Kyrtzidis 8ad00b26ee When a tag has nested-name ('struct foo::bar'), use not 'CurContext' but the context of the nested-name ('foo::').
llvm-svn: 58945
2008-11-09 22:53:32 +00:00
Argyrios Kyrtzidis e02eb2bac2 Simplify handling of nested-names in tags ('struct foo::bar').
-Use more of the non nested-name code path.
-Also use the ActOnTagStruct code path.

llvm-svn: 58944
2008-11-09 22:09:58 +00:00
Anders Carlsson 3442f82c2f Support named operands in inline asm statements.
llvm-svn: 58940
2008-11-09 18:54:14 +00:00
Argyrios Kyrtzidis 16ac9be7f0 Implement Sema support for C++ nested-name-specifiers.
llvm-svn: 58916
2008-11-08 17:17:31 +00:00
Argyrios Kyrtzidis 32a0379575 Implement support for C++ nested-name-specifiers ('foo::bar::x') in the Parser side.
No Sema functionality change, just the signatures of the Action/Sema methods.

llvm-svn: 58913
2008-11-08 16:45:02 +00:00
Argyrios Kyrtzidis c7e67a04c3 Introduce annotation tokens, a special kind of token, created and used only by the parser to replace a group of tokens with a single token encoding semantic information.
Will be fully utilized later for C++ nested-name-specifiers.

llvm-svn: 58911
2008-11-08 16:17:04 +00:00
Sebastian Redl 842ef52ff3 Move named cast helpers out of Sema, as Chris requested. This requirse making a few functions public that weren't before.
llvm-svn: 58906
2008-11-08 13:00:26 +00:00
Argyrios Kyrtzidis 0d9ee2eb2e Revert r58880, it breaks test/SemaCXX/constructor.cpp
llvm-svn: 58904
2008-11-08 12:02:25 +00:00
Argyrios Kyrtzidis 13042a4a4a Use only one constructor for CXXMethodDecl. Keep initialization stuff into one place.
llvm-svn: 58902
2008-11-08 11:24:06 +00:00
Daniel Dunbar 238475c8ca Avoid redundant cast<>s / simplify type dispatch.
llvm-svn: 58892
2008-11-08 06:12:46 +00:00
Daniel Dunbar bbc0af7e37 Support getTypeInfo, getTypeAlign, getTypeSize on const Type*s.
- Size/align are not effected by CVR qualifiers.

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

llvm-svn: 58891
2008-11-08 05:48:37 +00:00
Daniel Dunbar 8ec8048f93 "Fix" PR3021, don't crash on generating record types when we can't
generate the type of a member.

llvm-svn: 58889
2008-11-08 04:42:29 +00:00
Daniel Dunbar ad0a0f9cd2 Silence a gcc warning.
llvm-svn: 58888
2008-11-08 04:28:37 +00:00
Zhongxing Xu 3d43015bc7 Add a boilerplate for out-of-bound array checking. This has no real function currently.
llvm-svn: 58886
2008-11-08 03:45:42 +00:00
Argyrios Kyrtzidis 19b66a5e32 In a declarator, consider an identifier a constructor only if it is followed by '('.
Previously:

class C {
  int C;  // Declarator::SetConstructor was called here.
};

llvm-svn: 58880
2008-11-08 01:09:16 +00:00
Sebastian Redl 015085fafa Greatly improve static_cast diagnostics
llvm-svn: 58873
2008-11-07 23:29:29 +00:00
Douglas Gregor a1f013e8ed Initial, partially-baked support for implicit user-defined conversions by conversion functions
llvm-svn: 58870
2008-11-07 22:36:19 +00:00
Argyrios Kyrtzidis e442635c37 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"

llvm-svn: 58866
2008-11-07 22:02:30 +00:00
Douglas Gregor dbc5daf058 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.

llvm-svn: 58860
2008-11-07 20:08:42 +00:00
Argyrios Kyrtzidis 56fa31bc87 Assert that Parser::MaybeParseOperatorFunctionId is called when token is kw_operator, and replace ExpectAndConsume for the 'operator' token with a ConsumeToken.
llvm-svn: 58855
2008-11-07 15:54:02 +00:00
Douglas Gregor 450c75a15f Separate the parsing of type-specifiers from other declaration specifiers, so that we can parse a C++ type-specifier-seq
llvm-svn: 58854
2008-11-07 15:42:26 +00:00
Argyrios Kyrtzidis 3175fa5139 Properly deserialize ParamInfo of FunctionDecl.
When allocating an array for ParamInfo, the "decl->getNumParams()" call was used, but this will return 0 since it checks ParamInfo (which isn't yet defined and is null).
The result was that ParamInfo got an array of zero length to hold the ParmVarDecls.

llvm-svn: 58850
2008-11-07 14:22:23 +00:00
Argyrios Kyrtzidis 6709e7d4cc Fix crash caused by this:
void f() {
   int +; // crash here
}

llvm-svn: 58846
2008-11-07 13:01:22 +00:00
Zhongxing Xu 2c677c34d5 Finish the implementation of VisitCompoundLiteralExpr. As VisitInitListExpr is
available, things get much simplified.

One addition is that CompoundLiteralExpr can appear both in rvalue and lvalue
context.

llvm-svn: 58837
2008-11-07 10:38:33 +00:00
Zhongxing Xu e79a4e667b Make the assertion real.
llvm-svn: 58833
2008-11-07 08:57:30 +00:00
Douglas Gregor 7d5fc7e28b Initial, rudimentary implementation of operator overloading for binary
operators. For example, one can now write "x + y" where x or y is a
class or enumeration type, and Clang will perform overload resolution
for "+" based on the overloaded operators it finds.

The other kinds of overloadable operators in C++ will follow this same
approach. 

Three major issues remain:
  1) We don't find member operators
  2) Since we don't have user-defined conversion operators, we can't
  call any of the built-in overloaded operators in C++ [over.built].
  3) Once we've done the semantic checks, we drop the overloaded
  operator on the floor; it doesn't get into the AST at all.

llvm-svn: 58821
2008-11-06 23:29:22 +00:00
Douglas Gregor 11d0c4c098 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".

llvm-svn: 58817
2008-11-06 22:13:31 +00:00
Douglas Gregor 2ad7ee9145 Reclaim some bits in IdentifierInfo, for later use as overloaded operator names.
llvm-svn: 58806
2008-11-06 16:32:23 +00:00
Sebastian Redl b426f63302 Sema-check virtual declarations. Complete dynamic_cast checking.
llvm-svn: 58804
2008-11-06 15:59:35 +00:00
Douglas Gregor d7fc872d5c Add the remaining C++0x keywords
llvm-svn: 58802
2008-11-06 15:17:27 +00:00
Ted Kremenek ab4782510b Fix regression with handling of CFMakeCollectable.
llvm-svn: 58771
2008-11-05 22:17:20 +00:00
Sebastian Redl 75c54764fd Improve assert messages.
llvm-svn: 58770
2008-11-05 22:15:14 +00:00
Sebastian Redl 3c5aa4d1a9 Move named cast sema functions to their own file.
llvm-svn: 58769
2008-11-05 21:50:06 +00:00
Douglas Gregor 831c93f6c0 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").

llvm-svn: 58767
2008-11-05 20:51:48 +00:00
Sebastian Redl 6a43b1c435 A small error message improvement and some comment cleanup for static_cast.
llvm-svn: 58762
2008-11-05 17:54:26 +00:00
Ted Kremenek 2855a93f07 initXXX methods can return owned objects
llvm-svn: 58758
2008-11-05 16:54:44 +00:00
Douglas Gregor cfd8ddc6de Keep track of whether a C++ class is an aggregate. Don't allow initialization of non-aggregates with initializer lists.
llvm-svn: 58757
2008-11-05 16:20:31 +00:00
Douglas Gregor 6f5431543a Implement C++ copy-initialization for declarations. There is now some
duplication in the handling of copy-initialization by constructor,
which occurs both for initialization of a declaration and for
overloading. The initialization code is due for some refactoring.

llvm-svn: 58756
2008-11-05 15:29:30 +00:00
Douglas Gregor e8381c00eb 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) { };
  };

llvm-svn: 58749
2008-11-05 04:29:56 +00:00
Cedric Venet 0ce19ba350 Update CMakeLists.txt
llvm-svn: 58716
2008-11-04 20:31:17 +00:00
Anders Carlsson a6b508a28c Make it an error if an Objective-C declaration is not in the global scope.
llvm-svn: 58705
2008-11-04 16:57:32 +00:00
Chris Lattner b8c18fa59a LinkageSpecDecl is c++ specific, move it to DeclCXX
llvm-svn: 58704
2008-11-04 16:51:42 +00:00
Sebastian Redl ee54797234 Some cleanup of the cast checkers. Don't canonicalize types when not needed. Use distinct diagnostics for distinct errors.
llvm-svn: 58700
2008-11-04 15:59:10 +00:00
Douglas Gregor 8ea1f53420 Add a new expression class, ObjCSuperExpr, to handle the Objective-C 'super'. Remove ObjCThis from PredefinedExpr
llvm-svn: 58698
2008-11-04 14:56:14 +00:00
Douglas Gregor 97a9c81b05 Create a new expression class, CXXThisExpr, to handle the C++ 'this' primary expression. Remove CXXThis from PredefinedExpr
llvm-svn: 58695
2008-11-04 14:32:21 +00:00
Douglas Gregor 5496d4caa0 Now that we have copy initialization support, use it for checking the default arguments
llvm-svn: 58692
2008-11-04 13:57:51 +00:00
Douglas Gregor 8e12c38115 Diagnose use of 'this' in a C++ default argument. Thanks to Eli for correcting my bogus assertion about it already being handled
llvm-svn: 58691
2008-11-04 13:41:56 +00:00
Sebastian Redl 273ce56d7a Trivial style fix.
llvm-svn: 58689
2008-11-04 11:45:54 +00:00
Anders Carlsson 6b0dc85119 #define NULL as 0 when compiling as C++. This fixes the carbon.cpp and cocoa.mm test failures.
llvm-svn: 58685
2008-11-04 06:53:14 +00:00
Anders Carlsson 13abd7e98b Implement lowering of va_arg in clang directly. (This is 32-bit X86 only for now).
llvm-svn: 58681
2008-11-04 05:30:00 +00:00
Anders Carlsson 4961890c07 Fix bug in va_copy
llvm-svn: 58680
2008-11-04 05:29:05 +00:00
Ted Kremenek 24b1d9f57e Handle prefix '_' that may appear in front of the name of 'Release' functions
llvm-svn: 58666
2008-11-04 00:36:12 +00:00
Steve Naroff c989a7b6c0 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
llvm-svn: 58654
2008-11-03 23:29:32 +00:00
Ted Kremenek 14f18653f6 Hook up the Plist diagnostic client to the driver.
Fix Plist output.

llvm-svn: 58652
2008-11-03 23:18:07 +00:00
Douglas Gregor fa7431a807 Check that this cannot be used in a default argument. Happily, it was already implemented
llvm-svn: 58649
2008-11-03 22:47:57 +00:00
Ted Kremenek 0cbd963817 Add path diagnostics client for emitting path reports using Plists.
llvm-svn: 58647
2008-11-03 22:33:57 +00:00
Ted Kremenek e868c00d5a Rename 'HTMLDiagnostics.h' to 'PathDiagnosticClients.h'
llvm-svn: 58646
2008-11-03 22:31:48 +00:00
Douglas Gregor c28b57d703 Implicit support for direct initialization of objects of class type, e.g.,
X x(5, 7);

llvm-svn: 58641
2008-11-03 20:45:27 +00:00
Douglas Gregor 2fe9883a96 Standard conversion sequences now have a CopyConstructor field, to
cope with the case where a user-defined conversion is actually a copy
construction, and therefore can be compared against other standard
conversion sequences. While I called this a hack before, now I'm
convinced that it's the right way to go.

Compare overloads based on derived-to-base conversions that invoke
copy constructors. 

Suppress user-defined conversions when attempting to call a
user-defined conversion.

llvm-svn: 58629
2008-11-03 19:09:14 +00:00
Douglas Gregor 0537942f3c 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).

llvm-svn: 58622
2008-11-03 17:51:48 +00:00
Douglas Gregor ab13857072 Eliminate header dependency ASTContext -> TargetInfo
llvm-svn: 58613
2008-11-03 15:57:00 +00:00
Douglas Gregor 66583c5ff3 Implement C++ DR 106 and C++ DR 540, both of which deal with
reference-collapsing. 

Implement diagnostic for formation of a reference to cv void.

Drop cv-qualifiers added to a reference type when the reference type
comes from a typedef.

llvm-svn: 58612
2008-11-03 15:51:28 +00:00
Douglas Gregor 8af6e6d415 Connect ASTContext to TargetInfo when determining the size_t, ptrdiff_t, and wchar_t types. Fixes recent breakage on Linux.
llvm-svn: 58609
2008-11-03 14:12:49 +00:00
Chris Lattner 8cc7be369c Fix PR3001: if we have an error parsing an initializer, make sure to remove
the designator corresponding to it, otherwise Sema and later parsing will
get confused.

llvm-svn: 58603
2008-11-03 09:28:22 +00:00
Chris Lattner 7d7fff2303 privatize some methods.
llvm-svn: 58602
2008-11-03 09:11:11 +00:00
Zhongxing Xu c8c71979a6 Add some notes for SCA.
llvm-svn: 58597
2008-11-03 06:04:23 +00:00
Zhongxing Xu 8ea09cc542 Fix 80-col violations.
llvm-svn: 58596
2008-11-03 05:18:34 +00:00
Zhongxing Xu 2d330ef8fa - Remove AnonTypedRegion, which is not to be used.
- Prepare AnonPointeeRegioin for later use.

llvm-svn: 58595
2008-11-03 04:12:24 +00:00
Sebastian Redl 1384553cbe Source ranges for named cast diagnostics.
llvm-svn: 58570
2008-11-02 22:21:33 +00:00
Zhongxing Xu 2e8e604704 1. When a pointer to struct is used as an argument, GRSimpleVals::EvalCall()
sets the whole struct to Unknown. Then we cannot assume the V passed to
   BindStruct() is always a CompoundVal. When it is an UnknownVal, we call
   BindStructToVal(UnknownVal).

2. Change the signature of InitializeStructToUndefined() to BindStructToVal()
   to reuse the code.

llvm-svn: 58564
2008-11-02 12:13:30 +00:00
Eli Friedman d50881c6a9 More fallout from r58501: primary fix is some more corrections to make
the types for size_t and ptrdiff_t more accurate.  I think all of these
are correct, but please compare the defines for __PTRDIFF_TYPE__ and 
__SIZE_TYPE__ to gcc to double-check; this particularly applies to 
those on BSD variants, since I'm not sure what they do here; I assume 
here that they're the same as on Linux.

Fixes wchar_t to be "int", not "unsigned int" (which I think is 
correct on everything but Windows).

Fixes ptrdiff_t to be "int" rather than "short" on PIC16; "short" is an 
somewhat strange choice because it normally gets promoted, and it's not 
consistent with the choice for size_t.

llvm-svn: 58556
2008-11-02 02:43:55 +00:00
Ted Kremenek b9b794d60b Enhance return-of-stack-address checker to recognize regions created by alloca().
llvm-svn: 58553
2008-11-02 00:35:25 +00:00
Ted Kremenek 9bf363979d Add transfer function logic for alloca().
llvm-svn: 58552
2008-11-02 00:35:01 +00:00
Ted Kremenek 16783cfc31 Added AllocaRegion, which represents regions created by calls to alloca().
llvm-svn: 58551
2008-11-02 00:34:33 +00:00
Ted Kremenek 29925c8ea2 Fixed a horrible bug in HTMLDiagnostics.cpp where bugs referencing source ranges that occur within macros would not be emitted at all.
llvm-svn: 58550
2008-11-02 00:33:58 +00:00
Daniel Dunbar cb4638599c Move IRBuilder type definition to common file.
- No functionality change.

llvm-svn: 58546
2008-11-01 01:53:16 +00:00
Douglas Gregor eebb5c10aa Semantic checking of constructor declarations and classification of default/copy constructors
llvm-svn: 58538
2008-10-31 20:25:05 +00:00