Compare commits

...

3655 Commits

Author SHA1 Message Date
Tanya Lattner
ef55b5d87a Fix bugs section.
llvm-svn: 46992
2008-02-12 06:28:54 +00:00
Tanya Lattner
1c4be00c9e Merge release notes from mainline.
llvm-svn: 46986
2008-02-12 05:16:42 +00:00
Tanya Lattner
06834b2734 release tag.
llvm-svn: 46982
2008-02-12 02:43:50 +00:00
Tanya Lattner
3e45ec8ee2 Merge from mainline.
Don't dump the function!

llvm-svn: 46699
2008-02-04 06:29:04 +00:00
Tanya Lattner
4149ab2eb3 Merge from mainline.
Provide correct DWARF register numbering for debug information emission on x86-32/Darwin.
This should fix bunch of issues.

llvm-svn: 46698
2008-02-04 06:17:46 +00:00
Tanya Lattner
23177b1ff0 Merge from mainline.
Trivial patch to fix two warnings

llvm-svn: 46272
2008-01-23 03:56:34 +00:00
Tanya Lattner
7ae6b34d1d Merge from mainline.
One too many )'s breaks 'make clean' with certain versions of make.
This fixes PR1927

llvm-svn: 46248
2008-01-22 07:16:09 +00:00
Tanya Lattner
d18515a257 Merge from mainline.
Fix the failures in the PPC JIT by marking relocation entries for
external symbols (e.g. 'fmod') as needing a stub.  This regression
was introduced by Evan's jit patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071231/056749.html

With this fixed, the two ExecutionEngine failures are passing on ppc,
and the ppc jit works on freebench and olden.

llvm-svn: 46225
2008-01-21 22:45:15 +00:00
Tanya Lattner
99d99dcaa2 Merge from mainline.
Need to handle any 'nest' parameter before integer
parameters, since otherwise it won't be passed in
the right register.  With this change trampolines
work on x86-64 (thanks to Luke Guest for providing
access to an x86-64 box).

llvm-svn: 46215
2008-01-21 20:47:24 +00:00
Tanya Lattner
e41e59505e Merge from mainline.
Honour ByVal parameter attribute for name decoration.

llvm-svn: 46214
2008-01-21 20:45:28 +00:00
Tanya Lattner
c1dde534b1 Merge from mainline.
Make sure the caller doesn't use freed memory.
Fixes PR1935.

llvm-svn: 46213
2008-01-21 20:43:02 +00:00
Tanya Lattner
a489619ead UnXFAIL this test.
llvm-svn: 46169
2008-01-18 19:18:51 +00:00
Tanya Lattner
2e1232ef6f Merge from mainline.
Revert the part of 45849 that treated weak globals
as weak globals rather than commons.  While not wrong,
this change tickled a latent bug in Darwin's strip,
so revert it for now as a workaround.

llvm-svn: 46168
2008-01-18 19:15:06 +00:00
Tanya Lattner
f2190a5c18 Merge from mainline.
Revert the part of 45848 that treated weak globals
as weak globals rather than commons.  While not wrong,
this change tickled a latent bug in Darwin's strip,
so revert it for now as a workaround.

llvm-svn: 46167
2008-01-18 19:13:34 +00:00
Tanya Lattner
93f7a28af9 Update for current year.
llvm-svn: 46121
2008-01-17 06:01:52 +00:00
Tanya Lattner
e1a9bf1233 Set version to 2.2
Regenerated configure with autoconf 2.60. Do not use 2.61 until AutoGen.sh is updated!

llvm-svn: 46118
2008-01-17 05:54:18 +00:00
Tanya Lattner
cf9988be1f Creating 2.2 release branch
llvm-svn: 46114
2008-01-17 05:09:49 +00:00
Evan Cheng
04af661b1f DAE bug fix. Don't lose parameter attributes on vararg arguments.
llvm-svn: 46113
2008-01-17 04:18:54 +00:00
Devang Patel
16808a32f4 Enable CBE
llvm-svn: 46112
2008-01-17 02:10:08 +00:00
Evan Cheng
54c20b559e When a live virtual register is being clobbered by an implicit def, it is spilled
and the spill is its kill. However, if the local allocator has determined the
register has not been modified (possible when its value was reloaded), it would
not issue a restore. In that case, mark the last use of the virtual register as
kill.

llvm-svn: 46111
2008-01-17 02:08:17 +00:00
Fariborz Jahanian
386699515b Computed length of a __func__ identifier used in an objective-c method correctly,
when creating its type.

llvm-svn: 46109
2008-01-17 01:36:09 +00:00
Chris Lattner
5630c4f217 Fix arg promotion to propagate the correct attrs on the calls to
promoted functions.  This is important for varargs calls in 
particular.  Thanks to duncan for providing a great testcase.

llvm-svn: 46108
2008-01-17 01:17:03 +00:00
Seo Sanghyeon
15051b4caf Ignore --param
llvm-svn: 46107
2008-01-17 01:08:43 +00:00
Ted Kremenek
e780f408b1 Added some experimental optimizations to remove dead values from the
state.

llvm-svn: 46106
2008-01-17 00:52:48 +00:00
Steve Naroff
1aa1941889 Declarator::clear(): Null out variable after it's been deleted.
This avoids a double free (which is good:-)

Bug submitted by Eli.

llvm-svn: 46105
2008-01-17 00:36:28 +00:00
Evan Cheng
dc5b4c57d7 Replace std::vector<bool> with BitVector.
llvm-svn: 46104
2008-01-17 00:35:26 +00:00
Steve Naroff
d8583eb993 Simplify comment.
llvm-svn: 46103
2008-01-16 23:56:32 +00:00
Steve Naroff
8a0abea999 Type::isArithmeticType(): disallow incomplete enum decls.
Bug submitted by Eli.

llvm-svn: 46102
2008-01-16 23:54:22 +00:00
Ted Kremenek
506e507508 Changed sorting criteria for DSPtr to put sub-expressions first in the value
map. This will allow us to quickly prune them from maps without searching the
entire map.

llvm-svn: 46101
2008-01-16 23:35:31 +00:00
Ted Kremenek
692b01b0be Changed sorting criteria for DSPtr to sort Decl* before Expr*, and
to sort sub-expressions before Block-level expressions.

llvm-svn: 46100
2008-01-16 23:33:44 +00:00
Evan Cheng
7be1528004 Fixes a nasty dag combiner bug that causes a bunch of tests to fail at -O0.
It's not safe to use the two value CombineTo variant to combine away a dead load.
e.g. 
v1, chain2 = load chain1, loc
v2, chain3 = load chain2, loc
v3         = add v2, c 
Now we replace use of v1 with undef, use of chain2 with chain1.
ReplaceAllUsesWith() will iterate through uses of the first load and update operands:
v1, chain2 = load chain1, loc
v2, chain3 = load chain1, loc
v3         = add v2, c 
Now the second load is the same as the first load, SelectionDAG cse will ensure
the use of second load is replaced with the first load.
v1, chain2 = load chain1, loc
v3         = add v1, c
Then v1 is replaced with undef and bad things happen.

llvm-svn: 46099
2008-01-16 23:11:54 +00:00
Duncan Sands
32b0ff6814 Trampoline support for x86-64. This looks like
it should work, but I have no machine to test
it on.  Committed because it will at least
cause no harm, and maybe someone can test it
for me!

llvm-svn: 46098
2008-01-16 22:55:25 +00:00
Ted Kremenek
a14396d51d IntegerLiterals are no longer evaluated to create separate nodes; their
values are determined when evaluating the parent expression.

llvm-svn: 46096
2008-01-16 22:28:08 +00:00
Ted Kremenek
493444fc19 Fixed bug where we performed addition instead of subtraction during
constant propagation.

llvm-svn: 46095
2008-01-16 22:20:36 +00:00
Ted Kremenek
e914bb8183 Fixed iterator bug in ExplodedNodeImpl::NodeGroup::end(); we would improperly
handle the case where the number of nodes was 0.

Fixed bug in GREngineImpl where we did not proceed to the next statement
when processing a PostStmt location.

llvm-svn: 46093
2008-01-16 22:13:19 +00:00
Ted Kremenek
ac886cb835 Added initial graph visualization support for the GRConstants analysis.
llvm-svn: 46092
2008-01-16 21:46:15 +00:00
Ted Kremenek
873bbd53a4 Fixed invalid typedefs in the root and eop iterators for ExplodedGraph.
llvm-svn: 46091
2008-01-16 21:45:54 +00:00
Chris Lattner
39f156183d Handle attribute(used) global variables that are i8.
llvm-svn: 46090
2008-01-16 21:35:43 +00:00
Dale Johannesen
ed20366706 Do not mark EH tables no-dead-strip unless the
associated function is so marked.

llvm-svn: 46088
2008-01-16 19:59:28 +00:00
Ted Kremenek
88d5909bed Added support from retrieving stored values to variables.
llvm-svn: 46087
2008-01-16 19:47:19 +00:00
Ted Kremenek
47b62c1a5f Added support for assignments in GRConstants.
llvm-svn: 46086
2008-01-16 19:42:59 +00:00
Ted Kremenek
7e7070b594 Fixed bug where GRConstants::AddBindings() did not check for values
that were "not a constant."

llvm-svn: 46085
2008-01-16 19:28:16 +00:00
Ted Kremenek
deac51943a Fixed bug in cleanup of nodes in ExplodedNodeImpl where we should directly
call the dstor instead of using delete.

llvm-svn: 46084
2008-01-16 19:27:42 +00:00
Chris Lattner
a65e1f3b31 Move promoteExprToType from being a static method in SemaExpr.cpp to being
a method named ImpCastExprToType in Sema.

Use this method to insert implicit casts for case statements from their 
operand type to the condition type of the switch.  This fixes a crash on
test/CodeGen/statements.c, reported by Eli Friedman.

llvm-svn: 46083
2008-01-16 19:17:22 +00:00
Chris Lattner
45b985c664 add accessors to switchstmt.
llvm-svn: 46082
2008-01-16 19:16:00 +00:00
Ted Kremenek
334139f58e Fixed broken bitmasking in the ctor of ProgramPoint.
llvm-svn: 46081
2008-01-16 19:11:06 +00:00
Ted Kremenek
29a9d00a56 Added missing call to the checker's Initialize() method in the alternate
ctor for GREngine.

llvm-svn: 46080
2008-01-16 18:59:52 +00:00
Ted Kremenek
34eb8bb3bd Added missing ctor to ExplodedGraph.
llvm-svn: 46079
2008-01-16 18:59:09 +00:00
Ted Kremenek
f81d2c9a06 Fixed incorrect pointer mask.
llvm-svn: 46078
2008-01-16 18:58:48 +00:00
Ted Kremenek
db0b651de9 Shortened driver option for running the GR-constants analysis to --grconstants.
llvm-svn: 46076
2008-01-16 18:21:49 +00:00
Ted Kremenek
7773c4fafd Add missing header file for GRConstants analysis.
llvm-svn: 46075
2008-01-16 18:19:20 +00:00
Ted Kremenek
2e12c2e790 Hooked up the GRConstants analysis to the driver.
Fixed some compilation errors with GREngine that showed up during
template instantiation.

llvm-svn: 46074
2008-01-16 18:18:48 +00:00
Chris Lattner
aebbe4700a add testcase for regression
llvm-svn: 46073
2008-01-16 18:03:52 +00:00
Chris Lattner
52188501f6 Fix a ppc long double regression I introduced yesterday due to a
simplification.  This fixes automotive-basicmath on PPC.

llvm-svn: 46072
2008-01-16 17:59:31 +00:00
Ted Kremenek
2d700ed2ba More cleanups in DoStmt. The NodeSets are now vectors instead of sets, since
node caching in GREngine will guarantee that we do not insert a node twice into
a nodeset.

llvm-svn: 46071
2008-01-16 17:56:25 +00:00
Steve Naroff
17832a48f8 Sema::MergeFunctionDecl()...make sure diagnostic is accurate (wrt function declarations/definitions). Patch by Carl Lewis!
llvm-svn: 46070
2008-01-16 15:01:34 +00:00
Chris Lattner
7ca4d5b1f3 merge a few pieces of code that do the store/load to stack
pattern to use EmitStackConvert now.

llvm-svn: 46066
2008-01-16 07:51:34 +00:00
Chris Lattner
87bc3e7ece rename ExpandBIT_CONVERT to EmitStackConvert, generalizing
it to allow it to emit different load and store kinds.

llvm-svn: 46065
2008-01-16 07:45:30 +00:00
Chris Lattner
a2c7ff3386 simplify a bunch of code by using SelectionDAG::CreateStackTemporary
instead of inlining its body.

llvm-svn: 46062
2008-01-16 07:03:22 +00:00
Chris Lattner
91d86242f9 Change legalizeop of FP_ROUND and FP_EXTEND to not fall through
into the ANY_EXTEND/ZERO_EXTEND/SIGN_EXTEND code to simplify it.

Unmerge the code for FP_ROUND and FP_EXTEND from each other to 
make each one simpler.

llvm-svn: 46061
2008-01-16 06:57:07 +00:00
Chris Lattner
6e3379c07b make sure to use a cpu that has sse.
llvm-svn: 46060
2008-01-16 06:32:02 +00:00
Chris Lattner
e8bb9f2190 make it more clear that this predicate only applies to scalar FP types.
llvm-svn: 46058
2008-01-16 06:24:21 +00:00
Chris Lattner
14e616ef0b introduce a isTypeInSSEReg predicate, which allows us to simplify
some code.  No functionality change.

llvm-svn: 46055
2008-01-16 06:19:45 +00:00
Chris Lattner
8f7cec859e My previous commit had an incomplete message, it should have been:
make the 'fp return in ST(0)' optimization smart enough to
look through token factor nodes.  THis allows us to compile 
testcases like CodeGen/X86/fp-stack-retcopy.ll into:

_carg:
	subl	$12, %esp
	call	L_foo$stub
	fstpl	(%esp)
	fldl	(%esp)
	addl	$12, %esp
	ret

instead of:

_carg:
	subl	$28, %esp
	call	L_foo$stub
	fstpl	16(%esp)
	movsd	16(%esp), %xmm0
	movsd	%xmm0, 8(%esp)
	fldl	8(%esp)
	addl	$28, %esp
	ret

Still not optimal, but much better and this is a trivial patch.  Fixing 
the rest requires invasive surgery that is is not llvm 2.2 material.

llvm-svn: 46054
2008-01-16 05:56:59 +00:00
Chris Lattner
ea001f1db7 make the 'fp return in ST(0)' optimization smart enough to
look through token factor

llvm-svn: 46053
2008-01-16 05:53:06 +00:00
Chris Lattner
de5c74f18e various whitespace cleanups, no functionality change.
llvm-svn: 46052
2008-01-16 05:52:18 +00:00
Ted Kremenek
73e5f2bb17 Adjusted DSPtr::Profile method again, since my last patch broke the build.
llvm-svn: 46051
2008-01-16 05:51:13 +00:00
Chris Lattner
2e50a6f90f Factor the ReachesChainWithoutSideEffects out of dag combiner into
a public SDOperand::reachesChainWithoutSideEffects method.  No 
functionality change.

llvm-svn: 46050
2008-01-16 05:49:24 +00:00
Ted Kremenek
29185f17e9 Changed 'Profile' method for DSPtr to incorporate the flags from the
variant type, and not just the pointer value.

llvm-svn: 46049
2008-01-16 05:49:09 +00:00
Devang Patel
b3696e4f14 Do not strip llvm.used values.
llvm-svn: 46045
2008-01-16 03:33:05 +00:00
Ted Kremenek
fb55354fc9 Renamed some internal classes for the GR-Constant Propagation analysis.
Cleaned up GRConstants::AddBinding to not directly reference the
predecessor node.  Now we just manipulate the current state, and a driver
function creates nodes as needed.

llvm-svn: 46040
2008-01-16 00:53:15 +00:00
Fariborz Jahanian
19d42bf0a5 Typo.
llvm-svn: 46038
2008-01-16 00:09:11 +00:00
Fariborz Jahanian
b860cbf052 Added support for rewriting of continue/break statements inside ObjC2's foreach-stmt.
llvm-svn: 46037
2008-01-15 23:58:23 +00:00
Ted Kremenek
de8d62b132 Added skeleton implementation of new constant-prop. analysis using
the graph reachability engine.

llvm-svn: 46036
2008-01-15 23:55:06 +00:00
Ted Kremenek
03bc2afa65 Added ctor to GRNodeBuilder.
llvm-svn: 46035
2008-01-15 23:54:22 +00:00
Ted Kremenek
7ea05687be Changed ImmutableMap::find to return an iterator instead of a pointer
to the tree node.

llvm-svn: 46034
2008-01-15 23:53:53 +00:00
Devang Patel
41f375a45c - Introduces versioning macro LLVM_LTO_VERSION
- Communicate symbol visibility
- Communicate code generation model

llvm-svn: 46033
2008-01-15 23:52:34 +00:00
Chris Lattner
5047536879 Commit a piece that I missed before, patch by Alain Frisch
llvm-svn: 46032
2008-01-15 23:27:40 +00:00
Dale Johannesen
00dfb551cc Missed file from previous checkin.
llvm-svn: 46030
2008-01-15 23:25:27 +00:00
Dale Johannesen
59a2250b0d Fix and enable EH for x86-64 Darwin. Adds
ShortenEHDataFor64Bits as a not-very-accurate
abstraction to cover all the changes in DwarfWriter.
Some cosmetic changes to Darwin assembly code for
gcc testsuite compatibility.

llvm-svn: 46029
2008-01-15 23:24:56 +00:00
Owen Anderson
897aed9109 Move some calls to getVRegDef higher in the callgraph, so they don't get executed as frequently in performance sensitive code.
llvm-svn: 46027
2008-01-15 22:58:11 +00:00
Chris Lattner
cc7ff8c1dd improve compatibility with mingw, patch by Alain Frisch
llvm-svn: 46026
2008-01-15 22:50:50 +00:00
Chris Lattner
f3e1155c41 add a test to ensure that argpromote of one argument doesn't
break the byval attr on some other argument.

llvm-svn: 46025
2008-01-15 22:38:12 +00:00
Anton Korobeynikov
06cbb65cb0 Add description of 'llvm.trap' intrinsic. Also, minor fixes in formatting.
llvm-svn: 46024
2008-01-15 22:31:34 +00:00
Chris Lattner
915ec14073 verify x86 generates ud2 for llvm.trap
llvm-svn: 46023
2008-01-15 22:22:02 +00:00
Steve Naroff
abefc391dd Finish up handling all permutations of "complex int" (in Sema::UsualArithmeticConversions()).
A FIXME remains to verify the conversion rules are consistent with GCC.

Thanks to Eli for the new/improved test case...

llvm-svn: 46022
2008-01-15 22:21:49 +00:00
Evan Cheng
51a09143c2 Unbreak the build.
llvm-svn: 46021
2008-01-15 22:19:35 +00:00
Chris Lattner
50baecd31e new testcase for llvm.trap.
llvm-svn: 46020
2008-01-15 22:17:26 +00:00
Chris Lattner
8e07533f20 If someone wants to implement ppc TRAP, they can go for it :)
llvm-svn: 46019
2008-01-15 22:15:02 +00:00
Chris Lattner
ec224888a6 The type of the 'abort' node should be pointer type (because
it's a function pointer) not MVT::Other.  This fixes builtin_trap
lowering on ppc, alpha, ia64

llvm-svn: 46018
2008-01-15 22:09:33 +00:00
Chris Lattner
9a249b0ce5 rename SDTRet -> SDTNone.
Move definition of 'trap' sdnode up from x86 instrinfo to targetselectiondag.td.

llvm-svn: 46017
2008-01-15 22:02:54 +00:00
Owen Anderson
1ba66e0cec Remove DefInst from LiveVariables::VarInfo. Use the facilities on MachineRegisterInfo instead.
llvm-svn: 46016
2008-01-15 22:02:46 +00:00
Chris Lattner
3c3fefde06 no need to expand ISD::TRAP to X86ISD::TRAP, just match ISD::TRAP.
llvm-svn: 46015
2008-01-15 21:58:22 +00:00
Chris Lattner
ee8df1f4d3 Add support for targets that have a legal ISD::TRAP.
llvm-svn: 46014
2008-01-15 21:58:08 +00:00
Chuck Rose III
fe2714fab3 Add files to windows project files. Also include <algorithm> explicitly so that vstudio build works
llvm-svn: 46013
2008-01-15 21:43:17 +00:00
Anton Korobeynikov
59e6d533bd Fix JIT encoding of trap/ud2 instruction
llvm-svn: 46012
2008-01-15 21:40:02 +00:00
Bill Wendling
d21d90cf98 Reformatted. It was confusing the other way. No functionality change.
llvm-svn: 46009
2008-01-15 21:16:32 +00:00
Gordon Henriksen
1390ef4163 Fix a memory correctness error noticed by valgrind (harmless in practice).
Thanks to Duncan Sands for noticing it.

llvm-svn: 46007
2008-01-15 20:02:11 +00:00
Duncan Sands
60bd71603b Testcase for gimplify_expr crash caused by an
unexpected placeholder_expr.

llvm-svn: 46006
2008-01-15 19:55:41 +00:00
Steve Naroff
6fcfd0581d - Change Type::isComplexType() to exlude GCC's complex integer extension. In general, we will keep the lowest level Type predicates "pure" (i.e. true to the C99 spec).
- Modify Sema::UsualArithmeticConversions() to work with the new definition of Type::isComplexType().

This is a nice cleanup and also fixes a bug submitted by Eli (which I've added to the test suite).

llvm-svn: 46005
2008-01-15 19:36:10 +00:00
Evan Cheng
4f7437f8af Oops. Forgot to commit this.
llvm-svn: 46003
2008-01-15 07:49:54 +00:00
Evan Cheng
eb30bb7d29 Oops. Forgot to commit this.
llvm-svn: 46002
2008-01-15 07:49:36 +00:00
Anton Korobeynikov
6bbbc4cbfa For PR1839: add initial support for __builtin_trap. llvm-gcc part is missed
as well as PPC codegen

llvm-svn: 46001
2008-01-15 07:02:33 +00:00
Chris Lattner
15346fae70 avoid pasting L + "foo" into L"foo".
llvm-svn: 46000
2008-01-15 05:22:14 +00:00
Chris Lattner
877ca77420 avoid token pasting between identifiers and wide strings:
abc+L"foo" -> abc L"foo", not abcL"foo"

llvm-svn: 45999
2008-01-15 05:14:19 +00:00
Chris Lattner
352ab9b4a2 clarify that byval is valid for any pointer argument.
llvm-svn: 45998
2008-01-15 04:34:22 +00:00
Evan Cheng
4d70ba3134 Rename CCIfStruct to CCIfByVal and CCStructAssign to CCPassByVal. Remove unused parameters of CCStructAssign and add size and alignment requirement info.
llvm-svn: 45997
2008-01-15 03:34:58 +00:00
Evan Cheng
48bdfe63e2 Both x86-32 and x86-64 handle byval parameter attributes.
llvm-svn: 45996
2008-01-15 03:15:41 +00:00
Evan Cheng
5b212ea818 ByVal stack slot alignment should be at least as large as pointer ABI alignment.
llvm-svn: 45995
2008-01-15 03:14:05 +00:00
Evan Cheng
a9ecdf6927 Revert my last commit. Not needed.
llvm-svn: 45994
2008-01-15 03:10:35 +00:00
Steve Naroff
8115902d6c Add a comment...
llvm-svn: 45993
2008-01-15 02:05:07 +00:00
Steve Naroff
7f988889ef Rework commit r45976, which was incorrect.
- Add Type::isComplexIntegerType(), Type::getAsComplexIntegerType().
- Don't inlude complex types with Type::isIntegerType(), which is too general.
- Use the new predicates in Sema::UsualArithmeticConversions() to recognize/convert the types.

llvm-svn: 45992
2008-01-15 01:41:59 +00:00
Ted Kremenek
e584359716 Removed implicit transitions to a "BlockExit" location; we now handle
the end of the block by processing empty blocks (at BlockEntrance) or
when we have just processed the last statement in a block (at PostStmt).

llvm-svn: 45991
2008-01-15 00:24:08 +00:00
Ted Kremenek
619bd1a8a0 Removed mutation of CFGBlock through operator[]. For now the underlying ASTs,
however, can still be manipulated through the returned Stmt*.

llvm-svn: 45990
2008-01-15 00:18:01 +00:00
Steve Naroff
d8c7d484af Make sure Sema::GetTypeForDeclarator() deals with abstract declarators when diagnosing incorrect code.
Bug submitted by Eli.

llvm-svn: 45989
2008-01-14 23:33:18 +00:00
Ted Kremenek
3e743661c5 Added prototype implementation of path-sens. analysis core engine.
llvm-svn: 45986
2008-01-14 23:24:37 +00:00
Ted Kremenek
50fd838140 Added operator[] for CFGBlock. This provides random access to the statements
of a block.

llvm-svn: 45984
2008-01-14 23:18:55 +00:00
Chris Lattner
49f980c334 Fix build issue on cygwin, patch by Sam Bishop
llvm-svn: 45977
2008-01-14 21:47:29 +00:00
Steve Naroff
c28f46c6b4 Teach Type::isIntegerType() about GCC's __complex__ integer extensions...
Bug submitted by Eli.

llvm-svn: 45976
2008-01-14 21:38:57 +00:00
Steve Naroff
012484d6c8 Fix crasher when redefining functions. Not 100% pleased with this solution, but it is clearly an improvement. Will discuss with Chris later.
llvm-svn: 45975
2008-01-14 20:51:29 +00:00
Duncan Sands
38987c1dcc Simplify CallInst::hasByValArgument using a new method.
llvm-svn: 45974
2008-01-14 19:57:00 +00:00
Duncan Sands
b5ca2e9fcb I noticed that the trampoline straightening transformation could
drop attributes on varargs call arguments.  Also, it could generate
invalid IR if the transformed call already had the 'nest' attribute
somewhere (this can never happen for code coming from llvm-gcc,
but it's a theoretical possibility).  Fix both problems.

llvm-svn: 45973
2008-01-14 19:52:09 +00:00
Chris Lattner
994718417a don't create the post-ra scheduler unless it is enabled.
llvm-svn: 45972
2008-01-14 19:00:06 +00:00
Chris Lattner
4272c12571 remove dead #include
llvm-svn: 45971
2008-01-14 18:45:28 +00:00
Ted Kremenek
cb994b6a72 Cleaned up comment.
llvm-svn: 45970
2008-01-14 18:42:38 +00:00
Ted Kremenek
94acc6ac9a Cleaned up comment.
llvm-svn: 45969
2008-01-14 18:41:42 +00:00
Ted Kremenek
a018a2c0f4 When serializing CompoundLiteralExpr, serialize out the file scope flag before
serializing the subexpression (Init), as this results in a more efficient
encoding in the bitstream.

llvm-svn: 45967
2008-01-14 18:29:39 +00:00
Steve Naroff
d32419de0d Record if a compound literal expression is @ file scope. This allows us to implement C99 6.5.2.5p6. This could have been done without modifying the AST (by checking the decl type and passing the info down to isContextExpr), however we concluded this is more desirable.
Bug/patch by Eli Friedman!

llvm-svn: 45966
2008-01-14 18:19:28 +00:00
Ted Kremenek
d065a790d9 Removed 'inline' keywords from methods now defined in ExplodedGraph.cpp.
llvm-svn: 45965
2008-01-14 18:11:35 +00:00
Evan Cheng
c8dc2f781f Need a space to separate Make options.
llvm-svn: 45964
2008-01-14 17:58:03 +00:00
Ted Kremenek
a0a3e9bb07 Change uses of std::cerr/std::cout to llvm::Lcerr/llvm::cout, and remove
#include<iostream>.

Patch provided by Sam Bishop.

llvm-svn: 45962
2008-01-14 16:44:48 +00:00
Steve Naroff
4871fe0b8f Revert r45951, Chris says it violates the C99 spec.
llvm-svn: 45961
2008-01-14 16:10:57 +00:00
Duncan Sands
ae8c041b85 This test is now the same as byval-1.ll, so remove it.
llvm-svn: 45960
2008-01-14 14:57:30 +00:00
Duncan Sands
4e079479bb Test that byval cannot be used with pointers to
types with no size.

llvm-svn: 45959
2008-01-14 14:55:05 +00:00
Anders Carlsson
a1afcab6f9 _asm is another valid alias for asm.
llvm-svn: 45957
2008-01-14 07:46:40 +00:00
Duncan Sands
1f5340c023 We now allow byval on fairly general pointer types.
llvm-svn: 45956
2008-01-14 06:53:45 +00:00
Chris Lattner
3c43efc9d1 Improve the FP stackifier to decide all on its own whether
an instruction kills a register or not.  This is cheap and 
easy to do now that instructions record this on their flags,
and this eliminates the second pass of LiveVariables from the
x86 backend.  This speeds up a release llc by ~2.5%.

llvm-svn: 45955
2008-01-14 06:41:29 +00:00
Anders Carlsson
1ba25ca171 Add codegen upport for implicit casts to aggregate exprs.
llvm-svn: 45954
2008-01-14 06:28:57 +00:00
Chris Lattner
f14ba63620 add a note
llvm-svn: 45953
2008-01-14 06:27:57 +00:00
Chris Lattner
fd65291aa3 Fix ASTContext::typesAreCompatible when analyzing a function type with
proto and function type without proto.  It would never call 
'functionTypesAreCompatible' because they have different type classes.

llvm-svn: 45952
2008-01-14 05:45:46 +00:00
Steve Naroff
090353191c Rewrite Expr::isNullPointerConstant() to deal with multiple levels of explicit casts.
Now, isNullPointerConstant() will return true for the following: "(void*)(double*)0"

llvm-svn: 45951
2008-01-14 02:53:34 +00:00
Evan Cheng
b9293c51bd Simplify code.
llvm-svn: 45950
2008-01-14 02:38:45 +00:00
Chris Lattner
26fe7ebc03 Fix the miscompilation of MiBench/consumer-lame that was exposed by Evan's
byval work.  This miscompilation is due to the program indexing an array out
of range and us doing a transformation that broke this.

llvm-svn: 45949
2008-01-14 02:09:12 +00:00
Chris Lattner
9a6db18b04 The isNotSuitableForSRA property is now dead, don't compute it.
llvm-svn: 45948
2008-01-14 01:32:52 +00:00
Chris Lattner
ab0537258f Change SRAGlobal to not depend on isNotSuitableForSRA, which makes it very
difficult to understand the invariants.

llvm-svn: 45947
2008-01-14 01:31:05 +00:00
Chris Lattner
20bbac3435 Make the 'shrink global to bool' optimization more self contained, and thus
easier to show that its safe.  No functionality change.

llvm-svn: 45946
2008-01-14 01:17:44 +00:00
Chris Lattner
92bd785323 Turn a memcpy from a double* into a load/store of double instead of
a load/store of i64.  The later prevents promotion/scalarrepl of the
source and dest in many cases.

This fixes the 300% performance regression of the byval stuff on 
stepanov_v1p2.

llvm-svn: 45945
2008-01-14 00:28:35 +00:00
Chris Lattner
57974c8d51 factor memcpy/memmove simplification out to its own SimplifyMemTransfer
method, no functionality change.

llvm-svn: 45944
2008-01-13 23:50:23 +00:00
Chris Lattner
8c5cdddfb9 simplify some code. If we can infer alignment for source and dest that are
greater than memcpy alignment, and if we lower to load/store, use the best 
alignment info we have.

llvm-svn: 45943
2008-01-13 22:30:28 +00:00
Chris Lattner
5a86612d3f simplify some code by adding a InsertBitCastBefore method,
make memmove->memcpy conversion a bit simpler.

llvm-svn: 45942
2008-01-13 22:23:22 +00:00
Duncan Sands
51fe7bbcf5 Whitespace tweak.
llvm-svn: 45940
2008-01-13 21:20:29 +00:00
Duncan Sands
08c728b519 Remove the assumption that byval has been applied to
a pointer to a struct.

llvm-svn: 45939
2008-01-13 21:19:59 +00:00
Duncan Sands
2796740ad6 Allow the byval attribute for pointers to any type with
a size, not just structs.

llvm-svn: 45938
2008-01-13 21:19:12 +00:00
Chris Lattner
5bc253c8f2 Fix PR1907, a nasty miscompilation because instcombine didn't
realize that ne & sgt  was a signed comparison (it was only 
looking at whether the left compare was signed).

llvm-svn: 45937
2008-01-13 20:59:02 +00:00
Duncan Sands
93ebe1df27 Check that nested functions don't get pointless
static chains.

llvm-svn: 45936
2008-01-13 18:44:12 +00:00
Steve Naroff
826e91ae04 Change Sema::CheckAddressOfOperation() to respect C99-only addressof rules.
Remove diagnostics from Sema::CheckIndirectionOperand(). C89/C99 allow dereferencing an incomplete type. clang appears to be emulating some incorrect gcc behavior (see below).

void
foo (void)
{
 struct b;
 struct b* x = 0;
 struct b* y = &*x; // gcc produces an error ("dereferencing pointer to incomplete type")
}

With this patch, the above is now allowed.

Bug/Patch by Eli Friedman!

llvm-svn: 45933
2008-01-13 17:10:08 +00:00
Duncan Sands
ff70c5de69 Small simplification.
llvm-svn: 45932
2008-01-13 08:12:17 +00:00
Duncan Sands
781f6549db When turning a call to a bitcast function into a direct call,
if this becomes a varargs call then deal correctly with any
parameter attributes on the newly vararg call arguments.

llvm-svn: 45931
2008-01-13 08:02:44 +00:00
Ted Kremenek
d122bbdb06 Moved destructor logic of templated class ExplodedGraph to non-templated
parent class ExplodedGraphImpl.

llvm-svn: 45930
2008-01-13 05:33:04 +00:00
Ted Kremenek
6d7aee6edd Added node cleanup to dstor of ExplodedGraph.
llvm-svn: 45929
2008-01-13 05:03:01 +00:00
Ted Kremenek
eb370bc386 Created ExplodedGraph.cpp and moved most method implementations of
ExplodedNodeImpl::NodeGroup from being defined inline to being defined
"out-of-line" in ExplodedGraph.cpp. This removes a dependence on including
<vector> in ExplodedGraph.h, and will hopefully result in smaller generated code
with negligible performance impact.

llvm-svn: 45928
2008-01-13 04:56:13 +00:00
Ted Kremenek
49bbee0b1d Moved 'ExplodedNodeGroup' into class 'ExplodedNode' as the nested class
'NodeGroup.'

llvm-svn: 45927
2008-01-13 04:20:10 +00:00
Ted Kremenek
39dfeadd93 Fixed lines preventing compilation.
llvm-svn: 45926
2008-01-13 04:18:40 +00:00
Ted Kremenek
2ae51a5d27 Now include "CFG.h" because the inline methods of "BlockEntrance" accessor
the methods of CFGBlock.

llvm-svn: 45925
2008-01-13 04:08:45 +00:00
Ted Kremenek
990d7d5205 Fixed some comments.
llvm-svn: 45924
2008-01-13 04:03:38 +00:00
Ted Kremenek
76245f3ed0 Removed ExplodedNode.h, since its contents are now in ExplodedGraph.h
llvm-svn: 45923
2008-01-13 04:00:44 +00:00
Ted Kremenek
8f13ec74c4 Merged ExplodedNode.h into ExplodedGraph.h, since the ExplodedNode class will
only be used in the context of the ExplodedGraph class.

llvm-svn: 45922
2008-01-13 04:00:16 +00:00
Ted Kremenek
cfe8235fa1 Changed implementation of successor and predecessor sets for ExplodedNode
to optimize for the common case of having a single predecessor and a single
successor.

llvm-svn: 45921
2008-01-13 03:55:50 +00:00
Chris Lattner
0d815f8f21 new testcase for rdar://5685492
llvm-svn: 45918
2008-01-13 00:19:57 +00:00
Chris Lattner
ca7faf6faa improve cygwin compatibility, patch by Sam Bishop
llvm-svn: 45917
2008-01-12 22:54:07 +00:00
Chris Lattner
0a8c2325fc allow __func__ in objc methods.
llvm-svn: 45915
2008-01-12 19:32:28 +00:00
Chris Lattner
afb514a7b4 clarify a note
llvm-svn: 45914
2008-01-12 18:58:46 +00:00
Evan Cheng
09dde6001d Add hasByValArgument() to test if a call instruction has byval argument(s).
llvm-svn: 45913
2008-01-12 18:57:32 +00:00
Chris Lattner
4f6c81ac68 we don't have to make an explicit copy of a byval argument when
inlining a function if we know that the function does not write
to *any* memory.  This implements test/Transforms/Inline/byval2.ll

llvm-svn: 45912
2008-01-12 18:54:29 +00:00
Evan Cheng
f755ff7be3 Indirect call with byval parameter requires a cast first.
llvm-svn: 45911
2008-01-12 18:53:07 +00:00
Chris Lattner
317e6ba07f Tighten up handling of __func__ and friends: it should be an array
of const char, and it should error if it occurs outside a function.

Is it valid in an objc method?  If so we should handle that too.

llvm-svn: 45910
2008-01-12 18:39:25 +00:00
Duncan Sands
0009c44464 Be more liberal in what parameter attributes are
allowed on the vararg arguments of a call.

llvm-svn: 45909
2008-01-12 16:42:01 +00:00
Chris Lattner
a81a0279cc Fix the type of predefined identifiers like __func__. Patch by
Eli Friedman!

llvm-svn: 45906
2008-01-12 08:14:25 +00:00
Chris Lattner
65531e8fb7 Fix a fixme, by only parsing extern "C" in C++ mode.
llvm-svn: 45905
2008-01-12 07:08:43 +00:00
Chris Lattner
38376f1595 Add first pieces of support for parsing and representing
extern "C" in C++ mode.  Patch by Mike Stump!

llvm-svn: 45904
2008-01-12 07:05:38 +00:00
Chris Lattner
22ad7abdfe Allow clients to specify the inline threshold when creating
the inliner pass.  Patch by Robert Zeh.

llvm-svn: 45903
2008-01-12 06:49:13 +00:00
Chris Lattner
459dc52df4 Add support for NetBSD, patch by Krister Walfridsson!
llvm-svn: 45902
2008-01-12 06:46:09 +00:00
Chris Lattner
177977ac19 When forming the squigly underline for a diagnostic, make sure to
verify that the source range corresponds to the current file, not
just the current line.  This allows us to emit:

a.c:1:44: error: invalid operands to binary expression ('double' and 'int *')
double a; int *b; void f(void) { int c = a +
                                         ~ ^

instead of:

a.c:1:44: error: invalid operands to binary expression ('double' and 'int *')
double a; int *b; void f(void) { int c = a +
~                                        ~ ^

for PR1906 (note the leading ~).

Thanks to Neil for noticing this.

llvm-svn: 45901
2008-01-12 06:43:35 +00:00
Evan Cheng
0395fd76cf Add -disable-lto optimization.
llvm-svn: 45900
2008-01-12 04:27:18 +00:00
Chris Lattner
ca2af72c7b this actually does pass with 4.0
llvm-svn: 45899
2008-01-12 01:45:22 +00:00
Evan Cheng
7411b510b2 Code clean up.
llvm-svn: 45898
2008-01-12 01:08:07 +00:00
Evan Cheng
02e78103ab ByVal arguments are passed on stack. Make sure to allocate a slot using size and alignment information on the parameter attribute.
llvm-svn: 45897
2008-01-12 01:07:41 +00:00
Chris Lattner
18df33d0c8 fix a wordo that gordon noticed :)
llvm-svn: 45896
2008-01-12 00:53:16 +00:00
Chris Lattner
6da61c2515 Any x86 instruction that reads from an invariant location is invariant.
This allows us to sink things like:
	cvtsi2sd	32(%esp), %xmm1
when reading from the argument area, for example.

llvm-svn: 45895
2008-01-12 00:35:08 +00:00
Chris Lattner
08af5a9dad implement support for sinking a load out the bottom of a block that
has no stores between the load and the end of block.  This works 
great and sinks hundreds of stores, but we can't turn it on because
machineinstrs don't have volatility information and we don't want to
sink volatile stores :(

llvm-svn: 45894
2008-01-12 00:17:41 +00:00
Chris Lattner
1f503ddab5 remove some incorrect classof's.
llvm-svn: 45893
2008-01-11 23:25:16 +00:00
Duncan Sands
5b721fc21d When DAE drops the varargs part of a function, ensure any
attributes on the vararg call arguments are also dropped.

llvm-svn: 45892
2008-01-11 23:13:45 +00:00
Evan Cheng
b51d228e79 More cbe byval fixes.
llvm-svn: 45891
2008-01-11 23:10:11 +00:00
Chris Lattner
5a3deb99b3 llvm-g++ 4.0 has completely different code for this warning,
just xfail it.

llvm-svn: 45890
2008-01-11 23:06:56 +00:00
Chris Lattner
031f5e1b8c new testcase
llvm-svn: 45888
2008-01-11 23:04:14 +00:00
Duncan Sands
b99f44aa5e Do not allow attributes beyond a function's last
parameter, even if it is a varargs function.  Do
allow attributes on the varargs part of a call,
but not beyond the last argument.  Only allow
selected attributes to be on the varargs part of
a call (currently only 'byval' is allowed).  The
reasoning here is that most attributes, eg inreg,
simply make no sense here.

llvm-svn: 45887
2008-01-11 22:36:48 +00:00
Chris Lattner
b5bd924e83 Teach argpromote to ruthlessly hack small byval structs when it can
get away with it, which exposes opportunities to eliminate the memory
objects entirely.  For example, we now compile byval.ll to:

define internal void @f1(i32 %b.0, i64 %b.1) {
entry:
	%tmp2 = add i32 %b.0, 1		; <i32> [#uses=0]
	ret void
}

define i32 @main() nounwind  {
entry:
	call void @f1( i32 1, i64 2 )
	ret i32 0
}

This seems like it would trigger a lot for code that passes around small
structs (e.g. SDOperand's or _Complex)...

llvm-svn: 45886
2008-01-11 22:31:41 +00:00
Duncan Sands
0ebaf91f48 Two occurrences on one line count as one...
llvm-svn: 45885
2008-01-11 21:46:24 +00:00
Duncan Sands
7e46c50c6a If there are attributes on the varargs part of a
call, don't discard them.

llvm-svn: 45884
2008-01-11 21:23:39 +00:00
Scott Michel
a8f67e04bd More CellSPU refinements:
- struct_2.ll: Completely unaligned load/store testing

- call_indirect.ll, struct_1.ll: Add test lines to exercise
   X-form [$reg($reg)] addressing

At this point, loads and stores should be under control (he says
in an optimistic tone of voice.)

llvm-svn: 45882
2008-01-11 21:01:19 +00:00
Dale Johannesen
04b99780cf Disable for now.
llvm-svn: 45881
2008-01-11 20:47:33 +00:00
Ted Kremenek
8d71e25590 Fix misspelling of "existent".
Do not use std::cerr; use llvm::cerr instead.

Patch provided by Sam Bishop!

llvm-svn: 45880
2008-01-11 20:42:05 +00:00
Chris Lattner
b66fbdde42 Use smallptrset instead of std::set for efficiency.
llvm-svn: 45878
2008-01-11 19:36:30 +00:00
Chris Lattner
4a70261f00 a byval argument is guaranteed to be valid to load.
llvm-svn: 45877
2008-01-11 19:34:32 +00:00
Chris Lattner
4062a625e5 Update this code to use eraseFromParent where possible. Compute
whether an argument is byval and pass into isSafeToPromoteArgument.

llvm-svn: 45876
2008-01-11 19:20:39 +00:00
Chris Lattner
e736e55d3c replace a loop with a constant time check.
llvm-svn: 45875
2008-01-11 18:55:10 +00:00
Chris Lattner
669e7054ca another minor datastructure tweak.
llvm-svn: 45874
2008-01-11 18:47:45 +00:00
Chris Lattner
a8ba28f6e4 start using smallvector to avoid vector heap thrashing.
llvm-svn: 45873
2008-01-11 18:43:58 +00:00
Chris Lattner
c70ed4ba5b add operator==/!= to smallvector.
llvm-svn: 45872
2008-01-11 18:42:02 +00:00
Chris Lattner
596875118c rename MachineInstr::setInstrDescriptor -> setDesc
llvm-svn: 45871
2008-01-11 18:10:50 +00:00
Chris Lattner
806dd0e2ac remove xchg and shift-reg-by-1 instructions, which are dead.
llvm-svn: 45870
2008-01-11 18:00:50 +00:00
Chris Lattner
ff5998e66b add a note, remove a done deed.
llvm-svn: 45869
2008-01-11 18:00:13 +00:00
Arnold Schwaighofer
06da9e2d43 hrm - correct spelling.
Actually were not riding any arguments. Sadly there is no semantic spell checker that is going to safe you from such a mistake.

llvm-svn: 45868
2008-01-11 17:10:15 +00:00
Arnold Schwaighofer
6cf72fbbaf Improve tail call optimized call's argument lowering. Before this
commit all arguments where moved to the stack slot where they would
reside on a normal function call before the lowering to the tail call
stack slot. This was done to prevent arguments overwriting each other.
Now only arguments sourcing from a FORMAL_ARGUMENTS node or a
CopyFromReg node with virtual register (could also be a caller's
argument) are lowered indirectly.

 --This line, and those below, will be ignored--

M    X86/X86ISelLowering.cpp
M    X86/README.txt

llvm-svn: 45867
2008-01-11 16:49:42 +00:00
Ted Kremenek
5906b9e79a Added ProgramPoint.cpp, which implements several methods of the subclasses
of ProgramPoint.

llvm-svn: 45866
2008-01-11 16:36:20 +00:00
Arnold Schwaighofer
bf1816ea7b Correct a copy and paste error.
llvm-svn: 45865
2008-01-11 14:34:56 +00:00
Evan Cheng
ef5285ef88 Some C backend ByVal parameter attribute support. Not yet complete.
llvm-svn: 45864
2008-01-11 09:12:49 +00:00
Evan Cheng
8c51394e01 Rename Int_CVTSI642SSr* to Int_CVTSI2SS64r* for naming consistency and remove unused instructions.
llvm-svn: 45861
2008-01-11 07:37:44 +00:00
Chris Lattner
9283173061 more flags set right
llvm-svn: 45860
2008-01-11 07:18:17 +00:00
Chris Lattner
f4b0c99d63 add some missing flags.
llvm-svn: 45859
2008-01-11 06:59:07 +00:00
Chris Lattner
6d7cf509d1 don't include loopinfo.h from this file.
llvm-svn: 45858
2008-01-11 06:30:04 +00:00
Chris Lattner
b3220147d2 Move typedef of loop to top of the file where it is more obvious.
llvm-svn: 45857
2008-01-11 06:29:42 +00:00
Chris Lattner
b97b83fbf7 Fix 80 col violations
llvm-svn: 45856
2008-01-11 06:27:42 +00:00
Chris Lattner
5cee13f1df document the byval parameter attribute.
llvm-svn: 45855
2008-01-11 06:20:47 +00:00
Chris Lattner
87b0c13104 add some notes.
llvm-svn: 45854
2008-01-11 06:17:47 +00:00
Chris Lattner
908117bf69 When inlining a functino with a byval argument, make an explicit
copy of it in case the callee modifies the struct.

llvm-svn: 45853
2008-01-11 06:09:30 +00:00
Evan Cheng
aaef8ce856 A couple of obvious off-by-one bugs.
llvm-svn: 45852
2008-01-11 03:07:46 +00:00
Scott Michel
8d5841ae3c More CellSPU refinement and progress:
- Cleaned up custom load/store logic, common code is now shared [see note
  below], cleaned up address modes

- More test cases: various intrinsics, structure element access (load/store
  test), updated target data strings, indirect function calls.

Note: This patch contains a refactoring of the LoadSDNode and StoreSDNode
structures: they now share a common base class, LSBaseSDNode, that
provides an interface to their common functionality. There is some hackery
to access the proper operand depending on the derived class; otherwise,
to do a proper job would require finding and rearranging the SDOperands
sent to StoreSDNode's constructor. The current refactor errs on the
side of being conservatively and backwardly compatible while providing
functionality that reduces redundant code for targets where loads and
stores are custom-lowered.

llvm-svn: 45851
2008-01-11 02:53:15 +00:00
Evan Cheng
4cc275c3fb Allow parameter attributes on varargs function parameters.
llvm-svn: 45850
2008-01-11 02:13:09 +00:00
Dale Johannesen
193daf0698 Weak zeroes don't go in bss on Darwin.
llvm-svn: 45849
2008-01-11 01:59:45 +00:00
Dale Johannesen
2ff66f08f2 Weak things initialized to 0 don't go in bss on Darwin.
Cosmetic changes to spacing to match gcc (some dejagnu
tests actually care).

llvm-svn: 45848
2008-01-11 00:54:37 +00:00
Ted Kremenek
b1dec454bb Renamed ProgramEdge.h to ProgramPoint.h
llvm-svn: 45847
2008-01-11 00:43:12 +00:00
Ted Kremenek
e5ccf9a96c Renamed ProgramEdge to ProgramPoint and changed subclasses of ProgramEdge
to have a much simpler, cleaner interpretation of what is a "location"
in a function (as encoded by a CFG).

llvm-svn: 45846
2008-01-11 00:40:29 +00:00
Ted Kremenek
d7a7abed62 Fixed 80-col violation.
llvm-svn: 45845
2008-01-11 00:18:40 +00:00
Chris Lattner
c8226f32e9 Simplify the side effect stuff a bit more and make licm/sinking
both work right according to the new flags.

This removes the TII::isReallySideEffectFree predicate, and adds
TII::isInvariantLoad. 

It removes NeverHasSideEffects+MayHaveSideEffects and adds
UnmodeledSideEffects as machine instr flags.  Now the clients
can decide everything they need.

I think isRematerializable can be implemented in terms of the
flags we have now, though I will let others tackle that.

llvm-svn: 45843
2008-01-10 23:08:24 +00:00
Fariborz Jahanian
af5d80cba5 Avoid redefinition of __objcFastEnumerationState
llvm-svn: 45842
2008-01-10 23:04:06 +00:00
Chris Lattner
f3bd2cd37c Clamp down on sinking of lots of instructions.
llvm-svn: 45841
2008-01-10 22:35:15 +00:00
Steve Naroff
98f7203680 - Teach Expr::isConstantExpr() about InitListExpr's (and offsetof, since I noticed it was missing).
- Rename CheckInitializer() to CheckInitializerTypes().
- Removed the isStatic argument to CheckInitializerTypes() and all of it's subroutines. Checking for constant expressions is now done separately.
- Added CheckForConstantInitializer().

llvm-svn: 45840
2008-01-10 22:15:12 +00:00
Fariborz Jahanian
939776756f Recover from user typo not having proper @interface decl and a bad foreach decl.
llvm-svn: 45839
2008-01-10 20:33:58 +00:00
Chris Lattner
8e60f2c996 IMPLICIT_USE and IMPLICIT_DEF are dead, remove them.
llvm-svn: 45838
2008-01-10 19:27:54 +00:00
Chris Lattner
1d07b65add add a note
llvm-svn: 45837
2008-01-10 18:25:41 +00:00
Fariborz Jahanian
2de9a0be09 Remove non-ascii chaaracter from diagnostic
llvm-svn: 45836
2008-01-10 18:10:31 +00:00
Ted Kremenek
e67952fcd9 Fixed non-ASCII quote.
llvm-svn: 45835
2008-01-10 18:08:55 +00:00
Fariborz Jahanian
c644ee4992 Warn (as gcc does) when @end does not close anything.
llvm-svn: 45834
2008-01-10 17:58:07 +00:00
Duncan Sands
53c954fa86 Output sinl for a long double FSIN node, not sin.
Likewise fix up a bunch of other libcalls.  While
there I remove NEG_F32 and NEG_F64 since they are
not used anywhere.  This fixes 9 Ada ACATS failures.

llvm-svn: 45833
2008-01-10 10:28:30 +00:00
Evan Cheng
f2553ab84f Only remat loads from immutable stack slots.
llvm-svn: 45831
2008-01-10 08:24:38 +00:00
Evan Cheng
8b03bafd37 Simplify some code.
llvm-svn: 45830
2008-01-10 08:22:10 +00:00
Chris Lattner
317332fc2a Start inferring side effect information more aggressively, and fix many bugs in the
x86 backend where instructions were not marked maystore/mayload, and perf issues where
instructions were not marked neverHasSideEffects.  It would be really nice if we could
write patterns for copy instructions.

I have audited all the x86 instructions down to MOVDQAmr.  The flags on others and on
other targets are probably not right in all cases, but no clients currently use this
info that are enabled by default.

llvm-svn: 45829
2008-01-10 07:59:24 +00:00
Evan Cheng
4c1f731905 Clearify the meaning of immutable StackObject.
llvm-svn: 45828
2008-01-10 07:19:43 +00:00
Chris Lattner
70ddafaf45 Fix a crash on code like: let x = 1 {x
llvm-svn: 45827
2008-01-10 07:01:53 +00:00
Chris Lattner
2e38f2458c rename X86InstrX86-64.td -> X86Instr64bit.td
llvm-svn: 45826
2008-01-10 05:50:42 +00:00
Chris Lattner
520d4adad3 add SDNPSideEffect node property declaration
llvm-svn: 45825
2008-01-10 05:48:23 +00:00
Chris Lattner
aca7ca3730 remove explicit sets of 'neverHasSideEffects' that can now be
inferred from the instr patterns.

llvm-svn: 45824
2008-01-10 05:45:39 +00:00
Chris Lattner
86c458a178 if an instr lacks a pattern, assume it has side effects (unless never has s-e is true).
llvm-svn: 45823
2008-01-10 05:40:54 +00:00
Chris Lattner
42c63ef96e start inferring 'no side effects'.
llvm-svn: 45822
2008-01-10 05:39:30 +00:00
Chris Lattner
94de7bc3aa get def use info more correct.
llvm-svn: 45821
2008-01-10 05:12:37 +00:00
Ted Kremenek
aa8c904dfc Added some text about the ccc script provided by Sanghyeon Seo.
llvm-svn: 45820
2008-01-10 04:59:05 +00:00
Chris Lattner
9e69654461 Infer mayload
llvm-svn: 45819
2008-01-10 04:44:48 +00:00
Chris Lattner
c72335878d add SDNPMayLoad to the 'load' sdnode definition. This is enough to get all the x86
instructions (with patterns) that load memory marked, for example.

llvm-svn: 45818
2008-01-10 04:44:32 +00:00
Chris Lattner
1ca2068227 realize that instructions who match intrinsics that read memory read memory.
Also, instructions with any nodes that are SDNPMayLoad also read memory.

llvm-svn: 45817
2008-01-10 04:38:57 +00:00
Chris Lattner
f171482a66 verify that the frame index is immutable before remat'ing (still disabled)
or being side-effect free.

llvm-svn: 45816
2008-01-10 04:16:31 +00:00
Owen Anderson
d445b8813f Don't use LiveVariables::VarInfo::DefInst.
llvm-svn: 45815
2008-01-10 03:12:54 +00:00
Evan Cheng
0f8c7c4a73 Codegen improvement has reduced one spill.
llvm-svn: 45814
2008-01-10 02:54:40 +00:00
Evan Cheng
a26552493b Mark byval parameter stack objects mutable for now.
llvm-svn: 45813
2008-01-10 02:24:25 +00:00
Evan Cheng
301b0cade5 Add a isImmutable bit to StackObject. Fixed stack objects are immutable (in the function) unless specified otherwise.
llvm-svn: 45812
2008-01-10 02:18:37 +00:00
Dale Johannesen
7ecb3b79c7 Emit unused EH frames for weak definitions on Darwin,
because assembler/linker can't cope with weak absolutes.
PR 1880.

llvm-svn: 45811
2008-01-10 02:03:30 +00:00
Chris Lattner
2cbf2f39ee add support for the GCC -include option.
llvm-svn: 45810
2008-01-10 01:53:41 +00:00
Seo Sanghyeon
77133e6d30 Compiler driver
llvm-svn: 45809
2008-01-10 01:43:47 +00:00
Chris Lattner
bceeefdc9c Fix some 80 col violations
llvm-svn: 45808
2008-01-10 01:43:14 +00:00
Chris Lattner
d2cdb97747 Ted apparently likes crazy whitespace at the end of line. Crush his spirit by
removing them, fitting the file into 80 columns. :)

llvm-svn: 45807
2008-01-10 01:41:55 +00:00
Fariborz Jahanian
7262fca0a6 Put return type of synthesize method on same line as method declaration, space after method declaration header.
llvm-svn: 45806
2008-01-10 01:39:52 +00:00
Owen Anderson
4f45cef2f9 Get rid of all uses of LiveVariables::VarInfo::DefInst in favor of the equivalent API from
MachineRegisterInfo.  Once all clients are switched over, the former will be going away.

llvm-svn: 45805
2008-01-10 01:36:43 +00:00
Chris Lattner
cb0e1bcf0c provide def_* and use_* iterators in addition to reg_* iterators.
The first only returns definitions of a register, the second only
returns uses, the third returns both.

llvm-svn: 45803
2008-01-10 01:01:27 +00:00
Ted Kremenek
3d55c84c99 Added "InfeasibleEdge" to represent an infeasible state transition.
llvm-svn: 45802
2008-01-10 00:58:25 +00:00
Owen Anderson
51b8e20ccf Add more comments explaining the basics of how the decision of when to rename and when to insert
copies is made.

llvm-svn: 45799
2008-01-10 00:47:01 +00:00
Evan Cheng
fead113fe0 Do not use the stack pointer directly, issue a copyfromreg instead. Otherwise we can end up with something like ADD32ri %esp, x which two-address pass won't like.
llvm-svn: 45798
2008-01-10 00:37:26 +00:00
Owen Anderson
8958a78576 Get rid of the isKillInst predicate. LiveVariables already provides this information.
llvm-svn: 45797
2008-01-10 00:33:11 +00:00
Chris Lattner
ec79bba97f Fix PR1845 and rdar://5676945. Generic vectors smaller
than hardware supported type will be scalarized, so we
can infer their alignment from that info.

We now codegen pr1845 into:

_boolVectorSelect:
	lbz r2, 0(r3)
	stb r2, -16(r1)
	blr 

llvm-svn: 45796
2008-01-10 00:30:57 +00:00
Chris Lattner
e34d7d0e24 new testcase for PR1845
llvm-svn: 45795
2008-01-10 00:30:38 +00:00
Fariborz Jahanian
db701b47d2 Pass rewritten output to 'clang' for verification.
llvm-svn: 45794
2008-01-10 00:30:24 +00:00
Fariborz Jahanian
82ae0152a7 Allow messaging expression as foreach's collection expression.
llvm-svn: 45793
2008-01-10 00:24:29 +00:00
Evan Cheng
73d1017871 Remove comments that do not correspond to anything after recent refactoring.
llvm-svn: 45792
2008-01-10 00:09:10 +00:00
Owen Anderson
1c8152ba03 Copies need to be inserted before the first terminator, not at the end of the block.
llvm-svn: 45791
2008-01-10 00:01:41 +00:00
Steve Naroff
a385fb8c2e Add a FIXME to commit r45784. Thanks mrs!
llvm-svn: 45790
2008-01-09 23:44:05 +00:00
Steve Naroff
e6b0ec8b5e Fix Sema::ActOnDeclarator() to call MergeFunctionDecl for function decls that aren't in scope. Since C functions are in a flat namespace, we need to give them special treatment (when compared with variables and typedefs).
llvm-svn: 45789
2008-01-09 23:34:55 +00:00
Ted Kremenek
24ea11d4e0 Renamed various traits and classes. Added "Infeasible" bit to ExplodedNodeImpl
so that nodes can be marked as representing an infeasible program point. This
flag lets the path-sensitive solver know that no successors should be generated
for such nodes.

llvm-svn: 45788
2008-01-09 23:11:36 +00:00
Evan Cheng
0e400d4cb7 Special copy SUnit's do not have SDNode's.
llvm-svn: 45787
2008-01-09 23:01:55 +00:00
Ted Kremenek
84ab850e46 Renamed Stmt***Edge and ***StmtEdge (where *** = "Stmt" or "Blk") classes to
BExpr*** and ***BExpr respectively. These edges represent program locations
between the entrance/exit of a block and Block-level Expressions.

Also added ***SExpr and SExpr*** ProgramEdges to represent the locations in the
program between the evaluation of subexpressions and block-level expressions.

llvm-svn: 45786
2008-01-09 22:52:38 +00:00
Ted Kremenek
fed4cce0cc Removed some files related to the path-sensitive solver as part of some
code restructuring.  (new files will be introduced shortly)

llvm-svn: 45785
2008-01-09 22:49:37 +00:00
Steve Naroff
c6edcbdb5d Fix ASTContext::typesAreCompatible to allow for int/enum compatibility (C99 6.7.2.2p4).
Fix Sema::MergeFunctionDecl to allow for function type compatibility (by using the predicate on ASTContext). Function types don't have to be identical to be compatible...

llvm-svn: 45784
2008-01-09 22:43:08 +00:00
Owen Anderson
436db42a3c Clean up StrongPHIElimination a bit, and add some more comments to the internal structures. There's
still more work to do on this front.

llvm-svn: 45783
2008-01-09 22:40:54 +00:00
Steve Naroff
08ddb8c55c Teach Sema::ActOnCompoundLiteral about constraint C99 6.5.2.5p3.
llvm-svn: 45782
2008-01-09 20:58:06 +00:00
Duncan Sands
48f22f0b80 Fix compile failures with g++-4.3.
llvm-svn: 45781
2008-01-09 19:42:09 +00:00
Chris Lattner
204e4a27b6 many cleanups and fixed, contributed by Sam Bishop
llvm-svn: 45780
2008-01-09 19:28:50 +00:00
Chris Lattner
119d81a4f4 Fix isIntegerConstantExpr to compare against zero for casts to bool instead of
truncating.  This allows us to compile:
 void foo() {
  static _Bool foo = 4;
}

into:
@foo1 = internal global i8 1
instead of:
@foo1 = internal global i8 4

llvm-svn: 45779
2008-01-09 18:59:34 +00:00
Chris Lattner
41a1ef0dfe implement proper support for _Bool in memory, which is usually i8, not i1.
This fixes a crash reported by Seo Sanghyeon

llvm-svn: 45778
2008-01-09 18:47:25 +00:00
Fariborz Jahanian
6fa7516bc9 Type-cast RHS of assignment to prevent warning compiling rewritten foreach code.
llvm-svn: 45777
2008-01-09 18:15:42 +00:00
Fariborz Jahanian
22f2347791 Fixed a bug whereby a parethesized collection expression was not being rewritten correctly.
llvm-svn: 45776
2008-01-09 17:50:00 +00:00
Owen Anderson
4de0c3978d StrongPHIElim: Now with even fewer trivial bugs!
llvm-svn: 45775
2008-01-09 10:41:39 +00:00
Owen Anderson
77c3fe441b Fix an infinite recursion bug in InsertCopies.
llvm-svn: 45774
2008-01-09 10:32:30 +00:00
Owen Anderson
e0fd9bd35a Fix some simple bugs. StrongPHIElimination now does not crash on 164.gzip.
llvm-svn: 45773
2008-01-09 06:19:05 +00:00
Evan Cheng
a31824a08e Fix sse2.psrl.w and sse2.psrl.q definitions.
llvm-svn: 45772
2008-01-09 02:16:44 +00:00
Fariborz Jahanian
b7e7ee9ff3 Typo fixed.
llvm-svn: 45771
2008-01-09 01:25:54 +00:00
Chris Lattner
7ff4a8bf3f Fix llvm-ld -Xlinker, patch by Daniel Teske!
llvm-svn: 45770
2008-01-09 01:01:17 +00:00
Fariborz Jahanian
05d2876ec3 Another test case for testing rewriteing of nested foreach-statement.
llvm-svn: 45769
2008-01-09 00:47:02 +00:00
Chris Lattner
9129f51f9b add a testcase
llvm-svn: 45768
2008-01-09 00:37:18 +00:00
Fariborz Jahanian
a305a5609e Remove dependency on objc.h
llvm-svn: 45767
2008-01-09 00:33:05 +00:00
Chris Lattner
45e5032b1d add a note
llvm-svn: 45766
2008-01-09 00:17:57 +00:00
Steve Naroff
66a26044f8 Teach Expr::isConstantExpr() about CompoundLiterals.
llvm-svn: 45764
2008-01-09 00:05:37 +00:00
Chris Lattner
82bebb2432 Fix a typo, patch by Mike Stump!
llvm-svn: 45763
2008-01-09 00:00:15 +00:00
Chris Lattner
51b01bf8a5 Make load->store deletion a bit smarter. This allows us to compile this:
void test(long long *P) { *P ^= 1; }

into just:

_test:
	movl	4(%esp), %eax
	xorl	$1, (%eax)
	ret

instead of code like this:

_test:
	movl	4(%esp), %ecx
        xorl    $1, (%ecx)
	movl	4(%ecx), %edx
	movl	%edx, 4(%ecx)
	ret

llvm-svn: 45762
2008-01-08 23:08:06 +00:00
Fariborz Jahanian
965a8961c7 Patch to rewrite ObjC2's foreach-stmt.
llvm-svn: 45760
2008-01-08 22:06:28 +00:00
Owen Anderson
1b0d5c747e Rename registers that do not need copies.
llvm-svn: 45759
2008-01-08 21:54:52 +00:00
Duncan Sands
7b1460cca4 Crashes llc when using Chris's new legalization logic.
llvm-svn: 45758
2008-01-08 21:51:53 +00:00
Ted Kremenek
a0a2881b1e Added "getRoot()" to ImmutableMap.
Made the ctor for ImmutableMap to construct a map from an AVL tree public.

llvm-svn: 45756
2008-01-08 21:05:59 +00:00
Ted Kremenek
9b0f70bb85 Fixed 80 col. violation.
llvm-svn: 45752
2008-01-08 19:38:55 +00:00
Ted Kremenek
96b1ce4f0a Added VISIBILITY_HIDDEN to classes/structs in anonymous namespaces.
llvm-svn: 45750
2008-01-08 18:19:08 +00:00
Ted Kremenek
83ebcef8ae Added VISIBILITY_HIDDEN to classes/structs in anonymous namespace.
llvm-svn: 45749
2008-01-08 18:15:10 +00:00
Chris Lattner
07fde9bde1 add a mayLoad property for machine instructions, a correlary to mayStore.
This is currently not set by anything.

llvm-svn: 45748
2008-01-08 18:05:21 +00:00
Ted Kremenek
7e41c29a86 Added most of the boilerplate to the driver needed to run the graph-reachability
constant propagation analysis.

llvm-svn: 45747
2008-01-08 18:04:06 +00:00
Duncan Sands
bb956ca730 Use size_t to store Pos, avoid truncating value
on 64-bit builds.  Analysis and original patch
by Török Edwin.  Code audit found another place
with the same problem, also fixed here.

llvm-svn: 45746
2008-01-08 10:06:15 +00:00
Chris Lattner
2940c5c56d Implement PR1795, an instcombine hack for forming GEPs with integer pointer arithmetic.
llvm-svn: 45745
2008-01-08 07:23:51 +00:00
Chris Lattner
ff71ec4dfb add match support for casts.
llvm-svn: 45744
2008-01-08 07:02:44 +00:00
Chris Lattner
b17db3afa8 remove darwin/i386 t-t
llvm-svn: 45743
2008-01-08 06:52:51 +00:00
Chris Lattner
89f36e6b21 Finally implement correct ordered comparisons for PPC, even though
the code generated is not wonderful.  This turns a miscompilation into
a code quality bug (noted in the ppc readme).  This fixes PR642, which
is over 2 years old (!).  Nate, please review this.

llvm-svn: 45742
2008-01-08 06:46:30 +00:00
Chris Lattner
184f79a5e1 Testcase for PR1721
llvm-svn: 45739
2008-01-08 05:16:29 +00:00
Owen Anderson
812e1ea7cf Actually insert copies now!
llvm-svn: 45738
2008-01-08 05:16:15 +00:00
Chris Lattner
97879424fe Fix PR1797
llvm-svn: 45736
2008-01-08 04:26:20 +00:00
Chris Lattner
e3e358c317 readability improvement suggested by Sam Bishop, thanks!
llvm-svn: 45735
2008-01-08 04:13:21 +00:00
Evan Cheng
00300ddff1 Minor fix to enable x86-64 pic jit (still fails for other reasons).
llvm-svn: 45734
2008-01-08 02:07:10 +00:00
Evan Cheng
4951da49aa Fix a x86-64 static codegen bug. This fixes a lot of x86-64 jit failures.
llvm-svn: 45733
2008-01-08 02:06:11 +00:00
Steve Naroff
039ad3cf90 Fix Sema::CheckConditionalOperands(). The null pointer constant checks need to precede the check for two pointer operands.
llvm-svn: 45732
2008-01-08 01:11:38 +00:00
Bill Wendling
3b6fe5fa8d Silence warning about loss of precision.
llvm-svn: 45731
2008-01-08 00:52:29 +00:00
Ted Kremenek
9384343c11 Added nodes_iterator to the GraphTrait for ExplodedNode<>.
llvm-svn: 45730
2008-01-08 00:46:00 +00:00
Ted Kremenek
a3da232ce7 Added GraphTraits<> partial specializations for ExplodedNode<> classes.
llvm-svn: 45729
2008-01-08 00:26:05 +00:00
Ted Kremenek
551e4ce74e Relocated comment in header.
llvm-svn: 45728
2008-01-08 00:07:06 +00:00
Evan Cheng
7250120177 Only mark instructions that load a single value without extension as isSimpleLoad = 1.
llvm-svn: 45727
2008-01-07 23:56:57 +00:00
Chris Lattner
ba734518c1 add a new bit.
llvm-svn: 45726
2008-01-07 23:16:55 +00:00
Evan Cheng
8242168ef4 Unbreak x86-64.
llvm-svn: 45725
2008-01-07 23:08:23 +00:00
Ted Kremenek
35ff5b0ee6 Added more boilerplate for processing end-of-paths.
llvm-svn: 45724
2008-01-07 22:22:13 +00:00
Chris Lattner
ef81aa75f6 add a note that is important for some fp apps.
llvm-svn: 45723
2008-01-07 21:59:58 +00:00
Ted Kremenek
8569309bca Added ownership of "checker state" within the ExplodedGraph. Moved code that
creates the initial root node from the constructor of ReachabilityEngine to
ReachabilityEngine::ExecuteWorklist.

llvm-svn: 45722
2008-01-07 21:56:52 +00:00
Fariborz Jahanian
dc917b9e07 Patch to start rewriting of ObjC2's foreach statement (work in progress).
llvm-svn: 45721
2008-01-07 21:40:22 +00:00
Chris Lattner
730d088be1 possible switch lowering improvement.
llvm-svn: 45720
2008-01-07 21:38:14 +00:00
Owen Anderson
47299489ec Oops, missed one.
llvm-svn: 45719
2008-01-07 21:32:09 +00:00
Owen Anderson
bbc6352d1f Make some predicates static.
llvm-svn: 45718
2008-01-07 21:30:40 +00:00
Fariborz Jahanian
6917870be5 Verify/add code to make sure types passed to interfaceTypesAreCompatible
are canonical. Asst in interfaceTypesAreCompatible if they are not.

llvm-svn: 45717
2008-01-07 20:12:21 +00:00
Chris Lattner
a30be59fa2 Fix a nasty corner case that Neil noticed in PR1900, where we would
incorrectly apply the multiple include optimization to files with 
guards like:

#if !defined(x) MACRO

where MACRO could expand to different things in different contexts.
Thanks Neil!

llvm-svn: 45716
2008-01-07 19:50:27 +00:00
Ted Kremenek
1b0ea82459 Substituted all instances of the string "Objc" for "ObjC". This fixes
some naming inconsistencies in the names of classes pertaining to Objective-C
support in clang.

llvm-svn: 45715
2008-01-07 19:49:32 +00:00
Duncan Sands
c50c210d76 I doubt the address of the Error string was intended
to be used for the force_interpreter parameter...
Spotted by gcc-4.2.

llvm-svn: 45714
2008-01-07 19:14:42 +00:00
Fariborz Jahanian
699e638e4f Make interfaceTypesAreCompatible a private method.
llvm-svn: 45713
2008-01-07 19:13:39 +00:00
Duncan Sands
d19a6f4836 Add missing newline at EOF.
llvm-svn: 45712
2008-01-07 19:13:36 +00:00
Ted Kremenek
9dbf8a93a7 Renamed SimulVertex, SimulGraph, and SimulEngine to:
ExplodedNode, ExplodedGraph  (to match the vocabulary in the RHS paper)
  ReachabilityEngine
  
The implementation of the core of the path-sensitive dataflow solver has
been de-templatized and places in ReachabilityEngine.cpp.

The solver is still incomplete.

llvm-svn: 45711
2008-01-07 19:08:42 +00:00
Ted Kremenek
dabea046f6 Minor tweak to serialization of ObjcForCollectionStmt: the three owned pointers
are now emitted in a batch, which reduces the metadata overhead in the
serialized bitcode.

llvm-svn: 45710
2008-01-07 18:35:04 +00:00
Fariborz Jahanian
d5450b7f07 Limit type of foreach's element and collection to be a pointer to
objc object type.

llvm-svn: 45709
2008-01-07 18:14:04 +00:00
Fariborz Jahanian
fef287cb67 Issue diagnostics if more than one declaration in objectove-c's foreach-stmt header.
llvm-svn: 45708
2008-01-07 17:52:35 +00:00
Nate Begeman
281653b25e Update the comment on scalar to vector to be a bit more clear.
llvm-svn: 45707
2008-01-07 17:52:24 +00:00
Chris Lattner
f5c973d061 minor cleanup.
llvm-svn: 45706
2008-01-07 17:51:46 +00:00
Nate Begeman
d3d49df3f1 Update test to catch recent x86 insert regression and improvements
llvm-svn: 45705
2008-01-07 17:49:23 +00:00
Duncan Sands
b18c30acec Small cleanup for handling of type/parameter attribute
incompatibility.

llvm-svn: 45704
2008-01-07 17:16:06 +00:00
Duncan Sands
d8d4170f84 Unbreak x86-32 darwin long double!
llvm-svn: 45703
2008-01-07 16:36:38 +00:00
Duncan Sands
28bf7ac219 Fix long double support on x86-32 linux.
llvm-svn: 45701
2008-01-07 13:44:22 +00:00
Gordon Henriksen
24db8d383d Pruning includes.
llvm-svn: 45700
2008-01-07 13:30:38 +00:00
Bill Wendling
a3bdad153f Operand 1 should be a register. We don't care if it's a preg, vreg, or 0.
llvm-svn: 45699
2008-01-07 08:05:29 +00:00
Chris Lattner
d7857eafd0 add a note
llvm-svn: 45698
2008-01-07 07:46:23 +00:00
Chris Lattner
f3efadcb5b remove #includage
llvm-svn: 45697
2008-01-07 07:42:25 +00:00
Chris Lattner
69fc766f63 split TargetInstrDesc out into its own header file.
llvm-svn: 45696
2008-01-07 07:33:08 +00:00
Chris Lattner
03ad885039 rename TargetInstrDescriptor -> TargetInstrDesc.
Make MachineInstr::getDesc return a reference instead
of a pointer, since it can never be null.

llvm-svn: 45695
2008-01-07 07:27:27 +00:00
Chris Lattner
3ef160b15a remove a dead method.
llvm-svn: 45694
2008-01-07 06:47:10 +00:00
Chris Lattner
fd2e338b85 simplify some code.
llvm-svn: 45693
2008-01-07 06:47:00 +00:00
Chris Lattner
e99a6caee4 Rename all the M_* flags to be namespace qualified enums, and switch
all clients over to using predicates instead of these flags directly.
These are now private values which are only to be used to statically
initialize the tables.

llvm-svn: 45692
2008-01-07 06:42:05 +00:00
Chris Lattner
d004f54155 use predicate.
llvm-svn: 45691
2008-01-07 06:37:29 +00:00
Chris Lattner
08a69ac2f5 add more and significantly better comments to the rest of the machineinstr
flags that can be set.  Add predicates for the ones lacking it, and switch
some clients over to using the predicates instead of Flags directly.

llvm-svn: 45690
2008-01-07 06:21:53 +00:00
Chris Lattner
769c86bf63 simplify some code using new predicates
llvm-svn: 45689
2008-01-07 05:40:58 +00:00
Chris Lattner
c5c63ff9d7 add some mroe comments, add a isImplicitDef() method, add
isConditionalBranch() and isUnconditionalBranch() methods.

llvm-svn: 45688
2008-01-07 05:38:38 +00:00
Chris Lattner
f376c99ea0 rename hasVariableOperands() -> isVariadic(). Add some comments.
Evan, please review the comments I added to getNumDefs to make sure
that they are accurate, thx.

llvm-svn: 45687
2008-01-07 05:19:29 +00:00
Chris Lattner
fd548c96cc Move M_* flags down in the file. Move SchedClass up in the
TargetInstrDescriptor class and shrink to 16-bits, saving a 
word in TargetInstrDescriptor.  Add some comments.

llvm-svn: 45686
2008-01-07 05:06:49 +00:00
Chris Lattner
8c69898157 remove a dead field.
llvm-svn: 45685
2008-01-07 04:57:42 +00:00
Chris Lattner
6f8713decb the name field of instructions is never set to a non-empty string,
just unconditionally use the def name of the instruction.

llvm-svn: 45684
2008-01-07 04:57:31 +00:00
Chris Lattner
6077962101 no need to explicitly clear these fields.
llvm-svn: 45683
2008-01-07 04:55:09 +00:00
Nate Begeman
f7c3ff6f80 Fix typo
llvm-svn: 45682
2008-01-07 04:01:26 +00:00
Gordon Henriksen
c75405bdb3 Removing a leaked file.
llvm-svn: 45681
2008-01-07 03:23:52 +00:00
Chris Lattner
b0d06b4381 Move a bunch more accessors from TargetInstrInfo to TargetInstrDescriptor
llvm-svn: 45680
2008-01-07 03:13:06 +00:00
Chris Lattner
f0f438a517 remove MachineOpCode typedef.
llvm-svn: 45679
2008-01-07 02:48:55 +00:00
Chris Lattner
d34c47653e remove some uses of MachineOpCode, move getSchedClass
into TargetInstrDescriptor from TargetInstrInfo.

llvm-svn: 45678
2008-01-07 02:46:03 +00:00
Chris Lattner
e55e115616 Add predicates methods to TargetOperandInfo, and switch all clients
over to using them, instead of diddling Flags directly.  Change the
various flags from const variables to enums.

llvm-svn: 45677
2008-01-07 02:39:19 +00:00
Gordon Henriksen
c7e991b7c3 Setting GlobalDirective in TargetAsmInfo by default rather than
providing a misleading facility. It's used once in the MIPS backend
and hardcoded as "\t.globl\t" everywhere else.

llvm-svn: 45676
2008-01-07 02:31:11 +00:00
Gordon Henriksen
efb08802ec Deleting an empty file. Thanks, /usr/bin/patch!
llvm-svn: 45675
2008-01-07 02:29:04 +00:00
Chris Lattner
a98c679de0 Rename MachineInstr::getInstrDescriptor -> getDesc(), which reflects
that it is cheap and efficient to get.

Move a variety of predicates from TargetInstrInfo into 
TargetInstrDescriptor, which makes it much easier to query a predicate
when you don't have TII around.  Now you can use MI->getDesc()->isBranch()
instead of going through TII, and this is much more efficient anyway. Not
all of the predicates have been moved over yet.

Update old code that used MI->getInstrDescriptor()->Flags to use the
new predicates in many places.

llvm-svn: 45674
2008-01-07 01:56:04 +00:00
Owen Anderson
0ec92e9d64 Update CodeGen for MRegisterInfo --> TargetInstrInfo changes.
llvm-svn: 45673
2008-01-07 01:35:56 +00:00
Owen Anderson
2a3be7bb6c Move even more functionality from MRegisterInfo into TargetInstrInfo.
Some day I'll get it all moved over...

llvm-svn: 45672
2008-01-07 01:35:02 +00:00
Gordon Henriksen
2d684b1fbf Ammending r45669 with a missing file.
llvm-svn: 45671
2008-01-07 01:33:09 +00:00
Gordon Henriksen
6047b6e140 With this patch, the LowerGC transformation becomes the
ShadowStackCollector, which additionally has reduced overhead with
no sacrifice in portability.

Considering a function @fun with 8 loop-local roots,
ShadowStackCollector introduces the following overhead
(x86):

; shadowstack prologue
        movl    L_llvm_gc_root_chain$non_lazy_ptr, %eax
        movl    (%eax), %ecx
        movl    $___gc_fun, 20(%esp)
        movl    $0, 24(%esp)
        movl    $0, 28(%esp)
        movl    $0, 32(%esp)
        movl    $0, 36(%esp)
        movl    $0, 40(%esp)
        movl    $0, 44(%esp)
        movl    $0, 48(%esp)
        movl    $0, 52(%esp)
        movl    %ecx, 16(%esp)
        leal    16(%esp), %ecx
        movl    %ecx, (%eax)

; shadowstack loop overhead
        (none)

; shadowstack epilogue
        movl    48(%esp), %edx
        movl    %edx, (%ecx)

; shadowstack metadata
        .align  3
___gc_fun:                              # __gc_fun
        .long   8
        .space  4

In comparison to LowerGC:

; lowergc prologue
        movl    L_llvm_gc_root_chain$non_lazy_ptr, %eax
        movl    (%eax), %ecx
        movl    %ecx, 48(%esp)
        movl    $8, 52(%esp)
        movl    $0, 60(%esp)
        movl    $0, 56(%esp)
        movl    $0, 68(%esp)
        movl    $0, 64(%esp)
        movl    $0, 76(%esp)
        movl    $0, 72(%esp)
        movl    $0, 84(%esp)
        movl    $0, 80(%esp)
        movl    $0, 92(%esp)
        movl    $0, 88(%esp)
        movl    $0, 100(%esp)
        movl    $0, 96(%esp)
        movl    $0, 108(%esp)
        movl    $0, 104(%esp)
        movl    $0, 116(%esp)
        movl    $0, 112(%esp)

; lowergc loop overhead
        leal    44(%esp), %eax
        movl    %eax, 56(%esp)
        leal    40(%esp), %eax
        movl    %eax, 64(%esp)
        leal    36(%esp), %eax
        movl    %eax, 72(%esp)
        leal    32(%esp), %eax
        movl    %eax, 80(%esp)
        leal    28(%esp), %eax
        movl    %eax, 88(%esp)
        leal    24(%esp), %eax
        movl    %eax, 96(%esp)
        leal    20(%esp), %eax
        movl    %eax, 104(%esp)
        leal    16(%esp), %eax
        movl    %eax, 112(%esp)

; lowergc epilogue
        movl    48(%esp), %edx
        movl    %edx, (%ecx)

; lowergc metadata
        (none)

llvm-svn: 45670
2008-01-07 01:30:53 +00:00
Gordon Henriksen
5180e85675 Enabling the target-independent garbage collection infrastructure by hooking it
up to the various compiler pipelines.

This doesn't actually add support for any GC algorithms, which means it 
temporarily breaks a few tests. To be fixed shortly.

llvm-svn: 45669
2008-01-07 01:30:38 +00:00
Chris Lattner
b296b0f1c1 The pic base can't be duplicated.
llvm-svn: 45668
2008-01-06 23:49:32 +00:00
Chris Lattner
a4ce4f6987 rename isLoad -> isSimpleLoad due to evan's desire to have such a predicate.
llvm-svn: 45667
2008-01-06 23:38:27 +00:00
Chris Lattner
4d3b0f579c rearrange some code.
llvm-svn: 45666
2008-01-06 22:50:31 +00:00
Chris Lattner
e2949f42d3 some simplifications/cleanups to ?: sema.
llvm-svn: 45665
2008-01-06 22:42:25 +00:00
Chris Lattner
cfb6f430b6 Emit warnings like "dereferencing void pointer" instead of trying to
pretty print the type name for void.

llvm-svn: 45664
2008-01-06 22:21:46 +00:00
Gordon Henriksen
db911e9037 Modify Makefile.rules to allow makefiles to prepend to C.Flags and
fiends. Change Makefile.ocaml to not touch CFLAGS.

llvm-svn: 45663
2008-01-06 21:54:35 +00:00
Chris Lattner
2a1993fb2c improve description of alignment, patch by Alain Frisch.
llvm-svn: 45662
2008-01-06 21:04:43 +00:00
Chris Lattner
ec56402557 Fix typo noticed by 'Danny' in PR1901
llvm-svn: 45661
2008-01-06 19:51:52 +00:00
Chris Lattner
466e8ebcc7 back out accidental commit.
llvm-svn: 45660
2008-01-06 19:19:32 +00:00
Chris Lattner
460d863ba5 fix an accidental commit that broke all the testers :(
llvm-svn: 45659
2008-01-06 19:18:52 +00:00
Duncan Sands
404eb05247 The transform that tries to turn calls to bitcast functions into
direct calls bails out unless caller and callee have essentially
equivalent parameter attributes.  This is illogical - the callee's
attributes should be of no relevance here.  Rework the logic, which
incidentally fixes a crash when removed arguments have attributes.

llvm-svn: 45658
2008-01-06 18:27:01 +00:00
Duncan Sands
55e5090fe8 When transforming a call to a bitcast function into
a direct call with cast parameters and cast return
value (if any), instcombine was prepared to cast any
non-void return value into any other, whether castable
or not.  Add a new predicate for testing whether casting
is valid, and check it both for the return value and
(as a cleanup) for the parameters.

llvm-svn: 45657
2008-01-06 10:12:28 +00:00
Chris Lattner
10324d0175 rename isStore -> mayStore to more accurately reflect what it captures.
llvm-svn: 45656
2008-01-06 08:36:04 +00:00
Duncan Sands
1694a53c5d Remove an unused variable.
llvm-svn: 45655
2008-01-06 07:43:13 +00:00
Chris Lattner
a348f55ec6 Change the 'isStore' inferrer to look for 'SDNPMayStore'
instead of "ISD::STORE".  This allows us to mark target-specific dag
nodes as storing (such as ppc byteswap stores).  This allows us to remove
more explicit isStore flags from the .td files.

Finally, add a warning for when a .td file contains an explicit 
isStore and tblgen is able to infer it.

llvm-svn: 45654
2008-01-06 06:44:58 +00:00
Chris Lattner
f4d55ec4e8 remove explicit isStore flags that are now inferrable.
llvm-svn: 45653
2008-01-06 05:55:01 +00:00
Chris Lattner
e20f380fbf remove some isStore flags that are now inferred automatically.
llvm-svn: 45652
2008-01-06 05:53:26 +00:00
Chris Lattner
e9dba0920b describe isStore and simplify the implementation of hasUnmodelledSideEffects.
No functionality change. 

llvm-svn: 45651
2008-01-06 05:43:21 +00:00
Chris Lattner
89c6566577 set the 'isstore' flag for instructions whose pattern is an
intrinsic that writes to memory.

llvm-svn: 45650
2008-01-06 05:36:50 +00:00
Nick Lewycky
0e519bb555 Accept both %y, %x and %x, %y as valid answers.
llvm-svn: 45649
2008-01-06 03:12:44 +00:00
Chris Lattner
e457fd1e9b remove some old hacky code that tried to infer whether a store
occured in a pattern, but failed miserably.  The new code works for
any instruction that has a store in its pattern, including all the 
x86 mem op mem instructions.

The only target-independent code that uses this is branch folding,
so this won't change anything in practice.

llvm-svn: 45648
2008-01-06 02:16:26 +00:00
Chris Lattner
27a4c1515a rearrange some code to allow inferring instr info from the pattern of the instr, but don't do so yet.
llvm-svn: 45647
2008-01-06 01:53:37 +00:00
Chris Lattner
d5326def4a improve const correctness.
llvm-svn: 45646
2008-01-06 01:52:22 +00:00
Chris Lattner
ea2d52d867 Split the impl of CodeGenInstruction out to its own .cpp file, add a getName() accessor.
llvm-svn: 45645
2008-01-06 01:35:39 +00:00
Chris Lattner
85467a17ae final cleanups.
llvm-svn: 45644
2008-01-06 01:21:51 +00:00
Chris Lattner
626b89daa4 further simplifications and cleanup
llvm-svn: 45643
2008-01-06 01:20:13 +00:00
Chris Lattner
827efa451f simplify some code
llvm-svn: 45642
2008-01-06 01:12:44 +00:00
Chris Lattner
ab3242fd46 rename CodegenDAGPatterns -> CodeGenDAGPatterns
llvm-svn: 45641
2008-01-06 01:10:31 +00:00
Chris Lattner
e59a3c79e5 split enum emission out from InstrInfoEmitter into it's own tblgen backend.
llvm-svn: 45640
2008-01-06 00:49:05 +00:00
Chris Lattner
78ac0747e7 fix build on case sensitive file systems.
llvm-svn: 45639
2008-01-05 23:37:52 +00:00
Bill Wendling
5fa2c64b78 Fix comment.
llvm-svn: 45638
2008-01-05 23:30:51 +00:00
Chris Lattner
7eac714b41 make this build with newer gcc's
llvm-svn: 45637
2008-01-05 23:29:51 +00:00
Chris Lattner
7980bba549 now that computing CodegenDAGPatterns doesn't implicitly print stuff
out, DAGISelEmitter can compute it in its ctor, which simplifies some code.

Now we can use CodegenDAGPatterns in other parts of tblgen that want access
to dag pattern info, woo!

llvm-svn: 45636
2008-01-05 22:58:54 +00:00
Chris Lattner
cc43e79bcd move Node Transformation printing from CodeGenDAGPatterns -> DAGISelEmitter.
The only difference in output is that we now print them in alphabetical 
order instead of reverse alphabetical order.

llvm-svn: 45635
2008-01-05 22:54:53 +00:00
Chris Lattner
e7170df043 move predicate printing code from CodeGenDAGPatterns -> DAGISelEmitter.
llvm-svn: 45634
2008-01-05 22:43:57 +00:00
Chris Lattner
9abe77b2d0 fix a fixme by improving const correctness.
llvm-svn: 45633
2008-01-05 22:30:17 +00:00
Chris Lattner
8cab021ca2 change getQualifiedName to be a global function.
Split the pattern parsing code out from the dag isel emitter into it's own file.

No functionality change.

llvm-svn: 45632
2008-01-05 22:25:12 +00:00
Nate Begeman
22950d26f5 Remove an incorrect optimization that is performed correctly by
the target independent legalizer.

llvm-svn: 45631
2008-01-05 20:51:30 +00:00
Nate Begeman
5743da502e If custom lowering of insert element fails, the result Val will be 0.
Don't overwrite a variable used by the fallthrough code path in this
case.

llvm-svn: 45630
2008-01-05 20:47:37 +00:00
Chris Lattner
647e61a42b Fix build issue on certain compilers.
llvm-svn: 45629
2008-01-05 20:15:42 +00:00
Gordon Henriksen
9231958391 Refactoring the x86 and x86-64 calling convention implementations,
unifying the copied algorithms and saving over 500 LOC. There should
be no functionality change, but please test on your favorite x86
target.

llvm-svn: 45627
2008-01-05 16:56:59 +00:00
Bill Wendling
be984cf10b Chris and Evan noticed that this check was compleatly fubared. I was
checking that there was a from a global instead of a load from the stub
for a global, which is the one that's safe to hoist.

Consider this program:

volatile char G[100];
int B(char *F, int N) {
  for (; N > 0; --N)
    F[N] = G[N];
}

In static mode, we shouldn't be hoisting the load from G:

$ llc -relocation-model=static -o - a.bc -march=x86 -machine-licm

LBB1_1: # bb.preheader
        leal    -1(%eax), %edx
        testl   %edx, %edx
        movl    $1, %edx
        cmovns  %eax, %edx
        xorl    %esi, %esi
LBB1_2: # bb
        movb    _G(%eax), %bl
        movb    %bl, (%ecx,%eax)

llvm-svn: 45626
2008-01-05 09:18:04 +00:00
Chris Lattner
ee61d14bf6 The current impl is really trivial, add some comments about how it can be made better.
llvm-svn: 45625
2008-01-05 06:47:58 +00:00
Chris Lattner
276178e49f allow sinking to be enabled for the jit
llvm-svn: 45624
2008-01-05 06:14:16 +00:00
Chris Lattner
e0f0c4aa02 enable sinking and licm of loads from the argument area. I'd like to enable this
for remat, but can't due to an RA bug.

llvm-svn: 45623
2008-01-05 06:10:42 +00:00
Chris Lattner
d4738ee8e1 simplify some code by using shorter accessors.
llvm-svn: 45622
2008-01-05 05:28:30 +00:00
Chris Lattner
86f4a2e4f2 revert my previous patch.
llvm-svn: 45621
2008-01-05 05:26:26 +00:00
Chris Lattner
69d7902cf1 factor some code better to avoid redundancy between
isReallySideEffectFree and isReallyTriviallyReMaterializable.  Why is a load from
a global considered side-effect-free but not rematable?

llvm-svn: 45620
2008-01-05 05:19:56 +00:00
Chris Lattner
9fa8ae6c6b getting the pic base has no side effects.
llvm-svn: 45618
2008-01-05 03:54:32 +00:00
Chris Lattner
d11ca169e7 don't sink anything with side effects, this makes lots of stuff work, but sinks almost nothing.
llvm-svn: 45617
2008-01-05 02:33:22 +00:00
Evan Cheng
880b080887 X86 JIT PIC jumptable support.
llvm-svn: 45616
2008-01-05 02:26:58 +00:00
Fariborz Jahanian
7b1b947ca1 twiks based on Chris's comment. No need to iterate thru a list of declarations
in a foreach-statement which is illegal (but not yet caught) .

llvm-svn: 45615
2008-01-05 01:40:08 +00:00
Chris Lattner
6ec78274df fix a common crash.
llvm-svn: 45614
2008-01-05 01:39:17 +00:00
Chris Lattner
e666bc272d remove a couple more unsafe xforms in the face of overflow.
llvm-svn: 45613
2008-01-05 01:22:42 +00:00
Chris Lattner
db026d703b remove the (x-y) < 0 comparison xform, it miscompiles
things that are not equality comparisons, for example:
   (2147479553+4096)-2147479553 < 0    !=   (2147479553+4096) < 2147479553

llvm-svn: 45612
2008-01-05 01:18:20 +00:00
Ted Kremenek
e84b32e506 Moved serialization code for ObjcForCollectionStmt to be in alphabetical order
with the rest of the Objective-C serialization code.

llvm-svn: 45609
2008-01-05 00:57:49 +00:00
Owen Anderson
3592b2352d I should not be allowed to commit when sleepy.
llvm-svn: 45608
2008-01-05 00:48:55 +00:00
Owen Anderson
1984732f22 Didn't mean to commit this.
llvm-svn: 45607
2008-01-05 00:43:37 +00:00
Owen Anderson
cc35708bac Didn't mean to commit this.
llvm-svn: 45606
2008-01-05 00:42:45 +00:00
Evan Cheng
f55b7381af Combine MovePCtoStack + POP32r into one instruction MOVPC32r so it can be moved if needed.
llvm-svn: 45605
2008-01-05 00:41:47 +00:00
Fariborz Jahanian
bad3218954 Minor refactoring of foreach's semantics code per Chris's suggetion.
llvm-svn: 45604
2008-01-04 23:59:09 +00:00
Owen Anderson
6bb0c52628 Move some more functionality from MRegisterInfo to TargetInstrInfo.
llvm-svn: 45603
2008-01-04 23:57:37 +00:00
Chris Lattner
881a212a70 unnest vector handling again.
llvm-svn: 45602
2008-01-04 23:32:24 +00:00
Fariborz Jahanian
e908cab389 Added a comment, minor refactoring of foreach parsing code per Chris's suggestion.
llvm-svn: 45601
2008-01-04 23:23:46 +00:00
Chris Lattner
f735409e11 we already test for exact type matches early, so we don't have to do
it explicitly for vectors.  This allows us to unnest some code.

llvm-svn: 45600
2008-01-04 23:20:56 +00:00
Chris Lattner
a52c2f2e3e simplify some of this code by removing the else/if chain and by
stripping down to canonical types early.

llvm-svn: 45599
2008-01-04 23:18:45 +00:00
Fariborz Jahanian
3622e5954b Minor changes as suggested by Chris L.
llvm-svn: 45598
2008-01-04 23:04:08 +00:00
Chris Lattner
a3fc41d616 move objc expr sema to its own file.
llvm-svn: 45597
2008-01-04 22:32:30 +00:00
Bill Wendling
0c209430b4 Don't recalculate the loop info and loop dominators analyses if they're
preserved.

llvm-svn: 45596
2008-01-04 20:54:55 +00:00
Wojciech Matyjewicz
2bd541c5ff fix typo
llvm-svn: 45595
2008-01-04 20:04:08 +00:00
Wojciech Matyjewicz
30e434569e fix typo
llvm-svn: 45594
2008-01-04 20:02:18 +00:00
Chris Lattner
4899a6aa6a Fix PR1897, patch by Wilhansen Li
llvm-svn: 45593
2008-01-04 19:12:28 +00:00
Chris Lattner
940cfebf90 add comments for the various AssignConvertType's, and split int->pointer from pointer->int.
llvm-svn: 45591
2008-01-04 18:22:42 +00:00
Chris Lattner
9bad62c72a Merge all the 'assignment' diagnostic code into one routine, decloning
it from several places.  This merges the diagnostics, making them more
uniform and fewer in number. This also simplifies and cleans up the code.

Some highlights:
1. This removes a bunch of very-similar diagnostics.
2. This renames AssignmentCheckResult -> AssignConvertType
3. This merges PointerFromInt + IntFromPointer which were always treated the same.
4. This updates a bunch of test cases that have minor changes to the produced diagnostics.

llvm-svn: 45589
2008-01-04 18:04:52 +00:00
Duncan Sands
d98c63ebb9 Testcase with non-integer "bitfields" (in quotes,
since they didn't actually need to be bitfields,
though they are marked as such).

llvm-svn: 45588
2008-01-04 17:31:56 +00:00
Chris Lattner
94cf8061e7 fix a build problem where NULL isn't implicitly defined by the headers this file includes.
llvm-svn: 45587
2008-01-04 16:27:03 +00:00
Gordon Henriksen
d829d2efeb Fix a typo in llvm.mli noticed by Alain Frisch.
llvm-svn: 45585
2008-01-04 13:21:02 +00:00
Duncan Sands
99fc7197f2 Testcase for PR1386.
llvm-svn: 45583
2008-01-04 13:15:39 +00:00
Bill Wendling
46813c58bb doc_code-ify some code in this doc.
llvm-svn: 45581
2008-01-04 12:04:32 +00:00
Gordon Henriksen
73d8967f02 Quote a path in the Ocaml makefile which is likely to include spaces on Windows.
llvm-svn: 45580
2008-01-04 11:55:57 +00:00
Evan Cheng
c1d1e54fc4 Unbreak tailcall opt in JIT.
llvm-svn: 45576
2008-01-04 10:50:28 +00:00
Evan Cheng
49ff8ecd03 X86 PIC JIT support fixes: encoding bugs, add lazy pointer stubs support.
llvm-svn: 45575
2008-01-04 10:46:51 +00:00
Bill Wendling
118ae4cd61 80-column violations.
llvm-svn: 45574
2008-01-04 08:59:18 +00:00
Bill Wendling
3bf5603ce4 Add that this preserves some analyses.
llvm-svn: 45573
2008-01-04 08:48:49 +00:00
Bill Wendling
66470d02c3 Move option to enable machine LICM into LLVMTargetMachine.cpp.
llvm-svn: 45572
2008-01-04 08:11:03 +00:00
Bill Wendling
d865697016 Call the parent's getAnalysisUsage.
llvm-svn: 45571
2008-01-04 07:50:05 +00:00
Chris Lattner
f3edc09f9b Add a really quick hack at a machine code sinking pass, enabled with --enable-sinking.
It is missing validity checks, so it is known broken.  However, it is powerful enough
to compile this contrived code:

void test1(int C, double A, double B, double *P) {
  double Tmp = A*A+B*B;
  *P = C ? Tmp : A;
}

into:

_test1:
	movsd	8(%esp), %xmm0
	cmpl	$0, 4(%esp)
	je	LBB1_2	# entry
LBB1_1:	# entry
	movsd	16(%esp), %xmm1
	mulsd	%xmm1, %xmm1
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
LBB1_2:	# entry
	movl	24(%esp), %eax
	movsd	%xmm0, (%eax)
	ret

instead of:

_test1:
	movsd	16(%esp), %xmm0
	mulsd	%xmm0, %xmm0
	movsd	8(%esp), %xmm1
	movapd	%xmm1, %xmm2
	mulsd	%xmm2, %xmm2
	addsd	%xmm0, %xmm2
	cmpl	$0, 4(%esp)
	je	LBB1_2	# entry
LBB1_1:	# entry
	movapd	%xmm2, %xmm1
LBB1_2:	# entry
	movl	24(%esp), %eax
	movsd	%xmm1, (%eax)
	ret

woo.

llvm-svn: 45570
2008-01-04 07:36:53 +00:00
Chris Lattner
b5c1d9b7da remove dead #includes and reorder the rest.
llvm-svn: 45569
2008-01-04 06:41:45 +00:00
Chris Lattner
bdd6acfb59 Fix PR1896
llvm-svn: 45568
2008-01-04 05:04:53 +00:00
Chris Lattner
69ea01446e Change the builtin matcher to emit a decision tree, which should help out
the VC++ 'nesting depth' issue.

llvm-svn: 45567
2008-01-04 04:38:35 +00:00
Chris Lattner
43542b3a93 fix nesting issues.
llvm-svn: 45566
2008-01-04 04:34:14 +00:00
Chris Lattner
b8f816e90d fix validation issues.
llvm-svn: 45565
2008-01-04 04:33:49 +00:00
Chris Lattner
7824d182da improve the description of types, patch by Alain Frisch
llvm-svn: 45564
2008-01-04 04:32:38 +00:00
Chris Lattner
a47634ecb1 Don't let IntrinsicID be uninitialized if it doesn't match.
llvm-svn: 45563
2008-01-04 03:32:52 +00:00
Evan Cheng
2e1ba07f16 Correct order of parameters.
llvm-svn: 45562
2008-01-04 02:22:21 +00:00
Fariborz Jahanian
775d5d02af Patch to add semantics check for ObjC2's foreacn statement.
llvm-svn: 45561
2008-01-04 00:27:46 +00:00
Chris Lattner
816dea2fc5 generalize some of the conversion warnings.
llvm-svn: 45560
2008-01-03 23:38:43 +00:00
Chris Lattner
166ae81be1 update for changes in diagnostic strings.
llvm-svn: 45559
2008-01-03 23:36:08 +00:00
Chris Lattner
874e024f10 regroup assignment-related diagnostics, fix a mistake in one.
llvm-svn: 45558
2008-01-03 23:13:36 +00:00
Bill Wendling
ddc77f8e4c Remove the default else. This was ending in code that looked like this:
if (!strcmp(Target, "x86")) {
  // ...
}
else
  IntrinsicID = Intrinsic::not_intrinsic;

llvm-svn: 45557
2008-01-03 23:02:16 +00:00
Chris Lattner
0a788433eb give better diagnostics for converting between function pointer and void*.
llvm-svn: 45556
2008-01-03 22:56:36 +00:00
Ted Kremenek
739d350369 renamed class "GRCP" (Graph Reachabilty Constant Propagation) to
"GREngine" (Graph Reachability Engine).  The idea is to provide a separation
of concerns between the constant prop. details and the core analysis engine.

llvm-svn: 45555
2008-01-03 22:46:25 +00:00
Ted Kremenek
7c54e520e7 Implemented End-Of-Path processing.
llvm-svn: 45554
2008-01-03 22:29:38 +00:00
Chris Lattner
84cea329d5 Remove symbols that don't exist, remove tabs, fix comment typo
llvm-svn: 45553
2008-01-03 22:15:32 +00:00
Ted Kremenek
0044908de0 Initial checking of GRConstantPropagation.cpp, which implements a constant
propagation analysis via graph reachability. This analysis (which is incomplete)
will be the basis for later developments on the core engine for path-sensitive
analysis analysis.

llvm-svn: 45552
2008-01-03 22:12:28 +00:00
Ted Kremenek
fde239df06 Fixed misuse of pointer within SimulVertex::addPredecessor()
llvm-svn: 45551
2008-01-03 22:09:27 +00:00
Ted Kremenek
9d375282cf SimulGraph::getVertex() now also returns a bool indicating if the returned
vertex was freshly created.

llvm-svn: 45550
2008-01-03 22:08:52 +00:00
Ted Kremenek
6abe02ada6 Constified methods front() and back() in CFGBlock.
llvm-svn: 45549
2008-01-03 22:07:58 +00:00
Ted Kremenek
d6c30e58e2 De-constified the pointers returned by the Dst() and Src() methods of
the various ProgramEdge classes.

llvm-svn: 45548
2008-01-03 22:07:01 +00:00
Fariborz Jahanian
c89ea091a2 Couple more uninitialized before use warning elimination.
llvm-svn: 45547
2008-01-03 20:04:58 +00:00
Fariborz Jahanian
243c611a05 Remove cause of misc. "variable might be used uninitialized in this function" warnings.
llvm-svn: 45546
2008-01-03 20:01:35 +00:00
Chuck Rose III
7f2e31a36a Adding new files to win32 build
llvm-svn: 45545
2008-01-03 19:53:03 +00:00
Fariborz Jahanian
5cc21a7e02 Fixed a bug reported by Chris, involving assiging 0 to a qualified object type.
llvm-svn: 45542
2008-01-03 18:46:52 +00:00
Chris Lattner
2b15cf705b simplify the lexer a bit, pulling stuff out of the default case.
llvm-svn: 45540
2008-01-03 17:58:54 +00:00
Fariborz Jahanian
732b8c2dc5 Patch to parse/build AST ObjC2's foreach statement.
llvm-svn: 45539
2008-01-03 17:55:25 +00:00
Gordon Henriksen
9b92e93d36 Ignoring output files.
llvm-svn: 45538
2008-01-03 17:42:08 +00:00
Chris Lattner
67793d8d60 add info on walking preds/succs of a block.
llvm-svn: 45537
2008-01-03 16:56:04 +00:00
Gordon Henriksen
f066fc477c First steps in in X86 calling convention cleanup.
llvm-svn: 45536
2008-01-03 16:47:34 +00:00
Duncan Sands
338b462b6f Test for handling of large bit offset from a
variable field offset.

llvm-svn: 45534
2008-01-03 11:53:52 +00:00
Chris Lattner
f391883670 don't hoist FP additions into unconditional adds + selects. This
could theoretically introduce a trap, but is also a performance issue.
This speeds up ptrdist/ks by 8%.

llvm-svn: 45533
2008-01-03 07:25:26 +00:00
Chris Lattner
705dc51f2c Fix PR1873, a problem finding stat-related symbols on linux, due to
"libc_nonshared.a". Patch by Edwin Török!

llvm-svn: 45532
2008-01-03 07:10:51 +00:00
Chris Lattner
1800c18ebd fix long lines.
llvm-svn: 45531
2008-01-03 07:05:49 +00:00
Chris Lattner
20455f204f Fix a crash reported by Seo Sanghyeon.
llvm-svn: 45530
2008-01-03 06:36:51 +00:00
Gordon Henriksen
7c87884ec3 Trying that again.
llvm-svn: 45529
2008-01-03 03:32:33 +00:00
Gordon Henriksen
8624d7b72e Fix a compile error on Windows.
llvm-svn: 45528
2008-01-03 03:21:18 +00:00
Evan Cheng
563fcc3428 Change MachineRelocation::DoesntNeedFnStub to NeedStub. This fields will be used
for non-function GV relocations that require function address stubs (e.g. Mac OS X in non-static mode).

llvm-svn: 45527
2008-01-03 02:56:28 +00:00
Chris Lattner
e35604ddb2 don't access element zero of an array of size zero.
llvm-svn: 45526
2008-01-03 01:25:31 +00:00
Chris Lattner
76719ba5f1 Remove the function attr cache for intrinsics. This does not maintain the
refcount on these correctly, and can end up referring to deleted 
attributes.  This fixes PR1881.

llvm-svn: 45525
2008-01-03 01:20:12 +00:00
Chris Lattner
b18b0b99c6 Don't create a new ParamAttrsList (which copies the vector) just to
get a profile.

llvm-svn: 45524
2008-01-03 00:29:27 +00:00
Duncan Sands
a7f7ac7072 An example for which the TYPE_SIZE was being set from
the initial value, while the type fields were not (this
is a qualified union type, so not all fields are always
present).  This resulted in the size of the corresponding
LLVM type being larger than the gcc TYPE_SIZE.

llvm-svn: 45522
2008-01-03 00:26:42 +00:00
Duncan Sands
1d03fb4e7e Test handling of records for which the fields are
not ordered by offset.

llvm-svn: 45520
2008-01-03 00:17:02 +00:00
Chris Lattner
d0e1f10078 move some code out of line, rearrange a bit.
llvm-svn: 45519
2008-01-03 00:10:22 +00:00
Chris Lattner
d135068e53 Disallow copying explicitly.
llvm-svn: 45518
2008-01-03 00:09:47 +00:00
Chris Lattner
3e13b8c173 Split param attr implementation out from Function.cpp into its
own file.  Don't #include ParameterAttributes.h into any major
public header files: just move methods out of line as appropriate.

llvm-svn: 45517
2008-01-02 23:42:30 +00:00
Chris Lattner
d2b0e15535 add missing #include
llvm-svn: 45516
2008-01-02 23:41:05 +00:00
Evan Cheng
96334b4e3b X86 PIC JIT bug fix: relocations for constantpool and jumptable.
llvm-svn: 45515
2008-01-02 23:38:59 +00:00
Chris Lattner
04cd35f88b remove blob of #if'd out code.
llvm-svn: 45512
2008-01-02 23:10:45 +00:00
Fariborz Jahanian
8361552af9 New declarations/defs for Objc2's foreach-statement. This is work in progress.
llvm-svn: 45511
2008-01-02 22:54:34 +00:00
Chris Lattner
4f20351142 When promoting array to pointer for argument, don't lose type qualifiers.
llvm-svn: 45510
2008-01-02 22:50:48 +00:00
Chris Lattner
41e423a6f5 fix this to use a valid triple.
llvm-svn: 45509
2008-01-02 22:21:45 +00:00
Ted Kremenek
161807f8d1 SimulVertex: Inverted argument order when calling the Profile method of StateTy.
SimulGraph: Inverted argument order when calling the Profile method of VertexTy
  (plus minor cleanups)
llvm-svn: 45508
2008-01-02 22:20:20 +00:00
Ted Kremenek
a26f5d188f Inverted argument order for ImmutableMap::Profile.
llvm-svn: 45507
2008-01-02 22:18:33 +00:00
Chris Lattner
0acc15c470 Fix a build issue on cygwin
llvm-svn: 45506
2008-01-02 22:03:27 +00:00
Chris Lattner
7977cca8e8 Fix PR1895: a crash on an ugly gcc extension.
llvm-svn: 45505
2008-01-02 21:54:09 +00:00
Chris Lattner
266a2ff3ac Compute the proper sourcerange for an CompoundLiteralExpr.
llvm-svn: 45504
2008-01-02 21:46:24 +00:00
Ted Kremenek
d7c6b0e664 Added iterator and profiling (i.e. FoldingSetNodeID) support to ImmutableMap.
llvm-svn: 45503
2008-01-02 21:31:48 +00:00
Ted Kremenek
c7523bcaaa Converted state reference within SimulVertex from StateTy* to StateTy.
This is more flexible.

llvm-svn: 45502
2008-01-02 21:31:13 +00:00
Chris Lattner
9a6774064b Fix PR1888, patch by Wilhansen Li.
llvm-svn: 45501
2008-01-02 21:30:58 +00:00
Chris Lattner
91678fc457 Fix a build problem with VC++ by not doing the target prefix
comparison for every builtin.  This reduces the depth of
the if/elseif chain dramatically.

llvm-svn: 45500
2008-01-02 21:24:22 +00:00
Bill Wendling
0ba4184404 Use the correct MachineRegisterInfo object.
llvm-svn: 45499
2008-01-02 21:10:54 +00:00
Bill Wendling
e1f28e7871 Machine LICM will check that operands are defined outside of the loop. Also
check that register isn't 0 before going further.

llvm-svn: 45498
2008-01-02 21:10:40 +00:00
Chris Lattner
54bb810997 Refactor the decl printer, patch by Mike Stump!
llvm-svn: 45497
2008-01-02 21:04:16 +00:00
Bill Wendling
f0b37780ca Remove dead code.
llvm-svn: 45496
2008-01-02 20:47:37 +00:00
Chris Lattner
5d998c5712 verify that aligned common support doesn't break.
llvm-svn: 45495
2008-01-02 19:48:24 +00:00
Chris Lattner
cce79c67ca darwin9 and above support aligned common symbols.
llvm-svn: 45494
2008-01-02 19:44:55 +00:00
Chris Lattner
dcbc0f3029 leopard and above support alignment for common symbols.
llvm-svn: 45493
2008-01-02 19:35:16 +00:00
Bill Wendling
5da1945cdd Use the new architecture to get the containing machine basic block for a machine
instruction. Also, use "splice" to move the new instruction instead of
remove/insert (where it was leaking memory anyway).

llvm-svn: 45492
2008-01-02 19:32:43 +00:00
Fariborz Jahanian
056e3a4e90 Issue diagnostic when objective-c's @interface is preceeded by a type specifier.
llvm-svn: 45491
2008-01-02 19:17:38 +00:00
Ted Kremenek
796b64337b Added/fixed some comments.
llvm-svn: 45490
2008-01-02 18:31:49 +00:00
Fariborz Jahanian
5e57e1890d Prevent crash on incorrect objc messaging expression.
llvm-svn: 45489
2008-01-02 18:09:46 +00:00
Ted Kremenek
dc8ebe5022 Sprinkled 'typename' and fixed a few typos and type declaration errors to
make these headers compile.

llvm-svn: 45488
2008-01-02 17:45:00 +00:00
Ted Kremenek
2290828271 Added fixme.
llvm-svn: 45487
2008-01-02 17:05:47 +00:00
Ted Kremenek
032cb4433e Allocate vertices using a BumpPtrAllocator.
llvm-svn: 45486
2008-01-02 17:00:32 +00:00
Nick Lewycky
d1200b00dc Don't be rude, emit debugging info where asked to.
llvm-svn: 45485
2008-01-02 02:49:20 +00:00
Owen Anderson
eee14601b1 Move some more instruction creation methods from RegisterInfo into InstrInfo.
llvm-svn: 45484
2008-01-01 21:11:32 +00:00
Chris Lattner
caaf8aae4d Make MachineRegisterInfo::getVRegDef more efficient by aiming the keep the def of the vreg at the start of the list, so the list doesn't need to be traversed.
llvm-svn: 45483
2008-01-01 21:08:22 +00:00
Chris Lattner
0cb9dd7aa2 switch the register iterator to act more like hte LLVM value iterator: dereferencing
it now returns the machineinstr of the use.  To get the operand, use I.getOperand().

Add a new MachineRegisterInfo::replaceRegWith, which is basically like
Value::replaceAllUsesWith.

llvm-svn: 45482
2008-01-01 20:36:19 +00:00
Gordon Henriksen
097102c32a Adding C bindings for SwitchInst::addCase.
Patch by Bryan O'Sullivan!

llvm-svn: 45481
2008-01-01 05:50:53 +00:00
Chris Lattner
39204d76c5 Add a trivial but handy function to efficiently return the machine
instruction that defines the specified vreg.  Crazy.

llvm-svn: 45480
2008-01-01 03:07:29 +00:00
Chris Lattner
8a497053a7 add efficient iteration support for register use/def's
within a machine function.

llvm-svn: 45479
2008-01-01 02:55:32 +00:00
Bill Wendling
6f8c9a8372 Update this testcase. The output needs to be disabled to pass.
llvm-svn: 45478
2008-01-01 01:34:36 +00:00
Chris Lattner
961e7427ea Implement automatically updated def/use lists for all MachineInstr register
operands.  The lists are currently kept in MachineRegisterInfo, but it does
not yet provide an iterator interface to them.

llvm-svn: 45477
2008-01-01 01:12:31 +00:00
Chris Lattner
b0fb17fd34 Fix a bug in my previous patch: refer to the impl not the pure virtual version. It's unclear why gcc would ever compile this...
llvm-svn: 45476
2008-01-01 01:05:34 +00:00
Chris Lattner
25568e4cef Fix a problem where lib/Target/TargetInstrInfo.h would include and use
a header file from libcodegen.  This violates a layering order: codegen
depends on target, not the other way around.  The fix to this is to 
split TII into two classes, TII and TargetInstrInfoImpl, which defines
stuff that depends on libcodegen.  It is defined in libcodegen, where 
the base is not.

llvm-svn: 45475
2008-01-01 01:03:04 +00:00
Chris Lattner
c23e6351de Factor out makefile dependency generation better.
Don't include system headers in the .d files.
Don't use $@ in the makefile rules, as there are two possible targets it could resolve to: use the one that we need explicitly.

llvm-svn: 45473
2007-12-31 23:58:31 +00:00
Duncan Sands
57a60f0466 Fix PR1833 - eh.exception and eh.selector return two
values, which means doing extra legalization work.
It would be easier to get this kind of thing right if
there was some documentation...

llvm-svn: 45472
2007-12-31 18:35:50 +00:00
Owen Anderson
7a73ae9a86 Move copyRegToReg from MRegisterInfo to TargetInstrInfo. This is part of the
Machine-level API cleanup instigated by Chris.

llvm-svn: 45470
2007-12-31 06:32:00 +00:00
Chris Lattner
574e7166e0 properly encapsulate the parent field of MBB and MI with get/set accessors.
llvm-svn: 45469
2007-12-31 04:56:33 +00:00
Chris Lattner
21ec2b4769 update a couple of references to SSARegMap.
llvm-svn: 45468
2007-12-31 04:16:08 +00:00
Chris Lattner
a10fff51d9 Rename SSARegMap -> MachineRegisterInfo in keeping with the idea
that "machine" classes are used to represent the current state of
the code being compiled.  Given this expanded name, we can start 
moving other stuff into it.  For now, move the UsedPhysRegs and
LiveIn/LoveOuts vectors from MachineFunction into it.

Update all the clients to match.

This also reduces some needless #includes, such as MachineModuleInfo
from MachineFunction.

llvm-svn: 45467
2007-12-31 04:13:23 +00:00
Gordon Henriksen
1f35454e99 Removing obsolete files from the Xcode project.
llvm-svn: 45466
2007-12-31 01:45:55 +00:00
Chris Lattner
5a1d88e91b slightly simplify and document SSARegMap.
llvm-svn: 45465
2007-12-30 23:40:31 +00:00
Chris Lattner
a5bb370aa4 Add new shorter predicates for testing machine operands for various types:
e.g. MO.isMBB() instead of MO.isMachineBasicBlock().  I don't plan on 
switching everything over, so new clients should just start using the 
shorter names.

Remove old long accessors, switching everything over to use the short
accessor: getMachineBasicBlock() -> getMBB(), 
getConstantPoolIndex() -> getIndex(), setMachineBasicBlock -> setMBB(), etc.

llvm-svn: 45464
2007-12-30 23:10:15 +00:00
Gordon Henriksen
1862b6daa0 Another backwards compatibility fix.
llvm-svn: 45463
2007-12-30 22:48:58 +00:00
Chris Lattner
db64f04ac6 - rename opType -> OpKind and contents -> Contents.
- eliminate the auxInfo union, merging it into the contents union.  This shaves 
  4 bytes off MachineOperand on a 32-bit machine.

- Use accessors in ctor methods.

- Add comments.

llvm-svn: 45462
2007-12-30 22:24:06 +00:00
Chris Lattner
6005589faf More cleanups for MachineOperand:
- Eliminate the static "print" method for operands, moving it
    into MachineOperand::print.
  - Change various set* methods for register flags to take a bool
    for the value to set it to.  Remove unset* methods.
  - Group methods more logically by operand flavor in MachineOperand.h

llvm-svn: 45461
2007-12-30 21:56:09 +00:00
Chris Lattner
c98c0e57eb MachineOperand:
- Add getParent() accessors.
  - Move SubReg out of the AuxInfo union, to make way for future changes.
  - Remove the getImmedValue/setImmedValue methods.
  - in some MachineOperand::Create* methods, stop initializing fields that are dead.

MachineInstr:
  - Delete one copy of the MachineInstr printing code, now there is only one dump
    format and one copy of the code.
  - Make MachineOperand use the parent field to get info about preg register names if
    no target info is otherwise available.
  - Move def/use/kill/dead flag printing to the machineoperand printer, so they are
    always printed for an operand.

llvm-svn: 45460
2007-12-30 21:31:53 +00:00
Chris Lattner
96317d2412 fix typo duncan noticed!
llvm-svn: 45459
2007-12-30 21:21:10 +00:00
Chris Lattner
35fececec9 simpilfy some register printing code.
llvm-svn: 45458
2007-12-30 21:08:36 +00:00
Chris Lattner
383a873a9a eliminate a copy of the machineoperand printing stuff. Keep the copy that
knows how to print offsets.

llvm-svn: 45457
2007-12-30 21:03:30 +00:00
Chris Lattner
49bd29daa0 Simplify and clean up some machine operand/instr printing/dumping stuff.
llvm-svn: 45456
2007-12-30 21:01:27 +00:00
Chris Lattner
0dad74d252 two register machineoperands are not identical unless their subregs match.
llvm-svn: 45455
2007-12-30 20:55:08 +00:00
Chris Lattner
81798417dc MachineOperand::getImmedValue -> MachineOperand::getImm
llvm-svn: 45454
2007-12-30 20:50:28 +00:00
Chris Lattner
5c4637816e Use MachineOperand::getImm instead of MachineOperand::getImmedValue. Likewise setImmedValue -> setImm
llvm-svn: 45453
2007-12-30 20:49:49 +00:00
Gordon Henriksen
86427bb2a9 Trying r45451 again, but this time warning-free on 3.10.x.
llvm-svn: 45452
2007-12-30 18:12:41 +00:00
Gordon Henriksen
8100a225c0 Remove some lines that are nonportable to Ocaml 3.06.
llvm-svn: 45451
2007-12-30 17:48:11 +00:00
Gordon Henriksen
4a4d73519e Add some doxygen comments to llvm-c/Core.h.
llvm-svn: 45450
2007-12-30 17:46:33 +00:00
Chris Lattner
3c6ce5b43c make machine operands fatter: give each one an up-pointer to the
machineinstr that owns it.

llvm-svn: 45449
2007-12-30 06:11:04 +00:00
Gordon Henriksen
12c53c8c84 Strengthening this test so it fails in release mode.
llvm-svn: 45446
2007-12-30 05:45:49 +00:00
Chris Lattner
ad0c83d65e split machineoperand out into its own header file.
llvm-svn: 45445
2007-12-30 04:40:25 +00:00
Bill Wendling
7749a9014b If we have a load of a global address that's not modified during the
function, then go ahead and hoist it out of the loop. This is the result:

$ cat a.c
volatile int G;

int A(int N) {
  for (; N > 0; --N)
    G++;
}
$ llc -o - -relocation-model=pic
_A:
...
LBB1_2: # bb
        movl    L_G$non_lazy_ptr-"L1$pb"(%eax), %esi
        incl    (%esi)
        incl    %edx
        cmpl    %ecx, %edx
        jne     LBB1_2  # bb
...
$ llc -o - -relocation-model=pic -machine-licm
_A:
...
        movl    L_G$non_lazy_ptr-"L1$pb"(%eax), %eax
LBB1_2: # bb
        incl    (%eax)
        incl    %edx
        cmpl    %ecx, %edx
        jne     LBB1_2  # bb
...

I'm limiting this to the MOV32rm x86 instruction for now.

llvm-svn: 45444
2007-12-30 03:18:58 +00:00
Nate Begeman
330aaa79e0 Allow implicit casts during arithmetic for OCUVector operations
Add codegen support and test for said casts.

llvm-svn: 45443
2007-12-30 02:59:45 +00:00
Nate Begeman
627daba0fd Allow splat casts for OCU vector assignments & add some comments.
llvm-svn: 45442
2007-12-30 01:45:55 +00:00
Nate Begeman
16a3a9d5f9 Rename stats to print-stats to avoid conflicting with llvm's
stats statistic when clang is built as a dylib.

llvm-svn: 45441
2007-12-30 01:38:50 +00:00
Nate Begeman
628028bd27 Allow codegen of vector fdiv
llvm-svn: 45440
2007-12-30 01:28:16 +00:00
Chris Lattner
add4b3f9ab remove unneeded #includes.
llvm-svn: 45439
2007-12-30 01:11:43 +00:00
Chris Lattner
79f6f6c87a remove a bunch of now-dead methods.
llvm-svn: 45438
2007-12-30 01:04:05 +00:00
Chris Lattner
b3fd2d7b63 use simplified operand addition methods.
llvm-svn: 45437
2007-12-30 01:01:54 +00:00
Chris Lattner
20421fe936 use simplified operand addition methods.
llvm-svn: 45436
2007-12-30 00:57:42 +00:00
Chris Lattner
bbbae8e1ce use simplified operand addition methods.
llvm-svn: 45435
2007-12-30 00:51:11 +00:00
Chris Lattner
b65293a075 make offset operand optional.
llvm-svn: 45434
2007-12-30 00:50:55 +00:00
Chris Lattner
4b762496a9 Shrinkify the machine operand creation method names.
llvm-svn: 45433
2007-12-30 00:45:46 +00:00
Chris Lattner
e35dfb827f Start using the simplified methods for adding operands.
llvm-svn: 45432
2007-12-30 00:41:17 +00:00
Chris Lattner
c002be7fdd switch MIBuilder over to use the simplified operand addition methods.
llvm-svn: 45431
2007-12-30 00:35:18 +00:00
Chris Lattner
d948c2d244 1. Make a static MachineOperand::create* method for every
operand type.
2. Move these create methods below the accessors.
3. Simplify all the MachineInstr::add* methods to use these.

llvm-svn: 45430
2007-12-30 00:29:19 +00:00
Chris Lattner
dc3c9050f8 tblgen shouldn't include headers from llvm codegen.
llvm-svn: 45429
2007-12-30 00:25:23 +00:00
Chris Lattner
c288ff1d78 simplify some code by factoring operand construction better.
llvm-svn: 45428
2007-12-30 00:12:25 +00:00
Chris Lattner
a77acbdcae implement codegen support for most unary operators when
initializing a global.  This handles important cases like:
float foo3 = -0.01f;

llvm-svn: 45427
2007-12-29 23:43:37 +00:00
Chris Lattner
6787a45a65 remove attribution from a variety of miscellaneous files.
llvm-svn: 45425
2007-12-29 22:59:10 +00:00
Chris Lattner
f87b59d683 regenerate
llvm-svn: 45424
2007-12-29 20:47:37 +00:00
Chris Lattner
cb1e357a1c remove attributions
llvm-svn: 45423
2007-12-29 20:46:15 +00:00
Gordon Henriksen
1158c533f7 Bindings for instruction calling conventions.
llvm-svn: 45422
2007-12-29 20:45:00 +00:00
Chris Lattner
345353d6b4 remove attributions from tools.
llvm-svn: 45421
2007-12-29 20:44:31 +00:00
Chris Lattner
bcf65db6f3 remove attributions from examples.
llvm-svn: 45420
2007-12-29 20:37:57 +00:00
Chris Lattner
8adcd9f32e remove attributions from utils.
llvm-svn: 45419
2007-12-29 20:37:13 +00:00
Chris Lattner
f3ebc3f3d2 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Chris Lattner
11cc8b3c14 remove attributions from the rest of the llvm makefiles.
llvm-svn: 45416
2007-12-29 20:11:13 +00:00
Chris Lattner
a087a8d2ce remove attribution from lib Makefiles.
llvm-svn: 45415
2007-12-29 20:09:26 +00:00
Chris Lattner
8fa21acd25 remove attributions from tools/utils makefiles.
llvm-svn: 45414
2007-12-29 20:07:17 +00:00
Chris Lattner
7429581c33 remove attributions from .def files.
llvm-svn: 45413
2007-12-29 20:03:32 +00:00
Chris Lattner
5926c0ebfb remove attribution from makefiles.
llvm-svn: 45412
2007-12-29 20:02:25 +00:00
Chris Lattner
e9cc742a17 Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.  Boy are my fingers tired. ;-)

llvm-svn: 45411
2007-12-29 19:59:42 +00:00
Chris Lattner
5b12ab8c93 Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.

llvm-svn: 45410
2007-12-29 19:59:25 +00:00
Chris Lattner
ebf5666abf Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.

llvm-svn: 45409
2007-12-29 19:56:08 +00:00
Chris Lattner
4e6cbb2fe2 this is done.
llvm-svn: 45408
2007-12-29 19:38:02 +00:00
Chris Lattner
d2b8a36f0e One readme entry is done, one is really easy (Evan, want to investigate
eliminating the llvm.x86.sse2.loadl.pd intrinsic?), one shuffle optzn
may be done (if shufps is better than pinsw, Evan, please review), and
we already know about LICM of simple instructions.

llvm-svn: 45407
2007-12-29 19:31:47 +00:00
Chris Lattner
0d90c8f016 upgrade this test
llvm-svn: 45406
2007-12-29 19:24:06 +00:00
Chris Lattner
3b6a82118b Fold comparisons against a constant nan, and optimize ORD/UNORD
comparisons with a constant.  This allows us to compile isnan to:

_foo:
	fcmpu cr7, f1, f1
	mfcr r2
	rlwinm r3, r2, 0, 31, 31
	blr 

instead of:

LCPI1_0:					;  float
	.space	4
_foo:
	lis r2, ha16(LCPI1_0)
	lfs f0, lo16(LCPI1_0)(r2)
	fcmpu cr7, f1, f0
	mfcr r2
	rlwinm r3, r2, 0, 31, 31
	blr 

llvm-svn: 45405
2007-12-29 08:37:08 +00:00
Chris Lattner
33de0c6e92 this xform is implemented.
llvm-svn: 45404
2007-12-29 08:19:39 +00:00
Christopher Lamb
b053b80b79 Disable null pointer folding transforms for non-generic address spaces. This should probably be a target-specific predicate based on address space. That way for targets where this isn't applicable the predicate can be optimized away.
llvm-svn: 45403
2007-12-29 07:56:53 +00:00
Chris Lattner
2de9b85297 make sure not to zap volatile stores, thanks a lot to Dale for noticing this!
llvm-svn: 45402
2007-12-29 07:15:45 +00:00
Chris Lattner
07ccbfa64a Codegen:
as:

_bar:
	pushl	%esi
	subl	$8, %esp
	movl	16(%esp), %esi
	call	L_foo$stub
	fstps	(%esi)
	addl	$8, %esp
	popl	%esi
	#FP_REG_KILL
	ret

instead of:

_bar:
	pushl	%esi
	subl	$8, %esp
	movl	16(%esp), %esi
	call	L_foo$stub
	fstpl	(%esi)
	cvtsd2ss	(%esi), %xmm0
	movss	%xmm0, (%esi)
	addl	$8, %esp
	popl	%esi
	#FP_REG_KILL
	ret

llvm-svn: 45401
2007-12-29 06:57:38 +00:00
Chris Lattner
5919b48fe9 don't fold fp_round(fp_extend(load)) -> fp_round(extload)
llvm-svn: 45400
2007-12-29 06:55:23 +00:00
Chris Lattner
8013bd339b avoid going through a stack slot to convert from fpstack to xmm reg
if we are just going to store it back anyway.  This improves things 
like:
double foo();
void bar(double *P) { *P = foo(); }

llvm-svn: 45399
2007-12-29 06:41:28 +00:00
Chris Lattner
3f9c6a7260 Delete a store whose input is a load from the same pointer:
x = load p
  store x -> p

llvm-svn: 45398
2007-12-29 06:26:16 +00:00
Chris Lattner
62ba67c0f7 add a note
llvm-svn: 45397
2007-12-29 05:51:58 +00:00
Christopher Lamb
c5fafa211a Fix OCUVector case in struct layout code.
llvm-svn: 45396
2007-12-29 05:10:55 +00:00
Christopher Lamb
d91c3d4926 Enable CodeGen for member expressions based on call expressions returning aggregate types. This enables expressions like 'foo().member.submember'.
llvm-svn: 45395
2007-12-29 05:02:41 +00:00
Christopher Lamb
fd9af54ad1 Make MemberExpr code safe w.r.t. address spaces.
llvm-svn: 45394
2007-12-29 04:06:57 +00:00
Chris Lattner
7cafd92aa9 expand note.
llvm-svn: 45393
2007-12-29 01:05:01 +00:00
Chris Lattner
e96658392d dead calls to llvm.stacksave can be deleted, even though they
have potential side-effects.

llvm-svn: 45392
2007-12-29 00:59:12 +00:00
Chris Lattner
bc03f70a07 upgrade this test
llvm-svn: 45391
2007-12-29 00:57:06 +00:00
Christopher Lamb
ad66035921 Fix an error in the base/idx accessors for ArraySubscriptExpr's that crops up with vector element access.
llvm-svn: 45390
2007-12-28 23:43:03 +00:00
Devang Patel
b57ff068cd Test -simplifycfg only.
llvm-svn: 45389
2007-12-28 22:59:48 +00:00
Chris Lattner
9d53b611d1 add a note.
llvm-svn: 45388
2007-12-28 22:30:05 +00:00
Chris Lattner
d798002401 add a note.
llvm-svn: 45387
2007-12-28 21:50:40 +00:00
Owen Anderson
3de3f9981e Add a testcase for my recent InstCombine fix, written by Nicholas.
llvm-svn: 45386
2007-12-28 21:08:43 +00:00
Owen Anderson
7363914ef7 Repair a transform that Chris noticed a bug in. Thanks to Nicholas for pointing out my stupid mistakes when writing this patch. :-)
llvm-svn: 45384
2007-12-28 07:42:12 +00:00
Chris Lattner
5179819beb disable this instcombine xform, it miscompiles:
define i32 @main() {
entry:
	%z = alloca i32		; <i32*> [#uses=2]
	store i32 0, i32* %z
	%tmp = load i32* %z		; <i32> [#uses=1]
	%sub = sub i32 %tmp, 1		; <i32> [#uses=1]
	%cmp = icmp ult i32 %sub, 0		; <i1> [#uses=1]
	%retval = select i1 %cmp, i32 1, i32 0		; <i32> [#uses=1]
	ret i32 %retval
}

into ret 1, instead of ret 0.

Christopher, please investigate.

llvm-svn: 45383
2007-12-28 06:24:31 +00:00
Chris Lattner
7ef31d3c53 various cleanups. Use IgnoreParenCasts instead of inlined versions.
llvm-svn: 45382
2007-12-28 05:38:24 +00:00
Chris Lattner
934edb210a unindent cases in a switch stmt, no functionality change.
llvm-svn: 45381
2007-12-28 05:31:15 +00:00
Chris Lattner
0846494750 Change Sema::ActOnCallExpr to construct the CallExpr early and put it into
and OwningPtr instead of constructing only after all of sema is done.  This
has a couple of effects:
1. it fixes memory leaks from all the error cases in sema
2. it simplifies the code significantly.

The cost of this is that the error case now new's and delete's an expr where
it did not before, but we don't care about the perf of the error case.

llvm-svn: 45380
2007-12-28 05:29:59 +00:00
Chris Lattner
6420345a34 move file to proper place in project.
llvm-svn: 45379
2007-12-28 05:27:01 +00:00
Chris Lattner
e4407ede20 Add accessors + iterator interface.
llvm-svn: 45378
2007-12-28 05:25:02 +00:00
Chris Lattner
180f0e9044 add a note
llvm-svn: 45377
2007-12-28 04:42:05 +00:00
Chris Lattner
02ac5e87e0 From Lucas Newman:
"Here's a tiny patch that lets the clang Xcode project build in any 
location, so llvm doesn't have to be checked out in your home folder."

llvm-svn: 45376
2007-12-28 00:38:23 +00:00
Anton Korobeynikov
4f00f531ad Ignore functions with internal linkages during linking. This snipped mimics the
behaviour of LinkGlobals() function.

llvm-svn: 45375
2007-12-27 23:21:57 +00:00
Chris Lattner
20bc6e06cd add a file I forgot to svn add.
llvm-svn: 45374
2007-12-27 21:46:27 +00:00
Chris Lattner
cc10d93dcf alphabetize in project.
llvm-svn: 45373
2007-12-27 20:59:50 +00:00
Chris Lattner
807979824e use -emit-llvm-bc
llvm-svn: 45372
2007-12-27 20:35:58 +00:00
Chris Lattner
40ad6cd854 no need to verify this, no errors/warnings are expected.
llvm-svn: 45371
2007-12-27 20:31:56 +00:00
Chris Lattner
11221033be Fix a crash on a top-level objc string, patch by Nico Weber
llvm-svn: 45370
2007-12-27 20:29:42 +00:00
Gordon Henriksen
05568bbd98 Adding bindings for target triple and data layout.
llvm-svn: 45369
2007-12-27 20:13:47 +00:00
Chris Lattner
5e530bcee3 - Use Tok.isObjCAtKeyword instead of Tok.getIdentifierInfo()->getObjCKeywordID().
The later fails if the token is not an identifier.
 - Replace tabs with spaces.
 - Various other cleanups.

Patch by Nico Weber!

llvm-svn: 45368
2007-12-27 19:57:00 +00:00
Gordon Henriksen
823f9730d7 Switch the bindings to use LLVMFoldingBuilder.
llvm-svn: 45367
2007-12-27 18:25:59 +00:00
Gordon Henriksen
d4749de856 Adding an uninitialized builder constructor to the Ocaml bindings.
llvm-svn: 45362
2007-12-26 21:21:51 +00:00
Anders Carlsson
c9d41e7d27 No need to do work that the folding builder does for us.
llvm-svn: 45361
2007-12-26 18:20:19 +00:00
Chris Lattner
bc13df19a8 one fewer uncond branch with my codegenprepare hack for single-mbb backedges.
llvm-svn: 45360
2007-12-26 17:23:47 +00:00
Seo Sanghyeon
acb00f4a73 Remove broken assert from CodeGen. Better check is done in Sema.
llvm-svn: 45358
2007-12-26 05:21:37 +00:00
Gordon Henriksen
d89e645c38 Tests for changes made in r45356, where IPO optimizations would drop
collector algorithms.

llvm-svn: 45357
2007-12-26 02:47:37 +00:00
Gordon Henriksen
520e64c0c2 Fixing several transforms which would drop the collector attribute
when copying functions.

llvm-svn: 45356
2007-12-25 22:16:06 +00:00
Chris Lattner
bea11173f5 update to llvm 2.0 syntax.
llvm-svn: 45355
2007-12-25 20:34:52 +00:00
Chris Lattner
ef1bbfc762 Don't break critical edges for single-bb loops, this helps with PR1877, though
it is only a partial fix.  This change is noise for most programs, but
speeds up Shootout-C++/matrix by 20%, Ptrdist/ks by 24%, smg2000 by 8%,
hexxagon by 9%, bzip2 by 9% (not sure I trust this), ackerman by 13%, etc.

OTOH, it slows down Shootout/fib2 by 40% (I'll update PR1877 with this info).

llvm-svn: 45354
2007-12-25 19:06:45 +00:00
Seo Sanghyeon
d42a60baa0 Actually parse q operation in llvm-ar
llvm-svn: 45353
2007-12-25 13:53:47 +00:00
Gordon Henriksen
f23d2a59c5 Disabling -g for ocaml builds; it's not downwards compatible.
llvm-svn: 45352
2007-12-25 08:37:43 +00:00
Gordon Henriksen
b969c5981b GC poses hazards to the inliner. Consider:
define void @f() {
            ...
            call i32 @g()
            ...
    }

    define void @g() {
            ...
    }

The hazards are:

  - @f and @g have GC, but they differ GC. Inlining is invalid. This
    may never occur.
  - @f has no GC, but @g does. g's GC must be propagated to @f.

The other scenarios are safe:

  - @f and @g have the same GC.
  - @f and @g have no GC.
  - @g has no GC.

This patch adds inliner checks for the former two scenarios.

llvm-svn: 45351
2007-12-25 03:10:07 +00:00
Gordon Henriksen
fb56bde933 Noting and enforcing that GC intrinsics are valid only within a
function with GC.

This will catch the error when the inliner inlines a function with
GC into a caller with no GC.

llvm-svn: 45350
2007-12-25 02:31:26 +00:00
Gordon Henriksen
9157c499fc Adjusting verification of "llvm.gc*" intrinsic prototypes to match
LangRef.

llvm-svn: 45349
2007-12-25 02:02:10 +00:00
Christopher Lamb
2b84813441 Make output files binary mode for -emit-llvm-bc
llvm-svn: 45348
2007-12-24 23:49:33 +00:00
Owen Anderson
bccb8c432d Flesh out the Briggs implementation a little bit more, fix a few FIXMEs.
llvm-svn: 45347
2007-12-24 22:12:23 +00:00
Christopher Lamb
d01dea749e Almost the best possible handling of stdin/stdout for llvm-emit-bc!
llvm-svn: 45346
2007-12-24 20:59:36 +00:00
Christopher Lamb
1c0f5d2436 Better handing of stdin/stdout for -emit-llvm-bc
llvm-svn: 45345
2007-12-24 20:56:07 +00:00
Chris Lattner
62a806d565 add a -backedge-hack llc-beta option to codegenprepare.
When specified, don't split backedges of single-bb loops.
This helps address PR1877

llvm-svn: 45344
2007-12-24 19:32:55 +00:00
Chris Lattner
6c234bf58f add a simple hack
llvm-svn: 45343
2007-12-24 19:27:46 +00:00
Anton Korobeynikov
ee6af40c95 Cygwin defines uint32_t as unsigned long. Unbreak call to std::min in this case
llvm-svn: 45342
2007-12-24 11:16:47 +00:00
Ted Kremenek
563b21b013 Added special support for stripping CRLF characters that may appear in the
output of nm.

llvm-svn: 45341
2007-12-24 08:04:39 +00:00
Christopher Lamb
5a3416409f Allow bitcode output to be redirected to stdout.
llvm-svn: 45340
2007-12-24 03:23:55 +00:00
Seo Sanghyeon
76270e6be6 Implement -emit-llvm-bc option
llvm-svn: 45339
2007-12-24 01:52:34 +00:00
Gordon Henriksen
84c7325ca1 Setting GlobalDirective in TargetAsmInfo by default rather than
providing a misleading facility. It's used once in the MIPS backend
and hardcoded as "\t.globl\t" everywhere else.

llvm-svn: 45338
2007-12-23 20:58:16 +00:00
Owen Anderson
6d070f39b8 Get rid of an unneeded #include.
llvm-svn: 45337
2007-12-23 20:34:06 +00:00
Gordon Henriksen
83097d8818 Fix some Ocaml GC errors noticed upon review.
llvm-svn: 45336
2007-12-23 17:10:23 +00:00
Gordon Henriksen
2a8cd89d03 C and Ocaml bindings for ExecutionEngine (i.e., the JIT compiler).
llvm-svn: 45335
2007-12-23 16:59:28 +00:00
Owen Anderson
e110199916 Sketch out an implementation of Briggs' copy placement algorithm.
llvm-svn: 45334
2007-12-23 15:37:26 +00:00
Owen Anderson
ef41b910e5 Add GraphTraits specializations for machine dominators.
llvm-svn: 45333
2007-12-23 15:16:46 +00:00
Seo Sanghyeon
6f1b274976 String literal in aggregate expression
llvm-svn: 45330
2007-12-23 03:11:58 +00:00
Chris Lattner
b907c3fca1 remove use of alloca.
llvm-svn: 45329
2007-12-23 01:40:15 +00:00
Anton Korobeynikov
03f8a3630d Unbreak mingw build
llvm-svn: 45328
2007-12-23 01:19:32 +00:00
Gordon Henriksen
e09a4f8515 Undo a wrong bit in that last patch.
llvm-svn: 45327
2007-12-22 23:34:26 +00:00
Gordon Henriksen
8790a22a30 Document a more robust implementation of performCustomLowering.
llvm-svn: 45326
2007-12-22 23:32:32 +00:00
Chris Lattner
00602f6105 fix some warnings. This code needs to be de-tabified :(
llvm-svn: 45325
2007-12-22 22:47:03 +00:00
Chris Lattner
91f3379660 fix strict-aliasing violation
llvm-svn: 45324
2007-12-22 22:45:38 +00:00
Chris Lattner
de272b1b63 initial code for forming an FGETSIGN node. This is disabled until
legalizer support goes in.

llvm-svn: 45323
2007-12-22 21:35:38 +00:00
Chris Lattner
afc8f13bf5 improve support for fgetsign
llvm-svn: 45322
2007-12-22 21:26:52 +00:00
Chris Lattner
efd1cddb5a Tell TargetLoweringOpt whether it is running before
or after legalize.

llvm-svn: 45321
2007-12-22 20:56:36 +00:00
Chris Lattner
843cad4df2 Add a new FGETSIGN operation, which defaults to expand on all
targets.

llvm-svn: 45320
2007-12-22 20:47:56 +00:00
Anton Korobeynikov
1b1250770c Erm, really disable :)
llvm-svn: 45319
2007-12-22 20:46:24 +00:00
Anton Korobeynikov
d34112a4ee Disable, until we'll really need it
llvm-svn: 45318
2007-12-22 20:41:12 +00:00
Gordon Henriksen
0c43064daf Fix a partial application typo.
llvm-svn: 45317
2007-12-22 19:41:30 +00:00
Gordon Henriksen
41689b52ab Use getIntrinsicID instead of looking up intrinsic prototypes. Also
fixes a bug with indirect calls. (Test case will be included with
ocaml collector patch.)

llvm-svn: 45316
2007-12-22 17:27:01 +00:00
Anton Korobeynikov
eed7c0b9f7 Unbreak build on gcc 3.x
llvm-svn: 45315
2007-12-22 14:27:49 +00:00
Anton Korobeynikov
2ffb2c9e59 Unbreak mingw build
llvm-svn: 45314
2007-12-22 14:26:49 +00:00
Evan Cheng
345a00ba05 Preliminary PIC JIT support for X86 (32-bit) / Darwin.
llvm-svn: 45313
2007-12-22 09:40:20 +00:00
Evan Cheng
db33a0211b Oops.
llvm-svn: 45312
2007-12-22 09:14:34 +00:00
Chris Lattner
74b2ab59fd implement InstCombine/shift-trunc-shift.ll. This allows
us to compile:
#include <math.h>
int t1(double d) { return signbit(d); }

into:

_t1:
	movd	%xmm0, %rax
	shrq	$63, %rax
	ret

instead of:

_t1:
	movd	%xmm0, %rax
	shrq	$32, %rax
	shrl	$31, %eax
	ret

on x86-64.

llvm-svn: 45311
2007-12-22 09:07:47 +00:00
Owen Anderson
5a4c05d047 Note what still needs doing.
llvm-svn: 45310
2007-12-22 04:59:10 +00:00
Owen Anderson
4534100765 Remove critical edge breaking. It won't be necessary as long as we are very careful when inserting copies.
llvm-svn: 45309
2007-12-22 04:50:11 +00:00
Gordon Henriksen
1621129e6b Ignoring generated files.
llvm-svn: 45308
2007-12-22 04:44:11 +00:00
Evan Cheng
f4f52dbc8c Fix JIT code emission of X86::MovePCtoStack.
llvm-svn: 45307
2007-12-22 02:26:46 +00:00
Ted Kremenek
dbc5385608 Added (incomplete) implementation of SimulEngine, a worklist-based dataflow
solver for path-sensitive, intra-procedural analysis.

llvm-svn: 45306
2007-12-22 01:43:37 +00:00
Devang Patel
7a2c66b11e If succ has succ itself as one of the predecessors then do
not merge current bb and succ even if bb's terminator is
unconditional branch to succ.

llvm-svn: 45305
2007-12-22 01:32:53 +00:00
Evan Cheng
ac134551c6 Allow JIT with non-static relocation model.
llvm-svn: 45304
2007-12-22 01:12:14 +00:00
Fariborz Jahanian
4f41b272c9 Another test case, testing a variety of objective-c type comparisons.
llvm-svn: 45302
2007-12-22 00:17:49 +00:00
Fariborz Jahanian
24e1a0bd35 Another test for objective-c's type comparison.
llvm-svn: 45301
2007-12-21 23:48:59 +00:00
Anton Korobeynikov
1e8c1308bb Fix silly typo in the FP CEP handling.
llvm-svn: 45300
2007-12-21 23:33:44 +00:00
Ted Kremenek
e7e26cd01e Converted Loc back to being of type ProgramEdge. Ultimately I believe we want
the ability to refer to the vertex set for all the vertices associated with an
edge. This will allow some nice queries over the graph, and (hopefully) will
reduce the memory footprint of SimulVertex.

llvm-svn: 45299
2007-12-21 23:23:12 +00:00
Ted Kremenek
e1d1a9479f Added preliminary implementation of SimulGraph, which represents the
intra-procedural supergraph of a path-sensitive dataflow analysis.

llvm-svn: 45298
2007-12-21 23:21:58 +00:00
Ted Kremenek
908cff9fa4 Changed "Location" from "ProgramEdge" to "ProgramEdge&" (slightly more svelt
memory representation).

llvm-svn: 45297
2007-12-21 22:57:10 +00:00
Ted Kremenek
95416706ed SimulVertex now subclasses FoldingSetNode.
llvm-svn: 45296
2007-12-21 22:41:58 +00:00
Ted Kremenek
1616945a7d Added Profile method to SimulVertex.
llvm-svn: 45295
2007-12-21 22:40:41 +00:00
Fariborz Jahanian
a7c705ddca This patch implements some of the more obscure type-checking involving
'id' quallified with protocols and static types which have categories and
inheritance which implement these protocols.

llvm-svn: 45294
2007-12-21 22:22:33 +00:00
Ted Kremenek
fda0aaf01b Updated Xcode project to be in sync with recent changes in file locations
introduced in r45292 (http://llvm.org/viewvc/llvm-project?rev=45292&view=rev)

llvm-svn: 45293
2007-12-21 21:48:31 +00:00
Ted Kremenek
bf593f81fa Directory restructing of Analysis files.
Created include/clang/Analysis/Analyses directory.
  - Moved LiveVariables.h and UninitializedValues.h into this dir.
  
Moved ExprDeclBitVector.h into Analysis/Support.

Updated all clients who use these headers to reflect the new paths.

llvm-svn: 45292
2007-12-21 21:42:19 +00:00
Ted Kremenek
f55ed782b4 Renamed file AnalysisVertex.h to SimulVertex.h
llvm-svn: 45291
2007-12-21 21:17:22 +00:00
Ted Kremenek
3d8b0d6948 Renamed class AnalysisVertex to SimulVertex
llvm-svn: 45290
2007-12-21 21:16:58 +00:00
Duncan Sands
85f26f28b9 Fix a brain fart by our beloved leader (the content
of this patch is the last line).

llvm-svn: 45289
2007-12-21 20:18:41 +00:00
Ted Kremenek
93e2031187 Fixed successor order for CFG basic blocks when handling: x && y. The bug
is best explained by illustration:

[ B2 ]
     1: x
     T: [B2.1] && ...
   Predecessors (1): B4
   Successors (2): B3 B1

Block "B3" should be the block where we evaluate "y" when "x" evaluates to
true. Previously we had the successor list reversed. Now this behavior matches
with how we handle other conditional branches.

Thanks to Nuno Lopes for reporting this problem.

llvm-svn: 45288
2007-12-21 19:49:00 +00:00
Devang Patel
505b4f1fd4 Convert opaque type when struct definition is seen.
llvm-svn: 45287
2007-12-21 19:35:28 +00:00
Duncan Sands
8c5822802e Get the verifier to check attributes on calls as well
as on functions.  Make it verify invokes and not just
ordinary calls.  As a (desired) side-effect, it is no
longer legal to have call attributes on arguments that
are being passed to the varargs part of a varargs
function (llvm-as drops them on the floor anyway).

llvm-svn: 45286
2007-12-21 19:19:01 +00:00
Duncan Sands
6a7703ed63 Make DAE not wipe out attributes on calls, and not drop
return attributes on the floor.  In the case of a call
to a varargs function where the varargs arguments are
being removed, any call attributes on those arguments
need to be dropped.  I didn't do this because I plan to
make it illegal to have such attributes (see next patch).
With this change, compiling the gcc filter2 eh test at -O0
and then running opt -std-compile-opts on it results in
a correctly working program (compiling at -O1 or higher
results in the test failing due to a problem with how we
output eh info into the IR).

llvm-svn: 45285
2007-12-21 19:16:16 +00:00
Devang Patel
016e41e8a6 Keep track of llvm struct size while adding fields.
Update addPaddingFields() interface.

llvm-svn: 45284
2007-12-21 18:43:53 +00:00
Fariborz Jahanian
56b5c96ef7 Patch to compare to objective-c static types where one or the other
(but not both) may be a protocol qualified static type.

llvm-svn: 45283
2007-12-21 17:34:43 +00:00
Nicolas Geoffray
31a2c3948e Fix unintented change from last commit
llvm-svn: 45282
2007-12-21 12:22:29 +00:00
Nicolas Geoffray
80c741e160 Enable EH for linux/ppc32 targets
llvm-svn: 45281
2007-12-21 12:19:44 +00:00
Evan Cheng
78c460c8c4 New entry.
llvm-svn: 45280
2007-12-21 01:31:58 +00:00
Evan Cheng
b54038fc29 Add a few more missing gcc builtin's.
llvm-svn: 45278
2007-12-21 01:30:39 +00:00
Fariborz Jahanian
fd6f3a2460 Test case for my last patch.
llvm-svn: 45277
2007-12-21 00:35:35 +00:00
Fariborz Jahanian
ff7d2bf255 More objective-c type analysis. This time involving objective types
of conforming protocols (or not).

llvm-svn: 45276
2007-12-21 00:33:59 +00:00
Ted Kremenek
1cf6c7aa5b Removed scoped_ptr, as its functionality is subsumed by OwningPtr.
llvm-svn: 45274
2007-12-21 00:15:29 +00:00
Ted Kremenek
b149889df6 Added class "StateVariant", a template class which serves to wrap states that
are generated by transfer functions used by the path-sensitive dataflow solver.

llvm-svn: 45273
2007-12-21 00:04:19 +00:00
Ted Kremenek
f40d2740b6 Added initial implementation of "AnalysisVertex", a class to represent a
location*state vertex in an intra-procedural, path-sensitive dataflow
supergraph.

llvm-svn: 45272
2007-12-20 23:24:55 +00:00
Fariborz Jahanian
76fcf32632 Another test for objective-c type comparison.
llvm-svn: 45271
2007-12-20 22:53:29 +00:00
Fariborz Jahanian
4368af07a7 More objective-c type checking. This time comparing objective-c known objects.
llvm-svn: 45269
2007-12-20 22:37:58 +00:00
Evan Cheng
01c7c198ee Fix JIT encoding for CMPSD as well.
llvm-svn: 45268
2007-12-20 19:57:09 +00:00
Ted Kremenek
5e2413384e Added OwningArrayPtr smart pointer class to provide an analogous class to
OwningPtr except that it works for pointers to arrays.

llvm-svn: 45266
2007-12-20 19:53:47 +00:00
Ted Kremenek
71d643f8b1 Converted uses of scoped_ptr to OwningPtr.
llvm-svn: 45265
2007-12-20 19:47:16 +00:00
Fariborz Jahanian
63b19f1b6e Patch to do type-checking for objctive-c's object types.
More is yet to come.

llvm-svn: 45263
2007-12-20 19:24:10 +00:00
Chris Lattner
1991794112 add accessor.
llvm-svn: 45262
2007-12-20 19:14:21 +00:00
Chris Lattner
63fbcdf6ca add new smart pointer for clang.
llvm-svn: 45261
2007-12-20 19:14:02 +00:00
Evan Cheng
c226ed0273 Type specification didn't match gcc's.
llvm-svn: 45260
2007-12-20 09:35:28 +00:00
Evan Cheng
f989141d30 More accurate checks for two-address constraints.
llvm-svn: 45259
2007-12-20 09:25:31 +00:00
Seo Sanghyeon
58bdfda87c Add newline
llvm-svn: 45257
2007-12-20 07:22:20 +00:00
Christopher Lamb
7d82bc46b8 Implement review feedback, including additional transforms
(icmp slt (sub A B) 1) -> (icmp sle A B)
icmp sgt (sub A B) -1) -> (icmp sge A B)

and add testcase.

llvm-svn: 45256
2007-12-20 07:21:11 +00:00
Chris Lattner
e2cf5b8c5c Add m_Zero().
llvm-svn: 45255
2007-12-20 04:47:44 +00:00
Evan Cheng
ddc9af11f0 Remove xfail. This is fixed.
llvm-svn: 45254
2007-12-20 02:25:21 +00:00
Evan Cheng
a509537e25 The physical register + virtual register joining requirement was much too strict.
llvm-svn: 45253
2007-12-20 02:23:25 +00:00
Evan Cheng
61bc51ee97 Bring back a burr scheduling heuristic that's still needed.
llvm-svn: 45252
2007-12-20 02:22:36 +00:00
Evan Cheng
26ee54eb05 Clean up previous patch: PHI uses should not prevent iv reuse if all other uses are addresses. This trades a constant multiply for one fewer iv.
llvm-svn: 45251
2007-12-20 02:20:53 +00:00
Chris Lattner
16a51da0e2 simplify this code with the new m_Zero() pattern. Make sure the select only
has a single use, and generalize it to not require N to be a constant.

llvm-svn: 45250
2007-12-20 01:56:58 +00:00
Devang Patel
c006744c38 Revert my previous check-in.
llvm-svn: 45249
2007-12-20 01:46:01 +00:00
Chris Lattner
8304df9024 Fix trivial self-infinite-recursion
llvm-svn: 45248
2007-12-20 01:38:17 +00:00
Anton Korobeynikov
dce44d87f8 More eye-candy stuff :)
llvm-svn: 45247
2007-12-20 01:30:27 +00:00
Anton Korobeynikov
5ab614824d Add iterators for child traversal.
llvm-svn: 45246
2007-12-20 01:21:50 +00:00
Bill Wendling
65c001e6bc Updated comments to reflect what "side effects" means in this situation.
llvm-svn: 45245
2007-12-20 01:08:10 +00:00
Fariborz Jahanian
134cbefba2 More objective-c typechecking stuff. This is work in progress and more patches
are due to arrive.

llvm-svn: 45244
2007-12-20 01:06:58 +00:00
Chris Lattner
6c9ffe9529 Implement codegen for ordered comparison builtins.
llvm-svn: 45243
2007-12-20 00:44:32 +00:00
Scott Michel
5f1470f03a More working CellSPU tests:
- vec_const.ll: Vector constant loads
- immed64.ll: i64, f64 constant loads

llvm-svn: 45242
2007-12-20 00:44:13 +00:00
Ted Kremenek
371efafb94 Created initial implementation of "BuildSerializer", and ASTConsumer
which serializes ASTs to a common output directory.  This ASTConsumer
is invoked using a combination of "-o" and "-serialize" from the driver.

llvm-svn: 45241
2007-12-20 00:34:58 +00:00
Ted Kremenek
62c462f9c5 Renamed "FileEntry::getDev()" to "FileEntry::getDevice()"
llvm-svn: 45240
2007-12-20 00:29:44 +00:00
Chris Lattner
2da14fb84f implement semantic analysis for __builtin_islessequal and friends.
llvm-svn: 45239
2007-12-20 00:26:33 +00:00
Devang Patel
6d279d484a Add lto version check mechanism.
llvm-svn: 45238
2007-12-20 00:24:01 +00:00
Ted Kremenek
8babe3d9c4 Added method getFileEntryForID() to SourceManager.
llvm-svn: 45237
2007-12-20 00:15:17 +00:00
Gordon Henriksen
59db63d5fc Use a module to group calling convention values, too.
llvm-svn: 45236
2007-12-20 00:13:26 +00:00
Chris Lattner
e202e6af48 simplify some code.
llvm-svn: 45235
2007-12-20 00:05:45 +00:00
Chris Lattner
43be2e6004 refactor some code that handles sema of direct function calls.
llvm-svn: 45234
2007-12-19 23:59:04 +00:00
Chris Lattner
9b65d3506e Add iterator interface to function/method parameters.
llvm-svn: 45233
2007-12-19 23:58:25 +00:00
Ted Kremenek
ca07147851 Split serialization ASTConsumers into two consumers: SingleFileSerializer and
BuildSerializer. The former serializes a single translation unit to a
corresponding .ast file. The second serializes ASTs to a common emission
direction.  The latter is not fully implemented yet.

llvm-svn: 45232
2007-12-19 23:49:37 +00:00
Ted Kremenek
96e05d4f31 Added methods createMainFileID() and createMainFileIDForMemBuffer() to
SourceManager to allow SourceManager to directly intern the MainFileID
when it is created.  Removed setMainFileID().

llvm-svn: 45231
2007-12-19 23:48:45 +00:00
Evan Cheng
e2a8ba7fec Allow iv reuse if the user is a PHI node which is in turn used as addresses.
llvm-svn: 45230
2007-12-19 23:33:23 +00:00
Gordon Henriksen
eb4ce98f98 Using modules to group enumerations in Ocaml bindings.
llvm-svn: 45229
2007-12-19 22:54:12 +00:00
Ted Kremenek
230bd918b2 Interned MainFileID within SourceManager. Since SourceManager is referenced by
both Preprocessor and ASTContext, we no longer need to explicitly pass
MainFileID around in function calls that also pass either Preprocessor or
ASTContext. This resulted in some nice cleanups in the ASTConsumers and the
driver.

llvm-svn: 45228
2007-12-19 22:51:13 +00:00
Ted Kremenek
f7bfae6b45 Typo fix.
llvm-svn: 45227
2007-12-19 22:32:34 +00:00
Gordon Henriksen
34eb6d877e Adding bindings for memory buffers and module providers. Switching
to exceptions rather than variants for error handling in Ocaml.

llvm-svn: 45226
2007-12-19 22:30:40 +00:00
Ted Kremenek
9a53275918 Added storage of the FileID of the the main source file of a translation unit
in SourceManager.

llvm-svn: 45225
2007-12-19 22:29:55 +00:00
Steve Naroff
fa5751f842 Various tweaks to the get/lookup instance/class method API's.
llvm-svn: 45224
2007-12-19 22:27:04 +00:00
Ted Kremenek
6c7807716b Removed "SourceFile" from TranslationUnit. This same information will (soon)
be available by querying the SourceManager within the ASTContext referenced by
the TranslationUnit.

llvm-svn: 45223
2007-12-19 22:24:34 +00:00
Chris Lattner
7bd082e188 Describe Nico's script for gcc interception. Patch by Nico Weber.
llvm-svn: 45222
2007-12-19 22:17:19 +00:00
Dale Johannesen
eadbf4b91c Enable EH on PPC Darwin. This basically works; there
are a couple of issues that show up with the optimizer,
but I don't think they're really EH problems.
(llvm-gcc testsuite users note:  By default the testsuite
uses the unwinding code that's built as part of your local
llvm-gcc, which does not work.  You need to trick it into
using the installed system unwinding code to get useful
results.)

llvm-svn: 45221
2007-12-19 21:54:36 +00:00
Scott Michel
5ecac82f71 CellSPU testcase, extract_elt.ll: extract vector element.
llvm-svn: 45219
2007-12-19 21:17:42 +00:00
Duncan Sands
aa31b92508 When inlining through an 'nounwind' call, mark inlined
calls 'nounwind'.  It is important for correct C++
exception handling that nounwind markings do not get
lost, so this transformation is actually needed for
correctness.

llvm-svn: 45218
2007-12-19 21:13:37 +00:00
Scott Michel
a246e09aa0 More working CellSPU test cases:
- call.ll: Function call
- ctpop.ll: Count population
- dp_farith.ll: DP arithmetic
- eqv.ll: Equivalence primitives
- fcmp.ll: SP comparisons
- fdiv.ll: SP division
- fneg-fabs.ll: SP negation, aboslute value
- int2fp.ll: Integer -> SP conversion
- rotate_ops.ll: Rotation primitives
- select_bits.ll: (a & c) | (b & ~c) bit selection
- shift_ops.ll: Shift primitives
- sp_farith.ll: SP arithmentic

llvm-svn: 45217
2007-12-19 20:50:49 +00:00
Scott Michel
098c113bc8 Two more test cases: or_ops.ll (arithmetic or operations) and vecinsert.ll
(vector insertions)

llvm-svn: 45216
2007-12-19 20:15:47 +00:00
Ted Kremenek
aff2343af3 Cleaned up "-o" option to print "-o=<path>" instead of "-o=<string>" when
doing clang --help.

llvm-svn: 45215
2007-12-19 19:50:41 +00:00
Chris Lattner
f1be288617 fix formatting
llvm-svn: 45214
2007-12-19 19:48:49 +00:00
Ted Kremenek
6c0b224011 Added "-o" option to driver. ASTConsumers will need to be gradually
rewired to utilize this option.

Renamed option --serialize-ast --serialize.

llvm-svn: 45213
2007-12-19 19:47:59 +00:00
Chris Lattner
c238331377 Add support for #pragma mark, which shouldn't warn about bogus tokens.
llvm-svn: 45212
2007-12-19 19:38:36 +00:00
Ted Kremenek
0061aeb316 Removed storing inode and device number in TranslationUnit.
Added "SourceFile" string to TranslationUnit to record corresponding
source file.

Updated serialization of TranslationUnits and logic in the driver to
correctly pass the source file information to the serializer.

llvm-svn: 45211
2007-12-19 19:27:38 +00:00
Chris Lattner
6a4f74593c fix some crazy indentation
llvm-svn: 45210
2007-12-19 19:23:28 +00:00
Steve Naroff
7e718bb3fd Soften the macro rewrite error to a warning (and change the text).
llvm-svn: 45209
2007-12-19 19:16:49 +00:00
Fariborz Jahanian
6a128ae962 Minor test twik.
llvm-svn: 45208
2007-12-19 19:07:24 +00:00
Ted Kremenek
0ec9a20bf0 Updated locations of TranslationUnit.[cpp,h] in XCode project.
Added AST/ASTConsumer.cpp to XCode project.

llvm-svn: 45206
2007-12-19 18:07:54 +00:00
Chris Lattner
2a70c95387 reenable this code, fix the testcase.
llvm-svn: 45205
2007-12-19 18:01:43 +00:00
Chris Lattner
99488aec20 disable my commit from yesterday, fixing a regression test failure.
llvm-svn: 45204
2007-12-19 17:49:45 +00:00
Fariborz Jahanian
a1e3420c49 This patch concludes implementation of dynamic objective-c type qualified by
protocol list.

llvm-svn: 45203
2007-12-19 17:45:58 +00:00
Anders Carlsson
2c26cc232f Fix the embarassing typo for real this time (- vs _), sorry about breaking the tests Steve.
llvm-svn: 45202
2007-12-19 17:43:24 +00:00
Ted Kremenek
6c3777c319 Moved generation of the name of the serialized AST file into
CreateASTSerializer.

llvm-svn: 45201
2007-12-19 17:25:59 +00:00
Steve Naroff
55cb4be8ae Emit errors when attempting to rewrite ObjC expressions that originate from a macro expansion.
We plan on fixing this and removing this restriction after the break...

llvm-svn: 45200
2007-12-19 14:32:56 +00:00
Steve Naroff
735a2716de Revert Anders r45191 commit...it broke several of the tests.
llvm-svn: 45199
2007-12-19 14:11:27 +00:00
Duncan Sands
e9d8861cdf Simplify LowerCallTo by using a callsite.
llvm-svn: 45198
2007-12-19 09:48:52 +00:00
Duncan Sands
030bce7b83 The C++ exception handling personality function wants
to know about calls that cannot throw ('nounwind'):
if such a call does throw for some reason then the
personality will terminate the program.  The distinction
between an ordinary call and a nounwind call is that
an ordinary call gets an entry in the exception table
but a nounwind call does not.  This patch sets up the
exception table appropriately.  One oddity is that
I've chosen to bracket nounwind calls with labels (like
invokes) - the other choice would have been to bracket
ordinary calls with labels.  While bracketing
ordinary calls is more natural (because bracketing
by labels would then correspond exactly to getting an
entry in the exception table), I didn't do it because
introducing labels impedes some optimizations and I'm
guessing that ordinary calls occur more often than
nounwind calls.  This fixes the gcc filter2 eh test,
at least at -O0 (the inliner needs some tweaking at
higher optimization levels).

llvm-svn: 45197
2007-12-19 07:36:31 +00:00
Scott Michel
9b834469e0 Add new immed16.ll test case, fix CellSPU errata to make test case work.
llvm-svn: 45196
2007-12-19 07:35:06 +00:00
Anders Carlsson
721f601507 Fix an embarassing typo and add some very limited support for the aligned attribute.
llvm-svn: 45195
2007-12-19 07:19:40 +00:00
Christopher Lamb
e592175f80 svn:ignore configure.out at the root level
llvm-svn: 45194
2007-12-19 06:43:23 +00:00
Christopher Lamb
6af61fab70 Change svn attributes to ignore build directories.
llvm-svn: 45193
2007-12-19 06:41:17 +00:00
Bill Wendling
b528a10e0a Modified to support comments better.
llvm-svn: 45192
2007-12-19 06:20:05 +00:00
Anders Carlsson
081f1b411d Normalize attribute names if possible so we won't have to do two strcmps for every attribute.
llvm-svn: 45191
2007-12-19 06:16:30 +00:00
Bill Wendling
ca77ecb40a Mark the "isRemat" instruction as never having side effects.
llvm-svn: 45190
2007-12-19 06:07:48 +00:00
Chris Lattner
0f8a39c793 fix broken assert.
llvm-svn: 45189
2007-12-19 05:38:06 +00:00
Chris Lattner
ea72f449fe Implement C99 6.7.5.3p1
llvm-svn: 45188
2007-12-19 05:31:29 +00:00
Chris Lattner
747359f973 fix more table abuses.
llvm-svn: 45187
2007-12-19 05:04:11 +00:00
Evan Cheng
9f06e5e2df Don't leave newly created nodes around if it turns out they are not needed.
llvm-svn: 45186
2007-12-19 01:34:38 +00:00
Ted Kremenek
f4c38c9289 Refactored inode and device number into FileEntry, and changed the
ADT storing FileEntry's in FileManager from a map to a set.

llvm-svn: 45184
2007-12-18 22:29:39 +00:00
Ted Kremenek
8c8947fb92 When serializing SourceManager, we now serialize out absolute paths
to serialized source files.

llvm-svn: 45183
2007-12-18 22:12:19 +00:00
Ted Kremenek
14020706d8 Added "GetCurrentDirectory()" to sys::Path.
llvm-svn: 45182
2007-12-18 22:07:33 +00:00
Ted Kremenek
f70d24d2ae Moved ReadBitcodeFile and EmitBitcodeFile out of TranslationUnit and made them
the standalone functions ReadASTBitcodeFile and EmitASTBitcodeFile
respectively.

llvm-svn: 45180
2007-12-18 21:44:50 +00:00
Steve Naroff
824a9d8d4b Fix serious regression with ObjcInterfaceDecl. Now that we are storing -1 to mean undefined, we need to change the respective getters from unsigned->int.
llvm-svn: 45179
2007-12-18 21:41:31 +00:00
Bill Wendling
166f746246 Add debugging info. Use the newly created "hasUnmodelledSideEffects" method.
llvm-svn: 45178
2007-12-18 21:38:04 +00:00
Ted Kremenek
25dbd71a4c Fixed broken includes introduced by recent (incomplete) patch to
TranslationUnit.

llvm-svn: 45177
2007-12-18 21:36:21 +00:00
Ted Kremenek
afb98f9c09 Moved TranslationUnit.h to include path.
llvm-svn: 45176
2007-12-18 21:34:50 +00:00
Ted Kremenek
879b75018f Moved TranslationUnit from Driver to AST library.
llvm-svn: 45175
2007-12-18 21:34:28 +00:00
Fariborz Jahanian
9f0e310861 Refactoring work. ObjcQualifiedIdType is now derived from 'Type'.
llvm-svn: 45174
2007-12-18 21:33:44 +00:00
Christopher Lamb
f00ac6dd93 Fold subtracts into integer compares vs. zero. This improves generate code for this case on X86
from
_foo:
        movl    $99, %ecx
        movl    4(%esp), %eax
        subl    %eax, %ecx
        xorl    %edx, %edx
        testl   %ecx, %ecx
        cmovs   %edx, %eax
        ret

to
_foo:
        xorl    %ecx, %ecx
        movl    4(%esp), %eax
        cmpl    $99, %eax
        cmovg   %ecx, %eax
        ret

llvm-svn: 45173
2007-12-18 21:32:20 +00:00
Anton Korobeynikov
95cc3e0e66 Support more insane CEP's in AsmPrinter (Yes, PyPy folks do really use them).
llvm-svn: 45172
2007-12-18 20:53:41 +00:00
Ted Kremenek
a51c88ccd8 Added to FileEntry a pointer to the <dev_t,ino_t> pair for the file, and
accessors to FileEntry to query these values.

llvm-svn: 45171
2007-12-18 20:45:25 +00:00
Christopher Lamb
b7016c53d1 Fix comments
llvm-svn: 45170
2007-12-18 20:33:11 +00:00
Christopher Lamb
74dbad9216 Remove an orthogonal transformation of the selection condition from my most recent submission.
llvm-svn: 45169
2007-12-18 20:30:28 +00:00
Ted Kremenek
74db04261b Added "isDirectory" method to llvm::sys::Path.
llvm-svn: 45168
2007-12-18 19:46:22 +00:00
Evan Cheng
483a969ece Fix PR1872: SrcValue and SrcValueOffset should not be used to compute load / store node id.
llvm-svn: 45167
2007-12-18 19:38:14 +00:00
Bill Wendling
7c0bea1ce9 Ignore shell scripts when doing "dsymutil" call.
llvm-svn: 45166
2007-12-18 19:21:52 +00:00
Chris Lattner
5f47cae3ce remove obviously dead uses of IncludeFile.
llvm-svn: 45165
2007-12-18 19:15:48 +00:00
Evan Cheng
78ced47a2f Also print alignment and volatileness.
llvm-svn: 45164
2007-12-18 19:06:30 +00:00
Chris Lattner
d92e71cf9a remove a dead annotation
llvm-svn: 45163
2007-12-18 19:04:24 +00:00
Ted Kremenek
3d71ad1976 Added some sectioning comments to Serialize.h.
Added additional serialization functors for use with std::foreach.

llvm-svn: 45162
2007-12-18 18:25:55 +00:00
Chris Lattner
2583a66295 add an obvious load folding missed optzn.
llvm-svn: 45161
2007-12-18 16:48:14 +00:00
Duncan Sands
3353ed09ac Rename isNoReturn to doesNotReturn, and isNoUnwind to
doesNotThrow.

llvm-svn: 45160
2007-12-18 09:59:50 +00:00
Christopher Lamb
30291f4a30 Fix typos.
llvm-svn: 45159
2007-12-18 09:45:40 +00:00
Christopher Lamb
8b09a464b4 Fold certain additions through selects (and their compares) so as to eliminate subtractions. This code is often produced by the SMAX expansion in SCEV.
This implements test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll

llvm-svn: 45158
2007-12-18 09:34:41 +00:00
Evan Cheng
91e0fc9cb4 FIX for PR1799: When a load is unfolded from an instruction, check if it is a new node. If not, do not create a new SUnit.
llvm-svn: 45157
2007-12-18 08:42:10 +00:00
Chris Lattner
37bd2ecb11 local static vars are globals also. This fixes a testcase
reported by Seo.

llvm-svn: 45156
2007-12-18 08:16:44 +00:00
Chris Lattner
d4fc27e937 remove the loc argument to Type::isConstantSizeType, which isn't useful.
llvm-svn: 45155
2007-12-18 07:18:16 +00:00
Chris Lattner
20aad334c7 Fix the location we emit the "not a constant" error for this:
int foo() {
  typedef int x[foo()];
  static int y = sizeof(x);
}

previously we'd emit it on the typedef, which made not sense at all.

llvm-svn: 45154
2007-12-18 07:15:40 +00:00
Chris Lattner
6d2d1b67ca Fix PR1863: an assertion due to not setting a location on return from
this method.

llvm-svn: 45153
2007-12-18 07:03:30 +00:00
Chris Lattner
78e34a00f4 Fix const propagation bug.
llvm-svn: 45152
2007-12-18 07:02:56 +00:00
Evan Cheng
e2dbba5828 SelectionDAG::dump() should print SrcValue of LoadSDNode and StoreSDNode.
llvm-svn: 45151
2007-12-18 07:02:08 +00:00
Chris Lattner
9a2e3cb48d avoid confusing terminology (what is a "word"?), fix scary markup, add section to TOC.
llvm-svn: 45150
2007-12-18 06:18:21 +00:00
Chris Lattner
dcb7cc59ae Fix an nice and subtle parser bug reported by Nico Weber.
llvm-svn: 45149
2007-12-18 06:06:23 +00:00
Steve Naroff
b723564c79 Add DefaultFunctionArrayConversion() to the indirection operator in Sema::ActOnUnaryOp().
This fixes a bug Chris forwarded from Oliver Hunt...

typedef struct { char name[100]; } entry;
char f1(entry *e) { return *e->name; }

llvm-svn: 45148
2007-12-18 04:06:57 +00:00
Christopher Lamb
ac7d631ed2 Don't forget to print address space qualifiers when printing out the type table! Thanks to Gordon Henriksen for pointing this out.
llvm-svn: 45147
2007-12-18 03:49:35 +00:00
Steve Naroff
b74406ba98 Fixe bogus error for variable argument methods. Sema::ObjcGetTypeForMethodDefinition() wasn't preserving the isVariadic boolean. Another fix is to avoid synthsizing the function decl entirely, however this is a separate issue that I don't want to deal with now. Also added a FIXME to Sema::CheckFunctionCall(), which is currently emitting a bogus warning.
llvm-svn: 45146
2007-12-18 03:41:15 +00:00
Anders Carlsson
aa5c91980e Turns out the LLVMFoldingBuilder can fold InsertElement. Knowing this, we can get rid of our special casing of constants when creating vectors.
llvm-svn: 45145
2007-12-18 02:45:33 +00:00
Dale Johannesen
a56aab57e9 Testcase for preceding FE fix
llvm-svn: 45144
2007-12-18 01:58:38 +00:00
Steve Naroff
1d2538cb4d Improve how we find private method decls. This involved:
- Changed Sema::ObjcActOnStartOfMethodDef() to register the methods with the global pools.
- Changed Sema::ActOnInstanceMessage() to look in global pools (should be much less error prone).
- Added a test case to message.m (for lookup that was broken).

Misc changes while I was investigating this...

- Changed Sema::ActOnAtEnd() to call AddFactoryMethodToGlobalPool (this looked like a cut/paste error).
- Added a comment and tweaked another where I was using the first person.

llvm-svn: 45142
2007-12-18 01:30:32 +00:00
Chris Lattner
52a9e40789 add a missed case.
llvm-svn: 45141
2007-12-18 01:19:18 +00:00
Evan Cheng
a8288f4294 Remove int_x86_sse2_movl_dq. It's replaced with a string compare.
llvm-svn: 45140
2007-12-18 01:04:25 +00:00
Evan Cheng
61eacb9048 These have matching builtin's in 4.2.
llvm-svn: 45139
2007-12-18 00:52:20 +00:00
Chris Lattner
b8be97e239 introduce a new CodeGenModule::getIntrinsic method, which wraps
Intrinsic::getDeclaration, allowing much more terse code.

llvm-svn: 45136
2007-12-18 00:25:38 +00:00
Steve Naroff
2050b0d05a Add __private_extern__ keyword and recognize it. Added a FIXME to indicate there is still work to do.
llvm-svn: 45135
2007-12-18 00:16:02 +00:00
Scott Michel
8172f85e2f i32 immediate constant test case for CellSPU
llvm-svn: 45134
2007-12-17 23:45:52 +00:00
Bill Wendling
34cc217741 s/hasSideEffects/hasUnmodelledSideEffects/g
llvm-svn: 45133
2007-12-17 23:19:54 +00:00
Bill Wendling
b3d85a5d4b Add "mayHaveSideEffects" and "neverHasSideEffects" flags to some instructions. I
based what flag to set on whether it was already marked as
"isRematerializable". If there was a further check to determine if it's "really"
rematerializable, then I marked it as "mayHaveSideEffects" and created a check
in the X86 back-end similar to the remat one.

llvm-svn: 45132
2007-12-17 23:07:56 +00:00
Evan Cheng
0e179d015f Bring back int_x86_sse2_movl_dq intrinsic for backward compatibility. Make sure
it's auto-upgraded to a shufflevector instruction.

llvm-svn: 45131
2007-12-17 22:33:23 +00:00
Scott Michel
c5cccb9e60 - Restore some i8 functionality in CellSPU
- New test case: nand.ll

llvm-svn: 45130
2007-12-17 22:32:34 +00:00
Ted Kremenek
bd5362511d Modified Deserializer::ReadCStr to allow C-strings to be read into a
std::vector<char> starting from any index in the vector.

llvm-svn: 45129
2007-12-17 22:25:12 +00:00
Bill Wendling
a2401be121 LD_Fp64m should have "isRematerializable" set.
llvm-svn: 45128
2007-12-17 22:17:14 +00:00
Bill Wendling
d5477afc1b Add "hasSideEffects" method to MachineInstrInfo class.
llvm-svn: 45126
2007-12-17 21:53:30 +00:00
Fariborz Jahanian
9b482ba9ec Fixed a comment describing a function
llvm-svn: 45125
2007-12-17 21:48:49 +00:00
Chris Lattner
619e18cce2 implement HeaderMap::LookupFile. I think headermaps are done now. All that is
left is this crazy thing called "testing".

llvm-svn: 45124
2007-12-17 21:38:04 +00:00
Bill Wendling
842ddea5e4 Add MachineLICM.cpp
llvm-svn: 45123
2007-12-17 21:14:45 +00:00
Chris Lattner
9f9a619a9f implement enough helper functions to successfully dump out the
contents of the header map.  Look ma, no assumptions about input data
here (aka, corrupt header maps can't crash the compiler - crazy thought).

llvm-svn: 45122
2007-12-17 21:06:11 +00:00
Fariborz Jahanian
24cb52c9b0 Patch to implemented objective-c's dynamic object pointer qualified with
the protocol list (id<P,...> types).

llvm-svn: 45121
2007-12-17 21:03:50 +00:00
Bill Wendling
939526a930 As per feedback, revised comments to (hopefully) make the different side effect
flags clearer.

llvm-svn: 45120
2007-12-17 21:02:07 +00:00
Chris Lattner
a0943c36ed Targets.cpp is gone.
llvm-svn: 45119
2007-12-17 20:56:50 +00:00
Chris Lattner
e6a76da763 Make the insertion point with an explicit new instead of the builder.
llvm-svn: 45118
2007-12-17 20:50:59 +00:00
Ted Kremenek
a59e0064d3 Removed CFG.cpp's dependence on #including iostream.
llvm-svn: 45116
2007-12-17 19:35:20 +00:00
Devang Patel
725b73ff42 Add cast operators in LLVMFoldingBuilder.
Patch by Richard Pennington.

llvm-svn: 45115
2007-12-17 19:06:26 +00:00
Ted Kremenek
3fbeaea7ee Modified format-string checking to not emit a warning when all of the
following hold:

(1) A vprintf-like function is called that takes the argument list via a
    via_list argument.

(2) The format string is a non-literal that is the parameter value of
    the enclosing function, e.g:
    
    void logmessage(const char *fmt,...) { 
      va_list ap;
      va_start(ap,fmt);
      fprintf(fmt,ap);  // Do not emit a warning.
    }
    
In the future this special case will be enhanced to consult the "format"
attribute attached to a function declaration instead of just allowing a blank
check for all function parameters to be used as format strings to vprintf-like
functions. This will happen when more support for attributes becomes
available.

llvm-svn: 45114
2007-12-17 19:03:13 +00:00
Chris Lattner
d39b8c0269 simplify some code, using new scoped_ptr support. Fix a bug in the
cross-endianness case, where we checked the version in the wrong endianness.
Amusingly, the GCC logic that detects mixed endianness hmaps and rejects 
them is dead for this very reason.

llvm-svn: 45113
2007-12-17 18:59:44 +00:00
Chris Lattner
4d5bcd938e cleanup this code, making it more "llvm-like".
Add comments to reset indicating that it deletes its pointer.
Add a new take() method, which can be used to get the pointer
without it being deleted.

llvm-svn: 45112
2007-12-17 18:58:23 +00:00
Chris Lattner
79764a6bee Finish hooking up the scaffolding for headermaps. They can now do everything
except resolve lookups.

llvm-svn: 45111
2007-12-17 18:44:09 +00:00
Ted Kremenek
ea63b1575c Format string checker: asprintf does not pass argumnents via va_list.
llvm-svn: 45110
2007-12-17 18:38:31 +00:00
Chris Lattner
4ffe46cbdf Start reading the headermap header, drop the 'errorstr' argument to
the create method.

llvm-svn: 45109
2007-12-17 18:34:53 +00:00
Duncan Sands
b5a79d0eaa Make invokes of inline asm legal. Teach codegen
how to lower them (with no attempt made to be
efficient, since they should only occur for
unoptimized code).

llvm-svn: 45108
2007-12-17 18:08:19 +00:00
Fariborz Jahanian
77b713b5d3 Also fixed similar regression for class methods, as well as more indentations.
llvm-svn: 45107
2007-12-17 18:07:01 +00:00
Chris Lattner
8d720d083a Sink getName into DirectoryLookup to simplify the client in clang.
llvm-svn: 45106
2007-12-17 17:57:27 +00:00
Fariborz Jahanian
5f6409532b Fixed a regression caused by refactoring of some meta-data generation routines using iteratgors.
Also fixed indentation problems.

llvm-svn: 45105
2007-12-17 17:56:10 +00:00
Ted Kremenek
73e921fdf2 Fixed 80 col violation.
llvm-svn: 45104
2007-12-17 17:50:39 +00:00
Ted Kremenek
5aa66bdfd6 Added driver option -Wno-format-nonliteral to silence format string related
warnings. This flag is the inverse of to GCC's -Wformat-nonliteral option (in
the clang driver, these warnings are on by default).

Patch provided by Shantonu Sen.

llvm-svn: 45103
2007-12-17 17:50:07 +00:00
Chris Lattner
faebb62651 Unbreak -v with framework paths. Patch by Shantonu Sen.
llvm-svn: 45102
2007-12-17 17:42:26 +00:00
David Greene
71eae8a5ee GLIBCXX_DEBUG fix. std::vector<>::end() is invalidated by erase.
llvm-svn: 45101
2007-12-17 17:42:03 +00:00
David Greene
c4a80fb574 Get rid of annoying spaces.
llvm-svn: 45100
2007-12-17 17:40:29 +00:00
David Greene
2a5967b36a Fix GLIBCXX_DEBUG errors. Erase invalidates std::vector iterators
passed the erased element.

llvm-svn: 45099
2007-12-17 17:39:51 +00:00
Ted Kremenek
05821322b4 Fixed another case where sizeof() returns the size in bytes, not bits.
This parallels a previous patch (duplicate logic caused the bug to appear
in multiple locations):
 
  r44316 (http://llvm.org/viewvc/llvm-project?rev=44316&view=rev).

Patch provided by Nuno Lopes.

llvm-svn: 45098
2007-12-17 17:38:43 +00:00
Gordon Henriksen
557fb1451e Disabling a RUN line that's broken until addrspace roundtrips
through llvm-as|llvm-dis.

llvm-svn: 45097
2007-12-17 16:09:28 +00:00
Gordon Henriksen
5a3fe03784 C and Ocaml bindings for address spaces, for that burgeoning market
for Ocaml-based compilers targeting embedded devices. :)

llvm-svn: 45096
2007-12-17 16:08:32 +00:00
Chris Lattner
1587e6db01 add headermap.cpp
llvm-svn: 45095
2007-12-17 08:22:46 +00:00
Chris Lattner
44bd21b7c1 finish stubbing out support for HeaderMap. Now we just need an implementation!
llvm-svn: 45094
2007-12-17 08:17:39 +00:00
Chris Lattner
712e3873a0 refactor an better comment framework lookup code. This moves it from
HeaderSearch into DirectoryLookup, as a particular framework lookup is 
specific to the directory we are currently querying.

llvm-svn: 45093
2007-12-17 08:13:48 +00:00
Chris Lattner
f62f75895f as it turns out, frameworks and headermaps are orthogonal. Make this so in
the internal representation.  This also fixes a bug where -I foo  -F foo would
not search foo as both a normal and framework include dir.

llvm-svn: 45092
2007-12-17 07:52:39 +00:00
Chris Lattner
dd00e625d2 add a portability fixme.
llvm-svn: 45091
2007-12-17 06:51:34 +00:00
Chris Lattner
3e206b3a0e teach RemoveDuplicates about header maps.
llvm-svn: 45090
2007-12-17 06:44:29 +00:00
Chris Lattner
c4ba38ed1e Step #1 in adding headermap support to clang.
llvm-svn: 45089
2007-12-17 06:36:45 +00:00
Chris Lattner
899ff4a26d rearrange some code and make it more efficient.
llvm-svn: 45087
2007-12-17 05:59:27 +00:00
Chris Lattner
28c91c5f35 add a hack so that codegen doesn't abort on missing sema of initializers, now
we emit stuff like this:

abort on missing sema of initializers, now
we emit stuff like this:

t3.c:1:24: warning: cannot codegen this initializer yet
const char x[2][4] = { { 'a', 'b', '\0', '\0' }, { 'c', 'd', 'e', '\0' } };
                       ^~~~~~~~~~~~~~~~~~~~~~~~

This should be removed when sema is finished.

llvm-svn: 45086
2007-12-17 05:17:42 +00:00
Christopher Lamb
083bb46370 regenerate.
llvm-svn: 45085
2007-12-17 01:17:35 +00:00
Christopher Lamb
edf0788758 Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
llvm-svn: 45082
2007-12-17 01:12:55 +00:00
Christopher Lamb
77560fbde7 Update to use new PointerType::getUnqual() api.
llvm-svn: 45081
2007-12-17 01:11:20 +00:00
Christopher Lamb
55c6d4f22f Make it clear in the LangRef that allocation instructions only operated on the generic address space. Implement support in the verifier for ensuring this is true.
llvm-svn: 45080
2007-12-17 01:00:21 +00:00
Anders Carlsson
ca6bcae0be Start generating SSE intrinsics.
llvm-svn: 45079
2007-12-16 22:33:50 +00:00
Steve Naroff
eaaae467c7 Sema::ActOnMemberReferenceExpr() needs to perform the default conversions.
Bug and test case provided by Carl Lewis.

llvm-svn: 45078
2007-12-16 21:42:28 +00:00
Duncan Sands
56ed48036b Revert this part of r45073 until the verifier is
changed not to reject invoke of inline asm.

llvm-svn: 45077
2007-12-16 21:01:21 +00:00
Chris Lattner
2af27c202c don't violate C TBAA rules, use FloatToBits instead.
llvm-svn: 45076
2007-12-16 20:41:33 +00:00
Chris Lattner
e3b05fe31b fix a questionable cast, thanks to Mike Stump for pointing this out.
llvm-svn: 45075
2007-12-16 20:26:54 +00:00
Chris Lattner
dab6bd902e Fix the JIT encoding of cmp*ss, which aborts with this assertion currently:
X86CodeEmitter.cpp:378: failed assertion `0 && "Immediate size not set!"'

I *think* this is right, but Evan, please verify.  It also looks like
CMPSDrr and maybe others are missing this info.  Evan, plz investigate.

llvm-svn: 45074
2007-12-16 20:12:41 +00:00
Duncan Sands
8e4847ee95 Make instcombine promote inline asm calls to 'nounwind'
calls.  Remove special casing of inline asm from the
inliner.  There is a potential problem: the verifier
rejects invokes of inline asm (not sure why).  If an
asm call is not marked "nounwind" in some .ll, and
instcombine is not run, but the inliner is run, then
an illegal module will be created.  This is bad but
I'm not sure what the best approach is.  I'm tempted
to remove the check in the verifier...

llvm-svn: 45073
2007-12-16 15:51:49 +00:00
Bill Wendling
fcf2085731 Remove spurious warnings from GCC:
warning: suggest a space before ';' or explicit braces around empty  
body in 'for' statement

Patch by Mike Stump (modified slightly by yours truly).

llvm-svn: 45071
2007-12-16 09:16:12 +00:00
Owen Anderson
7b8a741189 Break local interferences in StrongPHIElimination. One step closer...
llvm-svn: 45070
2007-12-16 05:44:27 +00:00
Owen Anderson
ccb3981256 A few more comments.
llvm-svn: 45069
2007-12-16 04:07:23 +00:00
Anton Korobeynikov
ce1489e575 Define addString() and lookup() out-of-line to dissuade the C++ compiler from inlining it.
llvm-svn: 45068
2007-12-16 01:36:16 +00:00
Anton Korobeynikov
fbb9e418b5 Provide GraphTraits and DOTGraphTraits interface for Trie.
Retoss private/public stuff.
Make copy ctor and operator= private.

llvm-svn: 45067
2007-12-16 01:27:04 +00:00
Anton Korobeynikov
06e60b714b Constify graph arguments
llvm-svn: 45066
2007-12-16 00:42:19 +00:00
Chris Lattner
39911a2258 swtich to smallptrset, which is more efficient than std::set.
llvm-svn: 45065
2007-12-15 23:20:07 +00:00
Chris Lattner
d6658d932b make clang -v output more similar to gcc's -v output.
llvm-svn: 45064
2007-12-15 23:11:06 +00:00
Anton Korobeynikov
659c3f8dd1 Use references in DF iterators. This eliminates copy-ctor calls on huge objects (graphs)
llvm-svn: 45063
2007-12-15 22:23:24 +00:00
Anders Carlsson
f5f6544edc We now support all MMX intrinsics. SSE intrinsics are next.
llvm-svn: 45062
2007-12-15 21:23:30 +00:00
Chris Lattner
60a288ab19 simplify the interfaces to ProcessInputFile and InitializePreprocessor
llvm-svn: 45060
2007-12-15 20:48:40 +00:00
Duncan Sands
26d6539e70 These are more correctly called signaling NaNs.
llvm-svn: 45059
2007-12-15 17:37:40 +00:00
Evan Cheng
23d2d4dc6c Make better use of instructions that clear high bits; fix various 2-wide shuffle bugs.
llvm-svn: 45058
2007-12-15 03:00:47 +00:00
Evan Cheng
cbeec14a6f __builtin_ia32_movqv4si is now expanded to a shuffle.
llvm-svn: 45057
2007-12-15 02:54:12 +00:00
Ted Kremenek
56ba5b3931 Removed "isSizeOfExpr" mode from StmtIterator. It turned out not to be
so useful and introduced a few bugs.

llvm-svn: 45051
2007-12-15 00:39:18 +00:00
Scott Michel
0aa7133f82 Start committing working test cases for CellSPU.
llvm-svn: 45050
2007-12-15 00:38:50 +00:00
Ted Kremenek
3291844bf0 Added "mode" to StmtIterator to record if the expression being iterated
over is the subexpression of a sizeof(expression).  Different clients
will wish to handle iteration over such subexpressions differently, and can
now easily query if they are iterating over such statements using the
StmtIterator's inSizeOfExpr().

llvm-svn: 45047
2007-12-14 23:40:56 +00:00
Steve Naroff
3ce37a6b8e - Remove getInstanceMethods/getClassMethods API on ObjcInterfaceDecl, ObjcProtocolDecl, and ObjcCategoryDecl. These methods are replaced by the respective iterators on each class.
- Add getInstanceMethodForSelector to ObjcInterfaceDecl, ObjcProtocolDecl, and ObjcCatgoryDecl. This hook will do a "shallow" lookup. This is a convenience method that reducing some of the iterator usage.
- Various changes to convert all clients to the above API's...
 

llvm-svn: 45046
2007-12-14 23:37:57 +00:00
Ted Kremenek
85e45f278c Added support to StmtIterator to traverse the size expression of a VLA type
declared in a sizeof.  For example:

 sizeof(int[foo()]);

the expression "foo()" is an expression that is executed during the evaluation
of sizeof.

llvm-svn: 45043
2007-12-14 22:52:23 +00:00
Evan Cheng
9556729128 Actually, MOVPQIto64mr is a dup of MOVPQI2QImr, MOV64toPQIrm is a dup of MOVQI2PQIrm.
llvm-svn: 45041
2007-12-14 20:08:14 +00:00
Evan Cheng
e28372c0d6 Fix (mem) <-> low 64-bits of xmm bugs pointed out by David Greene. Mac OS X Leopard assembler recognizes movq.
llvm-svn: 45040
2007-12-14 19:54:07 +00:00
Duncan Sands
1202d1b1c4 Teach the interpreter to read and write memory in the
endianness of the target not of the host.  Done by the
simple expedient of reversing bytes for primitive types
if the host and target endianness don't match.  This is
correct for integer and pointer types.  I don't know if
it is correct for floating point types.

llvm-svn: 45039
2007-12-14 19:38:31 +00:00
Dale Johannesen
f7cefdd5f0 x86-32 long doubles are 4-byte aligned on the stack
for parameter passing (only for that, on Darwin).

llvm-svn: 45038
2007-12-14 19:25:34 +00:00
Evan Cheng
a56e6ff9a7 Fix bsf / bsr jit encoding.
llvm-svn: 45037
2007-12-14 18:49:43 +00:00
Evan Cheng
f28c810036 Oops. Forgot these.
llvm-svn: 45036
2007-12-14 18:25:34 +00:00
Anders Carlsson
4d3094a9bb Simplify the vector code. Add more shift intrinsics.
llvm-svn: 45035
2007-12-14 17:48:24 +00:00
Dan Gohman
8a332b235d Add explicit keywords, and fix a minor typo that they uncovered.
llvm-svn: 45034
2007-12-14 15:41:34 +00:00
Dan Gohman
11352df8e4 Don't redirect stderr when it isn't needed.
llvm-svn: 45033
2007-12-14 15:15:11 +00:00
Dan Gohman
6869bfc351 Fix a typo in a comment.
llvm-svn: 45032
2007-12-14 15:13:08 +00:00
Dan Gohman
4069a593cc Fix a typo in a comment.
llvm-svn: 45031
2007-12-14 15:11:58 +00:00
Dan Gohman
9d2e9e376f Fix Intel asm syntax for the bsr and bsf instructions.
llvm-svn: 45030
2007-12-14 15:10:00 +00:00
Evan Cheng
0e6408124e Fix ctlz and cttz. llvm definition requires them to return number of bits in of the src type when value is zero.
llvm-svn: 45029
2007-12-14 08:30:15 +00:00
Evan Cheng
0fcf56f8f5 Bug fix. Must also match ResNo when matching an operand with a user.
llvm-svn: 45028
2007-12-14 08:25:15 +00:00
Anders Carlsson
f924f34b6b All MMX shift instructions took a <2 x i32> vector as the shift amount parameter. Change this to be <1 x i64> instead, which matches the assembler instruction.
llvm-svn: 45027
2007-12-14 06:38:54 +00:00
Kevin
c3286e9cef IE Menu Problem...
Originally, I included CSS hacks for IE.
However, my comments before the doctype was the reason IE was running in non-strict mode.  I did not know this.
When Chris removed the comments, IE correctly went into strict mode and my IE hacks were no longer needed (the hacks were getting in the way now).
solution:
*) Make sure doctype is first on all files
*) removed all IE hacks from menu.css (since the doctype issue fixes IE)

llvm-svn: 45025
2007-12-14 05:47:49 +00:00
Evan Cheng
e9fbc3f014 Implement ctlz and cttz with bsr and bsf.
llvm-svn: 45024
2007-12-14 02:13:44 +00:00
Seo Sanghyeon
d4d8c3c717 Array subscription in aggregate expression
llvm-svn: 45023
2007-12-14 02:04:12 +00:00
Bill Wendling
cb77f04e1f Add flags to indicate that there are "never" side effects or that there "may be"
side effects for machine instructions.

llvm-svn: 45022
2007-12-14 01:48:59 +00:00
Seo Sanghyeon
3abb6d8435 Implement dereference operator in aggregate expression
llvm-svn: 45020
2007-12-14 01:09:11 +00:00
Ted Kremenek
7d9a2e119d CFG bug fix: for sizeof(expressions), don't expand the control-flow
of "expressions", since they are not really evaluated.

llvm-svn: 45015
2007-12-13 22:44:18 +00:00
Fariborz Jahanian
c47dc4f5af Patch to make ObjcQualifiedInterfaceType inherit ObjcInterfaceType
llvm-svn: 45014
2007-12-13 20:47:42 +00:00
Dan Gohman
d4551fd0a4 Make it more clear that some things that can't be done in .td files can
still be done in the LLVM code generator. And update the summary for the
X86 target.

llvm-svn: 45013
2007-12-13 20:43:47 +00:00
Steve Naroff
d78c81b6de Sema::ActOnFinishFunctionBody(): Since we no longer synthesize a FunctionDecl for each method, remove the unconditional initialization to 0 and corresponding comment.
llvm-svn: 45008
2007-12-13 18:18:56 +00:00
Ted Kremenek
2f4ab7148c Add hack to SourceManager to support missing source files during
deserialization.  Eventually this should be replaced with a lazy-reading
mechanism that only reads source files when they are needed by clients.

llvm-svn: 45007
2007-12-13 18:12:10 +00:00
Ted Kremenek
31dcdb312b Add check in the driver to see if a serialized AST file has been successfully
deserialized.

llvm-svn: 45006
2007-12-13 18:11:11 +00:00
Ted Kremenek
685dc9b56e Changed set of top-level decls from a list to a vector.
llvm-svn: 45005
2007-12-13 17:54:02 +00:00
Ted Kremenek
15ddcef648 Changed -serialize-ast to not create a temporary directory, but instead
create a .ast file in the current working directory.  This mirrors the behavior
of the -c option for gcc.  Later we should add the ability to write the
serialized file anywhere.

llvm-svn: 45004
2007-12-13 17:50:11 +00:00
Chris Lattner
60af5f3b82 Set target data layout info in module.
llvm-svn: 45003
2007-12-13 17:34:31 +00:00
Chris Lattner
69b9ea5afa typo
llvm-svn: 45002
2007-12-13 17:27:09 +00:00
Chris Lattner
2048b067a6 debug info too.
llvm-svn: 45001
2007-12-13 17:25:36 +00:00
Ted Kremenek
9f5ad6c795 Minor spelling; punctuation correction.
llvm-svn: 45000
2007-12-13 16:41:01 +00:00
Wojciech Matyjewicz
86d51b896e Make these loops follow GetGEPOperands() behavior.
Let: %q = GEP %p, X, ...
If %p is a GEP, we can chase baseptr further, only if X==0.

llvm-svn: 44999
2007-12-13 16:22:58 +00:00
Bill Wendling
a5be19d3df Grammar fix: correct ' usage.
llvm-svn: 44998
2007-12-13 09:57:40 +00:00
Evan Cheng
2011df4e39 Fix typo.
llvm-svn: 44997
2007-12-13 07:50:36 +00:00
Chris Lattner
eb13c73c36 minor cleanups
llvm-svn: 44996
2007-12-13 07:47:54 +00:00
Chris Lattner
54424ad69c add some builtins.
llvm-svn: 44995
2007-12-13 07:41:58 +00:00
Chris Lattner
13653d7668 simplify some code.
llvm-svn: 44994
2007-12-13 07:34:23 +00:00
Chris Lattner
3c1334013d Don't do integer promotions of LHS for compound shift assignment. The LHS has to be a modifiable lvalue.
llvm-svn: 44993
2007-12-13 07:28:16 +00:00
Chris Lattner
d7b5a9aa1a remove some dead styles.
llvm-svn: 44992
2007-12-13 06:55:59 +00:00
Chris Lattner
d9c10096d7 nuke hte status page.
llvm-svn: 44991
2007-12-13 06:55:02 +00:00
Chris Lattner
196a226567 add a bunch of open projects
llvm-svn: 44990
2007-12-13 06:41:15 +00:00
Ted Kremenek
136a37f1eb Updated serialization of ParmVarDecl to serialize out objcDeclQualifier.
Previously this field was serialized out in VarDecl (a parent class), but
now the field belongs to ParmVarDecl.

llvm-svn: 44989
2007-12-13 06:28:13 +00:00
Chris Lattner
a5b4965c0e split get_involved into two pages: get_started and get_involved.
llvm-svn: 44988
2007-12-13 06:20:15 +00:00
Owen Anderson
53b677e4e8 Add register pairs to the list to check for local interferences.
llvm-svn: 44987
2007-12-13 05:53:03 +00:00
Owen Anderson
1f93edd08a Remove ugly and horrible code. It's not necessary for correctness, and can be added back later if it causes code quality issues.
llvm-svn: 44986
2007-12-13 05:43:37 +00:00
Chris Lattner
8610d2de02 wrap to 80 cols, many fixes to markup.
llvm-svn: 44985
2007-12-13 05:42:27 +00:00
Ted Kremenek
3a742d280c For uninitialized values analysis, added special treatment for declarations
of array types.  For things like:

  char x[10];
  
we should treat "x" as being initialized, because the variable "x" really
refers to the memory block of the array. Clearly x[1] is uninitialized, but
expressions like "(char*) x" really do refer to an initialized value. This
simple dataflow analysis does not reason about the contents of arrays.

This fixes: PR 1859 (http://llvm.org/bugs/show_bug.cgi?id=1859)

llvm-svn: 44984
2007-12-13 05:14:22 +00:00
Chris Lattner
2fe0dd09b3 Fix file header.
llvm-svn: 44983
2007-12-13 05:02:35 +00:00
Ted Kremenek
78dcda6059 Fixed bug in live-variable analysis and uninitialized-values analysis where
we incorrectly examine the expression within a sizeof() for use in computing
dataflow values.

This fixes: PR 1858 (http://llvm.org/bugs/show_bug.cgi?id=1858)

llvm-svn: 44982
2007-12-13 04:47:15 +00:00
Evan Cheng
37c36ed79a Be extra careful with extension use optimation. Now turned on by default.
llvm-svn: 44981
2007-12-13 03:32:53 +00:00
Nate Begeman
23ffde507f Apply CBE/MSIL patch to autoconf
llvm-svn: 44980
2007-12-13 02:24:45 +00:00
Nate Begeman
938d8cb8d9 Add install-libs target which only installs libraries, not tools
llvm-svn: 44979
2007-12-13 02:17:17 +00:00
Chris Lattner
52a6f82d0f use new interface.
llvm-svn: 44978
2007-12-13 02:05:09 +00:00
Zhou Sheng
461d8419a7 Remove this testcase as it will always fail on
platform like Darwin.

llvm-svn: 44977
2007-12-13 02:03:57 +00:00
Chris Lattner
67671ed4b7 add a helper method.
llvm-svn: 44976
2007-12-13 01:59:49 +00:00
Devang Patel
527048247b Add assert to detect incomplete implementation work.
llvm-svn: 44974
2007-12-13 01:24:16 +00:00
Nate Begeman
272ee458cf Do not build CBackend and MSIL regardless of configured targets
llvm-svn: 44973
2007-12-13 01:18:52 +00:00
Fariborz Jahanian
885890a47a Moved ObjcDeclQualifier to ParmVarDecl from VarDecl.
Ted, this change necessitates (de)/serialization of ParmVarDecl.

llvm-svn: 44972
2007-12-13 00:54:18 +00:00
Evan Cheng
827d30db19 Fold some and + shift in x86 addressing mode.
llvm-svn: 44970
2007-12-13 00:43:27 +00:00
Evan Cheng
687567bca5 Oops. Forgot these.
llvm-svn: 44969
2007-12-13 00:42:35 +00:00
Chris Lattner
70efff25be builtin id 0 is invalid, don't use a slot for it.
llvm-svn: 44968
2007-12-13 00:38:03 +00:00
Ted Kremenek
ce8d55b087 Implemented -serialize-ast option for the driver. This is not really tested
and is a work in progress.

llvm-svn: 44967
2007-12-13 00:37:31 +00:00
Fariborz Jahanian
56637d127f Fixed test to match the new diagnostic text.
llvm-svn: 44966
2007-12-13 00:16:34 +00:00
Chris Lattner
f0fbf077d2 Fix for edge profiling, patch by 'Marc' for PR1857
llvm-svn: 44965
2007-12-13 00:04:46 +00:00
Fariborz Jahanian
4d1288a67e Concatenation of objc strings.
llvm-svn: 44964
2007-12-12 23:55:49 +00:00
Chris Lattner
b8bd2db8b3 fix off-by-one error.
llvm-svn: 44963
2007-12-12 23:46:36 +00:00
Ted Kremenek
8fdd3d95eb Implemented prototype mode where the driver can operate on serialized ASTs
instead of source files.

llvm-svn: 44962
2007-12-12 23:41:08 +00:00
Evan Cheng
7df585d9c4 Cosmetic change.
llvm-svn: 44961
2007-12-12 23:15:59 +00:00
Evan Cheng
6e68381e02 Implicit def instructions, e.g. X86::IMPLICIT_DEF_GR32, are always re-materializable and they should not be spilled.
llvm-svn: 44960
2007-12-12 23:12:09 +00:00
Duncan Sands
fde556745b Remove host endianness info from TargetData and
put it in a new header System/Host.h instead.
Instead of getting the endianness from configure,
calculate it directly.

llvm-svn: 44959
2007-12-12 23:03:45 +00:00
Ted Kremenek
1daa3cfbae TargetInfo no longer includes a reference to SourceManager.
Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation.
Added many utility methods to FullSourceLoc to provide shorthand for:

    FullLoc.getManager().someMethod(FullLoc.getLocation());
    
instead we have:

    FullLoc.someMethod();
    
Modified TextDiagnostics (and related classes) to use this short-hand.

llvm-svn: 44957
2007-12-12 22:39:36 +00:00
Steve Naroff
f44cb63859 Encode enumeral types.
llvm-svn: 44956
2007-12-12 22:30:11 +00:00
Dan Gohman
015982aa32 Remove a forward-declaration for a non-existant class.
llvm-svn: 44955
2007-12-12 22:25:09 +00:00
Dan Gohman
7a7742c2fe Allow vector integer constants to be created with
SelectionDAG::getConstant, in the same way as vector floating-point
constants. This allows the legalize expansion code for @llvm.ctpop and
friends to be usable with vector types.

llvm-svn: 44954
2007-12-12 22:21:26 +00:00
Ted Kremenek
9b7632eef8 Removed "NULL" from default construction of FullSourceLoc (compilation errors on
some systems).

llvm-svn: 44953
2007-12-12 19:39:40 +00:00
Anton Korobeynikov
7ab71379b6 Use vector for child storage instead of map. This will also make
our life during future GraphTraits'ing slightly easier.

llvm-svn: 44952
2007-12-12 19:08:44 +00:00
Ted Kremenek
f82942d04c constified getFullLoc().
llvm-svn: 44951
2007-12-12 18:55:29 +00:00
Ted Kremenek
febe89a6da Changes to FullSourceLoc:
- Added cstor that takes no arguments to create an "invalid" location.
  - Removed non-const version of getSourceManager().
  - Renamed getSourceManager() to getManager.
  - Remover operator SourceLocatio().

llvm-svn: 44950
2007-12-12 18:54:21 +00:00
Ted Kremenek
50d23f007f Renamed getFullSourceLoc() -> getFullLoc().
llvm-svn: 44949
2007-12-12 18:46:37 +00:00
Ted Kremenek
d8bcfe27cc Added method: Preprocessor::getFullSourceLoc. Used by clients of Preprocessor
to get a FullSourceLoc from a SourceLocation.

llvm-svn: 44948
2007-12-12 18:41:40 +00:00
Ted Kremenek
23e2085701 Renamed FullContextSourceLocation to FullSourceLoc.
llvm-svn: 44947
2007-12-12 18:32:04 +00:00
Ted Kremenek
8d03cf953b Added utility static method to FullContextSourceLocation
for creating "invalid" location objects.

llvm-svn: 44946
2007-12-12 18:20:34 +00:00
Chris Lattner
83021e92ba make it a bit more clear in what way the ivar is consistent.
llvm-svn: 44945
2007-12-12 18:19:52 +00:00
Chris Lattner
85332c7534 add an ivar_size() method that never returns -1.
llvm-svn: 44944
2007-12-12 18:19:33 +00:00
Ted Kremenek
ea6999a1a5 Constified a predicate method.
llvm-svn: 44943
2007-12-12 18:18:05 +00:00
Ted Kremenek
fd5e5c4704 Added class FullContextSourceLocation: a tuple class that
contains both a SourceLocation and its associated
SourceManager. This class is useful for argument passing to
functions that expect both objects.

llvm-svn: 44942
2007-12-12 18:16:46 +00:00
Chris Lattner
0f29d98419 simplify some code, bump j. This fixes the remaining test failures.
llvm-svn: 44941
2007-12-12 18:11:49 +00:00
Ted Kremenek
6f6ff37b04 Moved construction of TargetInfo objects out of the Driver
and into the "Basic" library. TargetInfo objects are now
constructed from triples by calling the static method
TargetInfo::CreateTargetInfo.

llvm-svn: 44940
2007-12-12 18:05:32 +00:00
Chris Lattner
dd2bffdd0b handle the -1'ness of undefined lists
llvm-svn: 44939
2007-12-12 18:02:31 +00:00
Chris Lattner
061227aa59 unbreak the build. I'm still working on test failures.
llvm-svn: 44938
2007-12-12 17:58:05 +00:00
Duncan Sands
9ab0943b86 Revert r44626, which turned off the use of readonly
and readnone for functions with bodies because it
broke llvm-gcc-4.2 bootstrap.  It turns out that,
because of LLVM's array_ref hack, gcc was computing
pure/const attributes wrong (now fixed by turning
off the gcc ipa-pure-const pass).

llvm-svn: 44937
2007-12-12 16:01:40 +00:00
Wojciech Matyjewicz
309e5a723b 1. "Upgrage" comments.
2. Using zero-extended value of Scale and unsigned division is safe provided
   that Scale doesn't have the sign bit set.
   Previously these 2 instructions:
        %p = bitcast [100 x {i8,i8,i8}]* %x to i8*
        %q = getelementptr i8* %p, i32 -4
   were combined into:
        %q = getelementptr [100 x { i8, i8, i8 }]* %x, i32 0,
               i32 1431655764, i32 0
   what was incorrect.

llvm-svn: 44936
2007-12-12 15:21:32 +00:00
Christopher Lamb
17c405d29e Regenerate.
llvm-svn: 44934
2007-12-12 08:45:45 +00:00
Christopher Lamb
25f5076612 Implement part of review feedback for address spaces.
llvm-svn: 44933
2007-12-12 08:44:39 +00:00
Chris Lattner
7354e6a50e fix typo
llvm-svn: 44932
2007-12-12 08:17:45 +00:00
Chris Lattner
30d23e8289 more cleanups changing things like getInstanceVariables to iterators.
llvm-svn: 44930
2007-12-12 07:56:42 +00:00
Evan Cheng
0f42730722 Use shuffles to implement insert_vector_elt for i32, i64, f32, and f64.
llvm-svn: 44929
2007-12-12 07:55:34 +00:00
Evan Cheng
0a1254f634 Add a test case for -optimize-ext-uses.
llvm-svn: 44928
2007-12-12 07:54:08 +00:00
Chris Lattner
31bc07e6cf resolve some fixmes and clean up some code by eliminating the get*Vars apis to some classes and use iterators instead.
llvm-svn: 44927
2007-12-12 07:46:12 +00:00
Chris Lattner
854f3167c0 start cleaning up interfaces for objc bits and pieces by switching to an
iterator interface.

llvm-svn: 44926
2007-12-12 07:30:05 +00:00
Chris Lattner
da463fe7c1 split objc pieces of SemaDecl.cpp out into SemaDeclObjC.cpp
llvm-svn: 44925
2007-12-12 07:09:47 +00:00
Ted Kremenek
433a492f53 Added back VisitDeclStmt() to the StmtDumper, essentially reverting r44920:
http://llvm.org/viewvc/llvm-project?rev=44920&view=rev

Putting VisitDeclStmt() was motivated because it called DumpDeclarator(),
which printed out a little bit more information than just using the
child_iterator interface to visit the subexpressions of DeclStmt. To avoid
printing the initializers twice, DumpSubTree() now specially checks for
DeclStmts; in such cases it calls VisitDeclStmt() without using the
child_iterators to visit the subexpressions.

llvm-svn: 44924
2007-12-12 06:59:42 +00:00
Chris Lattner
61511e12e0 move function to a more logical location, add its grammar productions.
llvm-svn: 44923
2007-12-12 06:56:32 +00:00
Chris Lattner
074f325746 remove todo
llvm-svn: 44922
2007-12-12 06:54:22 +00:00
Evan Cheng
2a98956796 Lower a build_vector with all constants into a constpool load unless it can be done with a move to low part.
llvm-svn: 44921
2007-12-12 06:45:40 +00:00
Ted Kremenek
ee1a988bf6 Removed VisitDeclStmt(). The initializers of a DeclStmt are now automatically
printed out by DumpSubTree() via the child_iterator interface. This fixes a
bug where the initializers were being dumped twice.

llvm-svn: 44920
2007-12-12 06:44:12 +00:00
Chris Lattner
6d513f37c9 Unbreak -stats on cocoa.h
llvm-svn: 44919
2007-12-12 06:43:05 +00:00
Chris Lattner
b011825453 add run lines.
llvm-svn: 44918
2007-12-12 06:22:14 +00:00
Chris Lattner
58c8be81bb add run line
llvm-svn: 44917
2007-12-12 06:20:40 +00:00
Chris Lattner
2fbe8e98c4 add runline, make this test real.
llvm-svn: 44916
2007-12-12 06:20:18 +00:00
Chris Lattner
e01fc281c3 verify that tests contain RUN lines.
llvm-svn: 44915
2007-12-12 06:19:22 +00:00
Zhou Sheng
3115ba39e8 Add a guard to cxxabi header as other platform may
not support it.

llvm-svn: 44914
2007-12-12 06:16:47 +00:00
Chris Lattner
840e05ba11 simplify some code.
llvm-svn: 44913
2007-12-12 06:13:27 +00:00
Chris Lattner
5c11c41203 implement correct semantic analysis for shifts. For:
int test(int x, long long y) {
  return x << y;
}

we now realize the type of the shift is int, not long long.

This fixes a fixme from june.

llvm-svn: 44912
2007-12-12 05:47:28 +00:00
Chris Lattner
2d39e07112 Simplify some code, don't force the triple to a darwin triple if non-darwin.
llvm-svn: 44911
2007-12-12 05:01:48 +00:00
Zhou Sheng
ed5d693d67 Fixed PR1629.
Make lli interpreter correctly call external functions sin()/cos(),
__cxa_guard_acquire() and __cxa_guard_release().

llvm-svn: 44910
2007-12-12 04:55:43 +00:00
Chris Lattner
b8877d9c6d typo reported by Gabor Greif
llvm-svn: 44909
2007-12-12 04:22:37 +00:00
Chris Lattner
c6208a72f7 Fix a codegen crash on test/CodeGen/cast.c, reported by Keith.
llvm-svn: 44908
2007-12-12 04:13:20 +00:00
Chris Lattner
b3ba3d9827 Fix a bug in my previous patch, thanks to Jay Foad for
pointing this out and correcting the patch!

llvm-svn: 44907
2007-12-12 03:56:54 +00:00
Chris Lattner
4ebd7c2c19 fix typo pointed out by gordon
llvm-svn: 44906
2007-12-12 03:33:41 +00:00
Evan Cheng
63d33cfd2b Don't muck with phi nodes; bug fixes.
llvm-svn: 44905
2007-12-12 02:53:41 +00:00
Scott Michel
4a8bc7e105 Correct typo for Linux: s/esp/%rsp/
llvm-svn: 44904
2007-12-12 02:38:28 +00:00
Bill Wendling
bf85dd4f61 Bit masks conflicted. Needed to bump them by one.
llvm-svn: 44903
2007-12-12 01:51:58 +00:00
Owen Anderson
499e5bffcf Forgot to remove a register from the PHI-union after I'd determined that it
interfered with other registers.  Seems like that might be a good thing to do. :-)

llvm-svn: 44902
2007-12-12 01:25:08 +00:00
Chris Lattner
47fbe949c4 fix expected errors.
llvm-svn: 44901
2007-12-12 01:15:04 +00:00
Fariborz Jahanian
27c15cca19 Add -pedantic so test passes.
llvm-svn: 44900
2007-12-12 01:06:09 +00:00
Gordon Henriksen
0a68fe2ffc Add (very basic) bindings for ModuleProvider.
llvm-svn: 44899
2007-12-12 01:04:30 +00:00
Chris Lattner
e002fbea56 Add ObjC parser support for concatenated ObjC strings. Note that
this is passed to sema and ignored there, so the second part of the
string will not make it into the AST.  Passing to Fariborz to finish
Sema + AST construction.

llvm-svn: 44898
2007-12-12 01:04:12 +00:00
Fariborz Jahanian
c98d956778 Implemented type checking for pointer of objects of protocol-qualified types.
Note that incompatible-protocol-qualified-types.m is currently failing. This is
unrelated to this patch and Steve is looking at the general problem of not reporting
incompitible pointer types in return stetement..

llvm-svn: 44897
2007-12-12 01:00:23 +00:00
Evan Cheng
7bc8942532 Bug fix. Only safe to perform extension uses optimization if the source of extension is also defined in the same BB as the extension.
llvm-svn: 44896
2007-12-12 00:51:06 +00:00
Daniel Berlin
0af43a1895 Changes from Curtis Dunham implementing lazy cycle detection algorithm.
Changes from me implementing different way of representing points-to anything.
Changes from me that improve slightly on LCD.

llvm-svn: 44895
2007-12-12 00:37:04 +00:00
Evan Cheng
6766d2fa4f If deleting a reload instruction due to reuse (value is available in register R and reload is targeting R), make sure to invalidate the kill information of the last kill.
llvm-svn: 44894
2007-12-11 23:36:57 +00:00
Ted Kremenek
fc095b1669 Moved creation of SourceManager, HeaderSearch, TargetInfo, and LangOptions
into the loop that processes input files. These will soon become translation
unit specific (with the exception of LangOptions).

llvm-svn: 44893
2007-12-11 23:28:38 +00:00
Bill Wendling
38236ef6cb Need to grow the indexed map. Added debug statements.
llvm-svn: 44892
2007-12-11 23:27:51 +00:00
Chris Lattner
f641255a86 simplify code now that isConstantExpr really does always
return a loc.

llvm-svn: 44890
2007-12-11 23:15:04 +00:00
Chris Lattner
255e1323f3 Fix a case where we'd return "is not a constant expr" without
return a location.

llvm-svn: 44889
2007-12-11 23:11:17 +00:00
Fariborz Jahanian
16e703ade5 80-column please.
llvm-svn: 44888
2007-12-11 23:04:08 +00:00
Ted Kremenek
89fbadd3be Modified the internals of Diagnostic and DiagnosticClient to use
SourceManager*'s instead of SourceManager&'s. This allows the client specify a
NULL SourceManager when using a default constructed SourceLocation. Thus the
SourceManager can be NULL when the SourceLocation's isValid() == false.

The interface to most clients of Diagnostic remains the same.
Diagnostic::Report() is overload to either accept a SourceLocation and a
SourceManager&, or neither. Thus clients that do not have a SourceManager
cannot specify a SourceLocation.

Modified TextDiagnostics* to use this new interface.
Modified the driver to not passed in SourceManager when warning about "-I-".

llvm-svn: 44887
2007-12-11 22:57:35 +00:00
Fariborz Jahanian
4e56ed5fab Implemented rewriting of protocol-qualified global variable types.
Re-implemented some of rewriting of protocol-qualified function 
argument types to support it in its generality.

llvm-svn: 44886
2007-12-11 22:50:14 +00:00
Chris Lattner
3487a3009b gcc supports more targets.
llvm-svn: 44885
2007-12-11 22:32:45 +00:00
Chris Lattner
95f80da9fb update pch discussion
llvm-svn: 44884
2007-12-11 22:29:38 +00:00
Chris Lattner
a6b103a3c3 improve title
llvm-svn: 44883
2007-12-11 22:26:03 +00:00
Chris Lattner
6931189378 add a con of clang vs gcc
llvm-svn: 44882
2007-12-11 22:22:59 +00:00
Bill Wendling
642e15a7cb Simplify slightly.
llvm-svn: 44881
2007-12-11 22:22:22 +00:00
Anton Korobeynikov
7f01ebefc6 Remove Trie::Edge class. Now edge labels are stored into nodes itself.
llvm-svn: 44880
2007-12-11 21:55:38 +00:00
Devang Patel
b37b12d102 Match union field type when member expression is u->x
llvm-svn: 44879
2007-12-11 21:33:16 +00:00
Ted Kremenek
d4e5fbacab Mega-patch: ripped SourceManager out of Diagnostic/DiagnosticClient. Now
SourceManager is passed by reference, allowing the SourceManager to be
associated with a specific translation unit, and not the entire execution
of the driver.

Modified all users of Diagnostics to comply with this new interface.

Integrated SourceManager as a member variable of TargetInfo. TargetInfo will
eventually be associated with a single translation unit (just like
SourceManager).

Made the SourceManager reference in ASTContext private. Provided accessor
getSourceManager() for clients to use instead. Modified clients to comply with
new interface.

llvm-svn: 44878
2007-12-11 21:27:55 +00:00
Owen Anderson
f24dd1c1eb More progress on StrongPHIElimination. Now we actually USE the DomForest!
llvm-svn: 44877
2007-12-11 20:12:11 +00:00
Fariborz Jahanian
c86ee9ce90 Refactor Rewritetest::RewriteObjcQualifiedInterfaceTypes in preparation for more
general use.

llvm-svn: 44876
2007-12-11 19:56:36 +00:00
Devang Patel
e3f9fa6322 Refactor bit-field handling code into a separate method.
No functionality change.

llvm-svn: 44875
2007-12-11 19:51:39 +00:00
Bill Wendling
b678ae7c38 Blark! How in the world did this work without this?!
llvm-svn: 44874
2007-12-11 19:40:06 +00:00
Bill Wendling
7717a8a37d - Update the virtual reg to machine instruction map when hoisting.
- Fix subtle bug when creating initially creating this map.

llvm-svn: 44873
2007-12-11 19:17:04 +00:00
Fariborz Jahanian
3b5dca2533 For @optional unimplemented methods do not issue the warning.
llvm-svn: 44872
2007-12-11 19:10:26 +00:00
Bill Wendling
5143d898c8 Checking for "zero operands" during the "CanHoistInst()" method isn't necessary
because those with side effects will be caught by other checks in here.

Also, simplify the check for a BB in a sub loop.

llvm-svn: 44871
2007-12-11 18:45:11 +00:00
Fariborz Jahanian
251a943ce9 Fixed a parsing bug whereby @optional/@required keyword is not followed by
a method declaration.

llvm-svn: 44870
2007-12-11 18:34:51 +00:00
Nate Begeman
6dc8b4ed13 Allow the JIT to encode MMX instructions
llvm-svn: 44869
2007-12-11 18:06:14 +00:00
Wojciech Matyjewicz
5bf9f01349 Use correct member access operator.
(my test commit as well)

llvm-svn: 44868
2007-12-11 17:46:25 +00:00
Dan Gohman
5e1f8472d2 Rename these tests to use the appropriate suffixes.
llvm-svn: 44867
2007-12-11 15:55:52 +00:00
Dan Gohman
b582867567 Use not instead of ignore when an exit status is expected to always
be non-zero.

llvm-svn: 44866
2007-12-11 15:50:23 +00:00
Dan Gohman
cfed707c12 Don't redirect stderr when it isn't needed.
llvm-svn: 44865
2007-12-11 15:41:11 +00:00
Duncan Sands
f41217d4fa Fix compilation.
llvm-svn: 44864
2007-12-11 12:20:47 +00:00
Christopher Lamb
595798f041 Update credits.
llvm-svn: 44861
2007-12-11 09:32:07 +00:00
Christopher Lamb
308121c757 Add information on address space qualifiers for pointer types and global
declarations to the LangRef.

llvm-svn: 44860
2007-12-11 09:31:00 +00:00
Christopher Lamb
e92cba4535 Regenerate.
llvm-svn: 44859
2007-12-11 09:02:08 +00:00
Christopher Lamb
54dd24c2a7 Implement address space attribute for LLVM pointer types. Address spaces are
regions of memory that have a target specific relationship, as described in the 
Embedded C Technical Report. 

This also implements the 2007-12-11-AddressSpaces test, 
which demonstrates how address space attributes can be used in LLVM IR.

In addition, this patch changes the bitcode signature for stores (in a backwards 
compatible manner), such that the pointer type, rather than the pointee type, is 
encoded. This permits type information in the pointer (e.g. address space) to be 
preserved for stores.

LangRef updates are forthcoming.

llvm-svn: 44858
2007-12-11 08:59:05 +00:00
Chris Lattner
8975f49065 mention pork
llvm-svn: 44857
2007-12-11 07:59:50 +00:00
Chris Lattner
8e6a8f984c Teach VMCore to constant fold shufflevectors with constant operands.
This allows us to compile:

#include <emmintrin.h>
typedef __m128i VSInt16;
typedef short vSInt16 __attribute__ ((__vector_size__ (16)));
VSInt16 t3() {
  return (VSInt16)((vSInt16)_mm_set1_epi16(6518));
}

into:

_t3:
	movaps	LCPI1_0, %xmm0
	ret

instead of:
_t3:
	movl	$6518, %eax
	movd	%eax, %xmm0
	pextrw	$0, %xmm0, %eax
	xorps	%xmm0, %xmm0
	pinsrw	$0, %eax, %xmm0
	punpcklwd	%xmm0, %xmm0
	pshufd	$0, %xmm0, %xmm0
	ret

llvm-svn: 44856
2007-12-11 07:49:37 +00:00
Chris Lattner
6a6b3fb62b Implement constant folding if vector<->vector bitcasts where the number
of source/dest elements changes.  This implements
test/Transforms/InstCombine/bitcast-vector-fold.ll

llvm-svn: 44855
2007-12-11 07:29:44 +00:00
Reid Spencer
0b1df1d3da Don't have APInt.cpp depend upon DerivedTypes.h. This helps with splitting the
Support libraries separately into their own module.

llvm-svn: 44852
2007-12-11 06:53:58 +00:00
Anton Korobeynikov
3d23737c5f Add first and really dirty version of generic Trie structure
llvm-svn: 44851
2007-12-11 06:53:44 +00:00
Chris Lattner
5c6399eee6 significantly simplify some code, no functionality change.
llvm-svn: 44850
2007-12-11 06:07:39 +00:00
Chris Lattner
e8ea0374ac refactor some code, no functionality change.
llvm-svn: 44849
2007-12-11 05:55:02 +00:00
Chris Lattner
29a16af8de properly namespacify.
llvm-svn: 44845
2007-12-11 04:36:28 +00:00
Chris Lattner
63ba2c06c4 fix a build issue with non-apple-gcc-4.0 compilers.
llvm-svn: 44844
2007-12-11 04:33:00 +00:00
Steve Naroff
5cace62e66 Avoid the first person in a recently added comment.
llvm-svn: 44843
2007-12-11 03:38:03 +00:00
Steve Naroff
3f1223cb06 - Tweak several tests to be compatible with my last commit.
- Add a test to message.m for an unusual case for GCC compat (as suggested by Chris).

llvm-svn: 44842
2007-12-11 03:34:41 +00:00
Anders Carlsson
f1c18350e3 Generate more builtins.
llvm-svn: 44841
2007-12-11 03:09:22 +00:00
Steve Naroff
c30dcf1251 Change err_undef_protocolref to warn_undef_protocolref (this is consistent with GCC).
llvm-svn: 44840
2007-12-11 02:44:30 +00:00
Anders Carlsson
eee7566205 Generate code for some more intrinsics.
llvm-svn: 44839
2007-12-11 02:25:54 +00:00
Evan Cheng
303417d242 Switch over to MachineLoopInfo.
llvm-svn: 44838
2007-12-11 02:09:15 +00:00
Evan Cheng
f54030231e Pretty print shuffle mask operand.
llvm-svn: 44837
2007-12-11 02:08:35 +00:00
Evan Cheng
4fbf459549 - Improved v8i16 shuffle lowering. It now uses pshuflw and pshufhw as much as
possible before resorting to pextrw and pinsrw.
- Better codegen for v4i32 shuffles masquerading as v8i16 or v16i8 shuffles.
- Improves (i16 extract_vector_element 0) codegen by recognizing
  (i32 extract_vector_element 0) does not require a pextrw.

llvm-svn: 44836
2007-12-11 01:46:18 +00:00
Nate Begeman
a55a67ae91 x86 doesn't actually want to custom lower v3i32
llvm-svn: 44835
2007-12-11 01:41:33 +00:00
Chris Lattner
11fbda2b5a Reimplement support for strings that initialize global inits now that
the types are right in sema.  Thanks Steve.

llvm-svn: 44834
2007-12-11 01:38:45 +00:00
Devang Patel
7ae82e7305 Separate access field number is not required.
llvm-svn: 44833
2007-12-11 01:23:33 +00:00
Devang Patel
113bd8be70 Beautify comment.
llvm-svn: 44831
2007-12-11 00:54:19 +00:00
Devang Patel
ab6aadb34a Add support to share llvm fields for bit-fields.
For example, struct { char a; short b:2; };

llvm-svn: 44830
2007-12-11 00:49:18 +00:00
Gordon Henriksen
7843c16f31 CollectorMetadata and Collector are rejiggered to get along with
per-function collector model. Collector is now the factory for
CollectorMetadata, so the latter may be subclassed.

llvm-svn: 44827
2007-12-11 00:30:17 +00:00
Gordon Henriksen
a87d72b102 Project file maintenance.
llvm-svn: 44826
2007-12-11 00:29:16 +00:00
Chris Lattner
2945c46e93 Move TargetData::hostIsLittleEndian out of line, which means we
don't have to #include config.h in it.  #including config.h breaks
other projects that have their own autoconf stuff and try to #include
the llvm headers.  One obscure example is llvm-gcc.

llvm-svn: 44825
2007-12-11 00:28:59 +00:00
Gordon Henriksen
2b0eed278b Adding Ocaml bindings for the bitreader as requested by Sarah
Thompson. Usage should be something like this:

open Llvm
open Llvm_bitreader

match read_bitcode_file fn with
  | Bitreader_failure msg ->
      prerr_endline msg
  | Bitreader_success m -> 
      ...;
      dispose_module m

Compile with: ocamlc llvm.cma llvm_bitreader.cma
              ocamlopt llvm.cmxa llvm_bitreader.cmxa

llvm-svn: 44824
2007-12-11 00:20:48 +00:00
Steve Naroff
f727faf2ed Explicitly set the string literal type from "char *" to "constant array of char".
At this point, I am fairly certain the front-end is correct. Unfortunately, the back-end is still unhappy.

That said, I've commented out the two lines in globalinit.c that are causing problems.

Chris, please have a look...thanks!

llvm-svn: 44823
2007-12-11 00:00:01 +00:00
Ted Kremenek
c0870605be Fixed bug in CFG::PopulateBlkExprMap where the ordering
between fetching the size of the expression map (for use as
the next integer id for an Expr*) and the creation of the
entry in the map could be non-deterministic.  This could
cause the size of the map to be incremented prior to the
index being determine.

On Linux the map entry would be created first, causing the
map to the "size" to be incremented prior to it being
queried. On Mac OS X we had the reverse behavior. Now the
size is always queried prior to the new id being inserted
into the map.

This was the real cause of the bit-overrun triggered in
PR 1847:

  http://llvm.org/bugs/show_bug.cgi?id=1847
  
Also reverted the change in patch 44813, which was a bogus
fix to this problem:

  http://llvm.org/viewvc/llvm-project?rev=44813&view=rev

llvm-svn: 44822
2007-12-10 23:58:39 +00:00
Ted Kremenek
f182e81d85 Added missing inclusion of stdarg.h. Now CGExprScalar.cpp
compiles again on Linux.

llvm-svn: 44821
2007-12-10 23:44:32 +00:00
Anton Korobeynikov
21ade5880b Hey, English is not my native language :)
llvm-svn: 44820
2007-12-10 23:10:20 +00:00
Anton Korobeynikov
77eb5e649d Clarify the need of CFI() stuff
llvm-svn: 44819
2007-12-10 23:08:35 +00:00
Anton Korobeynikov
a6b0f7e244 Provide convenient way to disable CFI stuff for old/broken assemblers.
Use it for Darwin.

llvm-svn: 44818
2007-12-10 23:04:38 +00:00
Chris Lattner
d2265b45ae Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use
targetdata to validate that it is safe.  While I'm in there, fix some const
correctness issues and generalize the interface to the "operand folder".

llvm-svn: 44817
2007-12-10 22:53:04 +00:00
Steve Naroff
91f78080e3 Add support for initializing char arrays from string literals.
Adapted from a patch by Anders Carlsson.

llvm-svn: 44816
2007-12-10 22:44:33 +00:00
Ted Kremenek
9a698a1da7 Added two bounds checks to the BitVector class to detect
out-of-bounds bit accesses.  The checks are only performed
in a Debug build.

llvm-svn: 44815
2007-12-10 22:28:35 +00:00
Chris Lattner
ea9ac34d18 split isBinaryOp into a static and member version.
llvm-svn: 44814
2007-12-10 22:18:53 +00:00
Ted Kremenek
b4785e3054 Fixed off-by-one-error when resizing Bitvectors used for
dataflow analysis over expressions and decls.

This should fix bug 1847:

http://llvm.org/bugs/show_bug.cgi?id=1847

Thanks to Török Edwin for providing a test case that
identified the problem.

llvm-svn: 44813
2007-12-10 22:01:22 +00:00
John Criswell
fa06f0203b Fix some wording.
llvm-svn: 44810
2007-12-10 20:26:29 +00:00
Chris Lattner
433fb26707 add support for implicit cast from array to pointer that is not the element
type.

llvm-svn: 44809
2007-12-10 19:50:32 +00:00
Anders Carlsson
d0113e4be3 Revert change that broke the build.
llvm-svn: 44808
2007-12-10 19:46:20 +00:00
Chris Lattner
e665077f9a disable case that makes this fail.
llvm-svn: 44807
2007-12-10 19:44:50 +00:00
Anders Carlsson
b9eb82c3ee Add EmitShuffleVector helper method.
llvm-svn: 44806
2007-12-10 19:35:18 +00:00
Chuck Rose III
900a13e82c Add StringPool + new CodeGen files to win32 build
llvm-svn: 44805
2007-12-10 19:31:09 +00:00
Anders Carlsson
dc16e8f299 Address comments from Chris.
llvm-svn: 44804
2007-12-10 19:30:18 +00:00
Chris Lattner
8a72a7d586 Disable cfi directives for now, darwin does't support them.
These should probably be something like:

  CFI(".cfi_def_cfa_offset 16\n")

where CFI is defined to a noop on darwin and other platforms
that don't support those directives.

llvm-svn: 44803
2007-12-10 19:10:18 +00:00
Duncan Sands
9f76be61d1 Make PruneEH update the nounwind/noreturn attributes
on functions as it calculates them.

llvm-svn: 44802
2007-12-10 19:09:40 +00:00
Chris Lattner
456078d50d minor edits.
llvm-svn: 44801
2007-12-10 18:56:37 +00:00
Devang Patel
b3ae8d7dc2 Add assert to flag incomplete bit-field support.
llvm-svn: 44800
2007-12-10 18:52:06 +00:00
Devang Patel
3c31b54b47 Use getABITypeSizeInBits() instead of getTypeSizeInBits() during struct layout.
llvm-svn: 44799
2007-12-10 18:37:40 +00:00
Devang Patel
bb5c0d8960 Use getABITypeSizeInBits() instead of getTypeSizeInBits() during struct layout.
llvm-svn: 44798
2007-12-10 18:25:34 +00:00
Ted Kremenek
256a15d532 Added newline to end of file.
llvm-svn: 44797
2007-12-10 18:01:25 +00:00
Duncan Sands
5c65cb4633 Fix PR1836: in the interpreter, read and write apints
using the minimum possible number of bytes.  For little
endian targets run on little endian machines, apints are
stored in memory from LSB to MSB as before.  For big endian
targets on big endian machines they are stored from MSB to
LSB which wasn't always the case before (if the target and
host endianness doesn't match values are stored according
to the host's endianness).  Doing this requires knowing the
endianness of the host, which is determined when configuring -
thanks go to Anton for this.  Only having access to little
endian machines I was unable to properly test the big endian
part, which is also the most complicated...

llvm-svn: 44796
2007-12-10 17:43:13 +00:00
Chris Lattner
80c54698e8 be more clear about what we are comparing.
llvm-svn: 44795
2007-12-10 17:38:50 +00:00
Anton Korobeynikov
657be86229 And finally annotate X86-64 version of callback.
All bad stuff from SSE version is implicitely inherited :)

llvm-svn: 44794
2007-12-10 15:27:07 +00:00
Anton Korobeynikov
88e9d082d8 Provide annotation for SSE version of callback. It's even more
broken, because doesn't mark xmm regs properly

llvm-svn: 44793
2007-12-10 15:13:55 +00:00
Anton Korobeynikov
81e9dc4af7 Annotate JIT callback function with call frame infromation.
This will allow us (theoretically) to unwind through JITer.
The code wasn't verified, so I'm pretty sure offsets are wrong :)

llvm-svn: 44792
2007-12-10 14:54:42 +00:00
Duncan Sands
81b25817f9 It looks like this has been broken for some time -
get it to compile.

llvm-svn: 44791
2007-12-10 14:43:10 +00:00
Anders Carlsson
1b9853a9f8 Forgot this file.
llvm-svn: 44790
2007-12-10 08:48:18 +00:00
Chris Lattner
c3307e2418 fixes, thanks to Nico Weber
llvm-svn: 44789
2007-12-10 08:21:12 +00:00
Chris Lattner
428760a6e6 clean up the TOC.
llvm-svn: 44788
2007-12-10 08:19:29 +00:00
Chris Lattner
e396aaae28 finish the features description.
llvm-svn: 44787
2007-12-10 08:12:49 +00:00
Owen Anderson
ba61806ef1 A little more progress on StrongPHIElimination, now that I have a better sense of
how the CodeGen machinery works.

llvm-svn: 44786
2007-12-10 08:07:09 +00:00
Christopher Lamb
d202e03fe5 Improve branch folding by recgonizing that explict successor relationships impact the value of fall-through choices.
llvm-svn: 44785
2007-12-10 07:24:06 +00:00
Chris Lattner
b6a8cfea24 now with hackability.
llvm-svn: 44784
2007-12-10 07:23:52 +00:00
Chris Lattner
aa085d36e2 reorganize features, expound on a couple more.
llvm-svn: 44783
2007-12-10 07:14:08 +00:00
Chris Lattner
e404df76c0 incorporate suggestions from Joel Nelson.
llvm-svn: 44782
2007-12-10 06:01:32 +00:00
Chris Lattner
f572f3364d start making features be a more detailed description of the features/goals section on the main page.
llvm-svn: 44781
2007-12-10 05:52:05 +00:00
Chris Lattner
27a2709cfb add toc
llvm-svn: 44780
2007-12-10 05:23:01 +00:00
Chris Lattner
b072569682 don't duplicate goals on the features page.
llvm-svn: 44779
2007-12-10 05:20:47 +00:00
Chris Lattner
ab44e15ce7 update status
llvm-svn: 44778
2007-12-10 05:11:40 +00:00
Chris Lattner
fdfd014270 edits, switch the goals/why section.
llvm-svn: 44777
2007-12-10 05:10:14 +00:00
Chris Lattner
5a7359c8c2 minor edits
llvm-svn: 44776
2007-12-10 05:06:15 +00:00
Gordon Henriksen
4b904b9627 Delete the CollectorNamePool if it should become empty.
llvm-svn: 44775
2007-12-10 03:35:18 +00:00
Gordon Henriksen
dc5cafb74e Fix a typo spotted by Nick Lewycky.
llvm-svn: 44774
2007-12-10 03:30:21 +00:00
Gordon Henriksen
71183b6739 Adding a collector name attribute to Function in the IR. These
methods are new to Function:

  bool hasCollector() const;
  const std::string &getCollector() const;
  void setCollector(const std::string &);
  void clearCollector();

The assembly representation is as such:

  define void @f() gc "shadow-stack" { ...

The implementation uses an on-the-side table to map Functions to 
collector names, such that there is no overhead. A StringPool is 
further used to unique collector names, which are extremely
likely to be unique per process.

llvm-svn: 44769
2007-12-10 03:18:06 +00:00
Chris Lattner
e31cd5b564 add link to comparison page.
llvm-svn: 44763
2007-12-10 02:25:51 +00:00
Chris Lattner
609f9ccb2c Be more positive! Add to sidebar.
llvm-svn: 44762
2007-12-10 02:24:44 +00:00
Chris Lattner
10ebf4dcb1 updates.
llvm-svn: 44761
2007-12-10 02:18:15 +00:00
Gordon Henriksen
14a5569f4e Reverting dtor devirtualization patch.
_sabre_: it has a major problem: by the time ~Value is run, all of the "parts" of the derived classes have been destroyed
_sabre_: the vtable lives to fight another day

llvm-svn: 44760
2007-12-10 02:14:30 +00:00
Chris Lattner
3fbe73bef2 minor edits
llvm-svn: 44759
2007-12-10 02:05:32 +00:00
Chris Lattner
cf7cb4bbdd make more positive.
llvm-svn: 44758
2007-12-10 01:52:24 +00:00
Chris Lattner
12f9855a42 remove some dead code.
llvm-svn: 44757
2007-12-10 01:51:38 +00:00
Chris Lattner
13daba07d9 fix some warnings.
llvm-svn: 44756
2007-12-10 01:51:22 +00:00
Chris Lattner
d05f4ba524 Fix a big problem in the recent dtor refactoring work, now it passes 2007-11-19-InlineAsm.ll
llvm-svn: 44755
2007-12-10 01:48:29 +00:00
Chris Lattner
78eeea2ce9 Add a "comparing clang to other compilers" page, to help resolve some FAQ's.
llvm-svn: 44754
2007-12-10 01:44:24 +00:00
Chris Lattner
7f0ad21480 lots of this is done.
llvm-svn: 44753
2007-12-10 00:14:49 +00:00
Chris Lattner
cb04ac9599 abort when we lower an initializer to the wrong type, as we currently do for:
char text[] = "string";

llvm-svn: 44752
2007-12-10 00:05:55 +00:00
Chris Lattner
686628e052 extend or truncate the initializer for a string initializer to match its type.
llvm-svn: 44751
2007-12-10 00:00:56 +00:00
Chris Lattner
c25c42f3ca Implement codegen support for:
char text[8] = "string";

Big fixme remains.

llvm-svn: 44750
2007-12-09 23:49:42 +00:00
Anders Carlsson
92c4e44da1 Address Chris's comments.
llvm-svn: 44749
2007-12-09 23:39:18 +00:00
Anders Carlsson
895af08562 Move target specific builtin IDs to TargetBuiltins.h so that they can be used by CGBuiltin.cpp
llvm-svn: 44748
2007-12-09 23:17:02 +00:00
Gordon Henriksen
3e5be66ccb Devirtualizing Value destructor (PR889). Patch by Pawel Kunio!
llvm-svn: 44747
2007-12-09 22:46:10 +00:00
Chris Lattner
4d62f42eba Implement correct semantic analysis of subtractions, implementing
C99 6.5.6.

llvm-svn: 44746
2007-12-09 21:53:25 +00:00
Anders Carlsson
8e1d8cf241 Implement __builtin_ia32_mulps.
llvm-svn: 44745
2007-12-09 21:51:19 +00:00
Anders Carlsson
a020c43034 Generate code for target specific intrinsics.
llvm-svn: 44744
2007-12-09 21:20:04 +00:00
Chris Lattner
3ed83c1c0f The flags on tokens indicate whether they are the start of a *physical* line,
not the start of a logical line.  Be careful about this distinction, which 
affects when newlines are printed and when paste-avoidance happens, etc.  
This fixes PR1848, thanks to Neil for noticing this!

llvm-svn: 44743
2007-12-09 21:11:08 +00:00
Chris Lattner
84f450789a Fix a pretty big but subtle bug counting the number of newlines to emit.
This would cause us to emit different code (in -E mode) for these two files:

---
#define t(x) x

t(a
3)
---
#define t(x) x
t(a
3)
---

In one case, -E would print "a\n3", in the other it printed "a3".  Now
it prints "a3" for both.

This is part of PR1848.

llvm-svn: 44742
2007-12-09 20:45:43 +00:00
Chris Lattner
615315f307 Add dumping support for locations, make -dumptokens print out the location
info of each token.

llvm-svn: 44741
2007-12-09 20:31:55 +00:00
Chris Lattner
64443973c0 Duncan points out that the subtraction is unneeded since hte code
knows the vector is not pow2

llvm-svn: 44740
2007-12-09 17:56:34 +00:00
Chris Lattner
93cd101e5c Fix typo noticed by Nico Weber
llvm-svn: 44739
2007-12-09 17:50:14 +00:00
Gordon Henriksen
ad80af9677 Upgrading this test to 2.0 .ll syntax.
llvm-svn: 44738
2007-12-09 15:03:01 +00:00
Chris Lattner
7566350b74 many edits to the main page, add a prominant 'status' section.
llvm-svn: 44737
2007-12-09 09:05:23 +00:00
Chris Lattner
d93d0fc79a unindent, don't zap whitespace before/after paragraphs.
llvm-svn: 44736
2007-12-09 08:40:26 +00:00
Chris Lattner
dffc79530a simplify the menu css, make it a bit more attractive.
llvm-svn: 44735
2007-12-09 08:38:01 +00:00
Chris Lattner
fc3b9bfea8 cleanup some markup, e.g. & -> &amp;
llvm-svn: 44734
2007-12-09 08:17:09 +00:00
Chris Lattner
3f42d12072 Fix PR1782, patch by Wojtek Matyjewicz!
llvm-svn: 44733
2007-12-09 07:35:13 +00:00
Gordon Henriksen
76c5dfd7df Fix a very silly typo.
llvm-svn: 44732
2007-12-09 01:12:08 +00:00
Chris Lattner
9c4aad2dba avoid ///usr/include/foo.h, patch by Sean Middleditch
llvm-svn: 44731
2007-12-09 00:39:55 +00:00
Chris Lattner
283d094b75 implement support for functions that initialize globals.
llvm-svn: 44730
2007-12-09 00:36:01 +00:00
Chris Lattner
ad6094ddd3 Fix accidental commit by Bill.
llvm-svn: 44729
2007-12-09 00:27:38 +00:00
Chris Lattner
69d3298777 Add support for splitting the operand of a return instruction.
llvm-svn: 44728
2007-12-09 00:06:19 +00:00
Bill Wendling
3f19dfe794 Reverting 44702. It wasn't correct to rename them.
llvm-svn: 44727
2007-12-08 23:58:46 +00:00
Chris Lattner
e48fc80446 add many new cases to SplitResult. SplitResult now handles all the cases that LegalizeDAG does.
llvm-svn: 44726
2007-12-08 23:58:27 +00:00
Chris Lattner
de9046af54 Implement splitting support for store, allowing us to compile:
%f8 = type <8 x float>

define void @test_f8(%f8* %P, %f8* %Q, %f8* %S) {
	%p = load %f8* %P		; <%f8> [#uses=1]
	%q = load %f8* %Q		; <%f8> [#uses=1]
	%R = add %f8 %p, %q		; <%f8> [#uses=1]
	store %f8 %R, %f8* %S
	ret void
}

into:

_test_f8:
	movaps	16(%rdi), %xmm0
	addps	16(%rsi), %xmm0
	movaps	(%rdi), %xmm1
	addps	(%rsi), %xmm1
	movaps	%xmm0, 16(%rdx)
	movaps	%xmm1, (%rdx)
	ret

llvm-svn: 44725
2007-12-08 23:24:26 +00:00
Chris Lattner
de87224cd9 implement vector splitting of load, undef, and binops.
llvm-svn: 44724
2007-12-08 23:08:49 +00:00
Chris Lattner
1ef437d4e1 implement some methods.
llvm-svn: 44723
2007-12-08 22:40:18 +00:00
Chris Lattner
a5e7db115e add scaffolding for splitting of vectors.
llvm-svn: 44722
2007-12-08 22:37:41 +00:00
Nate Begeman
b52ad35bc4 Project cleanups
llvm-svn: 44721
2007-12-08 22:29:19 +00:00
Chris Lattner
5c62ba5fb8 Remove dead file and directory.
llvm-svn: 44720
2007-12-08 22:17:33 +00:00
Chris Lattner
8c8eaf6b92 reorganize header to separate into functional blocks.
llvm-svn: 44719
2007-12-08 21:59:32 +00:00
Chris Lattner
4063bd6eae split scalarization out to its own file.
llvm-svn: 44718
2007-12-08 20:30:28 +00:00
Chris Lattner
5c7c46baaf Split expansion out into its own file.
llvm-svn: 44717
2007-12-08 20:27:32 +00:00
Chris Lattner
029c816460 Split promotion support out to its own file.
llvm-svn: 44716
2007-12-08 20:24:38 +00:00
Chris Lattner
757d4beba9 Rename LegalizeDAGTypes.cpp -> LegalizeTypes.cpp
llvm-svn: 44715
2007-12-08 20:17:13 +00:00
Chris Lattner
92288147b6 Split the class definition of DAGTypeLegalizer out into a header.
Leave it visibility hidden, but not in an anon namespace.

llvm-svn: 44714
2007-12-08 20:16:06 +00:00
Gordon Henriksen
e33aec0dd6 Incorporating review feedback from Reid.
llvm-svn: 44713
2007-12-08 20:10:40 +00:00
Anders Carlsson
050f494f66 Add getTargetPrefix to TargetInfo, to be used with target specific intrinsics.
llvm-svn: 44712
2007-12-08 19:32:57 +00:00
Chris Lattner
abef872bc0 remove dead #include.
llvm-svn: 44711
2007-12-08 19:06:21 +00:00
Chris Lattner
d58954b040 add #include
llvm-svn: 44710
2007-12-08 19:03:30 +00:00
Chris Lattner
31e0f1af67 eliminate dependency on Bitcode headers.
llvm-svn: 44709
2007-12-08 19:01:44 +00:00
Chris Lattner
c779e00f17 remove dead #include, APInt.h already has the needed forward decls.
llvm-svn: 44708
2007-12-08 19:00:38 +00:00
Chris Lattner
e5256754e7 proper #include order.
llvm-svn: 44707
2007-12-08 19:00:03 +00:00
Gordon Henriksen
0c428fe3ec Ignoring generated files.
llvm-svn: 44706
2007-12-08 17:53:01 +00:00
Gordon Henriksen
4b41a6f529 Adding a StringPool data structure, which GC will use.
llvm-svn: 44705
2007-12-08 17:07:47 +00:00
Gordon Henriksen
05481d91be Fix bug in constructing Ocaml option types in the bindings.
llvm-svn: 44704
2007-12-08 16:55:43 +00:00
Chris Lattner
ff87f05e43 aesthetic changes, no functionality change. Evan, it's not clear
what 'Available' is, please add a comment near it and rename it
if appropriate.

llvm-svn: 44703
2007-12-08 07:22:58 +00:00
Bill Wendling
2b07d8c5a0 Renaming:
isTriviallyReMaterializable -> hasNoSideEffects
  isReallyTriviallyReMaterializable -> isTriviallyReMaterializable

llvm-svn: 44702
2007-12-08 07:17:56 +00:00
Chris Lattner
f47015bc74 Fix a significant code quality regression I introduced on PPC64 quite
a while ago.  We now produce:

_foo:
	mflr r0
	std r0, 16(r1)
	ld r2, 16(r1)
	std r2, 0(r3)
	ld r0, 16(r1)
	mtlr r0
	blr 

instead of:

_foo:
	mflr r0
	std r0, 16(r1)
	lis r0, 0
	ori r0, r0, 16
	ldx r2, r1, r0
	std r2, 0(r3)
	ld r0, 16(r1)
	mtlr r0
	blr 

for:

void foo(void **X) {
  *X = __builtin_return_address(0);
}

on ppc64.

llvm-svn: 44701
2007-12-08 07:04:58 +00:00
Chris Lattner
f6a8156e4f implement __builtin_return_addr(0) on ppc.
llvm-svn: 44700
2007-12-08 06:59:59 +00:00
Chris Lattner
a6c8297e84 refactor some code to avoid overloading the name 'usesLR' in
different places to mean different things.  Document what the
one in PPCFunctionInfo means and when it is valid.

llvm-svn: 44699
2007-12-08 06:39:11 +00:00
Chris Lattner
1ebfecc8d0 Implement correct isa<UnaryInstruction>, problem reported by "ST".
llvm-svn: 44697
2007-12-08 04:37:52 +00:00
Bill Wendling
4375173ba0 Incorporated comments from Evan and Chris:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071203/056043.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071203/056048.html

llvm-svn: 44696
2007-12-08 01:47:01 +00:00
Owen Anderson
086b2c4537 Fix several cache coherence bugs in MemDep/GVN that were found. Also add some (disabled) debugging code
to make such problems easier to diagnose in the future, written by Duncan Sands.

llvm-svn: 44695
2007-12-08 01:37:09 +00:00
Evan Cheng
92105ac0cd Doh
llvm-svn: 44694
2007-12-08 01:01:07 +00:00
Fariborz Jahanian
8ea0779624 Test case for my last patch for implementation of static protocoled type
used as reciver type of a message expression.

llvm-svn: 44693
2007-12-08 01:00:55 +00:00
Evan Cheng
cd6913627e Fix a compilation warning.
llvm-svn: 44692
2007-12-08 01:00:31 +00:00
Evan Cheng
ab87e735cd Fix a compilation warning.
llvm-svn: 44691
2007-12-08 01:00:21 +00:00
Chuck Rose III
c214d1605f Adding MachineLoopInfo.h,.cpp and MachineLICP.cpp to VStudio build
llvm-svn: 44690
2007-12-08 00:53:13 +00:00
Steve Naroff
1f6ed92dbb Omit the field name when including the super class structure template.
This allows us to access a superclasses ivars without deriving the absolute path.

The comments below say a bit more...

llvm-svn: 44688
2007-12-07 22:15:58 +00:00
Bill Wendling
fb706bc52b Initial commit of the machine code LICM pass. It successfully hoists this:
_foo:
        li r2, 0
LBB1_1: ; bb
        li r5, 0
        stw r5, 0(r3)
        addi r2, r2, 1
        addi r3, r3, 4
        cmplw cr0, r2, r4
        bne cr0, LBB1_1 ; bb
LBB1_2: ; return
        blr 

to:

_foo:
        li r2, 0
        li r5, 0
LBB1_1: ; bb
        stw r5, 0(r3)
        addi r2, r2, 1
        addi r3, r3, 4
        cmplw cr0, r2, r4
        bne cr0, LBB1_1 ; bb
LBB1_2: ; return
        blr

ZOMG!! :-)

Moar to come...

llvm-svn: 44687
2007-12-07 21:42:31 +00:00
Evan Cheng
b41d838d28 Add comment.
llvm-svn: 44686
2007-12-07 21:30:01 +00:00
Fariborz Jahanian
ff6a455c12 Implemented when static typing is combined with protocols and use as receiver
type.

llvm-svn: 44685
2007-12-07 21:21:21 +00:00
Steve Naroff
2c20c38ced Have Sema::CheckConstantInitList skip semantic analysis when the element type is a record (until we implement the FIXME). This removes a bogus error for the following code...
snarofflocal% cat bug.m

#import <Foundation/NSGeometry.h>

#define NUMHELICOPTERRECTS 5

static NSRect helicopterRects[NUMHELICOPTERRECTS] = {
    {{27, 0}, {18, 11}},	// Bottom
    {{0, 8}, {4, 11}},		// Tail
    {{0, 16}, {50, 1}},
    {{22, 5}, {18, 12}},	// Body
    {{0, 10}, {42, 3}}
};

llvm-svn: 44684
2007-12-07 21:12:53 +00:00
Steve Naroff
888f33cc44 Lookup methods in the global pool even when a statically typed object's class interface isn't in scope!
As the comment in the code indicates, I'm not fond of this. Nevertheless, gcc compat is a goal.

Here is the case I'm talking about...

#import <Foundation/Foundation.h>

@interface AnyClass : NSObject
- (NSRect)rect;
@end

@class Helicopter;

static void func(Helicopter *obj) {
  NSRect r = [obj rect];
}

...before this patch, we would warn/error. With this patch, everything "just works".

llvm-svn: 44682
2007-12-07 20:41:14 +00:00
Fariborz Jahanian
33c0e815f3 Patch for rewriting of @protocol.
llvm-svn: 44681
2007-12-07 18:47:10 +00:00
Evan Cheng
bfd373a53e Much improved v8i16 shuffles. (Step 1).
llvm-svn: 44676
2007-12-07 08:07:39 +00:00
Owen Anderson
b1d4fda856 Fix a stupid error that Chris pointed out.
llvm-svn: 44674
2007-12-07 04:04:55 +00:00
Steve Naroff
b2f8ff153d Rewrite 'super' within a class method. This required some minor tweaks to the front-end.
llvm-svn: 44673
2007-12-07 03:50:46 +00:00
Evan Cheng
26593a04db New test case.
llvm-svn: 44672
2007-12-07 01:48:46 +00:00
Evan Cheng
85cdba29b0 Add an option to control this heuristic tweak so I can test it.
llvm-svn: 44671
2007-12-07 00:28:32 +00:00
Fariborz Jahanian
2bbd03a755 Patch to implement "Protocol" as a built-in type declared as
"@class Protocol;"

llvm-svn: 44670
2007-12-07 00:18:54 +00:00
Evan Cheng
c829e5cdf0 Remove a bogus optimization. It's not possible to do a move to low element to a <8 x i16> or <16 x i8> vector.
llvm-svn: 44669
2007-12-06 22:14:22 +00:00
Evan Cheng
5cb41390ab Fix a bogus test case.
llvm-svn: 44668
2007-12-06 22:12:45 +00:00
Anders Carlsson
10c6110fca Add workaround to get test/Parser/compound_literal.c working again.
llvm-svn: 44666
2007-12-06 20:10:20 +00:00
Fariborz Jahanian
227c0d13bc On Steve's suggestion, moved handling of use of undeclared method in a message
to rewriter (my previous patch).

llvm-svn: 44665
2007-12-06 19:49:56 +00:00
Devang Patel
65a2288eef More struct bitfields layout work. Now handle,
struct STestB1 {char a; char b:2; } stb1;
struct STestB2 {char a; char b:5; char c:4} stb2;

llvm-svn: 44664
2007-12-06 19:16:05 +00:00
Dale Johannesen
5eff4de9c8 Redo previous patch so optimization only done for i1.
Simpler and safer.

llvm-svn: 44663
2007-12-06 17:53:31 +00:00
Fariborz Jahanian
6b644a6e05 test case for my very last patch.
llvm-svn: 44662
2007-12-06 17:43:04 +00:00
Chris Lattner
b36a98e9a3 Fix a bug handling typedefs of functions, patch by Nuno Lopes!
llvm-svn: 44661
2007-12-06 17:20:20 +00:00
Evan Cheng
8393dc7378 Turning simple splitting on. Start testing new coalescer heuristics as new llcbeta.
llvm-svn: 44660
2007-12-06 08:54:31 +00:00
Chris Lattner
eedaf92fcf third time around: instead of disabling this completely,
only disable it if we don't know it will be obviously profitable.
Still fixme, but less so. :)

llvm-svn: 44658
2007-12-06 07:47:55 +00:00
Chris Lattner
b5fdfb9612 Actually, disable this code for now. More analysis and improvements to
the X86 backend are needed before this should be enabled by default.

llvm-svn: 44657
2007-12-06 07:44:31 +00:00
Chris Lattner
7c709a5d08 implement a readme entry, compiling the code into:
_foo:
	movl	$12, %eax
	andl	4(%esp), %eax
	movl	_array(%eax), %eax
	ret

instead of:

_foo:
	movl	4(%esp), %eax
	shrl	$2, %eax
	andl	$3, %eax
	movl	_array(,%eax,4), %eax
	ret

As it turns out, this triggers all the time, in a wide variety of
situations, for example, I see diffs like this in various programs:

-       movl    8(%eax), %eax
-       shll    $2, %eax
-       andl    $1020, %eax
-       movl    (%esi,%eax), %eax
+       movzbl  8(%eax), %eax
+       movl    (%esi,%eax,4), %eax


-       shll    $2, %edx
-       andl    $1020, %edx
-       movl    (%edi,%edx), %edx
+       andl    $255, %edx
+       movl    (%edi,%edx,4), %edx

Unfortunately, I also see stuff like this, which can be fixed in the
X86 backend:

-       andl    $85, %ebx
-       addl    _bit_count(,%ebx,4), %ebp
+       shll    $2, %ebx
+       andl    $340, %ebx
+       addl    _bit_count(%ebx), %ebp

llvm-svn: 44656
2007-12-06 07:33:36 +00:00
Chris Lattner
d2bbbabbfb simplify some code.
llvm-svn: 44655
2007-12-06 06:25:04 +00:00
Chris Lattner
42558bf664 implement the rest of the functionality from SelectionDAGLegalize::ScalarizeVectorOp
llvm-svn: 44654
2007-12-06 05:53:43 +00:00
Chris Lattner
9bc22b4838 make it more clear what 'foo' is
llvm-svn: 44653
2007-12-06 04:20:07 +00:00
Chuck Rose III
cc2a661322 Adjust VStudio files to add JITMemoryManager files + include <cassert> from same.
llvm-svn: 44651
2007-12-06 02:03:01 +00:00
Chris Lattner
0ccb663cca move some ashr-specific code out of commonShiftTransforms into visitAShr.
llvm-svn: 44650
2007-12-06 01:59:46 +00:00
Dale Johannesen
05bbbda78a Fix PR1842.
llvm-svn: 44649
2007-12-06 01:43:46 +00:00
Fariborz Jahanian
c277f6f351 A missing method in a messaging expression issues a warning, clients must not
crash because of this.

llvm-svn: 44648
2007-12-06 01:37:55 +00:00
Chris Lattner
7f3587e344 add a new ExecutionEngine::createJIT which can be used if you only want
to create a JIT.  This lets you specify JIT-specific configuration items
like the JITMemoryManager to use.

llvm-svn: 44647
2007-12-06 01:34:04 +00:00
Chris Lattner
dc351b94f9 simplify creation of the interpreter, make ExecutionEngine ctor protected,
delete one ExecutionEngine ctor, minor cleanup.

llvm-svn: 44646
2007-12-06 01:08:09 +00:00
Chris Lattner
dfa39289a5 fix this when run on non x86 hosts.
llvm-svn: 44645
2007-12-06 01:05:52 +00:00
Evan Cheng
7fc1d98353 Fix for PR1831: if all defs of an interval are re-materializable, then it's a preferred spill candiate.
llvm-svn: 44644
2007-12-06 00:01:56 +00:00
Evan Cheng
d3d8017bcb If both result of the {s|z}xt and its source are live out, rewrite all uses of the source with result of extension.
llvm-svn: 44643
2007-12-05 23:58:20 +00:00
Ted Kremenek
260d01d6e6 Subdivided the function InitializeBaseLanguage into InitializeBaseLanguage,
GetLanguage, and InitializeLangOptions.  The goal is to break up this logic
into atomic units of functionality that can later be refactored into better
driver logic that is capable of handling a mixture of source files of
different languages.

llvm-svn: 44642
2007-12-05 23:49:08 +00:00
Chris Lattner
6a04fcb2f4 improve header guard
llvm-svn: 44641
2007-12-05 23:45:41 +00:00
Chris Lattner
55d8c3f71b split the JIT memory management code out from the main JIT logic into its
own JITMemoryManager interface.  There is no functionality change with 
this patch.

llvm-svn: 44640
2007-12-05 23:39:57 +00:00
Chris Lattner
2ed8f31f2f Avoid passing Diags into InitializeIncludePaths.
llvm-svn: 44639
2007-12-05 23:24:17 +00:00
Chris Lattner
5e224c32f4 add a note
llvm-svn: 44638
2007-12-05 23:05:06 +00:00
Chris Lattner
ad05e17491 add a note
llvm-svn: 44637
2007-12-05 22:58:19 +00:00
Steve Naroff
152dd812b2 Make sure Parser::ParseObjCSelectorExpression() handles unary selectors (with no arguments) properly.
llvm-svn: 44636
2007-12-05 22:21:29 +00:00
Ted Kremenek
cdcf6dcbcb Removed dependence on including iostream (use llvm/Support/Streams.h instead).
llvm-svn: 44635
2007-12-05 22:21:13 +00:00
Ted Kremenek
e095881856 Converted SerializationTest (--test-pickling) to use the new TranslationUnit
class to serialize and deserialize translation units.

llvm-svn: 44634
2007-12-05 22:08:43 +00:00
Steve Naroff
ff9f8efe4d Make sure the class methods get attached to the metaclass object.
Need to query the implementation, not the interface...

llvm-svn: 44633
2007-12-05 21:49:40 +00:00
Ted Kremenek
68d232b477 Added Driver/TranslationUnit.h and Driver/TranslationUnit.cpp to the
XCode project.

llvm-svn: 44632
2007-12-05 21:36:57 +00:00
Ted Kremenek
62f4302ec7 Added "TranslationUnit" class that will be used to provide an interface
for serializing/deserializing ASTs that is decoupled from the logic
in SerializationTest (which will soon be rewritten to use this interface).

llvm-svn: 44631
2007-12-05 21:36:08 +00:00
Ted Kremenek
dd1a7aade5 Modified: CreateTargetInfo(). Now takes Diagnostic* instead of Diagnostic&.
Modified: ctor of SerializationTest: Now takes LangOptions argument.  We
          will eventually serialize this as well.

llvm-svn: 44630
2007-12-05 21:34:36 +00:00
Bill Wendling
dc71f08586 Alphabetizing; I want to be the last in the file!!!! ;-)
llvm-svn: 44629
2007-12-05 21:26:54 +00:00
Scott Michel
7c56a522af Regenerated configure after autoconf/configure.ac change.
llvm-svn: 44628
2007-12-05 21:24:02 +00:00
Scott Michel
83d54c9ee0 Minor updates:
- Fix typo in SPUCallingConv.td
- Credit myself for CellSPU work
- Add CellSPU to 'all' host target list

llvm-svn: 44627
2007-12-05 21:23:16 +00:00
Duncan Sands
abba5e218c Commit 44487 broke bootstrap of llvm-gcc-4.2. It is
not yet clear why, but in the meantime work around the
problem by making less use of readnone/readonly info.

llvm-svn: 44626
2007-12-05 21:03:28 +00:00
Ted Kremenek
2968476c2d Added Basic/LangOptions.cpp to XCode project.
llvm-svn: 44625
2007-12-05 19:07:32 +00:00
Ted Kremenek
ae492c4f0c Implemented serialization of LangOptions.
llvm-svn: 44624
2007-12-05 19:06:15 +00:00
Evan Cheng
3b8a674469 Added canFoldMemoryOperand for PPC.
llvm-svn: 44623
2007-12-05 18:41:29 +00:00
Chris Lattner
36021a9cc1 I'm apparently the only sad lonely ppc user left :)
llvm-svn: 44622
2007-12-05 18:41:05 +00:00
Evan Cheng
8492bdeaa4 Update foldMemoryOperand.
llvm-svn: 44621
2007-12-05 18:36:37 +00:00
Chris Lattner
de9bfcf67a fix warnings
llvm-svn: 44620
2007-12-05 18:32:18 +00:00
Chris Lattner
8292519705 allow this to build
llvm-svn: 44619
2007-12-05 18:30:11 +00:00
Ted Kremenek
a4c13bd94b Moved creation of ASTConsumers that can operate on both freshly-parsed and
deserialized ASTs into the function CreateASTConsumer().  This function
is called by ProcessInputFile, and soon the logic that processes deserialized
ASTs.

llvm-svn: 44618
2007-12-05 18:27:04 +00:00
Fariborz Jahanian
b31a2f2a47 Patch to prevent crash on use of objc2 syntax.
llvm-svn: 44617
2007-12-05 18:16:33 +00:00
Fariborz Jahanian
d5db92ba97 Changed type-cast of "struct objc_super"'s 2nd initializer to match definition of
"struct objc_super".

llvm-svn: 44616
2007-12-05 17:29:46 +00:00
Chris Lattner
6eed001371 fix some bogus code noticed by Kevin Andre
llvm-svn: 44615
2007-12-05 17:21:34 +00:00
Neil Booth
06f20ea4ba Prior commit updated wrong if, apologies.
llvm-svn: 44614
2007-12-05 13:06:04 +00:00
Neil Booth
3ab004bca6 Handle zero correctly.
llvm-svn: 44613
2007-12-05 13:01:24 +00:00
Evan Cheng
678b86d6ce MachineInstr can change. Store indexes instead.
llvm-svn: 44612
2007-12-05 10:24:35 +00:00
Evan Cheng
06353b48b5 If a split live interval is spilled again, remove the kill marker on its last use.
llvm-svn: 44611
2007-12-05 09:51:10 +00:00
Evan Cheng
64b3baaaea Clobber more bugs.
llvm-svn: 44610
2007-12-05 09:05:34 +00:00
Evan Cheng
d7de56ac93 Fix kill info for split intervals.
llvm-svn: 44609
2007-12-05 08:16:32 +00:00
Chris Lattner
c9693c60a5 more scalarization
llvm-svn: 44608
2007-12-05 07:45:02 +00:00
Chris Lattner
1a0d49a63c scalarize vector binops
llvm-svn: 44607
2007-12-05 07:36:58 +00:00
Anders Carlsson
a297e7a888 Implement CodeGen for vectors. Don't create unnecessary conversion instructions if the value to be converted is a constant.
llvm-svn: 44606
2007-12-05 07:36:10 +00:00
Anders Carlsson
2c1ec6d5f7 Add sema checking for compound literal expressions.
llvm-svn: 44605
2007-12-05 07:24:19 +00:00
Anders Carlsson
e8ee04c0bc Implement codegen for builtin infinity functions.
llvm-svn: 44604
2007-12-05 07:22:48 +00:00
Anders Carlsson
cbdb6f5b5d Revert DidWarn change - It won't catch all cases anyway and GCC warns for every excess element. Maybe later we can add back the limit and make it smarter.
llvm-svn: 44603
2007-12-05 04:57:06 +00:00
Steve Naroff
2644aaf537 Recognize CompoundLiteralExpr's as valid lvalue's.
Also updated a FIXME in Sema::CheckInitializer()...

llvm-svn: 44602
2007-12-05 04:00:10 +00:00
Evan Cheng
269dbd31d0 - Mark last use of a split interval as kill instead of letting spiller track it.
This allows an important optimization to be re-enabled.
- If all uses / defs of a split interval can be folded, give the interval a
  low spill weight so it would not be picked in case spilling is needed (avoid
  pushing other intervals in the same BB to be spilled).

llvm-svn: 44601
2007-12-05 03:22:34 +00:00
Evan Cheng
bb26301864 Add a argument to storeRegToStackSlot and storeRegToAddr to specify whether
the stored register is killed.

llvm-svn: 44600
2007-12-05 03:14:33 +00:00
Scott Michel
d766e5d7c2 fixed header attribution
llvm-svn: 44599
2007-12-05 02:08:01 +00:00
Scott Michel
4834955fdf More stuff for CellSPU -- this should be enough to get an error-free
compilation (no files missing). Test cases remain to be checked in.

llvm-svn: 44598
2007-12-05 02:01:41 +00:00
Scott Michel
d1b5b9f68c Updated source file headers to llvm coding standard.
llvm-svn: 44597
2007-12-05 01:40:25 +00:00
Scott Michel
8d35728607 Two missing files.
llvm-svn: 44596
2007-12-05 01:31:18 +00:00
Scott Michel
eff980208a Main CellSPU backend files checked in. Intrinsics and autoconf files
remain.

llvm-svn: 44595
2007-12-05 01:24:05 +00:00
Dale Johannesen
9d43e3d841 Handle 0 correctly in string->APFloat conversion.
llvm-svn: 44594
2007-12-05 01:10:19 +00:00
Ted Kremenek
90a7c12bb4 Implemented serialization of: ObjCEncodeExpr, ObjCSelectorExpr.
llvm-svn: 44593
2007-12-05 00:43:08 +00:00
Ted Kremenek
166e505d27 Added serialization support of SourceManager to the clang driver.
llvm-svn: 44592
2007-12-05 00:26:13 +00:00
Ted Kremenek
e634142388 Renamed SourceManager::Read to SourceManager::CreateAndRegister.
Now sourcemanager deserializer automatically self-registers itself with
the deserializer.

llvm-svn: 44591
2007-12-05 00:19:51 +00:00
Ted Kremenek
57f4c00241 Implemented initial serialization support for SourceManager.
llvm-svn: 44590
2007-12-05 00:14:18 +00:00
Ted Kremenek
ca0cb926f4 Added "Emitter" functor to allow easy emitting of elements of a container
using std::for_each.

llvm-svn: 44589
2007-12-05 00:13:07 +00:00
Steve Naroff
0317aeb4b6 Add the definition of objc_super...
llvm-svn: 44588
2007-12-04 23:59:30 +00:00
Evan Cheng
e412a4427b Remove a unsafe optimization. This fixes 401.bzip2.
llvm-svn: 44587
2007-12-04 23:57:55 +00:00
Devang Patel
e9d786e54d Add --with-llvmgcc= and --with-llvmgxx= configure options.
llvm-svn: 44586
2007-12-04 22:54:47 +00:00
Ted Kremenek
6ca076cb7a Removed serialization of FileEntry and DirectoryEntry. This objects will
now be lazily recreated upon deserialization.

llvm-svn: 44585
2007-12-04 22:42:20 +00:00
Scott Michel
dfe09ed085 More files in the CellSPU drop...
llvm-svn: 44584
2007-12-04 22:35:58 +00:00
Fariborz Jahanian
1e34ce1045 Type-cast initializers for "struct objc_super" parameter to avoid warning.
llvm-svn: 44583
2007-12-04 22:32:58 +00:00
Scott Michel
6e22c651d1 More of the Cell SPU code drop from "Team Aerospace".
llvm-svn: 44582
2007-12-04 22:23:35 +00:00
Fariborz Jahanian
22c278a216 Test case for my last patch.
llvm-svn: 44581
2007-12-04 21:48:54 +00:00
Fariborz Jahanian
31e1850694 Don't assert if objc.h not declared when rewriting.
llvm-svn: 44580
2007-12-04 21:47:40 +00:00
Ted Kremenek
c638952f59 Implemented serialization of SrcMgr::ContentCache.
llvm-svn: 44578
2007-12-04 19:39:02 +00:00
Fariborz Jahanian
f256b48bc7 Removed a "TODO" comment as objc1 runtime does not need to do the "TODO".
llvm-svn: 44577
2007-12-04 19:31:56 +00:00
Fariborz Jahanian
1f606a999e Simplified setting up Method's scope before generating AST for its nody.
llvm-svn: 44576
2007-12-04 19:20:11 +00:00
Evan Cheng
cd8a89b3cd Spiller unfold optimization bug: do not clobber a reusable stack slot value unless it can be modified.
llvm-svn: 44575
2007-12-04 19:19:45 +00:00
Ted Kremenek
c6593c2c2e Fixed a few more comments to change "FileInfo" to "ContentCache."
llvm-svn: 44574
2007-12-04 18:59:28 +00:00
Ted Kremenek
f7260b191c Implemented serialization of FileEntry and DirectoryEntry.
llvm-svn: 44573
2007-12-04 18:21:35 +00:00
Ted Kremenek
0c2bea2909 Removed searching for "darwin" keyword in target triple. We don't really support
any alternative targets at this point other than "darwin," so we now default to
Darwin targets (for now).

llvm-svn: 44572
2007-12-04 17:07:35 +00:00
Ted Kremenek
bce8b49973 Removed IntrusiveSPtr. There are no clients of this class anymore, so it is
not needed, and it was never extensively tested.  If we need an intrusive
reference-counting smart pointer, we can always import intrusive_ptr from
boost.

llvm-svn: 44571
2007-12-04 16:54:09 +00:00
Chris Lattner
b892225fb9 Implement framework for scalarizing node results. This is sufficient
to codegen this:

define float @test_extract_elt(<1 x float> * %P) {
	%p = load <1 x float>* %P
	%R = extractelement <1 x float> %p, i32 0
	ret float %R
}

llvm-svn: 44570
2007-12-04 07:48:46 +00:00
Chris Lattner
681c9d6697 start providing framework for scalarizing vectors.
llvm-svn: 44569
2007-12-04 07:29:51 +00:00
Ted Kremenek
c8f444ff80 Implemented serialization of ObjCStringLiteral.
llvm-svn: 44568
2007-12-04 00:51:11 +00:00
Ted Kremenek
b8714c8ef1 Implemented serialization for ObjcAtThrowStmt.
llvm-svn: 44567
2007-12-04 00:40:49 +00:00
Ted Kremenek
98b3a71537 Implemented serialization of ObjcAtTryStmt.
llvm-svn: 44566
2007-12-04 00:38:30 +00:00
Evan Cheng
d1badb960e Discard split intervals made empty due to folding.
llvm-svn: 44565
2007-12-04 00:32:23 +00:00
Ted Kremenek
ee695a3456 Implemented serialization for ObjcAtFinallyStmt.
llvm-svn: 44564
2007-12-04 00:32:22 +00:00
Ted Kremenek
0bf3e33dcc Implemented serialization for ObjcAtCatchStmt.
llvm-svn: 44563
2007-12-04 00:28:54 +00:00
Ted Kremenek
9c26202c76 Fixed order of operands to strstr call.
llvm-svn: 44561
2007-12-03 23:25:59 +00:00
Ted Kremenek
eead4052e9 For target processing, on non-Darwin systems instead of using the host triple,
we default to "i386-apple-darwin".  This is an interim solution.

Removed processing of "linux" triples from Targets.cpp, since we don't have
any sensical Linux target support (yet).

Cleaned up error processing of targets; added better diagnostics.

llvm-svn: 44560
2007-12-03 23:23:21 +00:00
Scott Michel
d821fe741e More CellSPU files... more to follow.
llvm-svn: 44559
2007-12-03 23:14:43 +00:00
Scott Michel
c7bd8d9cb0 Makefile fragment for CellSPU.
llvm-svn: 44558
2007-12-03 23:12:49 +00:00
Scott Michel
256e9abbb9 First commit to CellSPU. More to follow
llvm-svn: 44557
2007-12-03 23:09:49 +00:00
Fariborz Jahanian
68c06b2d2c Change <Objc/objc.h> to <objc/objc.h>
llvm-svn: 44556
2007-12-03 23:04:29 +00:00
Ted Kremenek
8e3a2a93aa Implemented serialization of TargetInfo.
SerializationTest (subclass of ASTConsumer) now takes Diagnostics& in its ctor.

llvm-svn: 44555
2007-12-03 22:48:14 +00:00
Ted Kremenek
8cdc08ea49 Added some notes on the -triple and -arch options.
llvm-svn: 44554
2007-12-03 22:26:16 +00:00
Fariborz Jahanian
d0d2bd5089 Fixed a bug exposed by referencing an ivar field using component reference syntax.
llvm-svn: 44553
2007-12-03 22:25:42 +00:00
Ted Kremenek
68fcff9bfa Few cleanups to patch 44551:
http://llvm.org/viewvc/llvm-project?view=rev&revision=44551

Removed debugging fprintfs for printing targets.
Implemented error messages when processing invalid targets.

llvm-svn: 44552
2007-12-03 22:11:31 +00:00
Ted Kremenek
b061554caa Implemented initial support for "-triple" option to the clang driver. This
replaces the functionality previously provided by just "-arch" (which is still
supported but has different semantics).

The new behavior is as follows:

(1) If the user does not specify -triple:

   (a) If no -arch options are specified, the target triple used is the host
   triple (in llvm/Config/config.h).
   
   (b) If one or more -arch's are specified (and no -triple), then there is
       one triple for each -arch, where the specified arch is substituted
       for the arch in the host triple.  Example:
          host triple = i686-apple-darwin9
          command: clang  -arch ppc -arch ppc64 ...
          triples used: ppc-apple-darwin9  ppc64-apple-darwin9
          
(2) The user does specify a -triple (only one allowed):

  (a) If no -arch options are specified, the triple specified by -triple
      is used.  E.g clang -triple i686-apple-darwin9
      
  (b) If one or more -arch options are specified, then the triple specified
      by -triple is used as the primary target, and the arch's specified
      by -arch are used to create secondary targets.  For example:
      
      clang -triple i686-apple-darwin9 -arch ppc -arch ppc64
      
      has the following targets:
         i686-apple-darwin9  (primary target)
         ppc-apple-darwin9
         ppc64-apple-darwin9


Other changes related to the changes to the driver:

- TargetInfoImpl now includes the triple string.

- TargetInfo::getTargetTriple returns the triple for its primary target.

- test case test/Parser/portability.c has been updated because "-arch linux" is
  no longer valid ("linux" is an OS, not an arch); instead we use a bogus
  architecture "bogusW16W16" where WCharWidth=16 and WCharAlign=16.

llvm-svn: 44551
2007-12-03 22:06:55 +00:00
Chris Lattner
e5a91b4924 Fix an ast-print/ast-dump bug.
llvm-svn: 44550
2007-12-03 21:43:25 +00:00
Evan Cheng
40965448ff Bug fixes.
llvm-svn: 44549
2007-12-03 21:31:55 +00:00
Fariborz Jahanian
4f76f22975 Support for rewriteing of messaging of methods which return float.
llvm-svn: 44548
2007-12-03 21:26:48 +00:00
Gordon Henriksen
363b02003b Track dependencies when creating symlinks to LLVM libraries next
to the ocaml bindings. This is required on Windows where 'ln -sf'
actually creates a copy. Thanks to Alain Frisch for noticing this.

llvm-svn: 44547
2007-12-03 21:15:53 +00:00
Anton Korobeynikov
3ddfbf36e9 Regenerate
llvm-svn: 44546
2007-12-03 21:01:29 +00:00
Anton Korobeynikov
a638f11cd2 Fix fallout from my last patch: don't reject varargs functions :)
llvm-svn: 44545
2007-12-03 21:00:45 +00:00
Duncan Sands
38ef3a8ec7 Rather than having special rules like "intrinsics cannot
throw exceptions", just mark intrinsics with the nounwind
attribute.  Likewise, mark intrinsics as readnone/readonly
and get rid of special aliasing logic (which didn't use
anything more than this anyway).

llvm-svn: 44544
2007-12-03 20:06:50 +00:00
Chris Lattner
19970e62e7 update file comment.
llvm-svn: 44543
2007-12-03 19:43:18 +00:00
John Criswell
9c9405f4ef Fixed typo.
llvm-svn: 44542
2007-12-03 19:34:25 +00:00
Anton Korobeynikov
c09b265410 Regenerate
llvm-svn: 44541
2007-12-03 19:17:47 +00:00
Fariborz Jahanian
9e7b848ac8 Added support for messagings which return a structure-value.
(Also fixed a regression caused by recent changes to synthesis of structs).

llvm-svn: 44540
2007-12-03 19:17:29 +00:00
Devang Patel
bd75910fa7 If ExitValue operand is also defined in Loop header then
insert new ExitValue after this operand definition.

This fixes PR1828.

llvm-svn: 44539
2007-12-03 19:17:21 +00:00
Anton Korobeynikov
d62b10dc93 More sanity checks for function types.
Thanks goes to PyPy folks for generating broken stuff :)

llvm-svn: 44538
2007-12-03 19:16:54 +00:00
Chris Lattner
b39e02bcc2 Describe the notion of 'owners' of the code.
llvm-svn: 44537
2007-12-03 19:00:47 +00:00
Ted Kremenek
d85026d925 Added getTrueExpr() and getFalseExpr() to ConditionalOperator. These methods
provide handy accessors to the subexpressions of ConditionalOperator that
automatically take into account the GCC extension where the "LHS" expression is
omitted: e.g x ?: y;. When the LHS expression is available, getTrueExpr() is the
same as getLHS(); when LHS is NULL, getTrueExpr() returns the condition expression.

llvm-svn: 44536
2007-12-03 17:09:21 +00:00
Gordon Henriksen
4814cd2271 Applying Anton's binmode fix to the other ofstream too.
llvm-svn: 44535
2007-12-03 14:50:37 +00:00
Anton Korobeynikov
bf96d99383 Sorry, typo :)
llvm-svn: 44534
2007-12-03 14:35:57 +00:00
Anton Korobeynikov
7c5442b0e3 Open output file correctly. This is extremely important for
windows-based hosts, where files are opened in text mode by default.

llvm-svn: 44533
2007-12-03 14:28:26 +00:00
Evan Cheng
196faa9dc5 Typo
llvm-svn: 44532
2007-12-03 10:00:00 +00:00
Evan Cheng
85ef9834a6 Update kill info for uses of split intervals.
llvm-svn: 44531
2007-12-03 09:58:48 +00:00
Bill Wendling
db4e34984b Fix for testcase that assigns a dereferenced reference to a pointer. The
standard says that we should adjust the "reference to T" type to "T"
before analysis.

llvm-svn: 44530
2007-12-03 07:33:35 +00:00
Seo Sanghyeon
3d072bea09 Ignore typedefs in pointer arithmetic codegen.
llvm-svn: 44529
2007-12-03 06:23:43 +00:00
Anton Korobeynikov
9050bd1f68 Provide hook for _alloca to make JITing on Cygwin slightly happier :)
llvm-svn: 44528
2007-12-03 05:30:41 +00:00
Nick Lewycky
9746782cea lli -trace was removed back in 2003.
llvm-svn: 44527
2007-12-03 01:58:01 +00:00
Nick Lewycky
d93847a96a Type::IntTy hasn't existed for a while. Just sub in Type::Int32Ty.
llvm-svn: 44526
2007-12-03 01:52:52 +00:00
Anders Carlsson
5dd106b212 Handle initializing vector elements correctly. Emit just one warning if there are excess initializers, instead of one per initializer.
llvm-svn: 44525
2007-12-03 01:01:28 +00:00
Chris Lattner
4b6d965611 explain what I need to grant commit access.
llvm-svn: 44524
2007-12-03 00:36:20 +00:00
Chris Lattner
6e4f047422 add a fixme
llvm-svn: 44523
2007-12-02 23:05:46 +00:00
Chris Lattner
b4ef023bf6 fix typo noticed by Joshua Pennington
llvm-svn: 44522
2007-12-02 22:46:01 +00:00
Anders Carlsson
ef93b9d011 Implement __builtin_bswap32 and __builtin_bswap64.
llvm-svn: 44521
2007-12-02 21:58:10 +00:00
Chris Lattner
4e4186b2de fix logic for member expr codegen.
llvm-svn: 44520
2007-12-02 18:52:07 +00:00
Seo Sanghyeon
828429fea9 Fix isStructureType and isUnionType to ignore typedefs, as stated
in the header. Patch by Cédric Venet.

llvm-svn: 44519
2007-12-02 16:57:27 +00:00
Christopher Lamb
0cbd8723f3 Treat discarding array initializer elements as an extwarn (so -pedantic-errors flags it). Allow CodeGen to truncate the initializer if needed.
llvm-svn: 44518
2007-12-02 08:49:54 +00:00
Evan Cheng
f45a1d623c Remove redundant foldMemoryOperand variants and other code clean up.
llvm-svn: 44517
2007-12-02 08:30:39 +00:00
Chris Lattner
310369fb84 restore these lines, which fixes some regtest failures.
llvm-svn: 44516
2007-12-02 07:50:03 +00:00
Chris Lattner
6311b58000 all filevar's have static storage. Previously a global with
extern storage class was returning false from hasStaticStorage.
Ted, please review this.

llvm-svn: 44515
2007-12-02 07:47:49 +00:00
Christopher Lamb
39aeb4069b Commit test for CL 44440.
llvm-svn: 44514
2007-12-02 07:47:19 +00:00
Chris Lattner
e4f0feb534 Fix buggy test
llvm-svn: 44513
2007-12-02 07:46:00 +00:00
Chris Lattner
0475c8178f globals can't be vla's
llvm-svn: 44512
2007-12-02 07:32:25 +00:00
Chris Lattner
d8d18d561e add codegen support for global inits that require array decay.
llvm-svn: 44511
2007-12-02 07:30:13 +00:00
Chris Lattner
d45aa2a03b warn about unhandled initializers instead of crashing on them.
llvm-svn: 44510
2007-12-02 07:19:18 +00:00
Chris Lattner
5bcdf24a50 Handle global variable definitions which change the type of a definition, such as:
extern int x[];
void foo() { x[0] = 1; }
int x[10];
void bar() { x[0] = 1; }

llvm-svn: 44509
2007-12-02 07:09:19 +00:00
Chris Lattner
c48023bd5b remove the alloca insertion point inst, which is an internal helper.
llvm-svn: 44508
2007-12-02 06:32:24 +00:00
Chris Lattner
6d27513f6e merge the llvm global variable when there are multiple C decls.
llvm-svn: 44507
2007-12-02 06:30:46 +00:00
Chris Lattner
41af8182d8 implement codegen for functions whose function body type don't match
their prototype.

llvm-svn: 44506
2007-12-02 06:27:33 +00:00
Chris Lattner
c5b3aab66b merge functions with multiple function decls if they have the same name.
llvm-svn: 44505
2007-12-02 05:56:05 +00:00
Chris Lattner
e15d0dd63f Teach clang the prototype for __builtin_alloca.
llvm-svn: 44504
2007-12-02 05:42:36 +00:00
Chris Lattner
f0780fae43 convert the rest of the stderr users in codegen to use diagnostics.
llvm-svn: 44503
2007-12-02 01:49:16 +00:00
Chris Lattner
fc94434faf move unsupported warning into a centralized place.
llvm-svn: 44502
2007-12-02 01:43:38 +00:00
Chris Lattner
c8dbe1e5d6 Warn about unsupported codegen with the diags machinery, giving us:
t.c:3322:5: warning: cannot codegen this yet
    __asm__ ("bswap   %0" : "+r" (_data));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

instead of:

Unimplemented stmt!
(AsmStmt 0x80eaa0 <t.c:3331:5, line:3334:28>)

llvm-svn: 44501
2007-12-02 01:40:18 +00:00
Chris Lattner
963540dc28 register clz and ctz builtins.
llvm-svn: 44500
2007-12-02 01:20:23 +00:00
Chris Lattner
f3a59a1fb8 fix a crash when the rewriter would scan off the beginning of the file.
llvm-svn: 44499
2007-12-02 01:13:47 +00:00
Chris Lattner
e6535cfdd2 add support for custom client-specific diagnostics. As a testcase, make the
rewriter emit this error if it fails to rewrite an @encode:

t.m:17:9: error: rewriter could not replace sub-expression due to macros
    c = ENC(char *)[2] + 4;
        ^~~~~~~~~~~

... where ENC is: #define ENC @encode

llvm-svn: 44498
2007-12-02 01:09:57 +00:00
Oliver Hunt
a96fe8d5c5 Add support for __builtin_expect which is needed for assert,
among other things.

Also change a codegen warning to dump to stderr so it doesn't
mess with -emit-llvm output

llvm-svn: 44497
2007-12-02 01:03:24 +00:00
Chris Lattner
9724ce12f9 improve VC++ compatibility, patch by Cédric Venet.
llvm-svn: 44496
2007-12-02 00:47:03 +00:00
Oliver Hunt
aefc8fd415 Support initalisers for more than just int-typed static variables.
We now use the CodeGenModule logic for generating the constant 
initialiser expression, so happily further initialiser fixes should 
automatically work for statics as well.

llvm-svn: 44495
2007-12-02 00:11:25 +00:00
Gordon Henriksen
3e41367dd5 Adding ocamldoc-style comments for the Ocaml bindings.
llvm-svn: 44494
2007-12-01 21:01:15 +00:00
Gordon Henriksen
e000c6022f Fix a typo noticed by Alain Frisch.
llvm-svn: 44493
2007-12-01 20:59:23 +00:00
Fariborz Jahanian
9fac54d881 Compute side-effect for conditional expression.
llvm-svn: 44492
2007-12-01 19:58:28 +00:00
Chris Lattner
53efb14795 Add #include, patch by Cédric Venet
llvm-svn: 44491
2007-12-01 18:59:50 +00:00
Christopher Lamb
7d303b2a20 Better match llvm-gcc's behavior for CodeGen naming of anonymous structs and unions.
llvm-svn: 44490
2007-12-01 09:20:34 +00:00
Christopher Lamb
b0e6094a22 When generating the CodeGen type name of a struct, union, enum use the typedef
name if a tag type name is not available for the type. This matches how llvm-gcc 
chooses CodeGen type names.

This means that "typedef struct {...} foo" now results in a CodeGen name of 
"struct.foo" rather than "struct."

llvm-svn: 44489
2007-12-01 09:08:41 +00:00
Seo Sanghyeon
34f92ace1f Test commit
llvm-svn: 44488
2007-12-01 08:06:07 +00:00
Duncan Sands
68b6f50938 Integrate the readonly/readnone logic more deeply
into alias analysis.  This meant updating the API
which now has versions of the getModRefBehavior,
doesNotAccessMemory and onlyReadsMemory methods
which take a callsite parameter.  These should be
used unless the callsite is not known, since in
general they can do a better job than the versions
that take a function.  Also, users should no longer
call the version of getModRefBehavior that takes
both a function and a callsite.  To reduce the
chance of misuse it is now protected.

llvm-svn: 44487
2007-12-01 07:51:45 +00:00
Chris Lattner
ae7a834e74 make the unused expression warning less noisy by not warning about comma exprs whose
LHS and RHS both have side effects.

llvm-svn: 44486
2007-12-01 06:07:34 +00:00
Chris Lattner
e69d662bae simplify some code, add support for functions without a proto
llvm-svn: 44485
2007-12-01 05:58:21 +00:00
Chris Lattner
9e137aad78 fix a couple switch codegen problems Oliver reported.
llvm-svn: 44484
2007-12-01 05:27:33 +00:00
Ted Kremenek
3e14c152c6 Fixed bug in the serialization of SelectorTable where we did not register the
pointer of MultiKeywordSelectors.

Added optimization to the serialization of SelectorTable where we only serialize
out MultiKeywordSelectors that are ever referenced by an object other than the
SelectorTable.

llvm-svn: 44483
2007-12-01 04:43:17 +00:00
Evan Cheng
388f6f51a0 Fix a bug where splitting cause some unnecessary spilling.
llvm-svn: 44482
2007-12-01 04:42:39 +00:00
Owen Anderson
7f09c88977 Fixes for MachineLoopInfo, mostly from Evan. With these, it should be almost useable!
llvm-svn: 44480
2007-12-01 03:01:39 +00:00
Evan Cheng
69fda0a716 Allow some reloads to be folded in multi-use cases. Specifically testl r, r -> cmpl [mem], 0.
llvm-svn: 44479
2007-12-01 02:07:52 +00:00
Eric Christopher
e62b441b51 Add target triple to include/llvm/Config/config.h.in. Regenerate all files.
llvm-svn: 44478
2007-12-01 00:34:39 +00:00
Devang Patel
c7d9af8d6d Change LinkTimeOptimizer.h install location.
llvm-svn: 44477
2007-12-01 00:24:50 +00:00
Devang Patel
0fceaea8be Change lib lto install location.
llvm-svn: 44476
2007-11-30 23:27:57 +00:00
Chris Lattner
4431a1b19b start partitioning the diagnostics into two classes: those
that are builtin and those that are aren't.  This is a bunch
of API refactoring that will make this possible, but there is
no functionality change yet.

llvm-svn: 44473
2007-11-30 22:53:43 +00:00
Anders Carlsson
7a9a38abe0 String literals are always valid LValues.
llvm-svn: 44472
2007-11-30 22:47:59 +00:00
Ted Kremenek
c9bcda94ae Implemented serialization of SelectorTable and Selectors.
Modified serialization of IdentifierTable to self-register itself with
the Deserializer.

llvm-svn: 44471
2007-11-30 22:46:56 +00:00
Ted Kremenek
8ded669b04 Fixed subtle bug in Deserializer::JumpTo when jumping when the block-nesting
information matching did not exactly match the underlying stream's scoping
information.

llvm-svn: 44470
2007-11-30 22:45:05 +00:00
Ted Kremenek
1f80e8b6eb Fixed potential bug where CurWord is not zeroed out in JumpToBit.
llvm-svn: 44469
2007-11-30 22:39:46 +00:00
Chris Lattner
e9c810c87c pass diagnostics into the rewrite test client.
llvm-svn: 44468
2007-11-30 22:25:36 +00:00
Evan Cheng
b10dc27b20 Do not fold reload into an instruction with multiple uses. It issues one extra load.
llvm-svn: 44467
2007-11-30 21:23:43 +00:00
Anders Carlsson
3b754452eb Initialize CurMethodDecl to 0.
llvm-svn: 44463
2007-11-30 20:01:38 +00:00
Anders Carlsson
801c5c7467 GCC has an extension where the left hand side of the ? : operator can be omitted. Handle this in a few more places.
llvm-svn: 44462
2007-11-30 19:04:31 +00:00
Chris Lattner
907703cecd chain update requests properly.
llvm-svn: 44460
2007-11-30 18:52:58 +00:00
Anders Carlsson
452815a6b2 Initialize LaxVectorConversions.
llvm-svn: 44459
2007-11-30 18:29:41 +00:00
Duncan Sands
d4d7f9d69e Small optimization of parameter attribute lookup.
llvm-svn: 44458
2007-11-30 18:20:58 +00:00
Duncan Sands
b41f872013 Add a convenience method for modifying parameter
attributes.  While there, I noticed that not all
attribute methods returned a pointer-to-constant,
so I fixed that.

llvm-svn: 44457
2007-11-30 18:19:18 +00:00
Chris Lattner
1386de8757 fix a bug handling typedefs in member expr codegen. Patch
by Seo Sanghyeon

llvm-svn: 44455
2007-11-30 18:02:19 +00:00
Chris Lattner
b6a7b582ee Fix a codegen crash on void ?: reported by Oliver
llvm-svn: 44454
2007-11-30 17:56:23 +00:00
Chris Lattner
aa0b570dfb Support fully general case expressions, patch by Sanghyeon Seo!
llvm-svn: 44453
2007-11-30 17:44:57 +00:00
Duncan Sands
4e8c071612 Check that there are not more attributes than
function parameters.

llvm-svn: 44452
2007-11-30 15:52:20 +00:00
Christopher Lamb
0112f62bb9 Doh! Check in this long overdue test fix.
llvm-svn: 44450
2007-11-30 06:35:48 +00:00
Anders Carlsson
e1af1d20ef Support lax vector conversions.
llvm-svn: 44449
2007-11-30 04:21:22 +00:00
Devang Patel
cc45c338d1 Provide a way to update DescGlobals cache directly.
llvm-svn: 44446
2007-11-30 00:51:33 +00:00
Steve Naroff
205ec3d07a Yesterday, I simplified how we stream top-level decls.
After a discussion with Ted, we both came to the conclusion that adding a "HandleTopLevelDeclaration" hook to ASConsumer is far more elegant. The default implementation of HandleTopLevelDeclaration will be responsible for iterating over the ScopedDecl (which has a chain of the decls:-).

TODO: Once Ted adds HandleTopLevelDeclaration, make sure TagDecls are chainged appropriately...
llvm-svn: 44445
2007-11-29 23:05:20 +00:00
Ted Kremenek
bfcf8cdbd7 Added method "HandleTopLevelDeclaration" to ASTConsumer. This will eventually
be the new hook that ASTStreamer calls to feed top-level Decls to
ASTConsumers.

The difference between "HandleTopLevelDeclaration" and "HandleTopLevelDecl" is
that "HandleTopLevelDecl" is currently called by ASTStreamer for every
top-level declaration, including those that appear within a Decl chain. Using
the new interface, ASTStreamer would only call HandleTopLevelDeclaration for
Decls that appear that the beginning of a Decl chain (i.e., a group of related
decls).

To preserve the behavior that all subclasses of ASTConsumer currently expect,
the default implementation of HandleTopLevelDeclaration simply calls
HandleTopLevelDecl, and for decl chains it calls HandleTopLevelDecl for each
Decl* in a chain of Decls.

The advantage of this interface is that some subclasses of ASTConsumer only
really want the Decl chain, and not each individual Decl passed to them. This
extra level of indirection allows subclasses to override the default behavior
if they so desire.

llvm-svn: 44444
2007-11-29 23:05:17 +00:00
Evan Cheng
d35b5acae4 Do not lose rematerialization info when spilling already split live intervals.
llvm-svn: 44443
2007-11-29 23:02:50 +00:00
Christopher Lamb
2ed9afd777 Update the initializer's type, in addition to the decl, if we've changed the type of the decl based on it.
llvm-svn: 44440
2007-11-29 19:09:19 +00:00
Ted Kremenek
22a0d616f6 Added "complex.c" (a copy of test/Codegen/complex.) to the serialization
test suite.

llvm-svn: 44439
2007-11-29 19:05:51 +00:00
Ted Kremenek
870600d625 Only serialize top-level decls that appear at the head of a decl chain.
llvm-svn: 44438
2007-11-29 19:04:54 +00:00
Owen Anderson
ffa55112e0 Fix a miscompilation in spiff on PPC.
llvm-svn: 44437
2007-11-29 18:02:22 +00:00
Evan Cheng
8494ee175c Fix a major performance issue with splitting. If there is a def (not def/use)
in the middle of a split basic block, create a new live interval starting at
the def. This avoid artifically extending the live interval over a number of
cycles where it is dead. e.g.

bb1:
       = vr1204   (use / kill) <= new interval starts and ends here.
...
...
vr1204 =          (new def)   <= start a new interval here.
       = vr1204   (use)

llvm-svn: 44436
2007-11-29 10:12:14 +00:00
Evan Cheng
37ed3e6320 Update tests.
llvm-svn: 44435
2007-11-29 10:03:54 +00:00
Evan Cheng
f85c063ec0 Replace the odd kill# hack with something less fragile.
llvm-svn: 44434
2007-11-29 09:49:23 +00:00
Duncan Sands
8dfcd5975e Small parameter attributes cleanup.
llvm-svn: 44433
2007-11-29 08:30:15 +00:00
Chris Lattner
f5a095359e Pass the whole StringMapEntry into StringMapEntryInitializer::Initialize.
llvm-svn: 44432
2007-11-29 06:14:41 +00:00
Christopher Lamb
42e69f219d Support floating point literals of the form "1e-16f" which specify an exponent but no decimal point.
llvm-svn: 44431
2007-11-29 06:06:27 +00:00
Chris Lattner
d1f0e3d791 provide an optional API to allow datatypes in a stringmap to be *gasp*
initialized with a value if they want, by specializing the 
StringMapEntryInitializer class.

llvm-svn: 44430
2007-11-29 06:04:41 +00:00
Ted Kremenek
1150e25901 Enhanced serialization testing by also pretty-printing CFGs constructed from ASTs
both before and after serialization/deserialization. If the CFGs between the pre-
and post- serialized/deserialized ASTs differ, the serialization has failed.

llvm-svn: 44429
2007-11-29 01:24:25 +00:00
Evan Cheng
be255b0650 Fixed various live interval splitting bugs / compile time issues.
llvm-svn: 44428
2007-11-29 01:06:25 +00:00
Evan Cheng
147f7799c5 Kill info update bug.
llvm-svn: 44427
2007-11-29 01:05:47 +00:00
Ted Kremenek
2501c8294f Fixed test case to not expect a warning when one should not be emitted.
Removed redundant test case.

llvm-svn: 44426
2007-11-29 01:03:21 +00:00
Ted Kremenek
0865d8a5d0 Added test cases for -Wfloat-equal to test comparisons against literals that can be
represented exactly and inexactly by APFloats. For the former, we do not emit a
warning.

llvm-svn: 44425
2007-11-29 01:00:11 +00:00
Ted Kremenek
eda40e273e Enhanced implementation of -Wfloat-equal to check for comparisons against
floating-point literals that are represented exactly by the APFloat in
FloatingLiteral. For such literals, we do not emit a warning since such checks are
often performed in real code to see if a variable has changed from its original
value. This heuristic clearly can lead to false negatives, but the hope is it will
significantly reduce false positives to help make the compiler flag more useful.

llvm-svn: 44424
2007-11-29 00:59:04 +00:00
Ted Kremenek
3a2c950401 Added "isExact" field to FloatingLiteral. This flag indicates whether or not
the APFloat representing the parsed literal can represent the literal value
exactly.  This is useful when performing various semantic checks on the code,
and issuing appropriate warnings to users.

llvm-svn: 44423
2007-11-29 00:56:49 +00:00
Ted Kremenek
9924ca2e14 Removed potential buffer overrun (spotted by Neil Booth) when NumericLiteralParser
converts a parsed literal into an APFloat. We are still performing a copy of the
string, which hopefully will be removed eventually for performance reasons. This
version now is at least safe.

Changed rounding in APFloat construction in NumericLiteralParser from rmTowardsZero
to rmNearestTiesToEven.

llvm-svn: 44422
2007-11-29 00:54:29 +00:00
Steve Naroff
197616c3a8 Several fixes/simplifications surrounding how we stream top-level decl AST's.
The following code...

typedef struct cssm_data {} CSSM_DATA, *CSSM_DATA_PTR;

struct Y { int A; };

struct X { int A; } D; 

struct X E, F;

...now produces the following output...

> ../../Debug/bin/clang xx.c -ast-print
Read top-level tag decl: 'cssm_data'
typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data *CSSM_DATA_PTR;
Read top-level tag decl: 'Y'
Read top-level tag decl: 'X'
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'F'

...which is much more accurate than the previous -ast-print output...

typedef struct cssm_data CSSM_DATA;
typedef struct cssm_data CSSM_DATA;
Read top-level variable decl: 'D'
Read top-level variable decl: 'E'
Read top-level variable decl: 'E'

llvm-svn: 44421
2007-11-28 22:54:11 +00:00
Chris Lattner
cee633a873 New testcase for PR1744
llvm-svn: 44418
2007-11-28 22:43:34 +00:00
Ted Kremenek
5933768bec Converted AST Pretty-Printer to use iostreams instead of FILE*. This fixes
a bug where the statement pretty-printer used iostreams but the AST printer
did not.  This was an issue when dumping ASTs to something other than stderr.

Updated SerializationTest to use the new iostreams interface for the AST printer.

llvm-svn: 44417
2007-11-28 21:32:21 +00:00
Ted Kremenek
5d169cf285 Inlined test case to make it independent of the stmt_exprs test case in test/Sema.
llvm-svn: 44416
2007-11-28 21:29:54 +00:00
Chris Lattner
246b7b2dbf Work around a GCC bug, producing this code:
unsigned char *llvm_cbe_X;
...
  llvm_cbe_X = 0; *((void**)&llvm_cbe_X) = __builtin_stack_save();

instead of:

  llvm_cbe_X = __builtin_stack_save();

See PR1809 for details.

llvm-svn: 44415
2007-11-28 21:26:17 +00:00
Chris Lattner
3fbb6a83a8 Add a note
llvm-svn: 44414
2007-11-28 19:26:42 +00:00
Ted Kremenek
31540ed8fe Added the "Serialization" test directory to the set of tests executed.
Introduced a few line breaks to make the Makefile easier to read.

llvm-svn: 44413
2007-11-28 19:24:15 +00:00
Ted Kremenek
46cfdb9625 Added initial test case for testing serialization of ASTs. This test
case simply performs --test-pickling on the code found in Sema/stmt_exprs.c.

llvm-svn: 44412
2007-11-28 19:23:15 +00:00
Ted Kremenek
ac76a41717 Modified --test-pickling to perform an actual cross-check of serialized ASTs:
(1) Parsed ASTs are pretty-printed to a text file.
(2) The ASTs are serialized to disk.
(3) The ASTs are deserialized from disk.
(4) The deserialized ASTs are pretty-printed to a text file.
(5) The two pretty-printed files are compared. If they are different, the test
    fails.

llvm-svn: 44411
2007-11-28 19:21:47 +00:00
Ted Kremenek
44d5166cdb Changed TestRunner.sh to dump the output and generated script files in
subdirectories mirroring where the test case file is located

For example, for the test case "Sema/stmt_exprs.c", instead of the files
"Output/stmt_exprs.c.out" and "Output/stmt_exprs.c.out.script" being created, the
files "Output/Sema/stmt_exprs.c.out" and "Output/Sema/stmt_exprs.c.out.script" are
created. This prevents any collisions from different test directories that have the
same file name for a test case, and also makes it clear where the test case was
drawn from.

llvm-svn: 44410
2007-11-28 19:16:54 +00:00
Ted Kremenek
ab18e6d7fd Added missing "RUN:" to comment for test case file. This fixed a bug where the test
case testing the frontend's support of statement expressions was not being
executed.

llvm-svn: 44409
2007-11-28 19:05:11 +00:00
Chris Lattner
db2a6ef881 Fix a bug checking for 'int foo(void)' that didn't look through typedefs of void.
Bug pointed out by Michael Zolda, thanks!

llvm-svn: 44408
2007-11-28 18:51:29 +00:00
Chris Lattner
57ee7c6630 Implement ExpandOperationResult for ppc i64 fp->int, which fixes
CodeGen/Generic/fp_to_int.ll among others.  Its unclear why this 
just started failing...

llvm-svn: 44407
2007-11-28 18:44:47 +00:00
Chris Lattner
749478a61b for consistency, allow a fallthrough if the final check returns null.
llvm-svn: 44406
2007-11-28 18:30:18 +00:00
Chris Lattner
f4769da4b3 upgrade this test
llvm-svn: 44405
2007-11-28 18:22:12 +00:00
Chris Lattner
d6109cf328 make this test have a deterministic result.
llvm-svn: 44404
2007-11-28 18:20:49 +00:00
Duncan Sands
5208d1ab4a Add some convenience methods for querying attributes, and
use them.

llvm-svn: 44403
2007-11-28 17:07:01 +00:00
Duncan Sands
b5452fb829 Revert previous "fix" - the breakage was due to some
local changes, not the "not".

llvm-svn: 44402
2007-11-28 16:50:29 +00:00
Duncan Sands
0497916c88 This test somehow got an extra "not" during the
recent stderr updates.

llvm-svn: 44401
2007-11-28 15:36:27 +00:00
Duncan Sands
ff306287ff My compiler complains that "x always evaluates to true"
in this call:

	Result.IntVal = APInt(80, 2, x);

What is x?

	uint16_t x[8];

I deduce that the APInt constructor being used is this one:

  APInt(uint32_t numBits, uint64_t val, bool isSigned = false);

rather than this one:

  APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[]);

That doesn't seem right!  This fix compiles but is otherwise completely
untested.

llvm-svn: 44400
2007-11-28 10:36:19 +00:00
Duncan Sands
45a0c3265f Add missing newlines at EOF.
llvm-svn: 44399
2007-11-28 10:13:38 +00:00
Oliver Hunt
93c4ce650c Fix typo in writable string test
llvm-svn: 44398
2007-11-28 06:52:03 +00:00
Oliver Hunt
a951571941 Adding code gen tests for writable and shared string literals.
llvm-svn: 44397
2007-11-28 06:27:12 +00:00
Anders Carlsson
0e136ec1d3 Add correct types for the last remaining intrinsics.
llvm-svn: 44396
2007-11-28 06:09:44 +00:00
Chris Lattner
e499816a23 xfail a test
llvm-svn: 44395
2007-11-28 05:37:13 +00:00
Chris Lattner
fb30009465 Implement support for -fwritable-strings and make the code generator
merge string literals when it is not provided.

llvm-svn: 44394
2007-11-28 05:34:05 +00:00
Chris Lattner
e04dc1fa4d update this test after the fmrrd fix
llvm-svn: 44393
2007-11-28 05:27:07 +00:00
Anders Carlsson
299f2fc648 Add more intrinsics. We can now correctly parse both Carbon.h and Cocoa.h without having to do -arch ppc.
llvm-svn: 44392
2007-11-28 05:19:59 +00:00
Tanya Lattner
ec072113f0 Fix typo
llvm-svn: 44391
2007-11-28 05:14:49 +00:00
Tanya Lattner
8460374e30 Modified instructions to configure llvm-test by configure llvm with the Path --with-llvmgccdir set.
llvm-svn: 44390
2007-11-28 05:13:45 +00:00
Tanya Lattner
8f342f8ef3 Fix bug in regression tests that ignored stderr output in RUN lines. Updated tests and fixed broken run lines.
XFAILed 3 arm regressions (will file bugs)

llvm-svn: 44389
2007-11-28 04:57:00 +00:00
Chris Lattner
d0d8d4e3b9 fix compilation error noticed by Nuno Lopes
llvm-svn: 44388
2007-11-28 04:30:09 +00:00
Evan Cheng
c1648b6a0d Recover compile time regression.
llvm-svn: 44386
2007-11-28 01:28:46 +00:00
Owen Anderson
30767b15e9 Add MachineLoopInfo. This is not yet tested.
llvm-svn: 44384
2007-11-27 22:47:08 +00:00
Chris Lattner
f247e27666 commit testcase I forgot to svn add.
llvm-svn: 44383
2007-11-27 22:43:37 +00:00
Chris Lattner
57662f3882 several entries got significantly better, though they still aren't done.
llvm-svn: 44382
2007-11-27 22:41:52 +00:00
Chris Lattner
f3f4ad9dd6 implement a trivial readme entry.
llvm-svn: 44380
2007-11-27 22:36:16 +00:00
Chris Lattner
79ae9895f6 Fix a crash on invalid code due to memcpy lowering.
llvm-svn: 44378
2007-11-27 22:14:42 +00:00
Ted Kremenek
7c81bdd4e7 Migrated static functions that print decls into a DeclPrinter class,
which is now used (or subclasssed) by the ASTConsumers.  This new class
stores a FILE* that is used for writing, instead of just hardwiring output
to stderr (it defaults to stderr if no FILE* is provided).

Modified CreateASTPrinter() to accept a FILE* for printing.

llvm-svn: 44377
2007-11-27 21:46:50 +00:00
Chris Lattner
da22eeca44 add several cases that Expr::hasStaticStorage missed, pointed out by Oliver Hunt
llvm-svn: 44376
2007-11-27 21:35:27 +00:00
Chris Lattner
1a6bb70ad0 Set loc earlier in CheckSingleInitializer to avoid emitting a
diagnostic without a location.  This produces:

simpleTest.c:2:18: error: initializer element is not constant
int *myPointer = &(myArray[2]);
                 ^~~~~~~~~~~~~

instead of:

error: initializer element is not constant
llvm-svn: 44375
2007-11-27 21:21:35 +00:00
Chris Lattner
be5f3cb6f1 Make this actually work on systems that support ppc long double.
llvm-svn: 44374
2007-11-27 20:45:25 +00:00
Chris Lattner
fffd0ae2f1 Unbreak all of the darwin/ppc32 JIT failures having to do
with not being able to find printf.

llvm-svn: 44373
2007-11-27 20:41:32 +00:00
Ted Kremenek
14d5f741ab Updated GenLibDeps.pl to employ "use strict" to help prevent uses of variables
that have not yet been defined.

Removed used of grep and sed when parsing the results of "nm". This was
originally motivated because if the user has specified options to grep using
the environment variable GREP_OPTIONS this could break the script. Piping
through grep/sed/sort/uniq is also (to my understanding) not necessary, and
the equivalent operations can be done much faster in the Perl script.

Using a crude benchmark, these changes resulted in a 3x speedup in the
execution of GenLibDeps.pl.

llvm-svn: 44372
2007-11-27 19:31:11 +00:00
Nate Begeman
6f026a654c Support returning non-power-of-2 vectors to unblock some work
llvm-svn: 44371
2007-11-27 19:28:48 +00:00
Andrew Lenharth
b960acebde something wrong with this opt
llvm-svn: 44370
2007-11-27 18:31:30 +00:00
Chris Lattner
a7944d86de sizeof is defined by bitsin(char) not by units of 8 bits.
llvm-svn: 44369
2007-11-27 18:22:04 +00:00
Anton Korobeynikov
75445ae2c3 Add testcase for last llvm-gcc tweaks
llvm-svn: 44368
2007-11-27 18:21:29 +00:00
Chris Lattner
1cfe02c38b update to match change in mainline llvm.
llvm-svn: 44367
2007-11-27 18:20:52 +00:00
Steve Naroff
0ee0b0ab8c Move the null pointer constant check from Sema::CheckSingleInitializer/ActOnCallExpr/CheckMessageArgumentTypes/ActOnReturnStmt to Sema::CheckSingleAssignmentConstraints. This makes sure all null pointer assignments are considered compatible.
Thanks to Seo Sanghyeon for the bug, follow-through, and patch!

llvm-svn: 44366
2007-11-27 17:58:44 +00:00
Ted Kremenek
c6298de211 Added quotes around $(NM_PATH) argument to GenLibDeps.pl script so that
the "-p" option is actually seen by nm (it was being dropped as it was
considered as separate argument to the Perl script).

llvm-svn: 44365
2007-11-27 17:53:54 +00:00
Chris Lattner
1dfc48d4f6 Unbreak backwards compatibility with bytecode format. Regression
introduced by this patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071126/055824.html

llvm-svn: 44364
2007-11-27 17:48:06 +00:00
Duncan Sands
ad0ea2d430 Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls.  This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll).  Hopefully
a bitcode guru (who might that be? :) ) will fix it.

llvm-svn: 44359
2007-11-27 13:23:08 +00:00
Chris Lattner
db3467f8d4 handle __vector_size__ like vector_size
llvm-svn: 44358
2007-11-27 07:28:18 +00:00
Anders Carlsson
61d6f8d6c3 Add builtin type signature support for vector types. Add correct type signatures for a bunch of MMX builtins. We now parse all the intrinsics in mmintrin.h
llvm-svn: 44357
2007-11-27 07:22:09 +00:00
Anders Carlsson
24c59958f4 Add comment to CheckVectorCast.h
llvm-svn: 44356
2007-11-27 07:16:40 +00:00
Chris Lattner
f04b69b26c take an initial stab at setting function linkage right. Handle
static and inline at least.

llvm-svn: 44355
2007-11-27 06:46:51 +00:00
Zhou Sheng
34ffaeeeed Make this pass for CYGWIN.
llvm-svn: 44354
2007-11-27 06:23:59 +00:00
Zhou Sheng
73286d6309 Make this testcase compatible with CYGWIN.
llvm-svn: 44353
2007-11-27 06:17:01 +00:00
Chris Lattner
698b1cb28d err, no really.
llvm-svn: 44352
2007-11-27 06:14:32 +00:00
Chris Lattner
28caf2717a don't depend on ADL.
llvm-svn: 44351
2007-11-27 06:14:12 +00:00
Anders Carlsson
de71adff60 Report errors for invalid casts from/to vectors.
llvm-svn: 44350
2007-11-27 05:51:55 +00:00
Anders Carlsson
f511f646a4 Add more semantic analysis for inline asm statements.
llvm-svn: 44349
2007-11-27 04:11:28 +00:00
Owen Anderson
b0dd27ee91 Make LoopInfoBase more generic, in preparation for having MachineLoopInfo. This involves a small interface change.
llvm-svn: 44348
2007-11-27 03:43:35 +00:00
Owen Anderson
5aad0d7ea2 Add accessor for getting the underlying templated type. This is necessary for templated LoopInfo.
llvm-svn: 44347
2007-11-27 03:33:40 +00:00
Chuck Rose III
20a104c87f Moving TGLexer.h from source to header file tab in TableGen project file
llvm-svn: 44346
2007-11-27 01:25:12 +00:00
Dan Gohman
8bba724afc Change &| to |&.
llvm-svn: 44345
2007-11-27 00:50:57 +00:00
Dan Gohman
2dba0788a5 Change grep '' to grep {}.
Change 2>&1 | to |&.

llvm-svn: 44344
2007-11-27 00:10:35 +00:00
Dan Gohman
9ab9e9fa03 Don't redirect llvm-as's stderr to llvm-dis.
Change grep '' to grep {}.

llvm-svn: 44343
2007-11-27 00:07:33 +00:00
Dan Gohman
f151c8e760 Remove unnecessary && from the RUN lines of this test.
llvm-svn: 44342
2007-11-27 00:03:38 +00:00
Dan Gohman
9a69341725 Don't lower srem/urem X%C to X-X/C*C unless the division is actually
optimized. This avoids creating illegal divisions when the combiner is
running after legalize; this fixes PR1815. Also, it produces better
code in the included testcase by avoiding the subtract and multiply
when the division isn't optimized.

llvm-svn: 44341
2007-11-26 23:46:11 +00:00
Chuck Rose III
084b0eb3ca Add TGParser files to VStudio project files. Removed generated files section from TableGen project file as it is no longer needed. #Include <algorithm> directly from TGParser.cpp so it can see std::reverse.
llvm-svn: 44340
2007-11-26 23:19:59 +00:00
Ted Kremenek
fbb08bc2e2 Added optional pass-by-reference argument "isExact" to
NumericLiteralParser::GetFloatValue(). Upon method return, this flag has the value
true if the returned APFloat can exactly represent the number in the parsed text,
and false otherwise.

Modified the implementation of GetFloatValue() to parse literals using APFloat's
convertFromString method (which allows us to set the value of isExact).

llvm-svn: 44339
2007-11-26 23:12:30 +00:00
Ted Kremenek
871422eca9 Removed dependence on #including iostream.
llvm-svn: 44338
2007-11-26 22:50:46 +00:00
Ted Kremenek
6eefb85ef5 Fixed #include of objc/objc.h so that it works on case-sensitive filesystems.
llvm-svn: 44337
2007-11-26 22:49:09 +00:00
Ted Kremenek
2b0ce11952 Reverted changed to getTagDeclType() introduced in patch 44089:
http://llvm.org/viewvc/llvm-project?view=rev&revision=44089

"Decl" once again can no longer be NULL, so the NULL checks are not needed.

llvm-svn: 44336
2007-11-26 21:16:01 +00:00
Fariborz Jahanian
96502afb6f Fixed a rewrite bug in class synthesis (which I first thought was a rewrite API bug).
llvm-svn: 44335
2007-11-26 20:59:57 +00:00
Kevin
e01743a3a3 Removes link to status page till the info gets added. Someone put us on Reddit; Don't want it to look bad on the project. :)
http://programming.reddit.com/info/61f8g/comments/

llvm-svn: 44334
2007-11-26 20:47:14 +00:00
Fariborz Jahanian
a883d6ed89 Patch to fix a regression caused by recent rewrite changes.
A potential API bug in ReplaceText pending (A FIXME is added).

llvm-svn: 44333
2007-11-26 19:52:57 +00:00
Ted Kremenek
ebb1c0ca74 Fixed StmtPrinter to handle GCC extension to the ternary operator "?:" where
the LHS subexpression can be NULL.  Patch provided by Nuno Lopes!

llvm-svn: 44328
2007-11-26 18:27:54 +00:00
Ted Kremenek
138988765c Fixed bug in CFG construction where we did not properly handle the GCC
extension "?:" for the ternary operator, e.g.: x ?: y; This expression is
represented in the clang ASTs as a ConditionalOperator whose LHS expression is
NULL. Now we handle this special case, causing the block containing the
condition to be a predecessor to the block that "merges" the values of the
ternary operator.

Thanks to Nuno Lopes for identifying and diagnosing this bug!

llvm-svn: 44327
2007-11-26 18:20:26 +00:00
Bill Wendling
8da1db4f34 The checking for the delimiters of expected error/warning messages was
looking only for { and } instead of {{ and }}. Changed it to check for
this explicitly.

llvm-svn: 44326
2007-11-26 08:26:20 +00:00
Owen Anderson
9f0b6e9d46 Fix another bug that was causing siod to fail.
llvm-svn: 44325
2007-11-26 07:17:19 +00:00
Owen Anderson
7cad745d49 Fix a silly bug that Nicholas noticed.
llvm-svn: 44324
2007-11-26 03:27:38 +00:00
Owen Anderson
4f833c7610 Allow GVN to eliminate read-only function calls when it can detect that they are redundant.
llvm-svn: 44323
2007-11-26 02:26:36 +00:00
Chris Lattner
2ab40a6207 Fix sema support for the gnu ?: expression with a
missing middle expression, and fix a codegen bug where
we didn't correctly promote the condition to the right 
result type.  This fixes PR1824.

llvm-svn: 44322
2007-11-26 01:40:58 +00:00
Chris Lattner
a3ee6fa84f this works.
llvm-svn: 44321
2007-11-26 01:39:17 +00:00
Anton Korobeynikov
2f76e373ae Remove another leak. Due to some reason AliasSetTracker didn't had any dtor...
llvm-svn: 44320
2007-11-25 23:52:02 +00:00
Nick Lewycky
cdb7e54ca7 Add new SCEV, SCEVSMax. This allows LLVM to analyze do-while loops.
llvm-svn: 44319
2007-11-25 22:41:31 +00:00
Chris Lattner
c00e8adfe0 Implement PR1822
llvm-svn: 44318
2007-11-25 21:27:53 +00:00
Anton Korobeynikov
bd9df0f200 Remove a leak. Destroy LoopInfoBase object. releaseMemory() is actually called in its dtor.
llvm-svn: 44317
2007-11-25 18:41:39 +00:00
Chris Lattner
852ed06d60 sizeof() return size in bytes, not bits, patch by Nuno Lopes!
llvm-svn: 44316
2007-11-25 17:48:21 +00:00
Duncan Sands
185eeac0f8 Fix PR1816. If a bitcast of a function only exists because of a
trivial difference in function attributes, allow calls to it to
be converted to direct calls.  Based on a patch by Török Edwin.
While there, move the various lists of mutually incompatible
parameters etc out of the verifier and into ParameterAttributes.h.

llvm-svn: 44315
2007-11-25 14:10:56 +00:00
Reid Spencer
f7121af96d Don't ignore files that are no longer in use.
llvm-svn: 44313
2007-11-25 07:05:05 +00:00
Ted Kremenek
43fb8b0799 Moved logic for -Wfloat-equal to SemaChecking.cpp.
Moved utility functions IgnoreParen and friends to be static inline functions
defined in SemaUtil.h.

Added SemaUtil.h to Xcode project.

llvm-svn: 44312
2007-11-25 00:58:00 +00:00
Anders Carlsson
290aa8560b Check that the clobber registers are valid.
llvm-svn: 44311
2007-11-25 00:25:21 +00:00
Chris Lattner
5728bdd4db Fix a long standing deficiency in the X86 backend: we would
sometimes emit "zero" and "all one" vectors multiple times,
for example:

_test2:
	pcmpeqd	%mm0, %mm0
	movq	%mm0, _M1
	pcmpeqd	%mm0, %mm0
	movq	%mm0, _M2
	ret

instead of:

_test2:
	pcmpeqd	%mm0, %mm0
	movq	%mm0, _M1
	movq	%mm0, _M2
	ret

This patch fixes this by always arranging for zero/one vectors
to be defined as v4i32 or v2i32 (SSE/MMX) instead of letting them be
any random type.  This ensures they get trivially CSE'd on the dag.
This fix is also important for LegalizeDAGTypes, as it gets unhappy
when the x86 backend wants BUILD_VECTOR(i64 0) to be legal even when
'i64' isn't legal.

This patch makes the following changes:

1) X86TargetLowering::LowerBUILD_VECTOR now lowers 0/1 vectors into
   their canonical types.
2) The now-dead patterns are removed from the SSE/MMX .td files.
3) All the patterns in the .td file that referred to immAllOnesV or
   immAllZerosV in the wrong form now use *_bc to match them with a
   bitcast wrapped around them.
4) X86DAGToDAGISel::SelectScalarSSELoad is generalized to handle 
   bitcast'd zero vectors, which simplifies the code actually.
5) getShuffleVectorZeroOrUndef is updated to generate a shuffle that
   is legal, instead of generating one that is illegal and expecting
   a later legalize pass to clean it up.
6) isZeroShuffle is generalized to handle bitcast of zeros.
7) several other minor tweaks.

This patch is definite goodness, but has the potential to cause random
code quality regressions.  Please be on the lookout for these and let 
me know if they happen.

llvm-svn: 44310
2007-11-25 00:24:49 +00:00
Anders Carlsson
c163657f2f Forgot some X86 registers
llvm-svn: 44309
2007-11-25 00:23:10 +00:00
Anders Carlsson
5fa3f348f7 Add tables for GCC register names and aliases. This will be used for inline asm
llvm-svn: 44308
2007-11-24 23:38:12 +00:00
Ted Kremenek
0d20033c6a Added more test cases for uninitialized values checker.
llvm-svn: 44307
2007-11-24 23:06:58 +00:00
Ted Kremenek
2e04d73d83 Fixed bogus culling of uninitialized-values "taint" propagation during assignments.
We accidentally were throttling the propagation of uninitialized state across
assignments (e.g. x = y).  Thanks to Anders Carlsson for spotting this problem.

Added test cases to test suite to provide regression testing for the
uninitialized values analysis.

llvm-svn: 44306
2007-11-24 20:07:36 +00:00
Ted Kremenek
33407b3338 Moved dead-stores test cast to a new test suite subdirectory: Analysis.
llvm-svn: 44305
2007-11-24 19:49:35 +00:00
Chris Lattner
cab915f9cf Implement expand support for MERGE_VALUEs that only produces one result.
llvm-svn: 44304
2007-11-24 19:12:15 +00:00
Chris Lattner
6a49593aa5 add a immAllZerosV_bc pattern fragment for consistency with others.
llvm-svn: 44303
2007-11-24 19:02:07 +00:00
Chris Lattner
f72ad16263 remove bogus assertion that broke CodeGen/Generic/cast-fp.ll on x86
among others.

llvm-svn: 44302
2007-11-24 18:37:20 +00:00
Chris Lattner
6e3641897b Implement support for custom legalization in DAGTypeLegalizer::ExpandOperand.
Improve a comment.
Unbreak Duncan's carefully written path compression where I didn't realize
what was happening!

llvm-svn: 44301
2007-11-24 18:11:42 +00:00
Chris Lattner
f81d5886c6 Several changes:
1) Change the interface to TargetLowering::ExpandOperationResult to 
   take and return entire NODES that need a result expanded, not just
   the value.  This allows us to handle things like READCYCLECOUNTER,
   which returns two values.
2) Implement (extremely limited) support in LegalizeDAG::ExpandOp for MERGE_VALUES.
3) Reimplement custom lowering in LegalizeDAGTypes in terms of the new
   ExpandOperationResult.  This makes the result simpler and fully 
   general.
4) Implement (fully general) expand support for MERGE_VALUES in LegalizeDAGTypes.
5) Implement ExpandOperationResult support for ARM f64->i64 bitconvert and ARM
   i64 shifts, allowing them to work with LegalizeDAGTypes.
6) Implement ExpandOperationResult support for X86 READCYCLECOUNTER and FP_TO_SINT,
   allowing them to work with LegalizeDAGTypes.

LegalizeDAGTypes now passes several more X86 codegen tests when enabled and when
type legalization in LegalizeDAG is ifdef'd out.

llvm-svn: 44300
2007-11-24 07:07:01 +00:00
Chris Lattner
ab98c41337 add a note
llvm-svn: 44299
2007-11-24 06:13:33 +00:00
Chris Lattner
f5dfd15e98 upgrade this test
llvm-svn: 44298
2007-11-24 05:39:29 +00:00
Anders Carlsson
660bdd1c87 Keep track of whether the asm is volatile or not.
llvm-svn: 44297
2007-11-23 23:12:25 +00:00
Chris Lattner
893fe3bbd1 Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros.
llvm-svn: 44296
2007-11-23 22:42:31 +00:00
Chris Lattner
69ec1ec86a simplify some code.
llvm-svn: 44295
2007-11-23 22:36:49 +00:00
Chris Lattner
c2c4c7456c Fix APInt::countTrailingZeros to return BitWidth if the input is zero instead of returning some random large number.
llvm-svn: 44294
2007-11-23 22:36:25 +00:00
Chris Lattner
0cf083815a add a comment.
llvm-svn: 44293
2007-11-23 22:35:18 +00:00
Chris Lattner
7514abe56e splice some lines together, no functionality change.
llvm-svn: 44292
2007-11-23 22:34:59 +00:00
Chris Lattner
752b05fe94 !< is >=, not >. Thanks to Max Hailperin for pointing this out!
llvm-svn: 44291
2007-11-23 22:19:33 +00:00
Chris Lattner
136449a6d7 improve codegen for global variable initializers, implementing
test/CodeGen/global-with-initialiser.c

Patch by Oliver Hunt!

llvm-svn: 44290
2007-11-23 22:07:55 +00:00
Anders Carlsson
80a5ea3552 Check asm input and output expressions.
llvm-svn: 44289
2007-11-23 19:43:50 +00:00
Duncan Sands
8a3e9d2bee Ding dong, the DoesntAccessMemoryFns and
OnlyReadsMemoryFns tables are dead!  We
get more, and more accurate, information
from gcc via the readnone and readonly
function attributes.

llvm-svn: 44288
2007-11-23 19:30:27 +00:00
Duncan Sands
b23192f483 Remove some logic I thoughtlessly copied over
from the old ADCE implementation (there it was
correct because the transform was being done
for read-only functions).

llvm-svn: 44287
2007-11-23 09:10:17 +00:00
Chris Lattner
a8fbde3f78 Fix a bug where we'd try to find a scev value for a bitcast operand,
even though the bitcast operand did not have integer type.  This fixes
PR1814.

llvm-svn: 44286
2007-11-23 08:46:22 +00:00
Chris Lattner
9fcdc52243 Fix PR1820, an incredibly subtle macro expansion bug that Neil discovered.
Neil, please review this fix.

llvm-svn: 44285
2007-11-23 06:50:21 +00:00
Chris Lattner
1985d96dc9 Fix PR1817.
llvm-svn: 44284
2007-11-22 23:47:13 +00:00
Chris Lattner
a717ce7c70 add some static icmpinst predicates.
llvm-svn: 44283
2007-11-22 23:43:29 +00:00
Chris Lattner
176d048901 add missing #include
llvm-svn: 44282
2007-11-22 23:19:05 +00:00
Anton Korobeynikov
59c11686cc Don't crash on bogus llvm.noinline. This is first part of PR1817 (preventing reduction)
llvm-svn: 44281
2007-11-22 22:30:10 +00:00
Duncan Sands
a915b538d3 Turn invokes of nounwind functions into ordinary calls.
llvm-svn: 44280
2007-11-22 22:24:59 +00:00
Duncan Sands
38a5e82ef4 Teach alias analysis about readnone/readonly functions.
Based on a patch by Török Edwin.

llvm-svn: 44279
2007-11-22 21:43:27 +00:00
Duncan Sands
1c97d752df Readonly/readnone functions are allowed to throw
exceptions, so don't turn invokes of them into
calls.

llvm-svn: 44278
2007-11-22 21:40:06 +00:00
Chris Lattner
5241695dca resolve the last fixme's in the new tblgen parser.
llvm-svn: 44277
2007-11-22 21:06:59 +00:00
Chris Lattner
695506c046 change the Init print methods to return strings, and implement
print in terms of that.

llvm-svn: 44276
2007-11-22 21:05:25 +00:00
Chris Lattner
1b1e96b8d7 eliminate a bunch of print methods that are duplicate with the getAsString() method.
llvm-svn: 44275
2007-11-22 20:51:34 +00:00
Chris Lattner
f4127dd48e Rewrite the tblgen parser in a recursive descent style, eliminating the bison parser.
This makes the parser much easier to understand, eliminates a ton of global variables,
and gives tblgen nice caret diagnostics.  It is also faster, but tblgen probably doesn't
care about performance.

There are a couple of FIXMEs which I will take care of next.

llvm-svn: 44274
2007-11-22 20:49:04 +00:00
Duncan Sands
a89a113a20 Rename the 'const' parameter attribute to 'readnone',
and the 'pure' parameter attribute to 'readonly'.
Names suggested by DannyB.

llvm-svn: 44273
2007-11-22 20:23:04 +00:00
Nick Lewycky
3783b46f9e Instead of calculating constant factors, calculate the number of trailing
bits. Patch from Wojciech Matyjewicz.

llvm-svn: 44268
2007-11-22 07:59:40 +00:00
Nick Lewycky
016547d226 Create nodes for inline asm so that we don't crash looking for the node later.
llvm-svn: 44267
2007-11-22 03:07:37 +00:00
Anders Carlsson
94ea8aab34 Store output and input operands as well as clobber information in the AsmStmt. Ted, could you please review the serialization/deserialization code?
llvm-svn: 44266
2007-11-22 01:36:19 +00:00
Anders Carlsson
091a059c55 GCC fails if there is a trailing colon but no clobbers.
llvm-svn: 44265
2007-11-21 23:27:34 +00:00
Chuck Rose III
738fa17c4e Switching back to strtoll. Including config.h. On VStudio builds, this overrides strtoll.
llvm-svn: 44264
2007-11-21 19:36:25 +00:00
Duncan Sands
b87dde7e8e Fix a bug in which node A is replaced by node B, but later
node A gets back into the DAG again because it was hiding in
one of the node maps: make sure that node replacement happens
in those maps too.

llvm-svn: 44263
2007-11-21 16:43:19 +00:00
Nick Lewycky
1d6f196245 typo
llvm-svn: 44262
2007-11-21 05:21:54 +00:00
Dale Johannesen
e70850cf7b Fix compiler warning.
llvm-svn: 44261
2007-11-21 00:45:00 +00:00
Chuck Rose III
07b57d2626 This change does a couple of things. First it gets the Visual Studio builds working.
I added the lexing files to the VStudio projects and removed the .l files from the 
VStudio projects.  There was a problem with use of strtoll in TGLexer.cpp and Chris
suggested switching to strtol, so that's included here.

Additionally, this checkin adds minimal x64 builds to the VStudio builds.  Build issues
related to x64 in the windows specific files for DynamicLibrary.inc and Singals.inc
are worked around, but not ultimately solved.  Binaries used to be stored in

...\win32\{Debug|Release}

but are now kept in

...\win32\bin\{win32|x64}\{Debug|Release}

intermediate files will continue to be stored in the individual project directories under 
win32.  

Some names will likely change in the future to reflect that the vstudio projects
are no longer 32-bit only, but I wanted to get things up and running today so kept away
from bigger restructuring.

llvm-svn: 44260
2007-11-21 00:37:56 +00:00
Dale Johannesen
f265bec4b0 File missing from previous patch.
llvm-svn: 44259
2007-11-20 23:25:17 +00:00
Dale Johannesen
763e110a9f Fix .eh table linkage issues on Darwin. Some EH support
for Darwin PPC, but it's not fully working yet.

llvm-svn: 44258
2007-11-20 23:24:42 +00:00
Chris Lattner
8b9ecdad0c Add the ability to convert a tblgen type to a string.
llvm-svn: 44257
2007-11-20 22:25:16 +00:00
Anders Carlsson
81a5a69682 Store inline asm code in the AST.
llvm-svn: 44255
2007-11-20 19:21:03 +00:00
Anders Carlsson
4f8eb127e1 Add __builtin_abs
llvm-svn: 44254
2007-11-20 19:05:17 +00:00
Chris Lattner
5c3f1541a7 Improve function decl merging, patch by Oliver Hunt!
llvm-svn: 44253
2007-11-20 19:04:50 +00:00
Duncan Sands
04eb67e69a In order for parameter attribute uniquing to make
any sense it is important that ParamAttr::None gets
treated the same as not supplying an attribute at
all.  Rather than stripping ParamAttr::None out of
the list of attributes, assert if ParamAttr::None
is seen.  Fix up the bitcode reader which liked to
insert ParamAttr::None all over the place.  Patch
based on one by Török Edwin.

llvm-svn: 44250
2007-11-20 14:09:29 +00:00
Nick Lewycky
74a26e3750 Small cleanup. Use APInt::getHighBitsSet method instead of shift left.
"setcc" -> "icmp op" in comments. No functionality change.

llvm-svn: 44249
2007-11-20 08:44:50 +00:00
Nick Lewycky
5b18bd3368 Be more careful when transforming | to +. Patch from Wojciech Matyjewicz.
llvm-svn: 44248
2007-11-20 08:24:44 +00:00
Ted Kremenek
9e823c745d Added another test case for the Dead Stores checker that tests that
block-level expressions are evaluated the same as regular expressions. Test
case provided by Nuno Lopes.

llvm-svn: 44247
2007-11-20 03:03:00 +00:00
Ted Kremenek
9d0acca967 Updated CFGStmtVisitor and CFGRecStmtVisitor to have a notion of
"block-expressions" when visiting arbitrary expressions (via calls to
"Visit()").  This results in a refactoring where a dataflow analysis no
longer needs to always special case when handling block-expressions versus
non-block expressions.

Updated LiveVariables and UninitializedValues to conform to the slightly
altered interface of these visitor classes.

Thanks to Nuno Lopes for providing a test case that illustrated some
fundamental problems in the current design of the CFGXXXStmtVisitor classes
and how they were used.

llvm-svn: 44246
2007-11-20 03:01:58 +00:00
Chris Lattner
6edac0ad1d Testcase for PR1811
llvm-svn: 44244
2007-11-19 21:43:22 +00:00
Chris Lattner
09c0393d5e ExpandUnalignedLoad doesn't handle vectors right at all apparently.
Fix a couple of problems:
1. Don't assume the VT-1 is a VT that is half the size.
2. Treat vectors of FP in the vector path, not the FP path.

This has a couple of remaining problems before it will work with
the code in PR1811: the code below this change assumes that it can
use extload/shift/or to construct the result, which isn't right for
vectors.

This also doesn't handle vectors of 1 or vectors that aren't pow-2.

llvm-svn: 44243
2007-11-19 21:38:03 +00:00
Chris Lattner
6fa95ec19d Implement vector expand support for shuffle_vector. This fixes PR1811.
llvm-svn: 44242
2007-11-19 21:16:54 +00:00
Dan Gohman
aad83c8ee5 Remove meaningless qualifiers from return types, avoiding compiler warnings.
llvm-svn: 44240
2007-11-19 20:46:23 +00:00
Chris Lattner
67d77945e7 Implement splitting of UNDEF nodes. This is the first step towards fixing PR1811
llvm-svn: 44239
2007-11-19 20:21:32 +00:00
Ted Kremenek
e866e7b6fc Removed PersistentMap. It is now superseded in every way by the ImmutableMap
and ImmutableSet classes in the main LLVM libraries.

llvm-svn: 44237
2007-11-19 17:25:30 +00:00
Owen Anderson
c280216c00 Teach me to do stuff late at night.
llvm-svn: 44236
2007-11-19 16:10:59 +00:00
Dan Gohman
12a8610490 Fix a typo in a comment.
llvm-svn: 44235
2007-11-19 15:36:19 +00:00
Dan Gohman
d32081002e Add explicit keywords.
llvm-svn: 44234
2007-11-19 15:30:20 +00:00
Dan Gohman
36347a26f9 Add support in SplitVectorOp for remainder operators.
llvm-svn: 44233
2007-11-19 15:15:03 +00:00
Owen Anderson
99057116f6 Fix a factually incorrect statement pointed out by Max Hailperin.
llvm-svn: 44228
2007-11-19 07:44:43 +00:00
Chris Lattner
4205d25f06 Record the start of the current token, for use in error reporting.
llvm-svn: 44227
2007-11-19 07:43:52 +00:00
Chris Lattner
1a26296453 Add carat diagnostics to tblgen lexer errors.
llvm-svn: 44226
2007-11-19 07:38:58 +00:00
Ted Kremenek
eb8471bfa1 Added test case for dead stores checker (live variables analysis) that tests
for correct propagation/update of liveness information within subexpressions
of Block-Level expressions.  Test case provided by Nuno Lopes.

llvm-svn: 44225
2007-11-19 06:38:23 +00:00
Ted Kremenek
850f1155ad Fixed bug where LiveVariables was not properly propagating updates to liveness
state that occurred in subexpressions of Block-Level expressions. Bug and fix
provided by Nuno Lopes.

llvm-svn: 44224
2007-11-19 06:36:49 +00:00
Anders Carlsson
9c1011c090 Put back the flags field in the constant CF string type.
llvm-svn: 44222
2007-11-19 00:25:30 +00:00
Ted Kremenek
094079c0dc Added test case for dead-stores checker. Test case provided by Nuno Lopes.
llvm-svn: 44221
2007-11-18 20:06:35 +00:00
Ted Kremenek
7016e4d509 Fixed bug in WalkaST_VisitDeclSubExprs where we failed to properly check if
the StmtIterator referring to the initializers of a chain of Decls was equal
to the "end" iterator. The particular bug manifested when an iterator was
created on a chain of decls with no initializers.

Thanks to Nuno Lopes for reporting this bug and providing a patch.

llvm-svn: 44220
2007-11-18 20:06:01 +00:00
Chris Lattner
44158478bb Fix the Linker testcase regressions, by making MemoryBuffer::getFileOrSTDIN return
a valid but empty buffer if stdin is empty.

llvm-svn: 44219
2007-11-18 18:52:28 +00:00
Chris Lattner
b01e500f16 autoupgrade files that use callfoo as call foo.
llvm-svn: 44218
2007-11-18 18:43:24 +00:00
Chris Lattner
f527037485 print a call to a fastcc function as:
call x86_fastcallcc void @func( i32* %X, i64 0 )
not:
	callx86_fastcallcc  void @func( i32* %X, i64 0 )

This fixes Codegen/X86/fast-cc-merge-stack-adj.ll

llvm-svn: 44217
2007-11-18 18:32:16 +00:00
Chris Lattner
861302e264 fix bogus test that the more strict lexer is finding.
llvm-svn: 44216
2007-11-18 18:26:45 +00:00
Chris Lattner
c3cc30cdb8 Bugfix, this fixes CodeGen/X86/ldzero.ll and CodeGen/X86/2007-10-16-fp80_select.ll
llvm-svn: 44215
2007-11-18 18:25:18 +00:00
Chris Lattner
660c6b9a92 Replace the original flex lexer with a hand writen one. This
drops a dependency on flex and lets us make future progress more 
easily.  Yay for 2 fewer .cvs files to make silly conflicts with.

llvm-svn: 44213
2007-11-18 08:46:26 +00:00
Chris Lattner
6070028736 minor cleanups
llvm-svn: 44212
2007-11-18 05:48:46 +00:00
Chris Lattner
98c39513ab ensure header is self contained.
llvm-svn: 44211
2007-11-18 05:25:45 +00:00
Chris Lattner
da4ab67127 reimplement the tblgen lexer with a simple hand-written lexer. This eliminates
one dependency on flex and gets rid of two ".cvs" files.

llvm-svn: 44210
2007-11-18 02:57:27 +00:00
Steve Naroff
14f5f79bb6 Now that we are passing back "free standing decls", make sure -ast-dump works like -ast-print.
Also added a cast to be safe...

llvm-svn: 44209
2007-11-17 21:37:36 +00:00
Steve Naroff
c1e6d60b14 Make sure Sema::ParsedFreeStandingDeclSpec() returns a decl representing the type.
Adding basic printing to StmtPrinter::PrintRawDecl().

llvm-svn: 44208
2007-11-17 21:21:01 +00:00
Nate Begeman
d4d45c268c Add support for vectors to int <-> float casts.
llvm-svn: 44204
2007-11-17 03:58:34 +00:00
Ted Kremenek
b6c40f3f1b Reverted patch 44199:
http://llvm.org/viewvc/llvm-project?rev=44199&view=rev

This patch completely broke serialization due to an invariant I assumed but
did not hold. The assumed invariant was that all pointer IDs emitted by a call
to BatchEmitOwnedPtrs would be consecutive. This is only the case if there has
been no forward references to an owned pointer (and hence already registered
with the Serializer object).

llvm-svn: 44203
2007-11-17 03:34:33 +00:00
Dale Johannesen
7d97662467 Remove indeterminism from a loop. We think this will
fix an occasional nonrepeatable bootstrap failure we've
been seeing on Darwin.

llvm-svn: 44202
2007-11-17 02:48:01 +00:00
Dale Johannesen
06a10df562 Fix denormal check in float->APInt conversion.
PR 1804.

llvm-svn: 44201
2007-11-17 01:02:27 +00:00
Ted Kremenek
9d89f980aa Changed implementation of Serialize::EmitDiffPtrID and
Deserialize::ReadDiffPtrID to read and emit bools instead of unsigned
integers. This should result in a nice space optimization once we have
"auto-abbreviation" generation in place.

llvm-svn: 44200
2007-11-17 00:45:37 +00:00
Ted Kremenek
4d1e79c8ac Implemented optimization for BatchEmitOwnedPtrs that we only emit one complete
SerializedPtrID, followed by the *differences* in IDs. The big idea is that
most IDs will be just be 1 off from the previous (either that or NULL, which
we encode as a difference if 0), so this will greatly reduce the encoding
space for extra IDs to just 1 bit per pointer.

So far this optimization reduces serialization of Carbon.h by only 1%, but
we aren't using any abbreviations now in the Bitcode file to properly take
advantage of this optimization.

llvm-svn: 44199
2007-11-17 00:40:45 +00:00
Evan Cheng
8e22379303 Live interval splitting:
When a live interval is being spilled, rather than creating short, non-spillable
intervals for every def / use, split the interval at BB boundaries. That is, for
every BB where the live interval is defined or used, create a new interval that
covers all the defs and uses in the BB.

This is designed to eliminate one common problem: multiple reloads of the same
value in a single basic block. Note, it does *not* decrease the number of spills
since no copies are inserted so the split intervals are *connected* through
spill and reloads (or rematerialization). The newly created intervals can be
spilled again, in that case, since it does not span multiple basic blocks, it's
spilled in the usual manner. However, it can reuse the same stack slot as the
previously split interval.

This is currently controlled by -split-intervals-at-bb.

llvm-svn: 44198
2007-11-17 00:40:40 +00:00
Evan Cheng
aa72f72bd3 Shrinkfy.
llvm-svn: 44197
2007-11-17 00:31:16 +00:00
Evan Cheng
13e8b022f5 Typo.
llvm-svn: 44196
2007-11-16 23:55:08 +00:00
Dale Johannesen
a674612d94 Testcase from PR 1508 (although its's somewhat
orthogonal to the main problem there)

llvm-svn: 44194
2007-11-16 23:16:35 +00:00
Tanya Lattner
1db762ba63 Fix for PR1801
llvm-svn: 44193
2007-11-16 22:44:50 +00:00
Ted Kremenek
f115550f6f Added assertion in serialization of DeclRefExprs. DeclRefExprs can only
own the decl they reference if it is a FunctionDecl.  Note that his
ownership property is still considered a hack, and should be fixed.

llvm-svn: 44192
2007-11-16 19:00:35 +00:00
Ted Kremenek
50d7f6f620 Fixed bug in the serialization of FunctionDecls. We would incorrectly
query for the number of parameters for FunctionDecls that had type
FunctionTypeNoProto.

llvm-svn: 44191
2007-11-16 18:11:10 +00:00
Chris Lattner
48d52848d7 Tighten up address-of checking, implementing test/Sema/expr-address-of.c.
This fixes a bug reported by Seo Sanghyeon.

This was meant to be committed yesterday, but the commit failed.  doh.

llvm-svn: 44190
2007-11-16 17:46:48 +00:00
Anton Korobeynikov
b8a47244ac These were implemented
llvm-svn: 44189
2007-11-16 11:12:01 +00:00
Chris Lattner
c53b18362a Fix PR1800 by correcting mistaken logic.
llvm-svn: 44188
2007-11-16 06:04:17 +00:00
Chris Lattner
1b3f58a816 fix a typo
llvm-svn: 44187
2007-11-16 05:32:05 +00:00
Anton Korobeynikov
91460e43f1 Implement codegen for flt_rounds on x86
llvm-svn: 44183
2007-11-16 01:31:51 +00:00
Anton Korobeynikov
66b91e66ec Implement necessary bits for flt_rounds gcc builtin.
Codegen bits and llvm-gcc support will follow.

llvm-svn: 44182
2007-11-15 23:25:33 +00:00
Nate Begeman
bd117f06ba Basic non-power-of-2 vector support
llvm-svn: 44181
2007-11-15 21:15:26 +00:00
Chris Lattner
0640e3ef35 Fix transient failure on Lex/c90.c due to an uninit variable.
llvm-svn: 44180
2007-11-15 19:22:40 +00:00
Chris Lattner
4dcbc2090a add header file I forgot to check in
llvm-svn: 44179
2007-11-15 19:22:18 +00:00
Chris Lattner
609d413363 fix a bug Steve noticed, where a #import of the main file itself would fail.
llvm-svn: 44178
2007-11-15 19:07:47 +00:00
Anton Korobeynikov
6a7ddfdb8f Reverted r44163 per request
llvm-svn: 44177
2007-11-15 18:33:16 +00:00
Ted Kremenek
07941e21e9 Added hack when serializing DeclRefExprs. This should probably be fixed.
Some FunctionDecls do not appear at the top-level or are owned by a DeclStmt.
In calls to implicitly defined functions, a FunctionDecl is created, but only
the DeclRefExprs reference them. Since an implicitly defined function may be
called multiple times, there is no clear ownership model for such objects.

Temporary solution: when serializing out DeclRefExprs, emit an ownership bit
for the Decl. This bit is determined by querying the serializer to see if the
Decl has already been serialized. If it hasn't, emit the Decl as an owned
pointer.

I repeat: this is a hack.  This should be fixed.

llvm-svn: 44176
2007-11-15 18:26:39 +00:00
Ted Kremenek
4791e1a7bd Started separate section for method definitions for ObjC serialization.
Added missing deserialization case in Stmt::Create() switch statement.

llvm-svn: 44175
2007-11-15 18:10:29 +00:00
Daniel Berlin
bb3b099f82 Fix bugs in iterator invalidation
llvm-svn: 44174
2007-11-15 18:06:49 +00:00
Steve Naroff
c8fcbe09d0 No need to forward declare definition of objc_super...
llvm-svn: 44173
2007-11-15 17:06:21 +00:00
Steve Naroff
e3ffc2f4a9 Finish up variadic methods/messages.
llvm-svn: 44172
2007-11-15 13:05:42 +00:00
Steve Naroff
d8ea1ac576 Implement support for variadic methods (work in progress).
llvm-svn: 44171
2007-11-15 12:35:21 +00:00
Steve Naroff
05caa48fb4 Extend RewriteTest::RewriteObjCIvarRefExpr() to cope with static typing (when using -> on a type which corresponds to the implementation type).
llvm-svn: 44170
2007-11-15 11:33:00 +00:00
Steve Naroff
44864e48bd Tweak funky cast to accommodate messaging 'super'. This removes any spurious warnings.
llvm-svn: 44169
2007-11-15 10:43:57 +00:00
Steve Naroff
7fa2f040f3 Rewrite for messaging 'super'.
The code gen. results in some spurious warnings...a cast is forthcoming.

llvm-svn: 44168
2007-11-15 10:28:18 +00:00
Duncan Sands
d4494352f8 This assertion was bogus.
llvm-svn: 44167
2007-11-15 09:54:37 +00:00
Evan Cheng
2c1a50455c Fix a thinko in post-allocation coalescer.
llvm-svn: 44166
2007-11-15 08:13:29 +00:00
Nate Begeman
847bfbcaf0 Break out bool/true/false support into a LangOption
llvm-svn: 44164
2007-11-15 07:30:50 +00:00
Nick Lewycky
fbb24817cc Fix handling of overflow in loop calculation by adding new UDiv SCEV. This SCEV
is disabled in the sense that it will refuse to create one from a UDiv
instruction, until the code is better tested.

llvm-svn: 44163
2007-11-15 06:30:50 +00:00
Chris Lattner
0841c3b560 Fix PR1788 by taking the approach suggested by Richard Smith.
Thanks to him for his detailed analysis of the problem.

llvm-svn: 44162
2007-11-15 06:10:55 +00:00
Chris Lattner
820c1447b4 Import the boost scoped_ptr class to LLVM. This patch was prepared by
Cédric Venet.

llvm-svn: 44161
2007-11-15 05:57:06 +00:00
Nate Begeman
4c18c23eb3 Implement codegen of CXX Bool
llvm-svn: 44160
2007-11-15 05:40:03 +00:00
Chris Lattner
bb31a42fef Handle "bool" in all places that touch _Bool.
This fixes code like "if((bool)x) {}" for example.

Patch by Nate Begeman.

llvm-svn: 44159
2007-11-15 05:25:19 +00:00
Owen Anderson
1b74a9a628 More templatization.
llvm-svn: 44158
2007-11-15 05:00:15 +00:00
Chris Lattner
add10eecf9 many edits, patch by Kelly Wilson!
llvm-svn: 44157
2007-11-15 04:51:31 +00:00
Steve Naroff
f60782b8c9 - Implement ivar rewrite (patch by Fariborz).
- RewriteMessageExpr()...make implicit casts explicit with synthesizing call (removing warnings when calling objc_msgSend()).

llvm-svn: 44156
2007-11-15 02:58:25 +00:00
Bill Wendling
b3712f8146 Adding debug output during coalescing.
llvm-svn: 44154
2007-11-15 02:06:30 +00:00
Bill Wendling
8269925b1e Need to increment the iterator.
llvm-svn: 44153
2007-11-15 00:40:48 +00:00
Ted Kremenek
c5f3e5371c Fixed serious bug in BatchReadOwnedPtrs where in a chain of calls to
deserialize objects if BatchReadOwnedPtrs was called more than once in the
same call chain then the second call would overwrite the SerializedPtrIDs
being used by the first call. Solved this problem by making the vector that
holds the pointer IDs local to a function call. Now BatchReadOwnedPtrs is
reentrant.

llvm-svn: 44152
2007-11-15 00:05:03 +00:00
Steve Naroff
909d666681 Refinement to previous commit. Always cast the first argument to "id"...no need to special case self.
llvm-svn: 44149
2007-11-15 00:00:21 +00:00
Steve Naroff
e7f181986a Cast implicit "self" argument to "id". This removes all warnings associated with implicit references to self. It doesn't yet deal withexplicit references to self...
llvm-svn: 44148
2007-11-14 23:54:14 +00:00
Ted Kremenek
cf7a20a6c4 Fixed bug in serialization of EnumConstantDecl where we improperly
"default constructed" an APSInt.  Fixed another bug in the same method
where we did not allow the NextDeclarator to be NULL.

llvm-svn: 44147
2007-11-14 23:38:09 +00:00
Ted Kremenek
c77e5a126c Fixed bug when serializing QualTypes where we were serializing in the
qualifiers as part of the pointer address.

llvm-svn: 44146
2007-11-14 23:35:01 +00:00
Steve Naroff
03f2767368 Always generate a typedef for @class. The typedef removal logic that I'm removing only made sense when we were operating on preprocess files without typedef guards. Now that we have guards, it is incorrect to ever remove one (since it may increase the likelihood that the rewritten header can't be included stand alone).
llvm-svn: 44145
2007-11-14 23:02:56 +00:00
Chris Lattner
174a825f01 Fix a rewriter bug that steve noticed. Don't skip arbitrary things
between an @ and a p, just skip whitespace.

llvm-svn: 44144
2007-11-14 22:57:51 +00:00
Ted Kremenek
83b75f5ee8 Added QualType::ReadBackpatch to allow QualType initialization with
backpatching. This original was available, but then we removed it. It is back
again to help with deserialization of FieldDecls. Because FieldDecls are
currently owned by RecordDecls, which are owned by a TagType, the type of the
FieldDecl may not be deserialized prior to deserializing the FieldDecl. Thus
backpatching solves the problem of constructing a FieldDecl that references a
type that has not yet been deserialized.

Simplified serialization of TagType to not require passing in the
SerializedPtrID. Registration of the materialized type object is done after
the CreateImpl method returns (as with other types).

llvm-svn: 44143
2007-11-14 22:51:02 +00:00
Fariborz Jahanian
c6225532c3 Patch to comment out use of protocol qualifiers when rewriting ivars.
llvm-svn: 44142
2007-11-14 22:26:25 +00:00
Duncan Sands
f171b35c8b I discover array_lengthof, thanks to gabor on #llvm.
llvm-svn: 44139
2007-11-14 21:58:02 +00:00
Ted Kremenek
e25b79ff84 Implemented serialization of InitListExpr.
llvm-svn: 44137
2007-11-14 21:31:46 +00:00
Ted Kremenek
3db07a7016 Implemented serialization of CompoundLiteralExpr.
llvm-svn: 44134
2007-11-14 21:18:36 +00:00
Ted Kremenek
fab0c76a25 Added serialization of Union decls.
llvm-svn: 44133
2007-11-14 21:15:42 +00:00
Duncan Sands
730a32643f Tweak the descriptions of the new 'const' and 'pure' attributes.
llvm-svn: 44132
2007-11-14 21:14:02 +00:00
Ted Kremenek
00e0b40599 Removed assertion inserted only for temporary debugging.
llvm-svn: 44131
2007-11-14 19:36:11 +00:00
Ted Kremenek
ec56081f38 Added missing break statement.
Reordered serialization methods for FunctionTypeProto and FunctionTypeNoProto
to be alphabetical by serialized type name.

llvm-svn: 44130
2007-11-14 19:33:01 +00:00
Steve Naroff
dde78986fb Fairly major surgery to RewriteTest::SynthesizeObjcInternalStruct().
This allows us to handle funky stuff like...

#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
@interface NSLayoutManager : NSObject <NSCoding, NSGlyphStorage> {
#else /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
@interface NSLayoutManager : NSObject <NSCoding> {
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */

...which now rewrites to...

#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
#ifndef _REWRITER_typedef_NSLayoutManager
#define _REWRITER_typedef_NSLayoutManager
typedef struct objc_object NSLayoutManager;
#endif

struct NSLayoutManager {
    struct NSObject _NSObject;

#else /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
// @interface NSLayoutManager : NSObject <NSCoding> {
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */

llvm-svn: 44129
2007-11-14 19:25:57 +00:00
Evan Cheng
0cbe920d7c Oops. Debugging code shouldn't have been checked in.
llvm-svn: 44128
2007-11-14 19:08:32 +00:00
Ted Kremenek
26ba7973ea Implemented serialization of EnumDecl and EnumConstantDecl.
llvm-svn: 44127
2007-11-14 18:12:19 +00:00
Ted Kremenek
8e93ca3de5 Implemented serialization of FieldDecls.
llvm-svn: 44126
2007-11-14 17:47:01 +00:00
Ted Kremenek
31ae973708 SourceManager, IdentifierTable, Selectors are now serialized in their own
block separate from ASTContext. This block is serialized out AFTER writing out
ASTContext, but deserialized BEFORE reading in ASTContext. This permits the
optimization of the serialization of the IdentifierTable where we only write
out identifiers that are used.

This was needed because TagDecls are owned by Types, and TagDecls contain
identifiers. Thus types need to be written out first to register with the
serializer any identifiers they refer to (and hence need to be serialized out
with IdentifierTable).

llvm-svn: 44125
2007-11-14 17:46:35 +00:00
Ted Kremenek
1172416d65 Removed debug #define that was accidentally checked in while debugging
the deserializer.

Fixed assertion when "stream jumping" in the deserializer to properly function
when we have reached the end of the stream.

llvm-svn: 44124
2007-11-14 17:42:09 +00:00
Fariborz Jahanian
794793ec1c Removed unused variabel.
llvm-svn: 44123
2007-11-14 17:35:46 +00:00
Chris Lattner
e6c7a858b0 Fix a bug handling hex floats in c90 mode, pointed out by Neil.
llvm-svn: 44120
2007-11-14 16:14:50 +00:00
Steve Naroff
a509f04034 Fix yesterday's regression with rewriting @optional/@required.
llvm-svn: 44119
2007-11-14 15:03:57 +00:00
Steve Naroff
58ed6c04f2 Rewrite methods that span multiple lines.
llvm-svn: 44118
2007-11-14 14:34:23 +00:00
Steve Naroff
9e0887cff4 Allow properties within a protocol. The case below was asserting...now it works fine.
@protocol CAMediaTiming

@property int beginTime;

@end

Comments in the code tell the rest of the story...

llvm-svn: 44117
2007-11-14 14:15:31 +00:00
Duncan Sands
9e12a3f020 Simplify the attribute verification code.
llvm-svn: 44116
2007-11-14 14:02:11 +00:00
Duncan Sands
544e64aa96 Un XFAIL these tests, now that Bill has backported
the fix from 4.2.

llvm-svn: 44115
2007-11-14 13:40:53 +00:00
Anton Korobeynikov
46f4446bba Document pure/const parameter attributes
llvm-svn: 44111
2007-11-14 10:30:13 +00:00
Anton Korobeynikov
6ca98cd532 Regenerate
llvm-svn: 44110
2007-11-14 09:53:48 +00:00
Anton Korobeynikov
ea09c697d7 Add pure/const attributes. Documentation will follow.
llvm-svn: 44109
2007-11-14 09:52:30 +00:00
Anton Korobeynikov
2c6387803e Fix PIC jump table codegen on x86-32/linux. In fact, such thing should be applied
to all targets uses GOT-relative offsets for PIC (Alpha?)

llvm-svn: 44108
2007-11-14 09:18:41 +00:00
Duncan Sands
e2287ed552 Eliminate the recently introduced CCAssignToStackABISizeAlign
in favour of teaching CCAssignToStack that size 0 and/or align
0 means to use the ABI values.  This seems a neater solution.
It is safe since no legal value type has size 0.

llvm-svn: 44107
2007-11-14 08:29:13 +00:00
Ted Kremenek
3c9c7b84fe Implemented serialization of RecordDecls. Changed serialization of TagType to
have an owning pointer to the referred TagDecl. This should hopefully fix a
bug where TagDecls (including decls from structs, etc.) were not serialized.

llvm-svn: 44106
2007-11-14 08:06:37 +00:00
Ted Kremenek
545f7e39e1 Added two new overloaded versions of BatchEmitOwnedPtrs and
BatchReadOwnedPtrs.

llvm-svn: 44105
2007-11-14 08:05:03 +00:00
Evan Cheng
7f02cfa599 Clean up sub-register implementation by moving subReg information back to
MachineOperand auxInfo. Previous clunky implementation uses an external map
to track sub-register uses. That works because register allocator uses
a new virtual register for each spilled use. With interval splitting (coming
soon), we may have multiple uses of the same register some of which are
of using different sub-registers from others. It's too fragile to constantly
update the information.

llvm-svn: 44104
2007-11-14 07:59:08 +00:00
Duncan Sands
9c30fc234c XFAIL these tests until the fix gets backported
from llvm-gcc-4.2 to 4.0.

llvm-svn: 44103
2007-11-14 07:42:50 +00:00
Chris Lattner
322a04ec7c Document a limitation, patch contributed by George Russell
llvm-svn: 44102
2007-11-14 07:04:44 +00:00
Nick Lewycky
c6243020a6 Allow the block extractor take to take a list of basic blocks to not extract
from a file containing Function/BasicBlock pairings. This is not safe against
anonymous or abnormally-named Funcs or BBs.

Make bugpoint use this interface to pass the BBs list to the child bugpoint.

llvm-svn: 44101
2007-11-14 06:47:06 +00:00
Chris Lattner
07b201d9c0 implement test/Sema/typedef-prototype.c, allowing code
to declare a function with a typedef:

typedef int unary_int_func(int arg);
unary_int_func add_one;

This patch contributed by Seo Sanghyeon!

llvm-svn: 44100
2007-11-14 06:34:38 +00:00
Chris Lattner
a77e74edba Implement PR1796 and Transforms/SimplifyCFG/noreturn-call.ll
by inserting unreachable after no-return calls.

llvm-svn: 44099
2007-11-14 06:19:25 +00:00
Steve Naroff
c17b056427 Comment out recent regression r44096.
llvm-svn: 44098
2007-11-14 03:37:28 +00:00
Owen Anderson
9306de0727 Start the process of making MachineLoopInfo possible by templating Loop.
llvm-svn: 44097
2007-11-14 02:33:58 +00:00
Fariborz Jahanian
fe38ba24af Rewrite @optional/@required directives used inside protocol definitions.
llvm-svn: 44096
2007-11-14 01:37:46 +00:00
Fariborz Jahanian
da6165c3dc Rewrite of forward protocol declaration.
llvm-svn: 44095
2007-11-14 00:42:16 +00:00
Ted Kremenek
164faf98f3 Implemented serialization of FunctionTypeNoProto.
llvm-svn: 44094
2007-11-14 00:38:50 +00:00
Ted Kremenek
7068cef079 Implemented serialization of VariableArrayTypes.
llvm-svn: 44093
2007-11-14 00:31:36 +00:00
Ted Kremenek
eef4a6296f Implemented serialization of TypedefType.
llvm-svn: 44092
2007-11-14 00:27:46 +00:00
Ted Kremenek
ea27383d68 Implemented serialization of ConstantArrayType.
llvm-svn: 44091
2007-11-14 00:17:21 +00:00
Ted Kremenek
f35e589847 Implemented serialization of TagTypes.
llvm-svn: 44090
2007-11-14 00:03:56 +00:00
Ted Kremenek
919858a428 Modified ASTContext::getTagDeclType() to accept a NULL pointer for the passed
in TagDecl*. This allows the deserializer to use ASTContext to create the
TagTypes. Deserialize TagTypes then rely on pointer-backpatching to resolve
the decls.

This may not be the interface that we want, but as the implementation of
TagTypes will potentially change significantly in the future, I'm leaving this
for now. An appropriate FIXME is in place.

llvm-svn: 44089
2007-11-14 00:03:20 +00:00
Steve Naroff
971d2f1242 Fix regression with ObjC method definitions and -ast-print
llvm-svn: 44088
2007-11-13 23:48:03 +00:00
Fariborz Jahanian
bc92fd7542 Type encoding for structs.
llvm-svn: 44087
2007-11-13 23:21:38 +00:00
Hartmut Kaiser
6f5421cbee Fixed a compilation error.
llvm-svn: 44083
2007-11-13 23:04:28 +00:00
Hartmut Kaiser
dde99f6a07 Fixed a strange construct. Please review.
llvm-svn: 44082
2007-11-13 23:04:06 +00:00
Hartmut Kaiser
1d4816584f Updated VC++ build system
llvm-svn: 44081
2007-11-13 23:03:32 +00:00
Steve Naroff
7b8fa4746a Rewrite method definition bodies. Also renamed a method to distinguish between method declarations and definitions.
llvm-svn: 44080
2007-11-13 23:01:27 +00:00
Ted Kremenek
204a1d3976 Removed line with typo (declared friendship with ASTContext). Line was
not needed since friendship is declared elsewhere.

llvm-svn: 44079
2007-11-13 22:57:59 +00:00
Ted Kremenek
767e7507c2 Added pretty-printing of statements during serialization.
llvm-svn: 44078
2007-11-13 22:56:10 +00:00
Ted Kremenek
049059a7db Implemented serialization of AsmStmt (or rather what is currently implemented
in AsmStmt).

llvm-svn: 44077
2007-11-13 22:55:51 +00:00
Ted Kremenek
d86dcfe8ca Fixed bug in FunctionDecl serialization where we crashed when the
FunctionDecl had decls for its parameters but still had greater than 0
arguments.

llvm-svn: 44076
2007-11-13 22:51:08 +00:00
Ted Kremenek
da551c3b1e Implemented serialization for SizeOfAlignOfTypeExpr.
llvm-svn: 44075
2007-11-13 22:30:29 +00:00
Ted Kremenek
b8f51d5512 Implemented serialization for MemberExpr.
llvm-svn: 44074
2007-11-13 22:16:23 +00:00
Nate Begeman
a0f78974a6 Give AST-walk passes a way to access DeclSpec attributes on functions and
variables.

llvm-svn: 44073
2007-11-13 22:14:47 +00:00
Fariborz Jahanian
989e03989b Fixed a rewrite of metadata bug when category implementation has no matching interface.
llvm-svn: 44072
2007-11-13 22:09:49 +00:00
Ted Kremenek
24726c3fc9 Rewrote type serialization to used the same methodology as we do for Decls.
Removed tons of dead code in ASTContext concerning how types use to be
serialized.
Removed serialization methods from QualType that are no longer used.

llvm-svn: 44070
2007-11-13 22:02:55 +00:00
Nate Begeman
313f8ca67b Rename Sema method to follow class naming convention
llvm-svn: 44069
2007-11-13 21:49:48 +00:00
Chris Lattner
68f04fa941 Fix the regression on Transforms/GlobalOpt/deadglobal-2.ll from my
patch on friday.

llvm-svn: 44068
2007-11-13 21:46:23 +00:00
Chris Lattner
f150ace6cb upgrade test
llvm-svn: 44067
2007-11-13 21:42:48 +00:00
Fariborz Jahanian
5633835d17 Populate metadata with adrress of method code.
llvm-svn: 44066
2007-11-13 21:02:00 +00:00
Chris Lattner
47791a4051 Parse "sizeof(arr)[0]" as a sizeof of an expr if arr
is an expression.

llvm-svn: 44065
2007-11-13 20:50:37 +00:00
Owen Anderson
d8167ab332 Run computeDomForest() on the set of registers that need to be tested for
interference.

llvm-svn: 44064
2007-11-13 20:13:24 +00:00
Owen Anderson
569ef71e44 Preserve LiveVariables when doing critical edge splitting.
llvm-svn: 44063
2007-11-13 20:04:45 +00:00
Fariborz Jahanian
c54d8462fb Rewrite of method definitions in categories.
llvm-svn: 44062
2007-11-13 20:04:28 +00:00
Owen Anderson
4696e959fe Wow. I definitely shouldn't write code when I'm tird.
Make my previous patch actually do what it was intended to do.

llvm-svn: 44061
2007-11-13 19:56:28 +00:00
Fariborz Jahanian
98ba6cde3d Order of methods are OK and generated .c file can be compiled.
llvm-svn: 44060
2007-11-13 19:21:13 +00:00
Ted Kremenek
794d8a6cde Updated test case to flag about comparisons against constants. We may
invert this case (i.e., not flag a warning) in the future.

llvm-svn: 44059
2007-11-13 19:18:22 +00:00
Ted Kremenek
b83f182b59 Modified -Wfloat-equal logic to suppress warnings where floating point values
are compared against builtins such as __builtin_inf.

llvm-svn: 44058
2007-11-13 19:17:00 +00:00
Dale Johannesen
7904708369 Revert previous; these files aren't ready to go in yet.
llvm-svn: 44057
2007-11-13 19:16:02 +00:00
Dale Johannesen
7a7085f6d3 Add parameter to getDwarfRegNum to permit targets
to use different mappings for EH and debug info;
no functional change yet.
Fix warning in X86CodeEmitter.

llvm-svn: 44056
2007-11-13 19:13:01 +00:00
Fariborz Jahanian
1e5f64e2ea First patch in rewrie of method definitions. This is work in progress.
llvm-svn: 44055
2007-11-13 18:44:14 +00:00
Ted Kremenek
577437de8b Updated diagnostic for -Wfloat-equal to underline the offending expressions.
llvm-svn: 44054
2007-11-13 18:40:33 +00:00
Ted Kremenek
2272f72723 Added -Wfloat-equal option to the driver. This makes warnings about
floating point comparisons using == or != an opt-in rather than a default
warning.

Updated test case to use -Wfloat-equal.

llvm-svn: 44053
2007-11-13 18:37:02 +00:00
Chris Lattner
07328f0b8b Make llvm2cpp better, patch for PR1794, contributed by Zack Rusin.
llvm-svn: 44051
2007-11-13 18:22:33 +00:00
Chris Lattner
034b49dca0 Clean up types, removing some casts. Patch contributed by
Cedric Venet.

llvm-svn: 44050
2007-11-13 18:16:41 +00:00
Chris Lattner
2f72c427cf improve handling of address of global when checking for
constants and initializers.  Patch by Sanghyeon Seo, thanks!

llvm-svn: 44049
2007-11-13 18:05:45 +00:00
Evan Cheng
c891ae92dc Fix x86-64 jit: remove reliance on Dwarf numbers.
llvm-svn: 44048
2007-11-13 17:54:34 +00:00
Steve Naroff
b666625493 Teach Sema::CheckCompareOperands() about "void *" (C99 6.5.9p2)
llvm-svn: 44047
2007-11-13 14:57:38 +00:00
Bill Wendling
77b13af9a6 Unifacalize the CALLSEQ{START,END} stuff.
llvm-svn: 44045
2007-11-13 09:19:02 +00:00
Chris Lattner
61ce4dff7a Implement PR1786 by iterating between dead cycle elimination
and simplifycfg in the rare cases when it is needed.

llvm-svn: 44044
2007-11-13 07:32:38 +00:00
Chris Lattner
36d5575660 Many typos, grammaro, and wording fixes. Patch by
Kelly Wilson, thanks!

llvm-svn: 44043
2007-11-13 07:06:30 +00:00
Steve Naroff
e50478e0b0 Tune the lookup logic in Sema::ActOnInstanceMessage() to handle private methods (declared within the implementation).
llvm-svn: 44041
2007-11-13 04:10:18 +00:00
Steve Naroff
9d0d4dc7bd Minor indenting changes and removed a level of casting in getClassInterface();
llvm-svn: 44039
2007-11-13 01:40:57 +00:00
Fariborz Jahanian
3a9fe93286 Patch to set context (interface, category, etc.) in which method is declared.
llvm-svn: 44038
2007-11-13 01:10:08 +00:00
Bill Wendling
f359fed9f9 Unify CALLSEQ_{START,END}. They take 4 parameters: the chain, two stack
adjustment fields, and an optional flag. If there is a "dynamic_stackalloc" in
the code, make sure that it's bracketed by CALLSEQ_START and CALLSEQ_END. If
not, then there is the potential for the stack to be changed while the stack's
being used by another instruction (like a call).

This can only result in tears...

llvm-svn: 44037
2007-11-13 00:44:25 +00:00
Steve Naroff
4a158f37f9 Fix Sema::CheckAssignmentConstraints() to operate on the canonical, unqualified type.
llvm-svn: 44036
2007-11-13 00:31:42 +00:00
Ted Kremenek
e9b83bbd68 Renamed all serialization "Materialize" methods to "Create" to conform with
the new serialization API.

llvm-svn: 44035
2007-11-13 00:25:37 +00:00
Ted Kremenek
e7033b0356 Renamed serialization method "Materialize" to "Create". This is an API change.
llvm-svn: 44034
2007-11-13 00:25:08 +00:00
Ted Kremenek
cd51750512 Restructured serialization code for decls to make it cleaner, easier to
understand, and batched the emission owned subobjects (using
BatchEmitOwnedPtr) to get a smaller output bitcode size.

llvm-svn: 44033
2007-11-13 00:15:39 +00:00
Ted Kremenek
be0a4b734e Fixed bug with inconsistent serialization/deserialization in matching
calls to BatchEmitOwnedPtrs and BatchReadOwnedPtrs.

llvm-svn: 44032
2007-11-13 00:13:57 +00:00
Bill Wendling
c8f2f68e87 Move SYSCTL stuff close to where it's used.
llvm-svn: 44031
2007-11-12 23:55:19 +00:00
Devang Patel
f48ae28600 Build universal llvm.
llvm-svn: 44030
2007-11-12 23:53:43 +00:00
Anton Korobeynikov
bfb139ec93 Completely forgot, that we have some debug information emission on PPC. This should fix
some regressions on ppc nightly tests.

llvm-svn: 44029
2007-11-12 23:36:13 +00:00
Fariborz Jahanian
21f54eeacf Patch to do statically typed ivar references.
llvm-svn: 44028
2007-11-12 22:29:28 +00:00
Steve Naroff
fedb49771d Add category method definitions incrementally, removing a FIXME (like we do for class implementations).
llvm-svn: 44027
2007-11-12 22:05:31 +00:00
Fariborz Jahanian
2d0d3ba43e Minor twik for when there is no super class and 'super' is errornously used.
llvm-svn: 44026
2007-11-12 20:20:37 +00:00
Fariborz Jahanian
d98a734bd6 'super' nailed.
llvm-svn: 44025
2007-11-12 20:13:27 +00:00
Bruno Cardoso Lopes
b439132d16 Added JumpTable support
Fixed some AsmPrinter issues
Added GLOBAL_OFFSET_TABLE Node handle.

llvm-svn: 44024
2007-11-12 19:49:57 +00:00
Steve Naroff
040f696bfc Fix regression to Sema::ObjcActOnStartOfMethodDef()...need to initialize InvalidType field to false.
llvm-svn: 44023
2007-11-12 19:48:27 +00:00
Steve Naroff
cd002f5a0e Add an error diagnostic to Parse::ParseObjCMessageExpression().
This now exposes the following bug...

******************** TEST 'Sema/message.m' FAILED! ********************
Command: 
 clang -fsyntax-only -verify Sema/message.m
Output:
Errors seen but not expected:
  Line 9: invalid receiver to message expression
******************** TEST 'Sema/message.m' FAILED! ********************

As far as I can tell, all messages to method agruments fail.

The method arguments are built by Sema::ObjcActOnStartOfMethodDef().

llvm-svn: 44022
2007-11-12 19:18:37 +00:00
Ted Kremenek
e33ba16368 Added versions of ReadPtr that takes an explicit SerializedPtrID. This allows
clients of the Deserializer to read the pointer ID before they are ready
to deserialize the object (which can mean registering a pointer reference
with the backpatcher).

Changed some methods that took an argument "SerializedPtrID" to "const SerializedPtrID&" (pass-by-reference).  This is to accommodate a future
revision of SerializedPtrID where it may be much fatter than an unsigned
integer.

llvm-svn: 44021
2007-11-12 19:11:15 +00:00
Ted Kremenek
0035bf33c4 In Stmt serialization, renamed directEmit to EmitImpl and
directMaterialize to CreateImpl.

llvm-svn: 44020
2007-11-12 18:04:32 +00:00
Owen Anderson
c520c4b325 Break critical edges coming into blocks with PHI nodes.
llvm-svn: 44019
2007-11-12 17:27:27 +00:00
Steve Naroff
b342361c0d Now that we can refer to instance variables, make sure they are considered lvalues.
llvm-svn: 44017
2007-11-12 14:34:27 +00:00
Steve Naroff
e46504b278 Implement instance variable references.
llvm-svn: 44016
2007-11-12 14:29:37 +00:00
Steve Naroff
e3d1ab29da - Minor cleanup to yesterday's changes to Sema::ObjcActOnStartOfMethodDef();
- Add Sema::CurMethodDecl, in preparation for adding ObjcIvarRefExpr.
- Add ObjcInterfaceDecl::lookupInstanceVariable(), in prep for adding ivars.
- A couple renames in ObjcInterfaceDecl, while I was in the vicinity:-)

llvm-svn: 44015
2007-11-12 13:56:41 +00:00
Gordon Henriksen
1ced282c73 Typo fix in the tutorial.
llvm-svn: 44014
2007-11-12 13:46:21 +00:00
Duncan Sands
5dc0c9282f Compile fix.
llvm-svn: 44013
2007-11-12 13:43:23 +00:00
Owen Anderson
933b5b7e62 Add a flag for indirect branch instructions.
Target maintainers: please check that the instructions for your target are correctly marked.

llvm-svn: 44012
2007-11-12 07:39:39 +00:00
Evan Cheng
be51f28e2b Refactor some code.
llvm-svn: 44010
2007-11-12 06:35:08 +00:00
Steve Naroff
8e5c112add Forgot this file from my last commit...
llvm-svn: 44009
2007-11-12 05:02:46 +00:00
Steve Naroff
ff4dbff4f4 Remove Action::ObjcActOnMethodDefinition(). Rationale:
- It is not an "action" - it is never called by the parser.
- It was only used by one method, Sema::ObjcActOnStartOfMethodDef().

As a result, the logic it embodied is now directly implemented in Sema::ObjcActOnStartOfMethodDef().

llvm-svn: 44008
2007-11-12 04:59:00 +00:00
Steve Naroff
3434bebec9 Make sure @property is allowed within a category.
Bug submitted by Keith Bauer.

CookieJar:Desktop keith$ cat test.m
#import <WebKit/WebKit.h>

llvm-svn: 44007
2007-11-12 04:22:52 +00:00
Steve Naroff
d0bf516e70 Remove Sema::ObjcBuildMethodParameter().
Modify Sema::ParseParamDeclarator() to work for both ActOnStartOfFunctionDef() and ObjcActOnStartOfMethodDef().

llvm-svn: 44006
2007-11-12 03:44:46 +00:00
Owen Anderson
556fb3467b Fix rewriting of PHI nodes.
Could someone more familiar with machine-level stuff review this for me?

llvm-svn: 44005
2007-11-12 02:13:07 +00:00
Hartmut Kaiser
28af9f7d00 Updated VC++ build system
llvm-svn: 44004
2007-11-12 01:24:50 +00:00
Owen Anderson
f66f0d619a Remove unnecessary #include's.
llvm-svn: 44003
2007-11-12 01:19:28 +00:00
Owen Anderson
a1cd45213d As Chris and Evan pointed out, BreakCriticalMachineEdges doesn't really need
to be a pass of its own.  Instead, move it out into a helper method.

llvm-svn: 44002
2007-11-12 01:05:09 +00:00
Owen Anderson
55f4e5d2dd Fix on 64-bit machines.
llvm-svn: 44001
2007-11-12 00:56:04 +00:00
Steve Naroff
b313fc3203 Replace 2 method definition actions (ActOnFunctionDefBody, ActOnMethodDefBody) with 1 method definition action (ActOnFinishFunctionBody). I can't think of any reason that we would need two action hooks.
llvm-svn: 44000
2007-11-11 23:20:51 +00:00
Steve Naroff
bb87572d70 Replace 3 method definition functions (ObjcParseMethodDefinition, ParseObjCInstanceMethodDefinition, ParseObjCClassMethodDefinition) with 1 method definition function (ParseObjCMethodDefinition).
Less code/confusion.

llvm-svn: 43999
2007-11-11 19:54:21 +00:00
Anton Korobeynikov
0644bb865e Clarify the meaning of '-2' register number
llvm-svn: 43998
2007-11-11 19:53:50 +00:00
Anton Korobeynikov
4edfea438a Use TableGen to emit information for dwarf register numbers.
This makes DwarfRegNum to accept list of numbers instead.
Added three different "flavours", but only slightly tested on x86-32/linux.
Please check another subtargets if possible,

llvm-svn: 43997
2007-11-11 19:50:10 +00:00
Steve Naroff
49effdefef Tweak Sema::ActOnInstanceMessage() to treat the built-in "Class" type the same as "id".
llvm-svn: 43996
2007-11-11 17:52:25 +00:00
Steve Naroff
cac26f4f5f This is the last 5% of the solution to teaching Sema::ActOnInstanceMessage() about private methods (r43989).
While the diff is large, the idea is very simple. When we parse method definitions (in an @implementation), we need to add them incrementally (rather than wait until the @end).

Other details...

- Renamed Sema::ActOnAddMethodsToObjcDecl() to Sema::ActOnAtEnd(). The methods are now optional arguments.
- Removed Parser::AllImplMethods (a nice cleanup).
- Added location info to ObjcImplementationDecl (since we will need it very soon:-)
- Modified message.m test to no longer allow the bogus diagnostic.

llvm-svn: 43995
2007-11-11 17:19:15 +00:00
Steve Naroff
5f9ae64f6e Make sure Sema::CheckIncrementDecrementOperand() removes typedefs when doing it's analysis.
Thanks to Seo Sanghyeon for his excellent (first) bug fix!

llvm-svn: 43994
2007-11-11 14:15:57 +00:00
Anton Korobeynikov
a468a11d80 Add convenient helper to obtain list of ints
llvm-svn: 43993
2007-11-11 11:19:37 +00:00
Steve Naroff
22e078e013 Teach Sema::ActOnInstanceMessage() about private methods. That is, methods declared in an implementation (but not listed in the interface).
This commit is only 95% of the bug fix. The last piece to this puzzle is to add the method decls to the implementation incrementally (as we encounter them). At the moment, the methods aren't added until we see an @end (which is too late).

I will complete this later...

llvm-svn: 43989
2007-11-11 00:10:47 +00:00
Dale Johannesen
b988e7e8cd Add CCAssignToStackABISizeAlign for convenience in
dealing with types whose size & alignment are
different on different subtargets.  Use it for x86 f80.

llvm-svn: 43988
2007-11-10 22:07:15 +00:00
Fariborz Jahanian
0bd56b7727 Fixed a bug which exposed the internally built type to user code.
llvm-svn: 43987
2007-11-10 22:00:55 +00:00
Fariborz Jahanian
16e3123071 pretty priting for method definitions.
llvm-svn: 43986
2007-11-10 20:59:13 +00:00
Steve Naroff
257b4a2467 Fix a basic bug (having to do with typedefs) in Sema::UsualArithmeticConversions().
This resuled in the following crash below.

Also modified the usual-float.c test case to capture this case.

[steve-naroffs-imac:clang/test/Sema] snaroff% ../../../../Debug/bin/clang usual-float.c
Assertion failed: (0 && "Sema::UsualArithmeticConversions(): illegal float comparison"), function UsualArithmeticConversions, file SemaExpr.cpp, line 960.
0   clang                               0x001ef9b9 _ZN40_GLOBAL__N_Signals.cpp_00000000_4E6DAF8315PrintStackTraceEv + 45
1   clang                               0x001efd5f _ZN40_GLOBAL__N_Signals.cpp_00000000_4E6DAF8313SignalHandlerEi + 323
2   libSystem.B.dylib                   0x90c6297b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   libSystem.B.dylib                   0x90cdb782 raise + 26
5   libSystem.B.dylib                   0x90cead3f abort + 73
6   libSystem.B.dylib                   0x90cdc923 __assert_rtn + 101
7   clang                               0x00077316 _ZN5clang4Sema26UsualArithmeticConversionsERPNS_4ExprES3_b + 1004
8   clang                               0x000803cf _ZN5clang4Sema27CheckMultiplyDivideOperandsERPNS_4ExprES3_NS_14SourceLocationEb + 181
9   clang                               0x0007a8e8 _ZN5clang4Sema10ActOnBinOpENS_14SourceLocationENS_3tok9TokenKindEPvS4_ + 472
10  clang                               0x000cf058 _ZN5clang6Parser26ParseRHSOfBinaryExpressionENS_6Action12ActionResultILj0EEEj + 1286
11  clang                               0x000cf2de _ZN5clang6Parser25ParseAssignmentExpressionEv + 86

llvm-svn: 43985
2007-11-10 19:45:54 +00:00
Ted Kremenek
b0cdfeb4ba Fixed a bug introduced by my last patch. Now we properly clear out the BatchIDVec
vector before reusing it.

llvm-svn: 43984
2007-11-10 19:33:26 +00:00
Ted Kremenek
cdf5fca367 Fixed hack in BatchReadOwnedPtrs to no longer use the array of pointers passed in for
deserialization as a temporary location for storing serialized pointer identifiers. The
definition of SerializedPtrID will likely change significantly in the future, and the
current implementation caused compilation errors on some 64-bit machines.

llvm-svn: 43983
2007-11-10 19:28:49 +00:00
Ted Kremenek
195c478e1b Updated method signature to conform with the typedef in the method prototype.
llvm-svn: 43982
2007-11-10 19:19:32 +00:00
Steve Naroff
68754c59bc Since we are all working on Leopard, change the built-in MacOS X version number (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) to target Leopard. This is only a short term solution, until the clang driver implements the "-mmacosx-version-min" flag (which will compute this value based on the target).
llvm-svn: 43981
2007-11-10 18:06:36 +00:00
Fariborz Jahanian
6aafd4130b Minor code clean up in method def area.
llvm-svn: 43980
2007-11-10 17:40:57 +00:00
Fariborz Jahanian
85e1d0d807 Represent method definitions as separate AST nodes. Pretty print will come next.
llvm-svn: 43979
2007-11-10 16:31:34 +00:00
Arnold Schwaighofer
d2c16ff905 Update tailcall code to include inline attribute operand for memcpy.
llvm-svn: 43978
2007-11-10 10:48:01 +00:00
Ted Kremenek
739156ab7c Changed the serialization of IdentifierTable to only serialize out entries
that are referenced in the ASTs. This assumes that we serialize out the
decls/stmts first, and use the pointer-tracking logic in the Serializer to
determine if an IdentifierInfo (or its string key) is ever referenced.

This is a significant space optimization for serialized ASTs.

Consider the following program:

void foo(int x,int y) {
  return x > y ? x : y+1;
}

Here are the sizes of the files for the serialized ASTs:

        Full IdentifierTable: 23676 bytes
 Only-referenced Identifiers:   304 bytes.

For this simple program, this is a 77% reduction in the file size of the
serialized ASTs.

llvm-svn: 43975
2007-11-10 02:11:55 +00:00
Ted Kremenek
11d700bfba Modifed the test serialization driver to...
(1) serialize out top-level decls BEFORE serializing out translation unit
structures like ASTContext.

(2) deserialize out translation unit structures like ASTContext before
top-level decls by first skipping the decls in the bitstream, deserializing
ASTContext and friends, and then jumping back to the bitstream block with the
decls and then deserializing them.

Change (1) allows us to utilize the pointer-tracking system in the Serializer
to only serialize out metadata that is actually referenced by the ASTS.

Change (2) allows us to deserialize the metadata first as before, which
signficantly reduces the amount of pointer backpatching the deserializer
would have to do if the decls were deserialized first.

llvm-svn: 43974
2007-11-10 02:07:12 +00:00
Ted Kremenek
55e30be8ec Added "random access" to the Deserializer to allow a client to jump to any
serialized block in the bitstream, including a block in an entirely different
nesting than the current block. This is useful for deserializing objects from
a bitstream in an order different from the order that they were serialized.

llvm-svn: 43973
2007-11-10 02:02:34 +00:00
Ted Kremenek
a7f49ce570 Made Deserializer a friend class of BitstreamReader.
Moved some of the logic in BitstreamReader::ExitBlock into a utility function
BitstreamReader::PopBlockScope. The latter is a private method. It will also
be called by Deserializer to manipulate the current "block scope."

llvm-svn: 43972
2007-11-10 02:00:38 +00:00
Evan Cheng
9e0216deab Added -test-opts to specify test options.
llvm-svn: 43971
2007-11-10 01:33:27 +00:00
Chris Lattner
ef067a2828 rename getInstantiationLoc to match the scheme of isPhysicalLoc.
llvm-svn: 43969
2007-11-09 23:59:17 +00:00
Chris Lattner
198b3e085d change source location to have two bits for macros, tracking
whether the location is the start and/or end of an expansion.
These are currently not set or used by anything.

llvm-svn: 43968
2007-11-09 23:52:16 +00:00
Fariborz Jahanian
7a017215eb Some code clean up in the form of name changes for functions which
process method definitions.

llvm-svn: 43967
2007-11-09 22:27:59 +00:00
Chris Lattner
f9f08bf4b0 Update links.
llvm-svn: 43964
2007-11-09 21:49:08 +00:00
Evan Cheng
05b94b8c13 Fix tests.
llvm-svn: 43961
2007-11-09 20:46:00 +00:00
Hartmut Kaiser
67297144ab Fixed a strange construct. Please review.
llvm-svn: 43960
2007-11-09 19:59:00 +00:00
Hartmut Kaiser
76886e1875 Updated VC++ build system
llvm-svn: 43959
2007-11-09 19:54:59 +00:00
Hartmut Kaiser
03f4d47254 Updated VC++ build system
llvm-svn: 43958
2007-11-09 19:53:21 +00:00
Fariborz Jahanian
b5605179c4 Added class context to method declarations. Provide "interface *" type
to 'self' method of instance methods.

llvm-svn: 43957
2007-11-09 19:52:12 +00:00
Chris Lattner
da043b68ad try again
llvm-svn: 43956
2007-11-09 19:24:54 +00:00
Evan Cheng
fb13fd6f93 Unbreak x86-64 jumptable.
llvm-svn: 43955
2007-11-09 19:11:23 +00:00
Anton Korobeynikov
5db5e352b9 Silence a warning
llvm-svn: 43954
2007-11-09 19:06:14 +00:00
Dale Johannesen
dfb85c7831 Revert previous rewrite per chris's comments.
llvm-svn: 43950
2007-11-09 18:07:11 +00:00
Chris Lattner
f9c0fd7488 Tighten up a check for folding away loads from (newly constant) globals. This
fixes a crash on Transforms/GlobalOpt/2007-11-09-GEP-GEP-Crash.ll and 
rdar://5585488.

llvm-svn: 43949
2007-11-09 17:33:02 +00:00
Fariborz Jahanian
19d4dbd217 Insert invisble arguments to method definition header.
llvm-svn: 43948
2007-11-09 17:18:29 +00:00
Steve Naroff
2011338446 Rewrite global variable initializers.
llvm-svn: 43947
2007-11-09 15:20:18 +00:00
Steve Naroff
8570fdec1a Recognize ObjCStringLiteral as a constant expression.
llvm-svn: 43946
2007-11-09 15:00:03 +00:00
Duncan Sands
303a5d6c8b Thanks to the XTARGET line, this test should still
be run on darwin, but I have no way of checking...

llvm-svn: 43945
2007-11-09 13:50:25 +00:00
Duncan Sands
e795efea5b Move MinAlign to MathExtras.h.
llvm-svn: 43944
2007-11-09 13:41:39 +00:00
Steve Naroff
1b232132ad - add typedef guards.
- tweak scanForProtocolRefs heuristic.
- disable RewriteInclude() for now.

llvm-svn: 43942
2007-11-09 12:50:28 +00:00
Anton Korobeynikov
550b98e147 Fix indent
llvm-svn: 43941
2007-11-09 12:34:20 +00:00
Anton Korobeynikov
98638aede6 Forget to commit users part of value mapper interface
llvm-svn: 43940
2007-11-09 12:27:04 +00:00
Anton Korobeynikov
8eeca1c252 And delete this one
llvm-svn: 43939
2007-11-09 12:22:04 +00:00
Anton Korobeynikov
7a96822f32 Make this header public
llvm-svn: 43938
2007-11-09 12:16:58 +00:00
Duncan Sands
e7a9ac929f Fix some load/store logic that would be wrong for
apints on big-endian machines if the bitwidth is
not a multiple of 8.  Introduce a new helper,
MVT::getStoreSizeInBits, and use it.

llvm-svn: 43934
2007-11-09 08:57:19 +00:00
Duncan Sands
bab9dc9433 Add terminating newline.
llvm-svn: 43933
2007-11-09 08:30:21 +00:00
Duncan Sands
0c7fba914d Check that the first and third characters, s and u,
are accessed with an alignment of 2 not 1.

llvm-svn: 43932
2007-11-09 07:47:29 +00:00
Duncan Sands
1445725759 Check that accesses to the second short, t, have
an alignment of 2 rather than 4.

llvm-svn: 43931
2007-11-09 07:46:02 +00:00
Bill Wendling
71df1dd59e Initial commit of files that support building LLVM the "Apple" way.
llvm-svn: 43929
2007-11-09 06:59:33 +00:00
Nick Lewycky
70248c92cf Add a link to the tutorial.
llvm-svn: 43928
2007-11-09 05:45:51 +00:00
Evan Cheng
797d56ff17 Much improved pic jumptable codegen:
Then:
        call    "L1$pb"
"L1$pb":
        popl    %eax
		...
LBB1_1: # entry
        imull   $4, %ecx, %ecx
        leal    LJTI1_0-"L1$pb"(%eax), %edx
        addl    LJTI1_0-"L1$pb"(%ecx,%eax), %edx
        jmpl    *%edx

        .align  2
        .set L1_0_set_3,LBB1_3-LJTI1_0
        .set L1_0_set_2,LBB1_2-LJTI1_0
        .set L1_0_set_5,LBB1_5-LJTI1_0
        .set L1_0_set_4,LBB1_4-LJTI1_0
LJTI1_0:
        .long    L1_0_set_3
        .long    L1_0_set_2

Now:
        call    "L1$pb"
"L1$pb":
        popl    %eax
		...
LBB1_1: # entry
        addl    LJTI1_0-"L1$pb"(%eax,%ecx,4), %eax
        jmpl    *%eax

		.align  2
		.set L1_0_set_3,LBB1_3-"L1$pb"
		.set L1_0_set_2,LBB1_2-"L1$pb"
		.set L1_0_set_5,LBB1_5-"L1$pb"
		.set L1_0_set_4,LBB1_4-"L1$pb"
LJTI1_0:
        .long    L1_0_set_3
        .long    L1_0_set_2

llvm-svn: 43924
2007-11-09 01:32:10 +00:00
Evan Cheng
f14006f4d6 Didn't mean to check these in.
llvm-svn: 43923
2007-11-09 01:28:33 +00:00
Evan Cheng
1bf166312b Bug fix. Passive nodes are not in SUnitMap.
llvm-svn: 43922
2007-11-09 01:27:11 +00:00
Chuck Rose III
0e7937654c Adding some recently added files to the VStudio projects
llvm-svn: 43919
2007-11-09 00:48:27 +00:00
Dale Johannesen
04fd82088e Rewrite Dwarf number handling per review comments.
llvm-svn: 43918
2007-11-09 00:47:10 +00:00
Ted Kremenek
908f96a2cf Changed method call to reflect updated serialization API.
llvm-svn: 43917
2007-11-09 00:43:55 +00:00
Ted Kremenek
1d9406c1ca Updated Deserializer class to provide more information about the current
block that is being visited in the bitstream.  The client can also now
skip blocks before reading them, and query the current abbreviation number
as seen from the perspective of the Deserializer.  This allows the client
to be more interactive in the deserialization process (if they so choose).

llvm-svn: 43916
2007-11-09 00:43:51 +00:00
Fariborz Jahanian
56ff146ec4 First patch toward rewriting of method definitions. This is work in progress.
llvm-svn: 43915
2007-11-08 23:49:49 +00:00
Devang Patel
94785aa1c7 Run this test only on darwin.
llvm-svn: 43912
2007-11-08 22:26:46 +00:00
Owen Anderson
65d2fcdd2a This preserves critical edge breaking.
llvm-svn: 43911
2007-11-08 22:23:57 +00:00
Owen Anderson
3bc8124a66 Make BreakCriticalMachineEdges available as a pass that can be depended on.
llvm-svn: 43910
2007-11-08 22:20:23 +00:00
Chris Lattner
f546408406 remove some temporary code.
llvm-svn: 43906
2007-11-08 20:53:07 +00:00
Chris Lattner
b74f6e82e4 add a getAtOffset() member to simplify some code.
llvm-svn: 43905
2007-11-08 20:51:02 +00:00
Ted Kremenek
da4c6c183d Rewrote serialization of IdentifierInfo and IdentifierTable to use methods Emit
and Materialize/Read instead of using specializations of SerializeTrait<>. The
resulting code is much cleaner. We are also setting the stage so that only the
parts of the IdentifierTable that are ever referenced within the ASTs are
serialized, and not the whole table.

llvm-svn: 43904
2007-11-08 19:52:41 +00:00
Ted Kremenek
67135ebaff Added typedef "SerializedPtrID" to represent the pointer handle written to disk
instead of just using "unsigned".  This gives us more flexibility in changing
the definition of the handle later, and is more self-documenting.

Added tracking of block stack in the Deserializer.  Now clients can query
if they are still within a block using the methods GetCurrentBlockLocation()
and FinishedBlock().

llvm-svn: 43903
2007-11-08 19:50:46 +00:00
Chris Lattner
34660fb75a add a fixme.
llvm-svn: 43902
2007-11-08 19:40:23 +00:00
Chris Lattner
bedd411589 significantly simplify the implementation of RewriteRope by changing the
implementation to be list<RopePiece> instead of vector<RopePiece*>.

llvm-svn: 43901
2007-11-08 19:39:57 +00:00
Fariborz Jahanian
8e632940fc Refactored parsing of main function body for reuse by objective-c methods.
llvm-svn: 43898
2007-11-08 19:01:26 +00:00
Andrew Lenharth
19ca5c7021 Better check
llvm-svn: 43897
2007-11-08 18:45:15 +00:00
Chris Lattner
3eb670721f improve MakeRopeString to avoid doing a malloc for every 2-character string
that gets inserted.  This speeds up the rewriter another 10%.

llvm-svn: 43896
2007-11-08 18:32:01 +00:00
Chris Lattner
9a00d3ec90 Simplify interface to MakeRopeString.
llvm-svn: 43895
2007-11-08 17:59:48 +00:00
Chris Lattner
3a21bd50e7 Fix backwards assert.
llvm-svn: 43894
2007-11-08 17:56:40 +00:00
Andrew Lenharth
8cf11aa330 Fix PR1780
llvm-svn: 43893
2007-11-08 17:39:28 +00:00
Lauro Ramos Venancio
f6a67bf700 [ARM] Implement __builtin_thread_pointer.
llvm-svn: 43892
2007-11-08 17:20:05 +00:00
Ted Kremenek
f2d68452c6 Implemented serialization of AddrLabelExpr.
Implemented serialization of ConditionalOperator.
Implemented serialization of StmtExpr.
Fixed bug in serialization of IndirectGoto (did not properly serialize subexpression).

llvm-svn: 43891
2007-11-08 16:32:00 +00:00
Steve Naroff
265a6b9693 Rewrite RewriteObjCStringLiteral(). This version is simpler (and unlike the previous one, works:-)
llvm-svn: 43890
2007-11-08 14:30:50 +00:00
Evan Cheng
ece4c68b82 If both parts of smul_lohi, etc. are used, don't simplify. If only one part is used, try simplify it.
llvm-svn: 43888
2007-11-08 09:25:29 +00:00
Owen Anderson
0be8c1dafe Add the majority of machine-level critical edge breaking pass. Most of this was written by Fernando, cleanup and updating to TOT by me.
This still needs a bit of work, particularly to handle jump tables properly.

llvm-svn: 43885
2007-11-08 07:55:43 +00:00
Chris Lattner
e90ce8def3 Add a new RewriteRope data structure which is a smarter way to represent the text
backing a rewrite buffer than using an std::vector<char>.  This class was hacked
together very quickly and needs to be cleaned up, but it seems to work.  It speeds
up rewriting a a 7M file from 6.43s to 0.24s on my machine.  The impl could also
be made to be a lot more algorithmically sound.

This produces identical output to using vector on this testcase, if it causes a
problems or bugs are encountered, it can be disabled by changing the 
RewriteBuffer::Buffer typedef back.

llvm-svn: 43884
2007-11-08 07:35:14 +00:00
Chris Lattner
7a7da75916 abstract out buffer type a bit better
llvm-svn: 43883
2007-11-08 05:42:25 +00:00
Chris Lattner
dc0cfc9fe3 use insert instead of replacing 0 bytes with text :)
llvm-svn: 43882
2007-11-08 04:41:51 +00:00
Chris Lattner
edebdb5b29 minor cleanups
llvm-svn: 43881
2007-11-08 04:41:04 +00:00
Chris Lattner
9fd5890e52 use std::copy instead of memcpy for abstraction.
Disable rewrite-tabs.  This speeds up processing of the commentified huge
crazy testcase steve gave me from 20s to 6.6s in a release build.

llvm-svn: 43880
2007-11-08 04:27:23 +00:00
Chris Lattner
4573cc708a Fix a rewriter bug that fariborz hit, when an @interface was the very very very
first thing in the file.

The trick is that text replacement should go after the insert point, 
not before it, because it will be replacing text after the point, not before 
it.

llvm-svn: 43879
2007-11-08 04:09:59 +00:00
Owen Anderson
bfbc12973d Take another stab at getting isLiveIn() and isLiveOut() right.
llvm-svn: 43869
2007-11-08 01:32:45 +00:00
Owen Anderson
4ac4ec215f Fix MachineDominators' getAnalysisUsage.
llvm-svn: 43868
2007-11-08 01:22:53 +00:00
Owen Anderson
17296e74b1 Oops, forgot to commit this file.
llvm-svn: 43867
2007-11-08 01:22:24 +00:00
Owen Anderson
9d86ef12c8 Bring UsedBlocks back. StrongPHIElimination needs this information.
llvm-svn: 43866
2007-11-08 01:20:48 +00:00
Ted Kremenek
a34b057762 Revised serialization of CaseStmt to emit all of the owned pointers (its
subexpressions) all together in one block at the end.

llvm-svn: 43862
2007-11-08 00:56:26 +00:00
Ted Kremenek
89704afa43 Revised BatchEmitOwnedPtrs to work better with constant pointers.
llvm-svn: 43861
2007-11-08 00:55:31 +00:00
Ted Kremenek
c1cddef7c9 Implemented serialization of CompoundAssignOperator.
llvm-svn: 43860
2007-11-08 00:41:37 +00:00
Devang Patel
ec51171319 Add assert for the case that is not handled.
struct { char a; short b:2; };

llvm-svn: 43859
2007-11-08 00:32:12 +00:00
Ted Kremenek
2419ac8792 Implemented serialization of UnaryOperator.
llvm-svn: 43858
2007-11-08 00:26:24 +00:00
Devang Patel
7c7a07d949 Keep track of beginning offset for the bit field that does not start at byte boundry.
llvm-svn: 43857
2007-11-08 00:17:59 +00:00
Ted Kremenek
8f74abd34a Revised implementation of BatchReadOwnedPtrs() that deserializes an
array of pointers to not allocate a second array to contain the pointer ids.

Fixed bug in the same member function where deserialized pointers were
not being registered with the backpatcher.

llvm-svn: 43855
2007-11-08 00:04:50 +00:00
Ted Kremenek
766fc8c14a Implemented serialization of CallExpr.
llvm-svn: 43854
2007-11-07 23:32:20 +00:00
Ted Kremenek
14b5fe537e Fixed bug where we did not properly serialize owned objects due to a missing
dereference.

llvm-svn: 43853
2007-11-07 23:32:06 +00:00
Ted Kremenek
1125bfa648 Added version of BatchEmitOwnedPtrs and BatchReadOwnedPtrs that emits/reads
an array of pointers of the same type.

llvm-svn: 43852
2007-11-07 23:18:40 +00:00
Ted Kremenek
2c325386b8 Implemented serialization of ArraySubscriptExpr.
Added "using ..." for "Serializer" and "Deserializer" to reduce amount
of typing for serialization methods.

llvm-svn: 43849
2007-11-07 22:53:01 +00:00
Ted Kremenek
e87ceeeb4a Implemented serialization of CastExpr.
llvm-svn: 43848
2007-11-07 22:42:34 +00:00
Ted Kremenek
b2b5e73f89 Implemented serialization of ImplicitCastExpr.
llvm-svn: 43847
2007-11-07 22:39:17 +00:00
Ted Kremenek
9d2bf704de Modified serialization of BinaryOperator and CaseStmt to use the new
BatchEmitOwnedPtrs() and BatchReadOwnedPtrs() methods.

Modified serialization of all Stmts to start their own record in the bitstream.

llvm-svn: 43846
2007-11-07 22:32:23 +00:00
Ted Kremenek
e079cb7b08 Added methods to batch emit and deserialize owned pointers. This allows
to group the pointer IDs together in the bitstream before their referenced
contents (which will lend itself to more efficient encoding).

llvm-svn: 43845
2007-11-07 22:30:29 +00:00
Dale Johannesen
1b9de4dd6f Complete conditionalization of Dwarf reg numbers.
Would somebody not on Darwin please make sure this
doesn't break anything.  Exception handling failures
would be the most likely symptom.

llvm-svn: 43844
2007-11-07 21:48:35 +00:00
Devang Patel
ef2d838fef Stay within 80 columns.
llvm-svn: 43843
2007-11-07 21:04:59 +00:00
Bill Wendling
6e976915a3 Add testcase
llvm-svn: 43839
2007-11-07 19:36:26 +00:00
Hartmut Kaiser
abcbb0493a Updated VC++ build system
llvm-svn: 43838
2007-11-07 19:34:40 +00:00
Hartmut Kaiser
b1d7cb2938 Updated VC++ build system
llvm-svn: 43837
2007-11-07 19:34:09 +00:00
Hartmut Kaiser
b964f650c9 Fixed compilation errors on VC++.
llvm-svn: 43836
2007-11-07 19:33:31 +00:00
Ted Kremenek
d68db575f3 Implemented serialization of StringLiteral.
llvm-svn: 43834
2007-11-07 19:08:19 +00:00
Ted Kremenek
f9062be688 Implemented serialization of ImaginaryLiteral.
llvm-svn: 43833
2007-11-07 18:53:02 +00:00
Ted Kremenek
569725f827 Implemented serialization of FloatingLiteral.
llvm-svn: 43832
2007-11-07 18:45:55 +00:00
Steve Naroff
1601858de5 Finishing touches on code generation for @try and friends.
- declare functions we use.
- cast arguments to objc_exception_match().
- don't take the & of _stack.buf.

llvm-svn: 43831
2007-11-07 18:43:40 +00:00
Fariborz Jahanian
1299a92327 Emit objective-c's meta-data at the end of rewriting to stdout.
llvm-svn: 43830
2007-11-07 18:40:28 +00:00
Ted Kremenek
81ad944c94 Implemented generic serialization of APFloat.
llvm-svn: 43829
2007-11-07 18:39:22 +00:00
Ted Kremenek
cc88d37531 Implemented serialization of signed integers.
llvm-svn: 43828
2007-11-07 18:24:34 +00:00
Steve Naroff
b7a032eb20 Remove old asserts from ASTContext::isObjcIdType() and isObjcClassType(). Instead, return false if the declarations aren't in scope. This was a hold over from when 'id' and 'Class' were initialized lazily.
llvm-svn: 43827
2007-11-07 18:07:59 +00:00
Fariborz Jahanian
8a348705a8 Fixed an array overflow bug.
llvm-svn: 43826
2007-11-07 17:43:16 +00:00
Fariborz Jahanian
e044087b56 Fixed typo.
llvm-svn: 43825
2007-11-07 17:29:15 +00:00
Ted Kremenek
c874c6a959 Implemented serialization of CharacterLiteral.
llvm-svn: 43824
2007-11-07 17:15:49 +00:00
Ted Kremenek
3c58662411 Implemented serialiation of PreDefinedExpr.
llvm-svn: 43823
2007-11-07 17:11:58 +00:00
Ted Kremenek
d47c8125a1 Implemented serialization of ContinueStmt.
llvm-svn: 43822
2007-11-07 17:05:07 +00:00
Ted Kremenek
3b4c08deae Implemented serialization of IndirectGotoStmt.
Added "FIXME" regarding the lack of source location information for IndirectGotoStmt.

llvm-svn: 43821
2007-11-07 17:02:32 +00:00
Steve Naroff
a733c7ffe4 Implement rewrite for @throw.
llvm-svn: 43820
2007-11-07 15:32:26 +00:00
Evan Cheng
e742ee1dbe Simplify my (il)logic.
llvm-svn: 43819
2007-11-07 08:08:25 +00:00
Ted Kremenek
5fd3040c57 Implemented serialization of GotoStmt.
llvm-svn: 43818
2007-11-07 08:07:46 +00:00
Ted Kremenek
35e20410aa Implemented serialization for ForStmt.
llvm-svn: 43817
2007-11-07 08:02:55 +00:00
Ted Kremenek
83e96b8d5a Implemented serialization of DoStmt.
llvm-svn: 43816
2007-11-07 07:53:55 +00:00
Ted Kremenek
f6d8ce1052 Implemented serialization for WhileStmt.
llvm-svn: 43815
2007-11-07 07:50:10 +00:00
Ted Kremenek
154c790538 Implemented serialization of IfStmt.
Fixed declarations of several "directEmit" methods of classes that subclass
Stmt that were missing a "virtual" keyword.

llvm-svn: 43814
2007-11-07 07:19:30 +00:00
Chris Lattner
4df68cf26a minor edit
llvm-svn: 43813
2007-11-07 07:07:55 +00:00
Chris Lattner
23dea1ef07 final edits.
llvm-svn: 43812
2007-11-07 06:46:51 +00:00
Chris Lattner
0903ac4837 chapter 7 edits
llvm-svn: 43811
2007-11-07 06:34:39 +00:00
Chris Lattner
d80488f0df edits for chapter 7
llvm-svn: 43810
2007-11-07 06:06:38 +00:00
Steve Naroff
4d7b367652 Teach ASTContext::tagTypesAreCompatible() about the built-in ObjC types (Class and id), removing a bogus warning.
llvm-svn: 43809
2007-11-07 06:03:51 +00:00
Chris Lattner
60ba5ef387 edits for chapter 5
llvm-svn: 43808
2007-11-07 05:47:48 +00:00
Chris Lattner
b2145a86f7 minor edits
llvm-svn: 43807
2007-11-07 05:28:43 +00:00
Ted Kremenek
acb9bcf22a Implemented serialization of SwitchStmt, CaseStmt, BreakStmt, DefaultStmt,
and ParenExpr.

llvm-svn: 43806
2007-11-07 05:25:31 +00:00
Owen Anderson
c6a5387d09 Add some more of StrongPHIElim.
llvm-svn: 43805
2007-11-07 05:17:15 +00:00
Chris Lattner
30f1db1ad9 edits.
llvm-svn: 43804
2007-11-07 05:07:10 +00:00
Steve Naroff
bf478ece48 Rewrite ObjC @try/@catch/@finally. Some minor tweaks to the AST nodes...
Still need to rewrite @throw (and do more testing)...

llvm-svn: 43803
2007-11-07 04:08:17 +00:00
Fariborz Jahanian
adfbbc3330 AST for objective-c's @throw statement and its pretty-printing.
llvm-svn: 43802
2007-11-07 02:00:49 +00:00
Devang Patel
b1ecfc6e25 Start struct bit field laout work.
This is far from complete.

llvm-svn: 43801
2007-11-07 01:57:13 +00:00
Ted Kremenek
a8cdf31aa0 Implemented serialization of LabelStmts.
llvm-svn: 43800
2007-11-07 00:48:04 +00:00
Ted Kremenek
ee4e7d4f25 Added special version of ReadPtr() that returns a deserialized pointer
by value.  This version prohibits backpatching of pointers, so it
useful when a pointee is always known to be deserialized beforehand.

llvm-svn: 43799
2007-11-07 00:47:33 +00:00
Fariborz Jahanian
defbf9a86c Fixed a pretty-printer bug whereby a @try statement with no @finally seg faulted.
llvm-svn: 43798
2007-11-07 00:46:42 +00:00
Ted Kremenek
ad1bc400d7 Added serialization/deserialization of NullStmts.
llvm-svn: 43797
2007-11-07 00:40:53 +00:00
Ted Kremenek
80fe8904e1 Added serialization/deserialization of DeclStmts.
Reordered stmt serialization method implementations to be in alphabetical order.

llvm-svn: 43796
2007-11-07 00:37:40 +00:00
Ted Kremenek
5fe293d7bc Fixed default ctor for APInt to properly initialize BitWidth to a
non-random value.

llvm-svn: 43795
2007-11-07 00:27:59 +00:00
Dale Johannesen
fbe69d2cd6 Interchange Dwarf numbers of ESP and EBP on x86 Darwin.
Much improvement in exception handling.

llvm-svn: 43794
2007-11-07 00:25:05 +00:00
Ted Kremenek
148aa5edbc Overhauled serialization of statements. We no longer use specialized SerializeTrait<> classes,
but methods in Stmt (like other objects we are serializing).  Full serialization of all statements
is not yet complete.

llvm-svn: 43793
2007-11-07 00:17:35 +00:00
Ted Kremenek
abcfe90802 Added static inline method "ReadVal" to QualType for more succinct
deserialization code of objects containing QualTypes.

llvm-svn: 43792
2007-11-07 00:13:45 +00:00
Fariborz Jahanian
e8a3016ac7 Rewrite for properties.
llvm-svn: 43791
2007-11-07 00:09:37 +00:00
Ted Kremenek
fa2bf434cc Fixed typo in the name of "ReadPreamble".
llvm-svn: 43790
2007-11-06 23:52:19 +00:00
Fariborz Jahanian
bcce2f8d54 Fix an inverted conditional,
--chris

llvm-svn: 43789
2007-11-06 23:06:16 +00:00
Tanya Lattner
5de0daf6b1 Implement the XTARGET feature for PR1778
This will mark a test as PASS for all targets specified. It will override whatever is in XFAIL.

llvm-svn: 43788
2007-11-06 22:32:17 +00:00
Ted Kremenek
453ab7d126 Started work on new serialization approach within ASTContext to
serialize Type objects in the order they are serialized in the Types
vector.  We also now rely on the methods within ASTContext to unique
Type objects and handle the actual creation of Type objects (these are
now called by the deserialization code).  This approach solves some
hairy issues with ownership of objects and allows us to naturally
handle recursive types.

llvm-svn: 43787
2007-11-06 22:26:16 +00:00
Ted Kremenek
7c91ccae88 QualType deserialization now requires that the underlying pointer type
must be deserialized without requiring backpatching.

llvm-svn: 43786
2007-11-06 22:23:53 +00:00
Ted Kremenek
93d446f535 Bug fix: inverted test condition to see if a serialized AST-bitcode
file had the correct preamble.

llvm-svn: 43785
2007-11-06 22:23:03 +00:00
Ted Kremenek
bf75685321 Serializer no longer automatically emits a root-level block in the bitstream.
llvm-svn: 43784
2007-11-06 22:22:25 +00:00
Ted Kremenek
cd0c32865c Augmented ReadPtr and ReadOwnedPtr to control whether or not a pointer is allowed to be backpatched
or can be registered with the deserializer to backpatch other pointers.

llvm-svn: 43783
2007-11-06 22:21:14 +00:00
Chris Lattner
581f006f5d make smallptrset more const and type correct, which caught a few
minor bugs.

llvm-svn: 43782
2007-11-06 22:12:43 +00:00
Dan Gohman
ccfc028283 Remainder operations must be either integer or floating-point.
llvm-svn: 43781
2007-11-06 22:11:54 +00:00
Chris Lattner
8201a9bca0 fix const correctness, BB is const, so its predecessors are too
llvm-svn: 43780
2007-11-06 22:07:40 +00:00
Chris Lattner
cbad11e027 don't put erase or query for non-allocainst pointers in an set of allocainsts*'s
llvm-svn: 43779
2007-11-06 22:07:22 +00:00
Fariborz Jahanian
f76f2b0c1c Patch for objc2's property ASTs, as well as pretty-priting the ASTs.
llvm-svn: 43778
2007-11-06 22:01:00 +00:00
Chris Lattner
d8515f8e80 Implement PR1777 by detecting dependent phis that
all compute the same value.

llvm-svn: 43777
2007-11-06 21:52:06 +00:00
Evan Cheng
dd71a5c37b When the allocator rewrite a spill register with new virtual register, it replaces other operands of the same register. Watch out for situations where
only some of the operands are sub-register uses.

llvm-svn: 43776
2007-11-06 21:12:10 +00:00
Duncan Sands
f042e862fd At the point of calculating the shift amount, the
type of SV has changed from what it originally was.
However we need the store width of the original.

llvm-svn: 43775
2007-11-06 20:39:11 +00:00
Ted Kremenek
77068e17d4 Misc. serialization changes to ASTContext and Decls. Serialization
for ASTContext is still rapidly evolving.

llvm-svn: 43774
2007-11-06 19:51:47 +00:00
Ted Kremenek
3a68de993a Revampled Serialization Tester to serialize and deserialize out an entire ASTContext and top-level decls.
llvm-svn: 43773
2007-11-06 19:50:53 +00:00
Ted Kremenek
e344bbbe84 Renamed "Flush()" to "FlushRecord()".
llvm-svn: 43772
2007-11-06 19:49:50 +00:00
Ted Kremenek
d015c7b4fd Added support for processing abbreviations in the Deserializer.
Added some #ifdef-controlled messages for debugging backpatching.

llvm-svn: 43771
2007-11-06 19:49:16 +00:00
Steve Naroff
2d8aaa7d74 Fix a "basic" bug that resulted in a bogus SourceLocation.
Off hand, I don't know why this change makes a difference (I thought the two constructor idioms were equivalent).

llvm-svn: 43770
2007-11-06 19:37:09 +00:00
Chris Lattner
26f288b9ea fixes from Kelly Wilson.
llvm-svn: 43767
2007-11-06 18:13:32 +00:00
Bill Wendling
56235a28ce Clarify some of the iostreams stuff.
llvm-svn: 43766
2007-11-06 09:36:34 +00:00
Evan Cheng
d5d59ad634 First step towards moving the coalescer to priority_queue based machinery.
llvm-svn: 43764
2007-11-06 08:52:21 +00:00
Evan Cheng
92d23e5204 Fix a bug where a def use operand isn't being detected as a sub-register use.
llvm-svn: 43763
2007-11-06 08:50:44 +00:00
Evan Cheng
2dbffa4e76 Add pseudo dependency to force two-address instruction to be scheduled after
other uses. There was a overly restricted check that prevented some obvious
cases.

llvm-svn: 43762
2007-11-06 08:44:59 +00:00
Chris Lattner
ff25240bae edits for chapter 3
llvm-svn: 43761
2007-11-06 07:26:32 +00:00
Chris Lattner
401bf39fa4 chapter 2 edits
llvm-svn: 43760
2007-11-06 07:16:22 +00:00
Chris Lattner
f0d84f1cc7 edits
llvm-svn: 43758
2007-11-06 06:32:18 +00:00
Chris Lattner
45d561ad99 improve decl merging logic to be more correct with
functions.  Patch contributed by Nuno Lopes, thanks!

llvm-svn: 43757
2007-11-06 06:07:26 +00:00
Chris Lattner
0fc613b85d Fix PR1774 and BasicAA/2007-11-05-SizeCrash.ll
llvm-svn: 43756
2007-11-06 05:58:42 +00:00
Owen Anderson
d378cea030 Add a few comments.
llvm-svn: 43755
2007-11-06 05:26:02 +00:00
Owen Anderson
eb964eb2c8 DomForest is a forest of registers, not instructions.
llvm-svn: 43754
2007-11-06 05:22:43 +00:00
Chris Lattner
978ec3c389 clarify what proto is.
llvm-svn: 43753
2007-11-06 05:07:30 +00:00
Chris Lattner
0bf330a1bc Add a real intro to the series.
llvm-svn: 43752
2007-11-06 05:02:48 +00:00
Owen Anderson
a9057f0b97 StrongPHIElimination requires LiveVariables.
llvm-svn: 43751
2007-11-06 04:49:43 +00:00
Chris Lattner
3209725c68 Add better validation for array types when merging decls. Patch
contributed by Oliver Hunt, thanks!

llvm-svn: 43750
2007-11-06 04:28:31 +00:00
Bruno Cardoso Lopes
87bb032c05 Better processor definition
llvm-svn: 43749
2007-11-06 03:15:20 +00:00
Chris Lattner
4f4048a174 typo from Ryan Brown.
llvm-svn: 43748
2007-11-06 01:40:41 +00:00
Chris Lattner
e6819aeee0 fixes from Ryan Brown.
llvm-svn: 43747
2007-11-06 01:39:12 +00:00
Owen Anderson
0d28238a1f Add a missing #include.
llvm-svn: 43746
2007-11-06 01:26:56 +00:00
Chris Lattner
362709dff1 wrap long lines
llvm-svn: 43745
2007-11-06 01:15:27 +00:00
Dan Gohman
08143e397d Add support for vector remainder operations.
llvm-svn: 43744
2007-11-05 23:35:22 +00:00
Dan Gohman
4decbc5002 Fix an abort in instcombine when folding creates a vector rem instruction.
llvm-svn: 43743
2007-11-05 23:16:33 +00:00
Rafael Espindola
fa0df55bdd Move the LowerMEMCPY and LowerMEMCPYCall to a common place.
Thanks for the suggestions Bill :-)

llvm-svn: 43742
2007-11-05 23:12:20 +00:00
Ted Kremenek
f7f7ddfd7e Added registration to deserialization engine of IdentifierInfo* as
IdentifierInfos are deserialized.

llvm-svn: 43741
2007-11-05 22:42:32 +00:00
Ted Kremenek
72f073acd4 Implemented serialization of TypedefDecls.
Fixed infinite recursion in VarDecl::InternalRead.

llvm-svn: 43739
2007-11-05 21:49:34 +00:00
Ted Kremenek
15f50ba755 In driver code implemented serialization of ASTContext. Working on serialization of simple ASTs.
llvm-svn: 43738
2007-11-05 21:39:35 +00:00
Ted Kremenek
7f6e70c5c2 Added skeleton for dispatch of Decl serialization.
llvm-svn: 43737
2007-11-05 21:38:00 +00:00
Ted Kremenek
4556582e2b Added support in serializer and deserializer to create arbitrary blocks.
Added detection of end-of-stream in deserializer.

llvm-svn: 43736
2007-11-05 21:36:35 +00:00
Dale Johannesen
4646aa3e33 Make labels work in asm blocks; allow labels as
parameters.  Rename ValueRefList to ParamList
in AsmParser, since its only use is for parameters.

llvm-svn: 43734
2007-11-05 21:20:28 +00:00
Ted Kremenek
58473ab478 For serialization of ASTContext, added special-casing of serialization
of type sets when emitting complex types and pointer types that are
also considered builtins.  These types are automatically created in
the ctor of ASTContext, and thus should not be serialized (was
producing an error during deserialization).

llvm-svn: 43733
2007-11-05 20:49:23 +00:00
Ted Kremenek
e7fb505f58 Added default creation of root-level block by bitstream serializer.
llvm-svn: 43732
2007-11-05 20:47:27 +00:00
Chris Lattner
2f86ed734d merge in various fixes from Kelly Wilson.
llvm-svn: 43731
2007-11-05 20:13:56 +00:00
Chris Lattner
fbfae1bd7e add some links to the tutorial index and between chapters.
llvm-svn: 43730
2007-11-05 20:04:56 +00:00
Chris Lattner
a25729e0d0 grammaro
llvm-svn: 43729
2007-11-05 19:33:52 +00:00
Devang Patel
b98d2050a2 If a value is incoming from outside the loop then the value does not need remapping and the value is never tracked through LastValueMap.
llvm-svn: 43728
2007-11-05 19:32:30 +00:00
Chris Lattner
4484d8d7f0 recursive types are our friend.
llvm-svn: 43727
2007-11-05 19:28:07 +00:00
Chris Lattner
2a8fd134ea mention possibility of using a visitor
llvm-svn: 43726
2007-11-05 19:25:14 +00:00
Chris Lattner
a94cfa13e7 clarify why prototype::codegen returns a function.
llvm-svn: 43725
2007-11-05 19:22:50 +00:00
Chris Lattner
fd3cb0890b TOC for chapter 8
llvm-svn: 43724
2007-11-05 19:10:15 +00:00
Chris Lattner
639a18dc26 add table of contents to each chapter.
llvm-svn: 43723
2007-11-05 19:06:59 +00:00
Lauro Ramos Venancio
1a30c18e88 [ARM] Fix code generation for:
static __thread struct {
    int a;
    int b;
} teste = {0, 0};

llvm-svn: 43722
2007-11-05 18:33:37 +00:00
Ted Kremenek
e93520d977 Fixed bug where tombstone key and empty key for DenseMap used for
pointer backpatching in deserializer were improperly created and
resulted in an assertion failure.

llvm-svn: 43721
2007-11-05 18:13:03 +00:00
Duncan Sands
f7ae8bd090 Don't output ABI size padding twice. By using the store
size for the field we get ABI padding automatically, so
no need to put it in again when we emit the field.

llvm-svn: 43720
2007-11-05 18:03:02 +00:00
Chris Lattner
38eec3071a add link to llvmbuilder doxygen docs
llvm-svn: 43719
2007-11-05 18:02:15 +00:00
Chris Lattner
9b2f7773ac spell identifier correctly.
llvm-svn: 43718
2007-11-05 17:54:34 +00:00
Chris Lattner
e02310d5e3 fix typo
llvm-svn: 43717
2007-11-05 17:52:04 +00:00
Fariborz Jahanian
63ac80e76a Misc. fixes. 1) Resurrect meta-data generation turned off by a previous patch.
2) Fixed a regression in meta-data generation caused by removal of '_interface' prefix from synthesize class name.
3) Added stubs for @try/@catch/@finally statements.

llvm-svn: 43716
2007-11-05 17:47:33 +00:00
Chris Lattner
2172186c7b Dan points out that mem2reg also promotes vectors: be more precise.
llvm-svn: 43715
2007-11-05 17:45:54 +00:00
Evan Cheng
8bb30184a8 Move SimpleRegisterCoalescing.h to lib/CodeGen since there is now a common
register coalescer interface: RegisterCoalescing.

llvm-svn: 43714
2007-11-05 17:41:38 +00:00
Ted Kremenek
a6d9f3c2cf Made methods "Emit" and "Materialize" in ASTContext (used for serialization) public.
llvm-svn: 43713
2007-11-05 17:41:25 +00:00
Chris Lattner
3527796804 clarify
llvm-svn: 43712
2007-11-05 17:39:26 +00:00
Chris Lattner
3a39ad630a fix typo
llvm-svn: 43711
2007-11-05 17:38:34 +00:00
Ted Kremenek
31b789c0d8 Added TypeSerialization.cpp and DeclSerialization.cpp to the XCode project.
llvm-svn: 43710
2007-11-05 17:04:40 +00:00
Duncan Sands
d6f131ba6f Fix some typos.
llvm-svn: 43709
2007-11-05 16:04:58 +00:00
Steve Naroff
96d20616c4 Sema::ActOnClassMessage()...if a class method isn't found, lookup an instance method. Since all classes are also instances, this is appropriate.
llvm-svn: 43708
2007-11-05 15:27:52 +00:00
Duncan Sands
f8bc406d5d Trivial fixes.
llvm-svn: 43707
2007-11-05 15:15:50 +00:00
Steve Naroff
bd72289baa Declare objc_selector outside the prototype for objc_msgSend(), removing a silly warning.
llvm-svn: 43706
2007-11-05 14:55:35 +00:00
Steve Naroff
e4f9b23458 Rewrite @selector(sel).
llvm-svn: 43705
2007-11-05 14:50:49 +00:00
Steve Naroff
98eb8d1275 - change the synthesized typedef (for classes) to be of type "objc_object".
- fix a couple bugs in RewriteObjCStringLiteral.
- convert "Class" -> "id" in RewriteMessageExpr.

llvm-svn: 43704
2007-11-05 14:36:37 +00:00
Evan Cheng
9337929aae Use movups to spill / restore SSE registers on targets where stacks alignment is
less than 16. This is a temporary solution until dynamic stack alignment is
implemented.

llvm-svn: 43703
2007-11-05 07:30:01 +00:00
Chris Lattner
6cdadb6041 add a link.
llvm-svn: 43702
2007-11-05 07:02:49 +00:00
Chris Lattner
044edf41df finish the tutorial, yaay.
comments and feedback welcome.

llvm-svn: 43701
2007-11-05 07:00:54 +00:00
Evan Cheng
17b0e3e1ae Skip over deleted val#'s.
llvm-svn: 43700
2007-11-05 06:46:45 +00:00
Evan Cheng
a406b47f14 Handle cases where a register and one of its super-register are both marked as
defined on the same instruction. This fixes PR1767.

llvm-svn: 43699
2007-11-05 03:11:55 +00:00
Evan Cheng
e12363dac5 Fix test case. Chris didn't do make check. :-)
llvm-svn: 43698
2007-11-05 03:04:26 +00:00
Bruno Cardoso Lopes
3e0d030dad Added support for PIC code with "explicit relocations" *only*.
Removed all macro code for PIC (goodbye "la").
Support tested with shootout bench.

llvm-svn: 43697
2007-11-05 03:02:32 +00:00
Gordon Henriksen
2657b218ea Bringing Passes.html up-to-date with the deletion of the
-emitbitcode option and the addition of -preverify.

llvm-svn: 43696
2007-11-05 02:05:35 +00:00
Chris Lattner
b7a5dbb4db Add the first section of chapter 8.
llvm-svn: 43695
2007-11-05 01:58:13 +00:00
Gordon Henriksen
2ed067a0d9 Deleting redundant copy of block extractor pass. See also PR1775.
llvm-svn: 43694
2007-11-05 01:54:05 +00:00
Evan Cheng
c68023a955 Doh. PR1187 -> PR1766.
llvm-svn: 43693
2007-11-05 01:00:44 +00:00
Evan Cheng
a8044084ac Fix PR1187.
llvm-svn: 43692
2007-11-05 00:59:10 +00:00
Duncan Sands
f07fa24289 If a long double is in a packed struct, it may be
that there is no padding.

llvm-svn: 43691
2007-11-05 00:35:07 +00:00
Steve Naroff
3865e4d8b4 Remove HandleObjcMetaDataEmission(), I inadvertantly resurrected it.
llvm-svn: 43690
2007-11-05 00:25:00 +00:00
Chris Lattner
350759513b finish the chapter.
llvm-svn: 43689
2007-11-05 00:23:57 +00:00
Duncan Sands
283207a71c Eliminate the remaining uses of getTypeSize. This
should only effect x86 when using long double.  Now
12/16 bytes are output for long double globals (the
exact amount depends on the alignment).  This brings
globals in line with the rest of LLVM: the space
reserved for an object is now always the ABI size.
One tricky point is that only 10 bytes should be
output for long double if it is a field in a packed
struct, which is the reason for the additional
argument to EmitGlobalConstant.

llvm-svn: 43688
2007-11-05 00:04:43 +00:00
Steve Naroff
f36987c79b Two additions...
- Synthesize the funky cast for objc_msgSend(). For the basic case, it looks like...

((id (*)(id, SEL))(void *)objc_msgSend)(obj, sel);

The "void *" cast is needed to workaround a GCC "bandaid" (Chris says it has something to do with the inliner). Without the extra "void *" cast, we get spurious warnings/notes that look like...

xx.m:17: warning: function called through a non-compatible type
xx.m:17: note: if this code is reached, the program will abort

- Add prototypes for the ObjC functions we call, objc_msgSend/objc_getClass for now (don't depend on them being included).

llvm-svn: 43685
2007-11-04 22:37:50 +00:00
Owen Anderson
eea82746b3 Another step of stronger PHI elimination down.
llvm-svn: 43684
2007-11-04 22:33:26 +00:00
Gordon Henriksen
35f398a9cd Deleting -emitbitcode option which did nothing.
llvm-svn: 43683
2007-11-04 20:28:31 +00:00
Chris Lattner
0e6b674993 fix typos
llvm-svn: 43682
2007-11-04 19:42:13 +00:00
Chris Lattner
9329e780cd Fix PR1761 by not printing (rip) suffix when in -static mode.
Evan, please review this.

llvm-svn: 43680
2007-11-04 19:23:28 +00:00
Gordon Henriksen
ad45991a86 Validation fix.
llvm-svn: 43679
2007-11-04 18:17:58 +00:00
Gordon Henriksen
c55d1f6c7f Typo fix.
llvm-svn: 43678
2007-11-04 18:14:08 +00:00
Gordon Henriksen
9f6c4c45d7 Completing Passes.html with the exception of -emitbitcode, which should be
removed. This document could still stand for significant improvement:

  * Editing the pass descriptions; most were lifted with minimal editing from
    comments. Although implementation details were elided, many of the were not
    written for the audience that would be interested in this document.
  * More "before and after" examples.
  * More implicit dependency details. (Perhaps listing transforms in
    -std-compile-opts order would help alleviate this.)
  * Adding documentation for how to invoke passes programmatically.
  * Rearranging the document into a more logical taxonomy. For instance, putting
    profiling passes together.

llvm-svn: 43677
2007-11-04 18:10:18 +00:00
Nick Lewycky
d954dcd138 Fix crash before main on ppc/linux with static constructors. PR1771
llvm-svn: 43676
2007-11-04 17:32:10 +00:00
Gordon Henriksen
a18a276350 Fix a validation error.
llvm-svn: 43675
2007-11-04 16:17:00 +00:00
Gordon Henriksen
d568767ecb Finishing initial docs for all transformations in Passes.html.
Also cleaned up some comments in source files.

llvm-svn: 43674
2007-11-04 16:15:04 +00:00
Gordon Henriksen
d210e9d880 Removing a dead reference from LLVM.xcodeproj.
llvm-svn: 43673
2007-11-04 16:12:17 +00:00
Duncan Sands
399d97987b Change uses of getTypeSize to getABITypeSize, getTypeStoreSize
or getTypeSizeInBits as appropriate in ScalarReplAggregates.
The right change to make was not always obvious, so it would
be good to have an sroa guru review this.  While there I noticed
some bugs, and fixed them: (1) arrays of x86 long double have
holes due to alignment padding, but this wasn't being spotted
by HasStructPadding (renamed to HasPadding).  The same goes
for arrays of oddly sized ints.  Vectors also suffer from this,
in fact the problem for vectors is much worse because basic
vector assumptions seem to be broken by vectors of type with
alignment padding.   I didn't try to fix any of these vector
problems.  (2) The code for extracting smaller integers from
larger ones (in the "int union" case) was wrong on big-endian
machines for integers with size not a multiple of 8, like i1.
Probably this is impossible to hit via llvm-gcc, but I fixed
it anyway while there and added a testcase.  I also got rid of
some trailing whitespace and changed a function name which
had an obvious typo in it.

llvm-svn: 43672
2007-11-04 14:43:57 +00:00
Evan Cheng
5c1b044899 If an interval is being undone clear its preference as well since the source interval may have been undone as well.
llvm-svn: 43670
2007-11-04 08:32:21 +00:00
Chris Lattner
296160d443 Fix PR1763 by allowing the 'q' constraint to work with 64-bit
regs on x86-64.

llvm-svn: 43669
2007-11-04 06:51:12 +00:00
Chris Lattner
ce8c62665a Disable tail duplication of call instructions. The cost
metric is way off for these in general, and this works around
buggy code like that in PR1764.  we'll see if there is a big
performance impact of this.  If so, I'll revert it tomorrow.

llvm-svn: 43668
2007-11-04 06:37:55 +00:00
Chris Lattner
65a146d418 finish the 'Memory in LLVM' section
llvm-svn: 43667
2007-11-03 22:22:30 +00:00
Steve Naroff
66697aa72f Add a method prototype slot/getter to the ObjCMessageExpr AST.
llvm-svn: 43666
2007-11-03 16:37:59 +00:00
Steve Naroff
a397efd915 Implement rewrite rules for ObjC string constants.
llvm-svn: 43665
2007-11-03 11:27:19 +00:00
Chris Lattner
dfcc3f26ae hack and slash the first 20% of chapter seven.
llvm-svn: 43663
2007-11-03 08:55:29 +00:00
Evan Cheng
66298e226f There are times when the coalescer would not coalesce away a copy but the copy
can be eliminated by the allocator is the destination and source targets the
same register. The most common case is when the source and destination registers
are in different class. For example, on x86 mov32to32_ targets GR32_ which
contains a subset of the registers in GR32.

The allocator can do 2 things:
1. Set the preferred allocation for the destination of a copy to that of its source.
2. After allocation is done, change the allocation of a copy destination (if
   legal) so the copy can be eliminated.

This eliminates 443 extra moves from 403.gcc.

llvm-svn: 43662
2007-11-03 07:20:12 +00:00
Chris Lattner
376cdaf50b Fix ownership model of ParseAST to allow the dtor of
ASTConsumer to process the AST before it is destroyed.
This allows elimination of HandleObjcMetaDataEmission.

llvm-svn: 43659
2007-11-03 06:24:16 +00:00
Fariborz Jahanian
9ffbd2d648 Provide both const and non-const accessor methods for @try and @finally ASTs.
My previous patch did the same for @catch AST.

llvm-svn: 43654
2007-11-03 00:38:38 +00:00
Fariborz Jahanian
e21451fc0d Provide const and none-const version of methods accessing various @catch nodes
llvm-svn: 43653
2007-11-03 00:34:02 +00:00
Dan Gohman
d7917b6248 Add std:: to sort calls.
llvm-svn: 43652
2007-11-02 22:24:01 +00:00
Dan Gohman
c981d72d1a Change illegal uses of ++ to uses of STLExtra.h's next function.
llvm-svn: 43651
2007-11-02 22:22:02 +00:00
Fariborz Jahanian
8815795049 pretty-print @try/@catch/@finally from AST as the validation of AST.
llvm-svn: 43649
2007-11-02 18:16:07 +00:00
Ted Kremenek
dda9a56975 Added most of the boilerplate code for Decl serialization. Still a few
key functions to implement.

llvm-svn: 43648
2007-11-02 18:05:11 +00:00
Ted Kremenek
3ae79b3d13 Added overloaded version of Deserializer::ReadOwnedPtr which allows
the target pointer to be passed by reference.  This can result in less
typing, as the object to be deserialized can be inferred from the
argument.

llvm-svn: 43647
2007-11-02 18:04:20 +00:00
Evan Cheng
2b93a20b09 Unbreak tailcall opt.
llvm-svn: 43646
2007-11-02 17:45:40 +00:00
Evan Cheng
0442889b18 Add run line.
llvm-svn: 43645
2007-11-02 17:36:58 +00:00
Evan Cheng
f851163c53 One more extract_subreg coalescing bug.
llvm-svn: 43644
2007-11-02 17:35:08 +00:00
Chris Lattner
0b271eb7af Expose InsertText, fixing an oversight.
llvm-svn: 43643
2007-11-02 17:26:47 +00:00
Chris Lattner
389d430c49 add a note
llvm-svn: 43642
2007-11-02 17:04:20 +00:00
Anders Carlsson
bfd60eedd7 Generate code for member exprs.
llvm-svn: 43641
2007-11-02 16:59:10 +00:00
Fariborz Jahanian
f859ef293c AST for @try statement.
llvm-svn: 43640
2007-11-02 15:39:31 +00:00
Duncan Sands
04059dd351 Fix a thinko.
llvm-svn: 43639
2007-11-02 15:18:06 +00:00
Neil Booth
758d0fd736 Remove some unnecessary C-style statics.
Restore an assertion that arithmetic can be performed on this format.

llvm-svn: 43638
2007-11-02 15:10:05 +00:00
Chris Lattner
74f87df108 fix typos
llvm-svn: 43637
2007-11-02 05:54:25 +00:00
Chris Lattner
ba2c3cdebb Finish chapter 6, and add a spiffy demo that shows off the language.
llvm-svn: 43636
2007-11-02 05:42:52 +00:00
Owen Anderson
2fd26c3641 VAArgInst does, in fact, read memory.
llvm-svn: 43633
2007-11-02 04:01:21 +00:00
Hartmut Kaiser
4a7d2d65e3 Updated VC++ build system
llvm-svn: 43632
2007-11-02 01:44:32 +00:00
Hartmut Kaiser
7d888fa180 Updated VC++ build system
llvm-svn: 43631
2007-11-02 01:44:08 +00:00
Evan Cheng
e453ff4913 Missing a getNumOperands check.
llvm-svn: 43630
2007-11-02 01:26:22 +00:00
Fariborz Jahanian
71234d8a9e AST for @finally statement.
llvm-svn: 43629
2007-11-02 00:18:53 +00:00
Fariborz Jahanian
9e63b98de7 AST build for @catch clause (this is work in progress).
llvm-svn: 43628
2007-11-01 23:59:59 +00:00
Neil Booth
ae077d232c Add back line whose removal somehow crept into prior patch
llvm-svn: 43627
2007-11-01 22:51:07 +00:00
Neil Booth
618d0fc377 When converting to integer, do bit manipulations in the destination
memory rather than in a copy of the APFloat.  This avoids problems
when the destination is wider than our significand and is cleaner.

Also provide deterministic values in all cases where conversion
fails, namely zero for NaNs and the minimal or maximal value
respectively for underflow or overflow.

llvm-svn: 43626
2007-11-01 22:43:37 +00:00
Ted Kremenek
5e2eb261af Simplified Serialization code for SourceLocation and SourceRange, and
updated it to the recently updated Serialization API.

Changed clients of SourceLocation serialization to call the
appropriate new methods.

Updated Decl serialization code to put new skeleton serialization code
in place that is much better than the older trait-specialization
approach.

llvm-svn: 43625
2007-11-01 22:25:41 +00:00
Ted Kremenek
478c6982a8 Removed ReadVal from SerializeTrait<T>, and also removed it from
Deserializer.

There were issues with Visual C++ barfing when instantiating
SerializeTrait<T> when "T" was an abstract class AND
SerializeTrait<T>::ReadVal was *never* called:

template <typename T>
struct SerializeTrait {
 <SNIP>
  static inline T ReadVal(Deserializer& D) { T::ReadVal(D); }
 <SNIP>
};

Visual C++ would complain about "T" being an abstract class, even
though ReadVal was never instantiated (although one of the other
member functions were).

Removing this from the trait is not a big deal.  It was used hardly
ever, and users who want "read-by-value" deserialization can simply
call the appropriate methods directly instead of relying on
trait-based-dispatch.  The trait dispatch for
serialization/deserialization is simply sugar in many cases (like this
one).

llvm-svn: 43624
2007-11-01 22:23:34 +00:00
Fariborz Jahanian
65590b2504 Bunch of class declarations for objective-c's @try-catch statement.
llvm-svn: 43623
2007-11-01 21:12:44 +00:00
Duncan Sands
44b8721de8 Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment.  This gives a primitive type for
which getTypeSize differed from getABITypeSize.  For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).

This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition).  Instead there is:

(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type.  For a primitive type, this is the minimum number
of bits.  For an i36 this is 36 bits.  For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.

(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it).  For an
i36 this is 40 bits, for an x86 long double it is 80 bits.  This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes).  There doesn't seem to be anything
corresponding to this in gcc.

(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment.  For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS.  This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes).  This is
TYPE_SIZE in gcc.

Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize.  This means that the size of an array
is the length times the getABITypeSize.  It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize.  Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case.  So alloca's and mallocs should use getABITypeSize.  Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.

Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.

In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases).  I will get around to auditing these too at some point,
but I could do with some help.

Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize.  I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers.  If someone wants to pack these types more
tightly they can always use a packed struct.

llvm-svn: 43620
2007-11-01 20:53:16 +00:00
Devang Patel
e11664a0ef Rename classes and collections that maintain record layout information.
Now, at AST level record info is maintained by ASTRecordLayout class.
Now, at code gen  level record info is maintained by CGRecordLayout class.

llvm-svn: 43619
2007-11-01 19:11:01 +00:00
Ted Kremenek
26a7f3fd56 Implemented serialization of QualTypes within ASTContext. Clarified
ownership model of some type pointers.  Added FIXMEs to serialization.

Added comments to ASTContext indicating which variables we are intentionally
*not* serializing.

llvm-svn: 43618
2007-11-01 18:11:32 +00:00
Fariborz Jahanian
ac73ff8868 Remaining work to collect objective-c's type qualifiers and use them to encode
method types.

llvm-svn: 43617
2007-11-01 17:18:37 +00:00
Steve Naroff
63006473d5 - Remove _interface_ prefix for the synthesized tag names.
- Also removed a tab from the generated struct (minor).

llvm-svn: 43616
2007-11-01 17:12:31 +00:00
Ted Kremenek
53155f379e Changed serialization/deserialization of BuiltinTypes to explicitly serialize
each type.  This ensures that the order in which the types are serialized
is clear and remains persistent.

llvm-svn: 43615
2007-11-01 17:10:34 +00:00
Ted Kremenek
baa461893b Reverted unnecessary inlining of operator!=, since negating operator== is
just as efficient and much more succinct.

llvm-svn: 43614
2007-11-01 16:35:25 +00:00
Devang Patel
32714064b1 Propagate bitfield info.
llvm-svn: 43613
2007-11-01 16:29:56 +00:00
Steve Naroff
50d4205ff9 Implement rewrite rule for commenting out protocol references. For example:
extern id /*<NSObject>*/ NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);

extern void NSDeallocateObject(id /*<NSObject>*/object);

extern id /*<NSObject>*/ NSCopyObject(id /*<NSObject>*/object, unsigned extraBytes, NSZone *zone);

llvm-svn: 43612
2007-11-01 13:24:47 +00:00
Duncan Sands
e0e774b6fd Don't barf on empty basic blocks. Do not rely on assert
doing something - this needs to work for release builds
too.  I chose to just abort rather than following the
fancy logic of abortIfBroken, because (1) it is a pain
to do otherwise, and (2) nothing is going to work if the
module is this broken.

llvm-svn: 43611
2007-11-01 10:50:26 +00:00
Bill Wendling
87f460f8ba Silence a warning saying that the variables always resolve to "true" in an
expression.

llvm-svn: 43610
2007-11-01 09:38:19 +00:00
Bill Wendling
b7cabbe295 Silence, accersed warning
llvm-svn: 43609
2007-11-01 08:51:44 +00:00
Bill Wendling
2b3f7a7e3b Get rid of compilation warning during release builds
llvm-svn: 43608
2007-11-01 08:24:40 +00:00
Chris Lattner
68613c7d31 Add the start of chapter 6, still much to go.
llvm-svn: 43607
2007-11-01 06:49:54 +00:00
Evan Cheng
fe1ac52836 - Coalesce extract_subreg when both intervals are relatively small.
- Some code clean up.

llvm-svn: 43606
2007-11-01 06:22:48 +00:00
Owen Anderson
2ed651ace7 Fix test/Transforms/DeadStoreElimination/PartialStore.ll, which had been
silently failing because of an incorrect run line for some time.

llvm-svn: 43605
2007-11-01 05:29:16 +00:00
Chris Lattner
b338a6b9f3 add support for vector type compatibility checking. Patch by Nate Begeman.
llvm-svn: 43604
2007-11-01 05:03:41 +00:00
Chris Lattner
dff7a3e919 remove verifier command line option: this should be part of the API, not
a command line optn.

llvm-svn: 43603
2007-11-01 04:43:13 +00:00
Chris Lattner
059a8df289 add a broken gcc version, thanks to P. Durante for pointing this out.
llvm-svn: 43602
2007-11-01 04:20:16 +00:00
Owen Anderson
fe41d79112 Now with less tabs!
llvm-svn: 43601
2007-11-01 03:54:23 +00:00
Steve Naroff
2f55b98725 Tweak RewriteInterfaceDecl() to generate a typedef (if one hasn't already been generated).
llvm-svn: 43600
2007-11-01 03:35:41 +00:00
Chris Lattner
c3ebf29ef6 Implement test/Sema/init.c by treating functions as constants.
llvm-svn: 43599
2007-11-01 02:45:17 +00:00
Dale Johannesen
440f9abab4 Test that expand_vector_elt(v2i64) works in 32-bit mode.
llvm-svn: 43598
2007-11-01 02:38:24 +00:00
Chris Lattner
6ab19ed78d Fix InstCombine/2007-10-31-StringCrash.ll by removing an obvious
(in hindsight) infinite recursion.  Simplify the code.

llvm-svn: 43597
2007-11-01 02:30:35 +00:00
Chris Lattner
74709473ed Fix InstCombine/2007-10-31-RangeCrash.ll
llvm-svn: 43596
2007-11-01 02:18:41 +00:00
Ted Kremenek
fb764e52b0 Rewrote backpatcher. Backpatcher now stores the "has final pointer"
flag in the **key** of the backpatch map, as opposed to the mapped
value which contains either the final pointer, or a pointer to a chain
of pointers that need to be backpatched.  The bit flag was moved to
the key because we were erroneously assuming that the backpatched
pointers would be at an alignment of >= 2 bytes, which obviously
doesn't work for character strings.  Now we just steal the bit from the key.

llvm-svn: 43595
2007-11-01 00:57:37 +00:00
Ted Kremenek
df0768e1b1 Added typedef "value_type" to DenseMap (similar typedef appears in std::map).
Added method FindAndConstruct() to DenseMap, which does the same thing as
operator[], except that it refers value_type& (a reference to both the
key and mapped data pair).  This method is useful for clients that wish
to access the stored key value, as opposed to the key used to do the
actual lookup (these need not always be the same).

Redefined operator[] to use FindAndConstruct() (same logic).

llvm-svn: 43594
2007-11-01 00:54:57 +00:00
Anders Carlsson
41b7c6b250 Put constant CFStrings in the __DATA,__cfstring section.
llvm-svn: 43593
2007-11-01 00:41:52 +00:00
Anders Carlsson
1e27f9b296 Stub out codegen for __builtin_constant_p. Remove any implicit cast exprs in the call to __builtin___CFStringMakeConstantString.
llvm-svn: 43592
2007-11-01 00:39:26 +00:00
Devang Patel
0b59b45870 Remove unnecessary method.
llvm-svn: 43591
2007-11-01 00:11:37 +00:00
Devang Patel
ad175428c6 start adding pading fields.
llvm-svn: 43590
2007-11-01 00:07:12 +00:00
Fariborz Jahanian
7a9c47480d 1) More additions for objective-c's qualifier type.
2) Fixed a test failure (which should have failed all along!).

llvm-svn: 43589
2007-10-31 23:53:01 +00:00
Anders Carlsson
e89b84ab29 Fix a typo that prevented pointer-to-int conversions from working.
llvm-svn: 43588
2007-10-31 23:18:02 +00:00
Devang Patel
f5fcb9870a Refactor code into a separate method.
llvm-svn: 43587
2007-10-31 23:17:19 +00:00
Fariborz Jahanian
c3cda76362 Fixed a bug exposed by fixing the assert in previous patch (one of the tests asserted).
llvm-svn: 43586
2007-10-31 23:08:24 +00:00
Fariborz Jahanian
aa9a95ca4f Changed direction of assert. Added more comments.
llvm-svn: 43585
2007-10-31 22:57:04 +00:00
Ted Kremenek
6aff871a84 Implemented more of serialization/deserialization for ASTContext. We now
(hypothetically) read in/write out most of the types.  Bugs likely exist.

llvm-svn: 43584
2007-10-31 22:44:07 +00:00
Ted Kremenek
fb41f72916 constified several pointer arguments for methods in the Deserializer.
llvm-svn: 43583
2007-10-31 22:42:03 +00:00
Steve Naroff
9c4fdddd0c Fix two rewriter bugs:
- For @class, don't generate multiple typedefs.
- Handle the following edge case interface...

@interface NSMiddleSpecifier : NSObject {}

@end

...which was incorrectly being rewritten to...

struct _interface_NSMiddleSpecifier {
        struct _interface_NSObject _NSObject;
};
{}

llvm-svn: 43582
2007-10-31 22:11:35 +00:00
Anders Carlsson
0370eb2034 Handle function calls that return aggregate expressions.
llvm-svn: 43581
2007-10-31 22:04:46 +00:00
Fariborz Jahanian
d822d68b74 More infrastructure to recognize objective-c's type qualifiers (in,inout, etc.)
llvm-svn: 43580
2007-10-31 21:59:43 +00:00
Dan Gohman
b43e020cdb Fix a regression in test/CodeGen/X86/2007-04-24-VectorCrash.ll introduced
by r43510. Gracefully handle constants with vector type that aren't
ConstantVector or ConstantAggregateZero.

llvm-svn: 43579
2007-10-31 21:36:31 +00:00
Owen Anderson
9396c39501 Add a preverifier pass to check that every basic block ends in a terminator, so that we don't segfault when verifying invalid code.
llvm-svn: 43578
2007-10-31 21:04:18 +00:00
Devang Patel
cc4c2930ae New test to verify llvm struct layout.
llvm-svn: 43577
2007-10-31 21:02:10 +00:00
Devang Patel
6029cbf872 Check whether next slot meets field type's alignment requirements.
If it does not then assert at the moment.

llvm-svn: 43576
2007-10-31 21:01:37 +00:00
Steve Naroff
aaba027717 Implement ObjC built-in types in MinimalAction.
This fixes the recent regression with selector-1.m and -parse-noop.

llvm-svn: 43575
2007-10-31 20:55:39 +00:00
Ted Kremenek
b681c68a7e Implemented short-circuited version of Builtin::Info::operator!=.
llvm-svn: 43574
2007-10-31 20:55:27 +00:00
Devang Patel
1c8788bbd0 Keep track of field offsets during structure layout.
Take 2.

llvm-svn: 43573
2007-10-31 20:08:22 +00:00
Devang Patel
75ef2f0b45 Take 2.
Make target info available to clang code generator.  This is far from complete but this helps clang codegen module make progress.

At the moment target triplet and target description strings are hard coded in clang::TargetInfo

llvm-svn: 43572
2007-10-31 20:01:01 +00:00
Ted Kremenek
c55cd9a38a Adjusted QualType deserialization to reflect updated deserialization API.
We now serialize ivar references inside of ASTContext.

llvm-svn: 43571
2007-10-31 20:00:03 +00:00
Ted Kremenek
705770664d Implemented deserialization of references. References are handled
just like pointers, except that they cannot be backpatched.  This
means that references are essentially non-owning pointers where the
referred object must be deserialized prior to the reference being
deserialized.  Because of the nature of references, this ordering of
objects is always possible.

Fixed a bug in backpatching code (returning the backpatched pointer
would accidentally include a bit flag).

llvm-svn: 43570
2007-10-31 19:58:32 +00:00
Devang Patel
7abb7acafd Initialize MemCpyFn
llvm-svn: 43569
2007-10-31 19:54:57 +00:00
Fariborz Jahanian
95b6076c77 Fixed problem with rewriting stand-alone @implementation (with no matching @interface).
A new test case added.

llvm-svn: 43568
2007-10-31 18:48:14 +00:00
Steve Naroff
6d40db0dde Implement a more sensible strategy for ObjC built-in types (addressing a long standing FIXME in Sema::GetObjcIdType()).
This removes several gross hacks to work around the previous "lazy" behavior.

Two notes:
- MinimalActions still needs to be taught about the built-in types (This breaks one of the -noop test cases). I started this, then added a FIXME.
- I didn't convert Sema::GetObjcProtoType() yet.

llvm-svn: 43567
2007-10-31 18:42:27 +00:00
Ted Kremenek
e32c067cc4 Preliminary support for serializing statements.
llvm-svn: 43566
2007-10-31 18:41:19 +00:00
Ted Kremenek
e119266c19 Added Serializer::EmitRef to deal with emitting arbitrary references.
Modified Serializer::EmitPtr to handle const pointers.

llvm-svn: 43565
2007-10-31 18:23:21 +00:00
Ted Kremenek
d2f7cc9f2b Updated path to clang.cpp in build documentation.
llvm-svn: 43564
2007-10-31 17:58:51 +00:00
Ted Kremenek
468b1cb96f Updated build instructions to not include an absolute line number in clang.cpp to add hard-coded paths.
llvm-svn: 43563
2007-10-31 17:57:30 +00:00
Ted Kremenek
08bed095eb Updated a comment to hopefully silence a Lattner warning.
llvm-svn: 43562
2007-10-31 17:53:38 +00:00
Ted Kremenek
9cc9335bdf Implemented serialization of Variable Array Types (VLAs).
llvm-svn: 43561
2007-10-31 17:50:23 +00:00
Fariborz Jahanian
aff228dfc7 Rewriteing of ivars changed to just copy directly from the source.
llvm-svn: 43560
2007-10-31 17:29:28 +00:00
Ted Kremenek
ff70faead8 Changed access control within FoldingSet for some ivars from "private"
to "protected".  This allows iterators to work.

llvm-svn: 43559
2007-10-31 17:12:47 +00:00
Ted Kremenek
fc581a9a89 Renamed ivar "ArrayTypes" in ASTContext to "ComplexArrayTypes".
Added skeleton code for serialization of ASTContext.

llvm-svn: 43558
2007-10-31 17:10:13 +00:00
Steve Naroff
ac0216385f Checking in some code that is still under construction.
I need to (finally) change the way Class/id/SEL/IMP are built-in...the current approach of doing it in the preprocessor is "broken". The other problem is Sema::GetObjcIdType/GetObjcSelType/GetObjcClassType, the hooks that initialize ASTContext lazily. These built-in types need to be done up front...

llvm-svn: 43557
2007-10-31 16:03:04 +00:00
Fariborz Jahanian
d728e949bb After Anders check-in, we can now encode 'Class' type.
llvm-svn: 43556
2007-10-31 16:00:13 +00:00
Ted Kremenek
f1d34d3fea Added a few clarifying steps the the "building clang" section.
llvm-svn: 43555
2007-10-31 15:31:24 +00:00
Rafael Espindola
419b6d7ce4 Make ARM and X86 LowerMEMCPY identical by moving the isThumb check into getMaxInlineSizeThreshold
and by restructuring the X86 version.

New I just have to move this to a common place :-)

llvm-svn: 43554
2007-10-31 14:39:58 +00:00
Dan Gohman
54048ec9e0 Fix a typo in a comment.
llvm-svn: 43553
2007-10-31 14:35:39 +00:00
Rafael Espindola
063f177300 Make ARM an X86 memcpy expansion more similar to each other.
Now both subtarget define getMaxInlineSizeThreshold and the expansion uses it.

This should not change generated code.

llvm-svn: 43552
2007-10-31 11:52:06 +00:00
Duncan Sands
3b4668a5d8 Promotion of sdiv/srem/udiv/urem.
llvm-svn: 43551
2007-10-31 08:57:43 +00:00
Duncan Sands
21ca939683 Add a newline at the end of the file.
llvm-svn: 43550
2007-10-31 08:49:24 +00:00
Chris Lattner
75045da563 fix validation
llvm-svn: 43549
2007-10-31 07:30:39 +00:00
Chris Lattner
1db6e89b7a okay, fine, make me finish this chapter. :)
Feedback appreciated!

llvm-svn: 43548
2007-10-31 07:29:43 +00:00
Chris Lattner
6b0fb58110 add the code for expression code that we'll add, though most of the
description is missing.

llvm-svn: 43547
2007-10-31 06:47:39 +00:00
Chris Lattner
149c55aba4 Add the first half of chapter 5: if/then/else.
To come: for statement.

llvm-svn: 43546
2007-10-31 06:30:21 +00:00
Chris Lattner
da1988477d __main is dead along with llvm-gcc3.
llvm-svn: 43545
2007-10-31 05:53:31 +00:00
Chris Lattner
5087e267c2 temporarily revert devang's patch to link in the llvm codegen etc.
llvm-svn: 43544
2007-10-31 04:53:03 +00:00
Steve Naroff
37e011ce43 Add some plumbing to help cope with rewriting "id<p>", "Class<p>*".
llvm-svn: 43543
2007-10-31 04:38:33 +00:00
Owen Anderson
0b59fa0605 Add the skeleton of a better PHI elimination pass.
llvm-svn: 43542
2007-10-31 03:37:57 +00:00
Owen Anderson
9b8f34f2ac Some fixes to get MachineDomTree working better.
llvm-svn: 43541
2007-10-31 03:30:14 +00:00
Anders Carlsson
f56a7aee2f Encode Class, SEL and Objective-C objects.
llvm-svn: 43540
2007-10-31 02:53:19 +00:00
Devang Patel
df62bc067a Keep track of field offsets during structure layout.
llvm-svn: 43539
2007-10-31 01:23:10 +00:00
Devang Patel
46c7003052 Make target info available to clang code generator.
This is far from complete but this helps clang codegen module
make progress.

llvm-svn: 43536
2007-10-31 00:59:29 +00:00
Dale Johannesen
b066c1f216 Make i64=expand_vector_elt(v2i64) work in 32-bit mode.
llvm-svn: 43535
2007-10-31 00:32:36 +00:00
Fariborz Jahanian
ca5338196f Added new type and bitfield fields in some decl types in preparation for objective-c's type qualifiers.
Added initialization of Class/SEMA types.

llvm-svn: 43534
2007-10-31 00:12:35 +00:00
Evan Cheng
240c1adade At end of LSR, replace uses of now constant (as result of SplitCriticalEdge) PHI node with the constant value.
llvm-svn: 43533
2007-10-30 23:45:15 +00:00
Ted Kremenek
4f4c3f9fd5 Added member function "size()" to FoldingSet to return the number of
nodes in the FoldingSet.

llvm-svn: 43531
2007-10-30 23:35:55 +00:00
Devang Patel
82ae5f255f Avoid unnecessary PATypeHolder copy.
llvm-svn: 43530
2007-10-30 23:22:14 +00:00
Steve Naroff
5cdcd9b61c Stop pre-defining objc_msgSend/objc_getClass in the preprocessor. Instead, I generate these declaration on the fly when rewriting a message expression.
llvm-svn: 43529
2007-10-30 23:14:51 +00:00
Devang Patel
17833d7068 New test.
llvm-svn: 43527
2007-10-30 23:07:47 +00:00
Ted Kremenek
e26f3c50c5 Updated some comments.
Disabled assignments for ContentCache.
Copy-ctor for ContentCache now has an assertion preventing it to
be copied from an object that already has an allocated buffer.

llvm-svn: 43526
2007-10-30 22:57:35 +00:00
Chris Lattner
595db86c9d __real__ and __imag__ can be lvalues. Add support to ast and codegen for them.
llvm-svn: 43525
2007-10-30 22:53:42 +00:00
Evan Cheng
c2dbfee43f It's not safe to tell SplitCriticalEdge to merge identical edges. It may delete the phi instruction that's being processed.
llvm-svn: 43524
2007-10-30 22:27:26 +00:00
Dale Johannesen
d50c8bcef6 Add missing SSE builtins: CVTPD2PI, CVTPS2PI,
CVTTPD2PI, CVTTPS2PI, CVTPI2PD, CVTPI2PS.

llvm-svn: 43523
2007-10-30 22:15:38 +00:00
Ted Kremenek
4c0ef37fbb Refactored CFG construction code that processes DeclStmts to use StmtIterator.
Now CFG construction transparently supports Variable Length Array declarations
with expressions for their sizes, and typedefs that include VLAs.

llvm-svn: 43520
2007-10-30 21:48:34 +00:00
Devang Patel
73721a12ca Refactor code into a separate method.
llvm-svn: 43519
2007-10-30 21:27:20 +00:00
Ted Kremenek
c08bca6ae8 Removed SrcMgr::FileInfo and SrcMgr::InfoRec and replaced them with a
single class: ContentCache.  This simplifies the logic in
SourceManager and makes the ownership of MemoryBuffers clearer.

llvm-svn: 43518
2007-10-30 21:08:08 +00:00
Ted Kremenek
78036cdd5c Tightened IgnoreParen.
llvm-svn: 43517
2007-10-30 21:03:09 +00:00
Devang Patel
ffe1e218f2 Fix 80 col violations.
llvm-svn: 43516
2007-10-30 20:59:40 +00:00
Chris Lattner
0b11172e8c minor tweaks
llvm-svn: 43515
2007-10-30 20:57:56 +00:00
Devang Patel
f5bda316c5 Use
+  llvm::DenseMap<Type *, llvm::PATypeHolder> TypeHolderMap;
instead of
-  llvm::DenseMap<Type *, llvm::PATypeHolder *> TypeHolderMap;

llvm-svn: 43514
2007-10-30 20:46:47 +00:00
Fariborz Jahanian
4d5b2baa1c Fixed tests.
llvm-svn: 43513
2007-10-30 20:41:57 +00:00
Chris Lattner
e0218997ab minor code cleanup
llvm-svn: 43512
2007-10-30 20:27:44 +00:00
Evan Cheng
0747bc1df6 Typo.
llvm-svn: 43511
2007-10-30 20:11:21 +00:00
Dan Gohman
9f39660c20 Add support for folding binary operators with vector zero operands.
llvm-svn: 43510
2007-10-30 19:00:49 +00:00
Chris Lattner
de21d55e70 shrinkify storage class to a bitfield, add a fixme about merging it in the future.
llvm-svn: 43509
2007-10-30 18:54:50 +00:00
Devang Patel
fa0cb1ef3a Remove commented out line.
llvm-svn: 43508
2007-10-30 18:31:12 +00:00
Fariborz Jahanian
18d7b30241 Revisited my last patch to be able to do encoding of ivar types with 'id'.
llvm-svn: 43507
2007-10-30 18:27:03 +00:00
Chris Lattner
74a0ae2c2a update some comments.
llvm-svn: 43506
2007-10-30 17:46:51 +00:00
Chris Lattner
39afd571a0 Avoid using macro expansions, which causes these to come out in -E mode.
llvm-svn: 43505
2007-10-30 17:45:43 +00:00
Fariborz Jahanian
509d8d6fc6 Added type encoding for 'id' type.
llvm-svn: 43504
2007-10-30 17:06:23 +00:00
Steve Naroff
f921385f40 Rewrite protocols.
llvm-svn: 43503
2007-10-30 16:42:30 +00:00
Ted Kremenek
9139310c76 Added vector to ASTContext to store references to "complete" VLA types
(VLAs with a specified size expresssion).  This vector owns the
references to these type objects.

llvm-svn: 43502
2007-10-30 16:41:53 +00:00
Steve Naroff
5448cf6d61 - Add location info to category/protocol AST's
- Rewrite categories.

llvm-svn: 43501
2007-10-30 13:30:57 +00:00
Duncan Sands
b508c53c63 Fix for visibility warnings generated by gcc-4.2.
llvm-svn: 43500
2007-10-30 13:14:37 +00:00
Duncan Sands
9ad5465005 Add support for expanding trunc stores. Consider
storing an i170 on a 32 bit machine.  This is first
promoted to a trunc-i170 store of an i256.  On a
little-endian machine this expands to a store of
an i128 and a trunc-i42 store of an i128.  The
trunc-i42 store is further expanded to a trunc-i42
store of an i64, then to a store of an i32 and a
trunc-i10 store of an i32.  At this point the operand
type is legal (i32) and expansion stops (legalization
of the trunc-i10 needs to be handled in LegalizeDAG.cpp).
On big-endian machines the high bits are stored first,
and some bit-fiddling is needed in order to generate
aligned stores.

llvm-svn: 43499
2007-10-30 12:50:39 +00:00
Duncan Sands
341f093bb1 If a call to getTruncStore is for a normal store,
offload to getStore rather than trying to handle
both cases at once (the assertions for example
assume the store really is truncating).

llvm-svn: 43498
2007-10-30 12:40:58 +00:00
Steve Naroff
4cd61acc33 Remove a couple FIXME's for rewriting ObjC interfaces (which are now being rewritten properly).
llvm-svn: 43494
2007-10-30 03:43:13 +00:00
Steve Naroff
c54840433f More support for rewriting ObjC intefaces. Still some edge cases to handle...
llvm-svn: 43493
2007-10-30 02:23:23 +00:00
Dale Johannesen
3f156de60d Fix argument types for PSLLQ, PSRLQ.
llvm-svn: 43490
2007-10-30 01:44:33 +00:00
Dale Johannesen
6aa304e529 Add missing MMX PSUBQ.
llvm-svn: 43488
2007-10-30 01:18:38 +00:00
Anders Carlsson
df4cc6160f Handle function types.
llvm-svn: 43485
2007-10-30 00:06:20 +00:00
Fariborz Jahanian
31d05db565 Assert if isObjcIdType is called before 'id' type is built.
llvm-svn: 43484
2007-10-30 00:00:49 +00:00
Ted Kremenek
843ebedde4 VariableArrayTypes (VLAs) without a size expression are now uniqued
and inserted into a FoldingSet owned by ASTContext.

llvm-svn: 43482
2007-10-29 23:37:31 +00:00
Fariborz Jahanian
797f24cd7e Encoding for objectiive-c methods.
llvm-svn: 43481
2007-10-29 22:57:28 +00:00
Evan Cheng
b024c4c81d - Bug fixes.
- Allow icmp rewrite using an iv / stride of a smaller integer type.

llvm-svn: 43480
2007-10-29 22:07:18 +00:00
Hartmut Kaiser
f557d896cb Updated VC++ build system
llvm-svn: 43479
2007-10-29 21:56:15 +00:00
Hartmut Kaiser
b20beb88cd Updated VC++ build system
llvm-svn: 43478
2007-10-29 21:54:46 +00:00
Hartmut Kaiser
ae240716ec Added a missing #include.
llvm-svn: 43477
2007-10-29 21:54:12 +00:00
Steve Naroff
e093339601 Remove a bunch of TODO's that have been done for quite some time...
llvm-svn: 43476
2007-10-29 21:39:29 +00:00
Steve Naroff
33a1e80dd1 This commit contains lot's of small tweaks to how we pass around and store SourceLocation's for interfaces/protocols/categories/implementations.
llvm-svn: 43475
2007-10-29 21:38:07 +00:00
Ted Kremenek
31974dfcdf Added support for StmtIterators to iterate over the size expressions
of VariableArrayTypes that appear in TypedefDecls.

for example:

  typedef int T[x][x];

the StmtIterator will iterate over "x" and "x" as subexpressions of
the DeclStmt for T.

llvm-svn: 43474
2007-10-29 21:38:03 +00:00
Ted Kremenek
899ef13376 Fixed deadcode bug where check for NULL decl occured within a block
where the decl would always be non-NULL.  Moved the check to after the
block to properly tidy up the iterator's state.

llvm-svn: 43473
2007-10-29 21:23:58 +00:00
Devang Patel
134b3f4b55 Add RecordOrganizer::layoutUnionFields()
llvm-svn: 43472
2007-10-29 20:50:19 +00:00
Ted Kremenek
2f70e71dcc Modified StmtIterator to support iteration over the size expressions
of VariableTypeArray types that appear in DeclStmts.

Removed operator-- from StmtIterator.  operator-- added undesired
complexity, and we have no consumers of it.

llvm-svn: 43471
2007-10-29 20:50:16 +00:00
Dan Gohman
ae95d72a52 Fix a DAGCombiner abort on a bitcast from a scalar to a vector.
llvm-svn: 43470
2007-10-29 20:44:42 +00:00
Ted Kremenek
6d845f0414 Modified CFG pretty-printing to directly use the (reverse) body
iterator of a CompountStmt instead of relying on StmtIterators.

llvm-svn: 43469
2007-10-29 20:41:04 +00:00
Dan Gohman
2aec186dd0 Don't bitcast from pointer-to-vector to pointer-to-array when
lowering load and store instructions.

llvm-svn: 43468
2007-10-29 20:34:35 +00:00
Dan Gohman
3bcd5fe9f1 Use an array instead of a fixed-length std::vector.
llvm-svn: 43467
2007-10-29 20:24:00 +00:00
Dan Gohman
d9911e21df Do a real assert if there is an unhandled vector instruction instead
of just printing to cerr.

llvm-svn: 43466
2007-10-29 20:14:29 +00:00
Evan Cheng
e106e2f142 Enable more fold (sext (load x)) -> (sext (truncate (sextload x)))
transformation. Previously, it's restricted by ensuring the number of load uses
is one. Now the restriction is loosened up by allowing setcc uses to be
"extended" (e.g. setcc x, c, eq -> setcc sext(x), sext(c), eq).

llvm-svn: 43465
2007-10-29 19:58:20 +00:00
Dan Gohman
1961c28d46 Add explicit keywords.
llvm-svn: 43464
2007-10-29 19:52:04 +00:00
Dan Gohman
7414e21ec0 Update a comment to reflect the current code.
llvm-svn: 43463
2007-10-29 19:32:39 +00:00
Dan Gohman
f5feb01056 Remove an unused function argument.
llvm-svn: 43462
2007-10-29 19:31:25 +00:00
Dan Gohman
50d42224d0 Fix a typo in a comment.
llvm-svn: 43461
2007-10-29 19:26:14 +00:00
Dan Gohman
8e8adada83 Avoid calling ValidStride when not all uses are addresses.
llvm-svn: 43460
2007-10-29 19:23:53 +00:00
Ted Kremenek
ef23e34bba Fixed warning concerning implicit conversion from a NULL pointer
constant to an unsigned int.  We now just directly assign the literal 0.

llvm-svn: 43459
2007-10-29 18:43:39 +00:00
Ted Kremenek
a80b257a21 Renamed internal variables of StmtIteratorBase to make the code
slightly more succinct.

Introduced VariableArrayType* within StmtIteratorBase to (soon)
support iteration over the size expressions of variable length arrays.

llvm-svn: 43455
2007-10-29 18:04:38 +00:00
Fariborz Jahanian
bc2759372b Do the encoding of ivar types in the ivar metadata.
llvm-svn: 43454
2007-10-29 17:16:25 +00:00
Ted Kremenek
e2763b0948 Added some comments.
Moved a dependent predicate in an if statement to be an assertion
within the if statement body.

llvm-svn: 43453
2007-10-29 17:13:39 +00:00
Chris Lattner
00860d7574 update testcase
llvm-svn: 43452
2007-10-29 17:06:35 +00:00
Ted Kremenek
5d18ce750a Added to test case for "self-comparison check" uses of relation operators: x < x and x > x
should emit warnings.

llvm-svn: 43451
2007-10-29 17:02:56 +00:00
Ted Kremenek
e451eae8d7 For non-floating point types, added check for expressions of the form
"x == x" and "x != x".  We emit a warning for these since they always evaluate
to a constant value and often indicate a logical error.

Added test case for this check.

llvm-svn: 43450
2007-10-29 16:58:49 +00:00
Devang Patel
d45e055f2c Insetead of assert() just emit an error message for
an unimplemented work  and continue.

llvm-svn: 43449
2007-10-29 16:56:27 +00:00
Ted Kremenek
fa907b8168 For floating point equality check, we now ignore parentheses. e.g.:
(x) == x  is the treated the same as x == x.

llvm-svn: 43448
2007-10-29 16:45:23 +00:00
Ted Kremenek
d4ecc6da67 For checking for floating point comparison using == or !=, we now suppress
errors for cases such as "x == x".

Added test case to test this feature.

llvm-svn: 43447
2007-10-29 16:40:01 +00:00
Evan Cheng
7b3f7feaea Avoid doing something dumb like rewriting using a 64-bit iv in 32-bit mode.
llvm-svn: 43446
2007-10-29 07:57:50 +00:00
Anders Carlsson
18acd44514 Address Chris's comments.
llvm-svn: 43445
2007-10-29 06:33:42 +00:00
Chris Lattner
909a54ccd4 add a note.
llvm-svn: 43444
2007-10-29 06:19:48 +00:00
Anders Carlsson
0f1cacd049 Fix logic error.
llvm-svn: 43443
2007-10-29 05:58:43 +00:00
Chris Lattner
c541c3ee15 Model stacksave and stackrestore as both writing memory, since we
don't model their dependences on allocas correctly.  This fixes
PR1745.

llvm-svn: 43442
2007-10-29 05:47:52 +00:00
Chris Lattner
b104d31bd9 when checking for type equality, ignore typedefs.
llvm-svn: 43441
2007-10-29 05:15:40 +00:00
Chris Lattner
5c5808a9a3 improve error recovery handling broken 'then' or 'else' stmts in
if statements.  This implements Sema/if-empty-body.c:f3, silencing
a bogus secondary warning.  It also improve the location info for
the nullstmts created for recovery purposes.

llvm-svn: 43440
2007-10-29 05:08:52 +00:00
Anders Carlsson
d849982e84 Add (partial) support for @encode.
llvm-svn: 43439
2007-10-29 05:01:08 +00:00
Owen Anderson
3692dbe492 Add a first attempt at dominator information for MBB's. Use with caution: this has been tested to compile. It has not yet been confirmed to generate correct analysis.
llvm-svn: 43438
2007-10-29 04:50:50 +00:00
Chris Lattner
70ae491e42 The callers of ParseStructDeclaration are not expecting it to
eat the terminating ;.  Fix one place where it did, allowing this
to compile without error:

struct x {
 int a;
 union {
  int b;
  float c;
 };

 int d;
};

This reduces diagnostics on PR1750 from 33 to 27.

llvm-svn: 43437
2007-10-29 04:42:53 +00:00
Chris Lattner
3bc4d20862 casting to void is ok for structs (C99 6.5.4p2), this fixes
one bogus error on PR1750.

llvm-svn: 43436
2007-10-29 04:26:44 +00:00
Chris Lattner
cc779571b8 Add prototype info for __builtin_memcpy, reducing #diagnostics from 37 to 34 on
PR1750

llvm-svn: 43435
2007-10-29 04:18:06 +00:00
Chris Lattner
645ff3ff61 Fix a parser bug on labeled inline asm stmts, allowing us
to parse stuff like:

asm volatile("1:  rex64/fxrstor (%[fx])\n\t"
       "2:\n"
       ".section .fixup,\"ax\"\n"
       "3:  movl $-1,%[err]\n"
       "    jmp  2b\n"
       ".previous\n"
       ".section __ex_table,\"a\"\n"
       "   .align 8\n"
       "   .quad  1b,3b\n"
       ".previous"
       : [err] "=r" (err)
       : [fx] "cdaSDb" (fx), "m" (*fx), "0" (0));

This reduces # diagnostics on PR1750 from 49 to 37.

llvm-svn: 43434
2007-10-29 04:06:22 +00:00
Chris Lattner
73c56c0735 Implement *skeletal* support for representing GNU inline asm stmts in the AST,
resolving a crash on a .i file in PR1750.  We now generate 49 errors on the
.i file in that bug.

llvm-svn: 43433
2007-10-29 04:04:16 +00:00
Chris Lattner
1159f065be Fix a major bug in the Type::getAs*Type methods: they didn't strip off
typeof(type) and typeof(expr) correctly.  Now provide a single point of
contact (Type::getDesugaredType) for doing the shallow stripping we need.

llvm-svn: 43432
2007-10-29 03:41:11 +00:00
Chris Lattner
b6fc40e60f I am not sure this is a good idea to be an option, but rename the option for
now.  It conflicts with clang's -pedantic flag.

llvm-svn: 43431
2007-10-29 03:14:55 +00:00
Chris Lattner
5e99fd8c0d Add support for the x86-64 'q' regigster modifier, and add support for the
b/h/w/k/q inline asm memory modifiers, which are just ignored.  This fixes
PR1748 and CodeGen/X86/2007-10-28-inlineasm-q-modifier.ll

llvm-svn: 43430
2007-10-29 03:09:07 +00:00
Anders Carlsson
ceced4ca73 Generate code for __builtin_classify_type.
llvm-svn: 43429
2007-10-29 02:59:40 +00:00
Anders Carlsson
7080597adf Add BuiltinType::Char_S to Type::isCharType
llvm-svn: 43428
2007-10-29 02:52:18 +00:00
Chris Lattner
9a641510bd Fix PR1749 and InstCombine/2007-10-28-EmptyField.ll by handling
zero-length fields better.

llvm-svn: 43427
2007-10-29 02:40:02 +00:00
Chris Lattner
4a15e04aee Fix PR1752 and LoopSimplify/2007-10-28-InvokeCrash.ll: terminators
can have uses too.  Wouldn't it be nice if invoke didn't exist? :)

llvm-svn: 43426
2007-10-29 02:30:37 +00:00
Ted Kremenek
8be9bc64ce Fixed assertion in Deserializer::~Deserializer that checks for
pointers that were not backpatched (previously checked the wrong invariant).

llvm-svn: 43425
2007-10-28 23:38:38 +00:00
Anton Korobeynikov
9dced3f9ae Add 'pedantic' mode to verifier rejecting syntactically valid, but 'bad' due to other reasons code
llvm-svn: 43424
2007-10-28 22:50:32 +00:00
Ted Kremenek
b6fafb6bf0 Implemented serialization for TypedefType.
llvm-svn: 43423
2007-10-28 21:21:04 +00:00
Ted Kremenek
387204749b Updated backpatching logic during object deserialization to perform
eager backpatching instead of waithing until all objects have been
deserialized.  This allows us to reduce the memory footprint needed
for backpatching.

llvm-svn: 43422
2007-10-28 21:17:59 +00:00
Duncan Sands
1826deda68 The guaranteed alignment of ptr+offset is only the minimum of
of offset and the alignment of ptr if these are both powers of
2.  While the ptr alignment is guaranteed to be a power of 2,
there is no reason to think that offset is.  For example, if
offset is 12 (the size of a long double on x86-32 linux) and
the alignment of ptr is 8, then the alignment of ptr+offset
will in general be 4, not 8.  Introduce a function MinAlign,
lifted from gcc, for computing the minimum guaranteed alignment.
I've tried to fix up everywhere under lib/CodeGen/SelectionDAG/.
I also changed some places that weren't wrong (because both values
were a power of 2), as a defensive change against people copying
and pasting the code.
Hopefully someone who cares about alignment will review the rest
of LLVM and fix up the remaining places.  Since I'm on x86 I'm
not very motivated to do this myself...

llvm-svn: 43421
2007-10-28 12:59:45 +00:00
Evan Cheng
c826ac533b New entry.
llvm-svn: 43420
2007-10-28 04:01:09 +00:00
Ted Kremenek
3fd831fd14 Implemented serialization of FunctionTypeProto.
llvm-svn: 43419
2007-10-28 00:59:26 +00:00
Ted Kremenek
d33b4adaed Implemented serialization of FunctionTypeNoProto.
llvm-svn: 43418
2007-10-27 19:58:08 +00:00
Ted Kremenek
3e6c227f97 Implemented serialization for VectorType.
llvm-svn: 43417
2007-10-27 19:05:09 +00:00
Ted Kremenek
8e8bf5d0bf More work on type serialization: added support for serializing BuiltinTypes.
llvm-svn: 43414
2007-10-26 23:52:52 +00:00
Ted Kremenek
9dd1e702fa Fixed bug where default SerializeTrait<>::Materialize would not return the materialized object pointer.
llvm-svn: 43413
2007-10-26 23:44:59 +00:00
Bill Wendling
2305de81a4 Test to make sure that if we have an unaligned memcpy, it will still compile.
llvm-svn: 43412
2007-10-26 23:43:35 +00:00
Fariborz Jahanian
801b63525d Path to synthesize 'instance' size field of _objc_class metadata.
llvm-svn: 43409
2007-10-26 23:09:28 +00:00
Evan Cheng
9dbe99dcd6 A number of LSR fixes:
- ChangeCompareStride only reuse stride that is larger than current stride. It
  will let the general reuse mechanism to try to reuse a smaller stride.
- Watch out for multiplication overflow in ChangeCompareStride.
- Replace std::set with SmallPtrSet.

llvm-svn: 43408
2007-10-26 23:08:19 +00:00
Ted Kremenek
6698b43389 Completed serialization of ConstantArrayTypes (now that APInt serialization is in place).
llvm-svn: 43407
2007-10-26 22:00:08 +00:00
Ted Kremenek
5e7133b090 Added SerializeAPInt.cpp and DeserializeAPInt.cpp to the XCode project.
llvm-svn: 43406
2007-10-26 21:53:37 +00:00
Ted Kremenek
2d95094bea Added serialization support for APInt.
llvm-svn: 43405
2007-10-26 21:50:10 +00:00
Steve Naroff
161a92b976 Start rewriting ObjC interfaces. As a start, we comment out all the methods. This involved refining how the parser/AST passes/manages SourceLocations for ObjcMethodDecl's.
llvm-svn: 43404
2007-10-26 20:53:56 +00:00
Fariborz Jahanian
3339d0d14e This patch allows synthesis generation of ivar offset for legacy objective-c @implementation
decl without an @interface decl.

llvm-svn: 43403
2007-10-26 20:50:24 +00:00
Ted Kremenek
18c1393ddb Fixed incorrect "path name" in preamble (comment) of header file.
llvm-svn: 43402
2007-10-26 20:44:02 +00:00
Ted Kremenek
f8555a23ec Fixed incorrect "path name" in preamble (comment) of header file.
llvm-svn: 43401
2007-10-26 20:42:45 +00:00
Bill Wendling
b0bfd69684 On second thought. Remove this as it should never be generated in the first
place.

llvm-svn: 43400
2007-10-26 20:34:37 +00:00
Bill Wendling
6d15b32c15 - Remove the hacky code that forces a memcpy. Alignment is taken care of in the
FE.
- Explicitly pass in the alignment of the load & store.
- XFAIL 2007-10-23-UnalignedMemcpy.ll because llc has a bug that crashes on
  unaligned pointers.

llvm-svn: 43398
2007-10-26 20:24:42 +00:00
Ted Kremenek
16c7d8ce5b Added skeleton implementation of serialization for types (not complete).
llvm-svn: 43397
2007-10-26 20:24:35 +00:00
Ted Kremenek
fc88b1ddb8 Added default implementation of SerializeTrait<> that dispatches to
calling member functions of the target type to perform type-specific
serialization.
                         
Added version of ReadPtr that allows passing references to uintptr_t
(useful for smart pointers).

llvm-svn: 43396
2007-10-26 20:23:27 +00:00
Fariborz Jahanian
99e96b0f11 Patch to synthesize computation of Ivar offset in rewritten c file.
Thanks to Steve N. to point out using of offsetof for this.

llvm-svn: 43391
2007-10-26 19:46:17 +00:00
Devang Patel
ed93c3c3b3 Codegen union member references.
llvm-svn: 43390
2007-10-26 19:42:18 +00:00
Devang Patel
7718d7a2eb Handle non LValue base expressions.
llvm-svn: 43387
2007-10-26 18:15:21 +00:00
Devang Patel
ffdb07c939 Code gen static initializer.
llvm-svn: 43386
2007-10-26 17:50:58 +00:00
Devang Patel
8717417b3b Codegen array initializers.
llvm-svn: 43385
2007-10-26 17:44:44 +00:00
Evan Cheng
d78a3e5555 Fix a crash. Make sure TLI is not null.
llvm-svn: 43384
2007-10-26 17:24:46 +00:00
Devang Patel
19c2b9a66f Codegen global array initializers.
llvm-svn: 43383
2007-10-26 16:31:40 +00:00
Fariborz Jahanian
22c6a22d76 Pretty printing for ivar list of an interface block.
llvm-svn: 43382
2007-10-26 16:29:12 +00:00
Anton Korobeynikov
d07d6a411c Fix off-by-one stack offset computations (dwarf information) for callee-saved
registers in case, when FP pointer was eliminated. This should fixes misc. random
EH-related crahses, when stuff is compiled with -fomit-frame-pointer.
Thanks Duncan for nailing this bug!

llvm-svn: 43381
2007-10-26 09:13:24 +00:00
Eric Christopher
18063916b5 clo/clz aren't supported on mips I. Keep them around for when we'll
want them later (mips32/64).

llvm-svn: 43380
2007-10-26 04:00:13 +00:00
Owen Anderson
b7971bbdd7 Make a comment better.
llvm-svn: 43379
2007-10-26 03:47:14 +00:00
Gordon Henriksen
78c63ac41e More fleshing out of docs/Passes.html, plus some typo fixes and
improved wording in source files.

llvm-svn: 43377
2007-10-26 03:03:51 +00:00
Evan Cheng
7f3d02471d Loosen up iv reuse to allow reuse of the same stride but a larger type when truncating from the larger type to smaller type is free.
e.g.
Turns this loop:
LBB1_1: # entry.bb_crit_edge
        xorl    %ecx, %ecx
        xorw    %dx, %dx
        movw    %dx, %si
LBB1_2: # bb
        movl    L_X$non_lazy_ptr, %edi
        movw    %si, (%edi)
        movl    L_Y$non_lazy_ptr, %edi
        movw    %dx, (%edi)
		addw    $4, %dx
		incw    %si
		incl    %ecx
		cmpl    %eax, %ecx
		jne     LBB1_2  # bb
	
into

LBB1_1: # entry.bb_crit_edge
        xorl    %ecx, %ecx
        xorw    %dx, %dx
LBB1_2: # bb
        movl    L_X$non_lazy_ptr, %esi
        movw    %cx, (%esi)
        movl    L_Y$non_lazy_ptr, %esi
        movw    %dx, (%esi)
        addw    $4, %dx
		incl    %ecx
        cmpl    %eax, %ecx
        jne     LBB1_2  # bb

llvm-svn: 43375
2007-10-26 01:56:11 +00:00
Hartmut Kaiser
1207cd6b1b Silenced a VC++ warning.
llvm-svn: 43374
2007-10-25 23:49:14 +00:00
Ted Kremenek
542e5f29b7 Updated backpatching during object deserialization to support "smart"
pointers that employ unused bits in a pointer to store extra data.

llvm-svn: 43373
2007-10-25 23:40:35 +00:00
Hartmut Kaiser
fc69d322f2 Clarified operator precedence.
Silenced VC++ warning.

llvm-svn: 43372
2007-10-25 23:15:31 +00:00
Hartmut Kaiser
d57aca25fc Disambiguated variable name to comply with VC++'s archaic variable scoping rules.
llvm-svn: 43371
2007-10-25 22:59:17 +00:00
Hartmut Kaiser
414d7e373e Updated VC++ build system
llvm-svn: 43370
2007-10-25 22:58:31 +00:00
Hartmut Kaiser
7e16ce5270 Disambiguated variable name to comply with VC++'s archaic variable scoping rules.
llvm-svn: 43369
2007-10-25 22:57:48 +00:00
Hartmut Kaiser
3a0cda1cf7 Updated VC++ build system
llvm-svn: 43368
2007-10-25 22:56:13 +00:00
Evan Cheng
29e29e63bd Do not rewrite compare instruction using iv of a different stride if the new
stride may be rewritten using the stride of the compare instruction.

llvm-svn: 43367
2007-10-25 22:45:20 +00:00
Ted Kremenek
066f60321d Modified StmtIterator to now include visiting the initialization expression for EnumConstantDecls.
llvm-svn: 43366
2007-10-25 22:24:19 +00:00
Devang Patel
b989c9e65c Fix "strbuf += stufflen;" crash.
llvm-svn: 43365
2007-10-25 22:19:13 +00:00
Dale Johannesen
65e804a9c3 Support non-POSIX hosts by removing use of strncasecmp.
llvm-svn: 43364
2007-10-25 21:54:43 +00:00
Devang Patel
5ea6d7f1be Document ConvertNewType() method and make it a private method.
llvm-svn: 43363
2007-10-25 21:40:12 +00:00
Ted Kremenek
5749aaedd9 Added DeclSerialization.cpp to XCode project.
llvm-svn: 43362
2007-10-25 21:39:10 +00:00
Ted Kremenek
1f1e756483 Added skeleton for Decl serialization.
llvm-svn: 43361
2007-10-25 21:37:16 +00:00
Fariborz Jahanian
51f2182338 Refactored several meta data for reusability.
Changed the entire rewrite of metadata to write to std::string
object instead of stdout.

llvm-svn: 43360
2007-10-25 20:55:25 +00:00
Bill Wendling
f73340efb9 Changed XXX to FIXME, and added comment to the README file
llvm-svn: 43359
2007-10-25 19:49:32 +00:00
Ted Kremenek
a83e6bc246 Added special treatment of serializing NULL pointers.
llvm-svn: 43357
2007-10-25 18:42:52 +00:00
Evan Cheng
5a38108374 Remove code that's commented out.
llvm-svn: 43356
2007-10-25 18:38:24 +00:00
Devang Patel
29e3824453 Cache llvm::Type through PATypeHolder.
llvm-svn: 43355
2007-10-25 18:32:36 +00:00
Ted Kremenek
222211a425 changed #include of Serialization.h to SerializationFwd.h to reduce
compilation time.

llvm-svn: 43354
2007-10-25 18:27:10 +00:00
Bill Wendling
5f7ed00d44 Added comment explaining why we are doing this check.
llvm-svn: 43353
2007-10-25 18:23:45 +00:00
Ted Kremenek
0cf94e9c91 Created header file to include minimal forward references needed for
object serialization.

llvm-svn: 43352
2007-10-25 18:19:29 +00:00
Chris Lattner
991b6b9d0c typo
llvm-svn: 43351
2007-10-25 18:05:29 +00:00
Chris Lattner
76a2273f6e some minor edits, link to Passes.html, make one point
I forgot about yesterday.

llvm-svn: 43350
2007-10-25 17:52:39 +00:00
Chris Lattner
36f81fb065 Fix a recovery bug Fariborz and I noticed yesterday. We were producing:
method.c:4:3: error: use of undeclared identifier 'BADIDENT'
        &BADIDENT, 0
         ^
method.c:5:2: error: expected '}'
};
 ^
method.c:3:14: error: to match this '{'
struct S A = {
             ^

now we only produce:

method.c:4:3: error: use of undeclared identifier 'BADIDENT'
        &BADIDENT, 0
         ^

llvm-svn: 43349
2007-10-25 17:27:01 +00:00
Chris Lattner
88710ff5b8 simplify change.
llvm-svn: 43348
2007-10-25 17:18:59 +00:00
Chris Lattner
94a41ff6c1 Fix a bug steve noticed when handling nested rewrites. We now turn this:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

into:

    NSAutoreleasePool * pool = objc_msgSend(objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_getUid("alloc")), sel_getUid("init"));

instead of:

    NSAutoreleasePool * pool = objc_msgSend(objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_getUid("alloc")), sel_getUid("init"))utoreleasePool"), sel_getUid("alloc")) init];

llvm-svn: 43347
2007-10-25 17:17:34 +00:00
Chris Lattner
211f8b8352 Convert one type of metadata to use std::string instead of
printf as an example.

llvm-svn: 43346
2007-10-25 17:07:24 +00:00
Ted Kremenek
93345274c2 Added Serialization.h, Serialize.h, Deserialize.h, Serialize.cpp, and
Deserialize.cpp to the XCode project.

llvm-svn: 43345
2007-10-25 16:09:09 +00:00
Ted Kremenek
bd8497b011 Added SourceLocation.cpp to XCode project.
llvm-svn: 43344
2007-10-25 16:03:53 +00:00
Ted Kremenek
4edcb4d676 Implemented serialization of SourceLocation and SourceRange objects.
llvm-svn: 43343
2007-10-25 16:02:43 +00:00
Ted Kremenek
6e64c3f8ec Added constness to accessors in CompoundStmt.
llvm-svn: 43342
2007-10-25 15:39:09 +00:00
Duncan Sands
d385f0759c Small formatting changes. Add a sanity check.
Use NVT rather than looking it up, since we have
it to hand.

llvm-svn: 43341
2007-10-25 12:35:51 +00:00
Duncan Sands
a8f4ba6eb9 Promote SETCC operands.
llvm-svn: 43340
2007-10-25 12:32:31 +00:00
Duncan Sands
cf0da03312 Correctly extract the ValueType from a VTSDNode.
llvm-svn: 43339
2007-10-25 12:30:51 +00:00
Duncan Sands
7e6e33beab Fix comment typos.
llvm-svn: 43338
2007-10-25 12:28:12 +00:00
Gordon Henriksen
77d27523b1 Fleshing out docs/Passes.html for some analyses.
llvm-svn: 43337
2007-10-25 10:18:27 +00:00
Evan Cheng
133694db06 If a loop termination compare instruction is the only use of its stride,
and the compaison is against a constant value, try eliminate the stride
by moving the compare instruction to another stride and change its
constant operand accordingly. e.g.

loop:
...
v1 = v1 + 3
v2 = v2 + 1
if (v2 < 10) goto loop
=>
loop:
...
v1 = v1 + 3
if (v1 < 30) goto loop

llvm-svn: 43336
2007-10-25 09:11:16 +00:00
Gordon Henriksen
ac72db5dbe Passes.html now 'passes' validation.
llvm-svn: 43335
2007-10-25 08:58:56 +00:00
Gordon Henriksen
50768f89d9 Bringing Passes.html structurally up-to-date, and enabling
semi-automated maintenance.

llvm-svn: 43334
2007-10-25 08:46:12 +00:00
Owen Anderson
4cee0451f0 Fix an obvious typo.
llvm-svn: 43333
2007-10-25 06:50:30 +00:00
Owen Anderson
4c209da848 More tutorial cleanups.
llvm-svn: 43332
2007-10-25 06:49:29 +00:00
Owen Anderson
af8059c1a7 Add proper footers.
llvm-svn: 43331
2007-10-25 06:45:01 +00:00
Owen Anderson
a24e5d6996 Don't bother providing code samples. Maintaining zip files in the repository is a pain.
llvm-svn: 43330
2007-10-25 06:41:23 +00:00
Chris Lattner
8b59eafb89 Add chapter 4, feedback appreciated.
llvm-svn: 43329
2007-10-25 06:23:36 +00:00
Chris Lattner
f98427142c remove unimplemented ctor, add some comments.
llvm-svn: 43328
2007-10-25 05:19:24 +00:00
Chris Lattner
46b4281b6a Run the verifier on generated code.
llvm-svn: 43327
2007-10-25 04:30:35 +00:00
Owen Anderson
7827a3f366 Fix for PR1741.
llvm-svn: 43326
2007-10-25 02:36:18 +00:00
Dale Johannesen
ea839ef1f0 Testcase for PR 1397.
llvm-svn: 43323
2007-10-25 00:50:14 +00:00
Chris Lattner
35e564ed09 Add a new ChooseExpr::isConditionTrue method to unify
some code.

llvm-svn: 43322
2007-10-25 00:29:32 +00:00
Owen Anderson
00974dce68 Make it possible for DomTreeBase to be constructed from MachineFunction's as well as just Function's.
llvm-svn: 43321
2007-10-25 00:16:57 +00:00
Fariborz Jahanian
3df412a6ea Refactored RewriteObjcMethodsMetaData to better rewrite
instance/class methods metadata.

llvm-svn: 43320
2007-10-25 00:14:44 +00:00
Ted Kremenek
d5cb7b055d Implemented prototype serialization of pointers, including support
for backpatching.

Added Deserialize::ReadVal.

llvm-svn: 43319
2007-10-25 00:10:21 +00:00
Ted Kremenek
ed763de6cb Added accessors to CompoundStmt to retrieve the source locations for the
left and right bracket.  This is useful for serialization.

llvm-svn: 43318
2007-10-25 00:08:50 +00:00
Devang Patel
e85285b9f3 Remove unused #includes
llvm-svn: 43317
2007-10-24 23:42:18 +00:00
Steve Naroff
574440fa58 More work on translating message expressions.
Still to do:

- Chris will fix a bug in the rewriting engine for nested stmts. For example, the following:

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 

tranlates to:

    NSAutoreleasePool * pool = objc_msgSend(objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_getUid("alloc")), sel_getUid("init"))utoreleasePool"), sel_getUid("alloc")) init];

...which is correct, except there is garbage after sel_getUid("init"). This is because the rewriter isn't updating the extent of the containing message expression. 

- Do the crazy cast thang.

llvm-svn: 43316
2007-10-24 22:48:43 +00:00
Devang Patel
d68df20620 Handle
foo()->a = 42;

llvm-svn: 43315
2007-10-24 22:26:28 +00:00
Dale Johannesen
a4a972e32d Another expansion for i64 multiply, suitable for PPC.
llvm-svn: 43314
2007-10-24 22:26:08 +00:00
Fariborz Jahanian
aa29fb4be8 Remove explicit use of size of known structs in metadata generation.
llvm-svn: 43313
2007-10-24 21:25:12 +00:00
Dale Johannesen
52bbe1b171 This was failing on Darwin, which defaults to PIC;
no lea was generated.  I think this follows the intent.

llvm-svn: 43312
2007-10-24 20:58:14 +00:00
Fariborz Jahanian
486f718f14 Couple of minor changes. 1) Metaclass metadata also has a reference to
protocol meta-data (unlike what documentation says). 2) Include objc.h so,
we can compile the generated metadata with both gcc and clang.

llvm-svn: 43311
2007-10-24 20:54:23 +00:00
Devang Patel
bc50aab635 Move RecordOrganizer into CodeGenTypes.cpp
llvm-svn: 43310
2007-10-24 20:38:06 +00:00
Dale Johannesen
4d06391c47 Fix off by 1 bug in printf->puts lowering.
llvm-svn: 43309
2007-10-24 20:14:50 +00:00
Fariborz Jahanian
b2f525dabc Refactord instance and class metadata emission. Refactored protocols metadata emission.
Implemented emission of category metadata,

llvm-svn: 43308
2007-10-24 19:23:36 +00:00
Ted Kremenek
83610ae6f4 Split Serialization.h into separate headers: Serialize.h and
Deserialize.h Serialization.h now includes trait speciailizations for
unsigned long, etc.

llvm-svn: 43307
2007-10-24 19:06:40 +00:00
Ted Kremenek
37a3275919 Modified current clients of Bitcode-Object serialization to use the
new split-header file configuration (Serialize.h and Deserialize.h)
now in place in the core LLVM repository.

Removed unneeded SerializeTrait specializations for enums in
TokenKinds.h

llvm-svn: 43306
2007-10-24 19:06:02 +00:00
Chris Lattner
55b8302dfe simplify some code by using the new isNaN predicate
llvm-svn: 43305
2007-10-24 18:54:45 +00:00
Chris Lattner
b6ed689722 add a nice predicate to check to see if nan
llvm-svn: 43304
2007-10-24 18:54:28 +00:00
Devang Patel
b67e596d86 Handle non-constant initializers.
llvm-svn: 43301
2007-10-24 18:05:48 +00:00
Devang Patel
43fc86d0f2 Visit CompoundLiteralExpr and InitListExpr
llvm-svn: 43300
2007-10-24 17:18:43 +00:00
Chris Lattner
3c799d7e9a Fix some long lines, move code around into logical groups.
llvm-svn: 43299
2007-10-24 17:06:59 +00:00
Chris Lattner
6953469880 Use Ted's new mutable child iterators to update the tree as we rewrite it.
This will make nested subexprs work.

llvm-svn: 43296
2007-10-24 16:57:36 +00:00
Ted Kremenek
38f87dd9d0 Modified operator* for StmtIterator to return Stmt*& instead of Stmt*.
This permits in-place replacement of the original AST statements.

llvm-svn: 43295
2007-10-24 16:52:34 +00:00
Owen Anderson
544f860f59 Update Makefile to use simpler llvm-config parameters.
llvm-svn: 43292
2007-10-24 16:06:42 +00:00
Owen Anderson
4c9dbd1e9f Update Makefile to use simpler llvm-config parameters.
llvm-svn: 43291
2007-10-24 16:04:08 +00:00
Chris Lattner
0083d8f38d switch some calls to SelectionDAG::getTargetNode to use
the one that takes an operand list instead of explicit
operands.  There is one left though, the more interesting
one :)

llvm-svn: 43290
2007-10-24 06:25:09 +00:00
Chris Lattner
c62877e9da Implement a couple of foldings for ordered and unordered comparisons,
implementing cases related to PR1738.

llvm-svn: 43289
2007-10-24 05:38:08 +00:00
Chris Lattner
9a760ebf32 further simplify run options, thanks to gordonh for pointing this out
llvm-svn: 43288
2007-10-24 05:09:48 +00:00
Chris Lattner
1fb0d5df69 Fix instructions now that PR1739 is fixed.
llvm-svn: 43287
2007-10-24 04:37:23 +00:00
Chris Lattner
4c9ec1aaa2 Fix PR1739.
llvm-svn: 43286
2007-10-24 04:35:54 +00:00
Steve Naroff
c77380b46f Incorporate some feedback from Chris...
llvm-svn: 43285
2007-10-24 01:09:48 +00:00
Devang Patel
ea37aa7d64 Constify methods and reuse RecordOrganizer object.
llvm-svn: 43284
2007-10-24 00:56:23 +00:00
Devang Patel
790afb0444 check base type.
llvm-svn: 43283
2007-10-24 00:54:17 +00:00
Devang Patel
f2423473b1 Add notes.
llvm-svn: 43282
2007-10-24 00:32:16 +00:00
Devang Patel
e531ae687a Use isUnionType() predicate.
llvm-svn: 43281
2007-10-24 00:28:49 +00:00
Devang Patel
c4e224e59c untabify
llvm-svn: 43280
2007-10-24 00:26:24 +00:00
Hartmut Kaiser
1759e27951 Added VC++ solution file allowing to build clang.
llvm-svn: 43279
2007-10-24 00:13:40 +00:00
Hartmut Kaiser
5277af121a Fixed a strange construct, please review.
llvm-svn: 43278
2007-10-24 00:07:36 +00:00
Hartmut Kaiser
d37ea4f6ed Silenced a VC++ warning.
llvm-svn: 43277
2007-10-24 00:06:59 +00:00
Hartmut Kaiser
36309e56eb Silenced a VC++ warning.
llvm-svn: 43276
2007-10-24 00:06:31 +00:00
Hartmut Kaiser
f8b2612b0c Updated VC++ build system
llvm-svn: 43275
2007-10-23 23:57:01 +00:00
Steve Naroff
db1ab1c2b0 Add some plumbing to rewrite message expressions (still under construction).
llvm-svn: 43274
2007-10-23 23:50:29 +00:00
Bill Wendling
38ccabcae9 Fix comment and use the "Size" variable that's already provided.
llvm-svn: 43271
2007-10-23 23:36:57 +00:00
Bill Wendling
e3b859298a If there's an unaligned memcpy to/from the stack, don't lower it. Just call the
memcpy library function instead.

llvm-svn: 43270
2007-10-23 23:32:40 +00:00
Devang Patel
61eaea88f8 Fix typo.
llvm-svn: 43269
2007-10-23 23:29:51 +00:00
Devang Patel
65c4afb940 Handle nested structs.
typdef struct A { int i; struct A *next; } A

llvm-svn: 43268
2007-10-23 23:26:46 +00:00
Dale Johannesen
10f4152471 Disable a couple more things for ppcf128.
llvm-svn: 43267
2007-10-23 23:20:14 +00:00
Ted Kremenek
f25f4a3de0 Implemented serialization for IdentifierInfo and IdentifierTable.
Updated serialization test code in the driver to test serialization of
these types.

llvm-svn: 43266
2007-10-23 22:18:37 +00:00
Ted Kremenek
97e3be7995 Added "ReadEnum" and "WriteEnum" to serialization classes.
llvm-svn: 43265
2007-10-23 22:17:03 +00:00
Bill Wendling
6f149c0571 This broke lots. Reverting.
llvm-svn: 43264
2007-10-23 22:04:26 +00:00
Owen Anderson
39b52ee00b Make DomTreeBase not a FunctionPass.
llvm-svn: 43263
2007-10-23 21:42:49 +00:00
Bill Wendling
8971440e56 Lowering a memcpy to the stack is killing PPC. The ARM and X86 backends already
have their own custom memcpy lowering code. This code needs to be factored out
into a target-independent lowering method with hooks to the backend. In the
meantime, just call memcpy if we're trying to copy onto a stack.

llvm-svn: 43262
2007-10-23 21:30:25 +00:00
Ted Kremenek
bd3501887f Added preliminary implementation of generic object serialization to bitcode.
llvm-svn: 43261
2007-10-23 21:29:33 +00:00
Owen Anderson
4ca0ca7e64 Unbreak the build. Forgot to commit this file.
llvm-svn: 43260
2007-10-23 21:04:37 +00:00
Owen Anderson
9c614117da Make DomTree and PostDomTree thin wrappers around DomTreeBase, rather than inheriting from it.
llvm-svn: 43259
2007-10-23 20:58:37 +00:00
Devang Patel
30efa2eec9 Handle simple struct member expr.
llvm-svn: 43258
2007-10-23 20:28:39 +00:00
Steve Naroff
e670dbb9e6 - Add rewrite rule for @class.
- Add setter/getter to ObjcClassDecl.
- Predefined key runtime functions.

llvm-svn: 43257
2007-10-23 20:20:08 +00:00
Evan Cheng
5d7032bb08 It's possible to commute instrctions with more than 3 operands.
llvm-svn: 43256
2007-10-23 20:14:40 +00:00
Fariborz Jahanian
f3d5a54722 Patch to complete metadata generation for each implemented class.
llvm-svn: 43255
2007-10-23 18:53:48 +00:00
Chris Lattner
07ae732cc4 new testcase
llvm-svn: 43252
2007-10-23 18:07:23 +00:00
Chris Lattner
788f0d340a llvm/test programs should not be execution programs. This
will hopefully fix Gabor's Sparc problem.

llvm-svn: 43251
2007-10-23 17:56:04 +00:00
Evan Cheng
847d42a85c isSubRegOf() is a dup of isSubRegister.
llvm-svn: 43249
2007-10-23 06:51:50 +00:00
Evan Cheng
ec271b104c Temporary solution: added a different set of BCTRL_Macho / BCTRL_ELF with right callee-saved defs set for ppc64.
llvm-svn: 43248
2007-10-23 06:42:42 +00:00
Chris Lattner
c3def1530a Fix validation problems, which were somewhat ironically in the "valid html" button code :)
llvm-svn: 43247
2007-10-23 06:30:50 +00:00
Chris Lattner
e9b16ec28a add a skeleton for part 4
llvm-svn: 43246
2007-10-23 06:27:55 +00:00
Chris Lattner
a02ab559a1 complete the codegen chapter
llvm-svn: 43245
2007-10-23 06:23:57 +00:00
Owen Anderson
b5d8904909 Now with valid HTML 4.01!
llvm-svn: 43244
2007-10-23 06:22:21 +00:00
Owen Anderson
3ee597e34a Add a link to the "writing an optimization" tutorial.
llvm-svn: 43243
2007-10-23 06:17:39 +00:00
Owen Anderson
c4bb8c75ca Add downloadable code sample for tutorial 2.
llvm-svn: 43242
2007-10-23 06:05:37 +00:00
Owen Anderson
299be453b5 Add the second of the "basic topics" tutorials.
llvm-svn: 43241
2007-10-23 06:03:24 +00:00
Owen Anderson
9e87698ec1 Reorder the optimization and bitcode tutorials.
llvm-svn: 43240
2007-10-23 06:02:14 +00:00
Chris Lattner
61353b41df Fix up a broken #include, move code to its own section, add conclusions.
llvm-svn: 43239
2007-10-23 05:43:01 +00:00
Chris Lattner
93b76e0c60 Finish up expr codegen.
llvm-svn: 43238
2007-10-23 04:51:30 +00:00
Chris Lattner
61b4ec70aa several improvements suggested by Dan, thanks!
llvm-svn: 43237
2007-10-23 04:27:44 +00:00
Devang Patel
3e11ccea96 Begin struct layout work.
llvm-svn: 43236
2007-10-23 02:10:49 +00:00
Fariborz Jahanian
d752eae488 Patch for initialization of class's Meta-class metadata.
llvm-svn: 43235
2007-10-23 00:02:02 +00:00
Evan Cheng
1f2dd35898 Fix memcpy lowering when addresses are 4-byte aligned but size is not multiple of 4.
llvm-svn: 43234
2007-10-22 22:11:27 +00:00
Fariborz Jahanian
6eafb030f0 This patch generates protocol metadata and all its sub-metadata.
llvm-svn: 43233
2007-10-22 21:41:37 +00:00
Dan Gohman
d09f1c40a2 The #include <iterator> isn't needed in this header.
llvm-svn: 43232
2007-10-22 20:44:10 +00:00
Dan Gohman
e0c3d9f338 Strength reduction improvements.
- Avoid attempting stride-reuse in the case that there are users that
   aren't addresses. In that case, there will be places where the
   multiplications won't be folded away, so it's better to try to
   strength-reduce them.

 - Several SSE intrinsics have operands that strength-reduction can
   treat as addresses. The previous item makes this more visible, as
   any non-address use of an IV can inhibit stride-reuse.

 - Make ValidStride aware of whether there's likely to be a base
   register in the address computation. This prevents it from thinking
   that things like stride 9 are valid on x86 when the base register is
   already occupied.

Also, XFAIL the 2007-08-10-LEA16Use32.ll test; the new logic to avoid
stride-reuse elimintes the LEA in the loop, so the test is no longer
testing what it was intended to test.

llvm-svn: 43231
2007-10-22 20:40:42 +00:00
Dan Gohman
bf474959a3 Fix the folding of multiplication into addresses on x86, which was broken
by the recent {U,S}MUL_LOHI changes.

llvm-svn: 43230
2007-10-22 20:22:24 +00:00
Evan Cheng
bdbed66333 Use ptr type in the immediate field of a BxA instruction so we don't end up selecting 32-bit call instruction for ppc64.
llvm-svn: 43228
2007-10-22 19:46:19 +00:00
Evan Cheng
5163a8f53e Add missing paratheses.
llvm-svn: 43227
2007-10-22 19:42:28 +00:00
Chris Lattner
fee916334a add a 'don't use me' marker.
llvm-svn: 43226
2007-10-22 19:41:46 +00:00
Duncan Sands
941db4da0a Support for expanding extending loads of integers with
funky bit-widths.

llvm-svn: 43225
2007-10-22 19:00:05 +00:00
Dan Gohman
a37eaf2bf9 Move the SCEV object factors from being static members of the individual
SCEV subclasses to being non-static member functions of the ScalarEvolution
class.

llvm-svn: 43224
2007-10-22 18:31:58 +00:00
Duncan Sands
8fc995069b Fix up the logic for result expanding the various extension
operations so they work right for integers with funky
bit-widths.  For example, consider extending i48 to i64
on a 32 bit machine.  The i64 result is expanded to 2 x i32.
We know that the i48 operand will be promoted to i64, then
also expanded to 2 x i32.  If we had the expanded promoted
operand to hand, then expanding the result would be trivial.
Unfortunately at this stage we can only get hold of the
promoted operand.  So instead we kind of hand-expand, doing
explicit shifting and truncating to get the top and bottom
halves of the i64 operand into 2 x i32, which are then used
to expand the result.  This is harmless, because when the
promoted operand is finally expanded all this bit fiddling
turns into trivial operations which are eliminated either
by the expansion code itself or the DAG combiner.

llvm-svn: 43223
2007-10-22 18:26:21 +00:00
Chris Lattner
ce2c3a456f fit in 80 cols :)
llvm-svn: 43222
2007-10-22 16:44:31 +00:00
Chris Lattner
560762d118 start of chapter 3
llvm-svn: 43221
2007-10-22 07:01:42 +00:00
Owen Anderson
c2b2fc0a26 Fix a few typos I noticed.
llvm-svn: 43220
2007-10-22 06:48:28 +00:00
Owen Anderson
3295cfde98 Add downloadable code samples.
llvm-svn: 43219
2007-10-22 06:35:07 +00:00
Chris Lattner
3a48708c91 Check in part 2: parser and ast.
llvm-svn: 43218
2007-10-22 06:34:15 +00:00
Owen Anderson
bbed04336c Fix some code to make it actually work.
llvm-svn: 43217
2007-10-22 06:29:31 +00:00
Bill Wendling
8830ffed4c Put correct link in example
llvm-svn: 43216
2007-10-22 05:10:05 +00:00
Chris Lattner
5e0f459da6 add part 1, review appreciated.
llvm-svn: 43215
2007-10-22 04:32:37 +00:00
Chris Lattner
5e63999d71 add an outline for "part 2".
llvm-svn: 43214
2007-10-22 03:19:07 +00:00
Chris Lattner
c14c8cd1a7 rename tutorial 1 -> JITTutorial1, make unimplemented links not be dead links.
llvm-svn: 43213
2007-10-22 03:12:24 +00:00
Evan Cheng
c92446af1f Fix an unfolding bug.
llvm-svn: 43212
2007-10-22 03:03:20 +00:00
Evan Cheng
8557603781 - Only perform the unfolding optimization when the folding in question is modref.
- Remove a bogus assertion.

llvm-svn: 43211
2007-10-22 03:01:44 +00:00
Chris Lattner
fd6f3257b8 add a mechanism for the JIT to invoke a function to lazily create functions as they are referenced.
llvm-svn: 43210
2007-10-22 02:50:12 +00:00
Chris Lattner
bf5e958ba0 llvm-gcc3 is dead, along with it __main.
llvm-svn: 43209
2007-10-22 02:39:47 +00:00
Anton Korobeynikov
7499a3b092 Reg2Mem cleanup and optimizations:
- enable phi instructions demotion to stack
 - create alloca instructions in the entry block

llvm-svn: 43208
2007-10-21 23:05:16 +00:00
Chris Lattner
edaf0b4651 LoadLibraryPermanently doesn't throw.
llvm-svn: 43207
2007-10-21 22:58:11 +00:00
Chris Lattner
b5163bb9f0 Add a convenience method for creating EE's.
llvm-svn: 43206
2007-10-21 22:57:11 +00:00
Dale Johannesen
8ee70112ea Allow for copysign having f80 second argument.
Fixes 5550319.

llvm-svn: 43205
2007-10-21 01:07:44 +00:00
Chris Lattner
36f06c80e6 Add promote operand support for [su]int_to_fp.
llvm-svn: 43204
2007-10-20 22:57:56 +00:00
Owen Anderson
18be874e67 Some improvements based on feedback from Anders.
llvm-svn: 43203
2007-10-20 06:12:33 +00:00
Owen Anderson
9f2be01f86 Fix some weird indenting in code.
llvm-svn: 43202
2007-10-20 05:41:39 +00:00
Owen Anderson
f747ab10fb Use getOrInsertFunction() in tutorial 1. This makes for shorter, simpler, and better example code.
llvm-svn: 43201
2007-10-20 05:40:47 +00:00
Owen Anderson
b207ff2c18 Add the beginnings of an LLVM tutorial. If anyone has suggestions, comments,
or would like to contribute, let me know!

llvm-svn: 43200
2007-10-20 05:23:06 +00:00
Chris Lattner
2ba4b148f3 Add result promotion of FP_TO_*INT, fixing CodeGen/X86/trunc-to-bool.ll
with the new legalizer.

llvm-svn: 43199
2007-10-20 04:32:38 +00:00
Chris Lattner
1c87f0c620 simplify some code.
llvm-svn: 43198
2007-10-20 04:09:48 +00:00
Chris Lattner
2bcac640b7 Implement promote and expand for operands of memcpy and friends.
This fixes CodeGen/X86/mem*.ll.

llvm-svn: 43197
2007-10-20 04:07:07 +00:00
Evan Cheng
f12967124c Added missing curly braces which renders the if clause useless in debug build.
llvm-svn: 43196
2007-10-20 04:01:47 +00:00
Dale Johannesen
771188cf60 Fix a few places vector operations were not getting
the operand's type from the right place.

llvm-svn: 43195
2007-10-20 00:07:52 +00:00
Evan Cheng
45e096c77e Resolve unfold tables ambiguity.
llvm-svn: 43194
2007-10-19 23:50:58 +00:00
Evan Cheng
f52a6fc50c New test case.
llvm-svn: 43193
2007-10-19 22:05:00 +00:00
Evan Cheng
35ff79370b Local spiller optimization:
Turn a store folding instruction into a load folding instruction. e.g.
     xorl  %edi, %eax
     movl  %eax, -32(%ebp)
     movl  -36(%ebp), %eax
     orl   %eax, -32(%ebp)
=>
     xorl  %edi, %eax
     orl   -36(%ebp), %eax
     mov   %eax, -32(%ebp)
This enables the unfolding optimization for a subsequent instruction which will
also eliminate the newly introduced store instruction.

llvm-svn: 43192
2007-10-19 21:23:22 +00:00
Bill Wendling
ac5c93040f Don't branch fold inline asm statements.
llvm-svn: 43191
2007-10-19 21:09:55 +00:00
Duncan Sands
a87c9e4b75 Add support for a few more nodes.
llvm-svn: 43190
2007-10-19 20:29:48 +00:00
Dale Johannesen
6802d0c96f Redo "last ppc long double fix" as Chris wants.
llvm-svn: 43189
2007-10-19 20:29:00 +00:00
Chris Lattner
8beb9dee0e Fix a crash on test/Sema/invalid-decl.c
llvm-svn: 43188
2007-10-19 20:10:30 +00:00
Bill Wendling
b5bc897864 Removed "-arch i386" by popular demand...
llvm-svn: 43186
2007-10-19 18:49:16 +00:00
Bill Wendling
5f1a253a3f Now with RUN line!
llvm-svn: 43185
2007-10-19 18:40:53 +00:00
Bill Wendling
89151b1f0a Remove the Foundation.h file because not everyone has that.
llvm-svn: 43184
2007-10-19 18:36:04 +00:00
Devang Patel
c0ced49a14 This test now passes.
llvm-svn: 43183
2007-10-19 17:11:01 +00:00
Anton Korobeynikov
f93fa13de7 Update this file for 2.0 syntax. Contributed by Jan Rehders
llvm-svn: 43182
2007-10-19 16:54:13 +00:00
Chris Lattner
064c31ebac Fix a really nasty vector miscompilation bill recently introduced.
llvm-svn: 43181
2007-10-19 16:47:35 +00:00
Hartmut Kaiser
321be0cd86 Updated VC++ build system
llvm-svn: 43180
2007-10-19 15:51:20 +00:00
Hartmut Kaiser
b5371d22eb Silenced a VC++ warning.
llvm-svn: 43179
2007-10-19 15:50:35 +00:00
Gabor Greif
24032f1ac2 add NL at end of file
llvm-svn: 43178
2007-10-19 15:38:32 +00:00
Chris Lattner
3ea519e56d rename ExpandOperation to ExpandOperationResult, as suggested
by Duncan

llvm-svn: 43177
2007-10-19 15:28:47 +00:00
Rafael Espindola
18a831d783 split LowerMEMCPY into LowerMEMCPYCall and LowerMEMCPYInline in the ARM backend.
llvm-svn: 43176
2007-10-19 14:35:17 +00:00
Duncan Sands
a9953e4d0a Support for expanding ADDE and SUBE.
llvm-svn: 43175
2007-10-19 13:06:17 +00:00
Duncan Sands
d9834b29dd If the value types are equal then this routine
asserts in later checks rather than producing
the ordinary load it is supposed to.  Avoid all
such hassles by directly returning an ordinary
load in this case.

llvm-svn: 43174
2007-10-19 13:05:40 +00:00
Rafael Espindola
813a0b1d29 Test byval with a 8 bit aligned struct
llvm-svn: 43173
2007-10-19 11:29:21 +00:00
Rafael Espindola
846c19dd70 Add support for byval function whose argument is not 32 bit aligned.
To do this it is necessary to add a "always inline" argument to the
memcpy node. For completeness I have also added this node to memmove
and memset.  I have also added getMem* functions, because the extra
argument makes it cumbersome to use getNode and because I get confused
by it :-)

llvm-svn: 43172
2007-10-19 10:41:11 +00:00
Chris Lattner
e5a6448533 Implement a few new operations.
llvm-svn: 43171
2007-10-19 04:46:45 +00:00
Chris Lattner
e31365eecc Implement expansion of SINT_TO_FP and UINT_TO_FP operands.
llvm-svn: 43170
2007-10-19 04:32:47 +00:00
Chris Lattner
9081d08083 implement support for custom expansion of any node type, in one place.
llvm-svn: 43169
2007-10-19 04:14:36 +00:00
Chris Lattner
b193576bc6 comment fixes
llvm-svn: 43168
2007-10-19 04:08:28 +00:00
Chris Lattner
d01b8ea4a5 Make use of TLI.ExpandOperation, remove softfloat stuff.
llvm-svn: 43167
2007-10-19 03:58:25 +00:00
Chris Lattner
3c7ee41c78 add expand support for bit_convert result, even allowing custom expansion.
llvm-svn: 43166
2007-10-19 03:33:14 +00:00
Chris Lattner
579db81f1c add a new target hook.
llvm-svn: 43165
2007-10-19 03:31:45 +00:00
Chris Lattner
5d979d57ae Add an easy microoptimization I noticed.
llvm-svn: 43164
2007-10-19 03:29:26 +00:00
Devang Patel
e1b7fa3410 New test.
llvm-svn: 43162
2007-10-19 01:28:02 +00:00
Bill Wendling
de16ad1446 Negative indices aren't allowed here.
llvm-svn: 43161
2007-10-19 01:10:49 +00:00
Dale Johannesen
10432e5a67 More ppcf128 issues (maybe the last)?
llvm-svn: 43160
2007-10-19 00:59:18 +00:00
Fariborz Jahanian
74a1cfaf21 rewrite of metadata for implemented instance methods.
llvm-svn: 43159
2007-10-19 00:36:46 +00:00
Steve Naroff
648e029a3d Include a simple test case for the previous commit...
llvm-svn: 43158
2007-10-19 00:05:15 +00:00
Steve Naroff
684dc4107f Fix the previous (short lived:-) FIXME.
I didn't realize that GCC considers this a hard error (I thought it was built-in).

Since it's not, we should simply emit an error.

[dylan:~/llvm/tools/clang] admin% cc -c trivial.m
trivial.m:6: error: cannot find interface declaration for 'NSConstantString'

[administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang trivial.m 
trivial.m:6:16: error: cannot find interface declaration for 'NSConstantString'
NSString *s = @"123";
               ^
1 diagnostic generated.

llvm-svn: 43157
2007-10-18 23:53:51 +00:00
Ted Kremenek
04746ce6f9 Fixed DeclStmt::child_begin() to actually create an iterator that
visits its decls, rather than just creating an "end()" iterator.

Fixed child_end() for statements and expressions to use
child_iterator() to create the end() iterator, rather than just
returning NULL.

Fixed bug in StmtIterator where we did not correctly detect if we had
marched off the end of the ScopedDecls.

llvm-svn: 43156
2007-10-18 23:28:49 +00:00
Fariborz Jahanian
e183a8259d Check for Nullness of value built in GetObjcProtoType.
llvm-svn: 43155
2007-10-18 22:59:23 +00:00
Ted Kremenek
efc244722f Minor grammar fix.
llvm-svn: 43154
2007-10-18 22:50:52 +00:00
Evan Cheng
463e2ab0ac - Added getOpcodeAfterMemoryUnfold(). It doesn't unfold an instruction, but only returns the opcode of the instruction post unfolding.
- Fix some copy+paste bugs.

llvm-svn: 43153
2007-10-18 22:40:57 +00:00
Steve Naroff
eee59ebb15 Add a FIXME to an assert.
Change a dyn_cast_or_null back to cast (which is more efficient).

llvm-svn: 43152
2007-10-18 22:17:45 +00:00
Fariborz Jahanian
c34409c281 Patch to rewrite ivar tables metadata for classes defined.
llvm-svn: 43151
2007-10-18 22:09:03 +00:00
Evan Cheng
aa9a225699 Use SmallVectorImpl instead of SmallVector with hardcoded size in MRegister public interface.
llvm-svn: 43150
2007-10-18 21:29:24 +00:00
Chris Lattner
0d466153b9 remove dead #include
llvm-svn: 43149
2007-10-18 21:23:00 +00:00
Devang Patel
df49cf52e2 Try again.
Instead of loading small global string from memory, use
integer constant.

llvm-svn: 43148
2007-10-18 19:52:32 +00:00
Owen Anderson
09b83ba6f1 Allow GVN to eliminate redundant calls to functions without side effects.
llvm-svn: 43147
2007-10-18 19:39:33 +00:00
Christopher Lamb
64035f3b8e Add an uppercase conversion utility function.
llvm-svn: 43146
2007-10-18 19:31:38 +00:00
Christopher Lamb
79dfbed6f6 Fix a misnamed parameter.
llvm-svn: 43145
2007-10-18 19:29:45 +00:00
Christopher Lamb
7f68cf0d57 Fix a typo
llvm-svn: 43144
2007-10-18 19:28:55 +00:00
Fariborz Jahanian
93191afdef First patch toward rewriting of objective-c's meta data.
llvm-svn: 43143
2007-10-18 19:23:00 +00:00
Steve Naroff
1bb21df47f Tweak a recent fix to UsualArithmeticConversions (made by Chris - r43113). The benefit of this tweak is it guarantees the entire routine operates on unqualified types (which I believe is a bit clearer).
llvm-svn: 43142
2007-10-18 18:55:53 +00:00
Chris Lattner
9715d9fb59 Fix PR1735 and Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll by
fixing some obviously broken code :(

llvm-svn: 43141
2007-10-18 18:49:29 +00:00
Bill Wendling
5616a608df Fix the command line.
llvm-svn: 43140
2007-10-18 18:26:40 +00:00
Ted Kremenek
0f39de13a0 Added StmtIterator.cpp and StmtIterator.h to the XCode project.
llvm-svn: 43139
2007-10-18 18:22:01 +00:00
Ted Kremenek
2ba761c7b8 Refactored StmtIterator into classes StmtIteratorBase (non-templated)
and StmtIteratorImpl (templated), which StmtIterator and
ConstStmtIterator now succintly subclass.

Implemented iteration over the initializers in DeclStmts.  This is not
thoroughly tested, so there may be bugs.

llvm-svn: 43138
2007-10-18 18:19:31 +00:00
Ted Kremenek
614d84aab3 Replaced virtual method call to child_begin() in child_end() by
directly inlining its logic.

llvm-svn: 43137
2007-10-18 18:17:43 +00:00
Devang Patel
371a5ef1de Fix test.
llvm-svn: 43136
2007-10-18 17:54:49 +00:00
Chris Lattner
ef6500992f this doesn't need dynamic_cast.
llvm-svn: 43133
2007-10-18 16:26:24 +00:00
Ted Kremenek
7aef89101d Fixed broken build.
llvm-svn: 43132
2007-10-18 16:25:40 +00:00
Chris Lattner
7813cec0d0 remove dead file
llvm-svn: 43131
2007-10-18 16:12:54 +00:00
Chris Lattner
9afb8e4e29 Reduce reliance on rtti info
llvm-svn: 43130
2007-10-18 16:11:18 +00:00
Chris Lattner
9b6ec77647 fix typo
llvm-svn: 43129
2007-10-18 16:10:48 +00:00
Chris Lattner
b12dce4bce update comment.
llvm-svn: 43128
2007-10-18 16:10:17 +00:00
Chris Lattner
1b88e3c2dd This requires rtti info because tblgen uses commandline,
and tblgen requires rtti.

llvm-svn: 43127
2007-10-18 15:57:29 +00:00
Chris Lattner
604b2314c8 tblgen uses dynamic_cast heavily, so it needs rtti info
llvm-svn: 43126
2007-10-18 15:54:45 +00:00
Hartmut Kaiser
c8107e54d5 Silenced a couple of VC++ warnings.
llvm-svn: 43125
2007-10-18 12:47:01 +00:00
Hartmut Kaiser
597e172d0a Updated VC++ build system
llvm-svn: 43124
2007-10-18 12:32:10 +00:00
Hartmut Kaiser
a420cf3f77 Updated VC++ build system
llvm-svn: 43123
2007-10-18 12:31:51 +00:00
Gordon Henriksen
ea31de8dc1 Work around downrev gccs which do not inherit visibility of the
Registry<>::iterator member class.

llvm-svn: 43122
2007-10-18 11:53:05 +00:00
Gordon Henriksen
03368e85b8 Missing 'public' keyword.
llvm-svn: 43121
2007-10-18 11:31:21 +00:00
Bill Wendling
070aca5d25 Pointer arithmetic should be done with the index the same size as the pointer.
llvm-svn: 43120
2007-10-18 08:32:37 +00:00
Duncan Sands
cb7aca0dcb Support for ADDC/SUBC.
llvm-svn: 43119
2007-10-18 08:22:16 +00:00
Evan Cheng
e6a41c066a Really fix PR1734. Carefully track which register uses are sub-register uses by
traversing inverse register coalescing map.

llvm-svn: 43118
2007-10-18 07:49:59 +00:00
Evan Cheng
0b18ddf55a Remove unnecessary include.
llvm-svn: 43117
2007-10-18 07:47:55 +00:00
Chris Lattner
84f3461c49 legalizing the ret operation on f64 shouldn't introduce a new
i64 bit convert needlessly.

llvm-svn: 43116
2007-10-18 06:17:07 +00:00
Owen Anderson
ca831a829d Move Split<...>() into DomTreeBase. This should make the #include's of DominatorInternals.h
in CodeExtractor and LoopSimplify unnecessary.

Hartmut, could you confirm that this fixes the issues you were seeing?

llvm-svn: 43115
2007-10-18 05:13:52 +00:00
Steve Naroff
a78c464c9e Fix a bug in Sema::CheckConditionalOperands(). When mixing pointers and null pointer constants, we need to promote the null pointer constant (which is an integer) to the pointer type. Test case is self explanatory.
This surfaced yesterday, when compiling test/Sema/cocoa.m on Leopard. Since this has nothing to do with ObjC, it's kind of bizarre this hasn't shown up before. I imagine Cocoa.h on Leopard may have changed recently? 

Thanks to Ted for localizing the bug and giving me a useful AST dump...

llvm-svn: 43114
2007-10-18 05:13:08 +00:00
Chris Lattner
fac7ac4130 UsualArithmeticConversions is crashing with an assert
when comparing "float" and "const float".  This "fixes" the
issue, but may not be the right fix.  Steve, please review.

Testcase here: test/Sema/usual-float.c

llvm-svn: 43113
2007-10-18 03:50:33 +00:00
Steve Naroff
8569d77349 Fix the following bug...
unsigned char asso_values[] = { 34 };
int legal2() { 
  return asso_values[0]; 
}

The code that creates the new constant array type was operating on the original type.

As a result, the constant type being generated was "unsigned char [1][]" (which is wrong).

The fix is to operate on the element type - in this case, the correct type is "unsigned char [1]"

I added this case to array-init.c, which clearly didn't catch this bogosity...

llvm-svn: 43112
2007-10-18 03:27:23 +00:00
Devang Patel
9497767458 XFAIL for now.
llvm-svn: 43111
2007-10-18 00:48:43 +00:00
Chris Lattner
c7f3981b27 remove extraneous space in @selector()
llvm-svn: 43110
2007-10-18 00:39:29 +00:00
Chris Lattner
810c1db3f5 remove typedef.
llvm-svn: 43109
2007-10-18 00:38:23 +00:00
Ted Kremenek
da9639d1a7 Changed the return type of type-specific Allocate() methods to return
void*.  This is hint that we are returning uninitialized memory rather
than a constructed object.

Patched ImutAVLTree to conform to this new interface.

llvm-svn: 43106
2007-10-18 00:30:14 +00:00
Ted Kremenek
336886a344 Implemented 90% functionality of new child_iterator for Stmt objects
that will (soon) allow iteration over the initializers in
declarations.  This new iterator mechanism is implemented by the
classes StmtIterator and ConstStmtIterator.

Patched a few files to use "operator++" instead of "operator+" on
child_iterators.

Friendship added in VarDecl to StmtIterator to allow returning a
reference to the initializer within the VarDecl.  We may not wish this
as a permanent solution.

llvm-svn: 43105
2007-10-18 00:24:38 +00:00
Chris Lattner
9c0f9fe151 Make control flow in Expr::isConstantExpr more simple and
local, making the code easier to read.

llvm-svn: 43104
2007-10-18 00:20:32 +00:00
Evan Cheng
cdcc1d0444 Reverting r43070 for now. It's causing llc test failures.
llvm-svn: 43103
2007-10-17 23:51:13 +00:00
Bill Wendling
37f888e6e8 Test to make sure we don't generate unwind info for non-64-bit Objective-C.
llvm-svn: 43102
2007-10-17 23:14:56 +00:00
Chris Lattner
c6d91c0f6d Add new API to rewrite one stmt/expr with another.
llvm-svn: 43101
2007-10-17 22:35:30 +00:00
Ted Kremenek
603fbbfcb7 ImutAVLTree now allocates tree nodes from the BumpPtrAllocator using
the new type-aligned Allocate() method.

llvm-svn: 43100
2007-10-17 22:17:01 +00:00
Ted Kremenek
3830606dee Removed inclusion of cassert, which is no longer needed.
llvm-svn: 43099
2007-10-17 22:12:14 +00:00
Ted Kremenek
27d207d2e7 Minor cosmetic cleanups in the calculation of alignments for
StringMapEntry objects.  No functionality change.

llvm-svn: 43097
2007-10-17 22:09:45 +00:00
Ted Kremenek
02c3267039 Added template function alignof() which provides a clean
function-based interface to getting the alignment of a type.

llvm-svn: 43096
2007-10-17 22:08:55 +00:00
Gordon Henriksen
0ab3d27641 Reverting unnecessary commit of generated files.
llvm-svn: 43095
2007-10-17 21:36:08 +00:00
Gordon Henriksen
ef5d08f4ea Switching TargetMachineRegistry to use the new generic Registry.
llvm-svn: 43094
2007-10-17 21:28:48 +00:00
Chris Lattner
9515625d0c Add rewriter support for @encode expressions. For example,
we currently turn:

    c = @encode(char *)[2] + 4;

into:

    c = "foo"[2] + 4;

Right now the foo string is hard coded, but you can imagine a world
where it wouldn't be :)

llvm-svn: 43093
2007-10-17 21:28:00 +00:00
Chris Lattner
42ebe5c1e6 The size returned by Rewriter::getRangeSize should include
the size of the last token.

llvm-svn: 43092
2007-10-17 21:23:07 +00:00
Chris Lattner
fd64ebd3e4 Fix assertion for raw lexer.
llvm-svn: 43091
2007-10-17 21:22:38 +00:00
Chris Lattner
8e129c23c8 Move token length calculation out of the diagnostics machinery into
the lexer, where it can be shared.

llvm-svn: 43090
2007-10-17 21:18:47 +00:00
Ted Kremenek
dbc8e043c2 Updated StringMap to use llvm::AlignOf to compute the alignment of map
entries.

llvm-svn: 43089
2007-10-17 21:13:50 +00:00
Gordon Henriksen
9c750f6fd1 Ignoring test/Transforms/LoopIndexSplit/Output.
llvm-svn: 43088
2007-10-17 21:11:33 +00:00
Ted Kremenek
a26294201f Added member template functions to MallocAllocator and
BumpPtrAllocator that implement allocations that return a properly
typed pointer.  For BumpPtrAllocator, the allocated memory is
automatically aligned to the minimum alignment of the type (as
calculated by llvm::AlignOf::Alignment).

llvm-svn: 43087
2007-10-17 21:10:21 +00:00
Ted Kremenek
391b728a99 Added llvm::AlignOf, a template class whose purpose is to portably
compute the minimum memory alignment of arbitrary types.

llvm-svn: 43086
2007-10-17 20:56:47 +00:00
Chris Lattner
4050f071e1 wean the diagnostics machinery off the preprocessor.
llvm-svn: 43085
2007-10-17 20:53:57 +00:00
Chris Lattner
02b436a05a Add a new type of lexer: a raw lexer, which does not require a preprocessor
object in order to do its thing.

llvm-svn: 43084
2007-10-17 20:41:00 +00:00
Devang Patel
b3dac3f5d9 Do not raise free() call that is called through invoke instruction.
llvm-svn: 43083
2007-10-17 20:12:58 +00:00
Steve Naroff
a3f1336e39 rename test file for builtin "id"...
llvm-svn: 43082
2007-10-17 18:39:04 +00:00
Hartmut Kaiser
2f842e613f Fixed linker errors (unresolved externals: split<>(...)) when compiling with VC++. Please review.
llvm-svn: 43081
2007-10-17 18:37:09 +00:00
Ted Kremenek
5c84c01c8b Fixed includes of "clang/AST/DeclObjC.h" to work on case-sensitive
filesystems (was "#include "clang/AST/DeclObjc.h", which worked fine
on a case-insensitive HFS+ volume on the Mac).

llvm-svn: 43080
2007-10-17 18:36:42 +00:00
Chris Lattner
caecf03215 add some comments.
llvm-svn: 43079
2007-10-17 18:28:59 +00:00
Dan Gohman
d0806a0508 Don't mention -enable-unsafe-fp-math in LangRef.html, as that option is
assumed to globally mutate the spec.

llvm-svn: 43078
2007-10-17 18:05:13 +00:00
Steve Naroff
0f7a2d2dd1 Predefine all the ObjC goodies from <objc/objc.h>. Removed all the ObjC goodies from the respective test files. Moving forward, it will be very nice to assume these builtin!
llvm-svn: 43077
2007-10-17 17:53:50 +00:00
Dan Gohman
07159205dd Define a helper function ConstantVector::getSplatValue for testing for
and working with broadcasted constants.

llvm-svn: 43076
2007-10-17 17:51:30 +00:00
Fariborz Jahanian
a32aaefadc Implementation of AST for @protocol expression.
llvm-svn: 43075
2007-10-17 16:58:11 +00:00
Hartmut Kaiser
7078da8e58 Updated VC++ build system.
Silenced some VC++ warnings.
Had to rephrase a partial specialization of the IntrospectionTrait struct in SerializationTest.cpp, please review.
Added a compiler specific workaround in IdentifierTable.h. Is that the way to fix this kind of issues?

llvm-svn: 43074
2007-10-17 15:00:17 +00:00
Hartmut Kaiser
ec8a8d1f51 Updated VC++ build system.
Silenced some VC warnings.

I'm getting linker errors, though: unresolved externals:

llvm::Split<class llvm::BasicBlock *,struct llvm::GraphTraits<class llvm::BasicBlock *> >(class llvm::DominatorTreeBase<class llvm::BasicBlock> &,class llvm::BasicBlock *)

and

llvm::Split<struct llvm::Inverse<class llvm::BasicBlock *>,struct llvm::GraphTraits<struct llvm::Inverse<class llvm::BasicBlock *> > >(class llvm::DominatorTreeBase<class llvm::BasicBlock> &,class llvm::BasicBlock *)

Where are these defined?

llvm-svn: 43073
2007-10-17 14:56:40 +00:00
Dan Gohman
8f518b9875 Add support for ISD::SELECT in SplitVectorOp.
llvm-svn: 43072
2007-10-17 14:48:28 +00:00
Duncan Sands
d42c812f4a Return Expand from getOperationAction for all extended
types.  This is needed for SIGN_EXTEND_INREG at least.
It is not clear if this is correct for other operations.
On the other hand, for the various load/store actions
it seems to correct to return the type action, as is
currently done.
Also, it seems that SelectionDAG::getValueType can be
called for extended value types; introduce a map for
holding these, since we don't really want to extend
the vector to be 2^32 pointers long!
Generalize DAGTypeLegalizer::PromoteResult_TRUNCATE
and DAGTypeLegalizer::PromoteResult_INT_EXTEND to handle
the various funky possibilities that apints introduce,
for example that you can promote to a type that needs
to be expanded.

llvm-svn: 43071
2007-10-17 13:49:58 +00:00
Devang Patel
91ff13edcc Apply "Instead of loading small c string constant, use integer constant directly" transformation while processing load instruction.
llvm-svn: 43070
2007-10-17 07:24:40 +00:00
Evan Cheng
0dde6e5761 Apply Chris' suggestions.
llvm-svn: 43069
2007-10-17 06:53:44 +00:00
Chris Lattner
12d5da49d3 Change fp to sint legalization on x86-32 to do 2 x i32
loads instead of 1 x i64 loads.  This doesn't change any functionality yet.

llvm-svn: 43068
2007-10-17 06:17:29 +00:00
Chris Lattner
253023b25f fix problems with test/sema/Cocoa.m etc on non-apple machines.
llvm-svn: 43067
2007-10-17 06:04:46 +00:00
Chris Lattner
693cbeadff fix some funny indentation, add comments.
llvm-svn: 43066
2007-10-17 06:02:13 +00:00
Evan Cheng
c8b5397000 One more extract_subreg coalescing bug fix.
llvm-svn: 43065
2007-10-17 05:29:37 +00:00
Evan Cheng
5cfc2c640f Update comments.
llvm-svn: 43064
2007-10-17 02:16:40 +00:00
Evan Cheng
7587d1bd19 Yet another test case for extract_subreg coalescing crash.
llvm-svn: 43063
2007-10-17 02:15:06 +00:00
Evan Cheng
9b0a44a2ce Fix MergeValueInAsValue(). It allows overlapping live ranges but should replace
their value numbers with the specified value number.

llvm-svn: 43062
2007-10-17 02:13:29 +00:00
Evan Cheng
a6fd8bc97e Clean up code that calculate MBB live-in's.
llvm-svn: 43061
2007-10-17 02:12:22 +00:00
Evan Cheng
8b8c7c9927 Clean up code that calculate MBB live-in's.
llvm-svn: 43060
2007-10-17 02:10:22 +00:00
Owen Anderson
84490d44ec Move splitBlock into DomTreeBase from DomTree.
llvm-svn: 43059
2007-10-17 02:03:17 +00:00
Anders Carlsson
f94cd1ffe6 Generate code for static variables that don't have initializers. Also, report an error if a static initializer is not constant.
llvm-svn: 43058
2007-10-17 00:52:43 +00:00
Anders Carlsson
86edafc6d6 Fix the build.
llvm-svn: 43057
2007-10-17 00:50:25 +00:00
Devang Patel
8d818f5e80 Use immediate stores.
llvm-svn: 43055
2007-10-16 23:44:18 +00:00
Ted Kremenek
970217fae9 Added Driver/SerializationTest.cpp to the XCode project.
llvm-svn: 43054
2007-10-16 23:40:12 +00:00
Dale Johannesen
e5facd51cb Disable attempts to constant fold PPC f128.
Remove the assumption that this will happen from
various places.

llvm-svn: 43053
2007-10-16 23:38:29 +00:00
Ted Kremenek
4e816133c8 Started work on clang object serialization. Experimental
serialization logic as well as driver code is now in
Driver/SerializationTest.cpp.  The status of this code is that it
should be used by no clients.

Added --test-pickling option to driver to run the serialization code.

Modified IdentifierInfo and IdentifierTable to have friend classes
that permit object serialization.  Such friendship may not be needed
in the final design.

llvm-svn: 43052
2007-10-16 23:37:27 +00:00
Fariborz Jahanian
6bd1d612ac Fix location processing of @selector: the range should include the @ sign.
llvm-svn: 43051
2007-10-16 23:21:02 +00:00
Steve Naroff
077c83bddb Add Sema::CheckMessageArgumentTypes()...
llvm-svn: 43050
2007-10-16 23:12:48 +00:00
Owen Anderson
7bcc28bf6c Fix some formatting.
llvm-svn: 43049
2007-10-16 22:59:15 +00:00
Chris Lattner
37390bed4d Fix location processing of @encode: the range should include the @ sign.
@selector probably gets this wrong also.

llvm-svn: 43048
2007-10-16 22:51:17 +00:00
Chris Lattner
a7c19feca2 Add a new Rewriter::getRangeSize method.
Rename SourceRange::Begin()/End() to getBegin()/getEnd() for
consistency with other code.
Start building the rewriter towards handling @encode.

llvm-svn: 43047
2007-10-16 22:36:42 +00:00
Fariborz Jahanian
ebac2cb235 Patch to diagnose duplicate method implementations.
llvm-svn: 43046
2007-10-16 21:52:23 +00:00
Steve Naroff
d275426449 Remove ObjcMethodDecl::getNumMethodParams/getMethodParamDecl, they aren't used/needed.
Change ObjcMethodDecl::getMethodType to getResultType, to match FunctionDecl.

llvm-svn: 43045
2007-10-16 21:36:54 +00:00
Chris Lattner
5a2fe28aca publish location info
llvm-svn: 43044
2007-10-16 21:21:26 +00:00
Evan Cheng
8f644cef0f Some clean up.
llvm-svn: 43043
2007-10-16 21:09:14 +00:00
Fariborz Jahanian
923aebe09c Steve, pointer out that getName() is available for selectors. Made code much smaller, thanks.
llvm-svn: 43042
2007-10-16 21:07:53 +00:00
Chris Lattner
0bd1c97293 Push the rewriter forward a bit more. Now it rewrites
#import to #include's as a test.

llvm-svn: 43041
2007-10-16 21:07:07 +00:00
Chris Lattner
9a36bb84ea these aren't const.
llvm-svn: 43040
2007-10-16 21:04:49 +00:00
Fariborz Jahanian
81ccd88f0e Fix problem dumping/printing method names with null selector.
llvm-svn: 43039
2007-10-16 20:52:13 +00:00
Fariborz Jahanian
4bef462a3e Patch to implement AST generation for objective-c's @selector expression.
llvm-svn: 43038
2007-10-16 20:40:23 +00:00
Steve Naroff
55f52da24c Emit diagnostics for methods not found.
llvm-svn: 43037
2007-10-16 20:39:36 +00:00
Owen Anderson
4187801f85 Template DominatorTreeBase by node type. This is the next major step towards
having dominator information on MBB's.

llvm-svn: 43036
2007-10-16 19:59:25 +00:00
Evan Cheng
fab7ca89d5 Fix PR1734.
llvm-svn: 43035
2007-10-16 19:29:47 +00:00
Dale Johannesen
e43b960d3b New test for svn rev 43033, radar 5538745.
llvm-svn: 43034
2007-10-16 18:10:14 +00:00
Dale Johannesen
e5530a35d4 Check for invalid cc's in f80 select.
llvm-svn: 43033
2007-10-16 18:09:08 +00:00
Chris Lattner
1366653e2f Fix a bug handling frame references in ppc inline asm when the frame offset
doesn't fit into 16 bits.

llvm-svn: 43032
2007-10-16 18:00:18 +00:00
Duncan Sands
ce042d0bc0 Document the fact that the verifier currently requires the
top bit of a ValueType to be zero.  Enforce this by ensuring
an assertion failure if someone tries to create a ValueType
without this property.  I chose this minimal approach rather
than a more official integration of the notion of reserved
bits into ValueType because I'm hoping that the verifier will
be changed to no longer require this :)

llvm-svn: 43031
2007-10-16 13:34:11 +00:00
Duncan Sands
bbbfbe95f7 Initial infrastructure for arbitrary precision integer
codegen support.  This should have no effect on codegen
for other types.  Debatable bits: (1) the use (abuse?)
of a set in SDNode::getValueTypeList; (2) the length of
getTypeToTransformTo, which maybe should be refactored
with a non-inline part for extended value types.

llvm-svn: 43030
2007-10-16 09:56:48 +00:00
Anton Korobeynikov
002c52ce6e Unbreak mingw32. Maybe there should be something like libClandSystem? :)
llvm-svn: 43029
2007-10-16 09:09:44 +00:00
Duncan Sands
052c843559 Fixes due to lack of type-safety for ValueType: (1) ValueType
being passed instead of an opcode; (2) ValueType being passed
for isVolatile (!) in getLoad.

llvm-svn: 43028
2007-10-16 09:07:20 +00:00
Arnold Schwaighofer
b3d58b98d0 Correction to tail call optimization code. The new return address
was stored to the acutal stack slot before the parameters were
lowered to their stack slot. This could cause arguments to be
overwritten by the return address if the called function had less
parameters than the caller function. The update should remove the
last failing test case of llc-beta: SPASS.

llvm-svn: 43027
2007-10-16 09:05:00 +00:00
Evan Cheng
ecf62cb763 Code clean up.
llvm-svn: 43026
2007-10-16 08:04:24 +00:00
Chris Lattner
cece03dd89 implement promotion of select and select_cc, allowing MallocBench/gs to
work with type promotion on x86.

llvm-svn: 43025
2007-10-16 03:00:22 +00:00
Chris Lattner
e6dcd505d0 initialization of references should not do default fn/array promotions.
This fixes a bug Anders noticed.

llvm-svn: 43024
2007-10-16 02:55:40 +00:00
Steve Naroff
698495522d Bad cast...need to use dyn_cast_or_null. Also changed Sema::InitBuiltinVaListType (which had the same bug).
llvm-svn: 43023
2007-10-16 00:00:18 +00:00
Fariborz Jahanian
76a9427783 Patch to parse @selector expressions.
llvm-svn: 43022
2007-10-15 23:39:13 +00:00
Steve Naroff
f73b784a5e Change the type of ObjCStringLiteral from "struct __builtin_CFString *" to "NSConstantString *".
This makes the typecheck much happier. Without this change, the type checker would have to special case "struct __builtin_CFString *". This change does assume the interface for NSConstantString is declared in the translation unit.

I left ASTContext::getCFConstantStringType() around for now (with a comment that says it is currently unused).

llvm-svn: 43021
2007-10-15 23:35:17 +00:00
Dan Gohman
9aa4fc5cd6 Teach IntrinsicLowering.cpp about the sin, cos, and pow intrinsics.
llvm-svn: 43020
2007-10-15 22:07:31 +00:00
Evan Cheng
04c44712d3 Make CalcLatency() non-recursive.
llvm-svn: 43017
2007-10-15 21:33:22 +00:00
Dan Gohman
a8656d4798 Fix a typo in a comment.
llvm-svn: 43016
2007-10-15 21:10:03 +00:00
Dan Gohman
d4f2165007 Document the -view-sunit-dags option.
llvm-svn: 43015
2007-10-15 21:07:59 +00:00
Steve Naroff
126b4d835f Fix a parser bug with message expressions - need to call ParsePostfixExpressionSuffix().
Now were correctly allow the following...

    i = [str rangeOfString:@"]"].length;

llvm-svn: 43012
2007-10-15 20:55:58 +00:00
Steve Naroff
32e44c0032 Move type compatibility predicates from Type to ASTContext. In addition, the predicates are now instance methods (they were previously static class methods on Type).
This allowed me to fix the following hack from this weekend...

// FIXME: Devise a way to do this without using strcmp.
// Would like to say..."return getAsStructureType() == IdStructType;", but
// we don't have a pointer to ASTContext.
bool Type::isObjcIdType() const {
  if (const RecordType *RT = getAsStructureType())
    return !strcmp(RT->getDecl()->getName(), "objc_object");
  return false;
}

...which is now...

bool isObjcIdType(QualType T) const {
  return T->getAsStructureType() == IdStructType;
}

Side notes:

- I had to remove a convenience function from the TypesCompatibleExpr class.

int typesAreCompatible() const {return Type::typesAreCompatible(Type1,Type2);}

Which required a couple clients get a little more verbose...

-    Result = TCE->typesAreCompatible();
+    Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2());

Overall, I think this change also makes sense for a couple reasons...

1) Since ASTContext vends types, it makes sense for the type compatibility API to be there.
2) This allows the type compatibility predeciates to refer to data not strictly present in the AST (which I have found problematic on several occasions).

llvm-svn: 43009
2007-10-15 20:41:53 +00:00
Dan Gohman
b6324c1243 Document the new llvm.sin, llvm.cos, and llvm.pow intrinsics. Feedback
is welcome!

llvm-svn: 43007
2007-10-15 20:30:11 +00:00
Anders Carlsson
7e13ab88a2 Add code generation and sema checking for __builtin_va_arg.
llvm-svn: 43006
2007-10-15 20:28:48 +00:00
Chris Lattner
06a4954e6e Change LowerFP_TO_SINT to create the specific code it needs instead of
unconditionally creating an i64 bitcast.  With the future legalizer
design, operation legalization can't introduce new nodes with illegal
types.

This fixes the rest of olden on ppc32.

llvm-svn: 43005
2007-10-15 20:14:52 +00:00
Evan Cheng
7bcfd8f880 LowerFP_TO_SINT must not create a stack object if it's not needed.
llvm-svn: 43004
2007-10-15 20:11:21 +00:00
Devang Patel
324fe8904f Add removeModuleProvider()
llvm-svn: 43002
2007-10-15 19:56:32 +00:00
Dan Gohman
e862243e1c Reapply the fix in 42908 for this file. This changes the function names
from "test" to "foo" so that they don't match the grep -i ST.

llvm-svn: 43001
2007-10-15 19:22:17 +00:00
Fariborz Jahanian
d4b3015dd7 Several name lookup conflict detection fixes involving objective-c names.
llvm-svn: 43000
2007-10-15 19:16:57 +00:00
Ted Kremenek
7bbc582bb3 Fixed incorrect renaming of method name (forgot two characters).
llvm-svn: 42999
2007-10-15 19:15:48 +00:00
Ted Kremenek
fcce4f378f Added more doxygen comments.
Renamed internal method of ImutAVLTree::RemoveMutableFlag to MarkImmutable.
Added enum for bit manipulation (more self-documentating).

llvm-svn: 42998
2007-10-15 18:52:34 +00:00
Evan Cheng
a5abba65b6 Fix PR1729: watch out for val# with no def.
llvm-svn: 42996
2007-10-15 18:33:50 +00:00
Chris Lattner
d6f7d44eae Move CreateStackTemporary out to SelectionDAG
llvm-svn: 42995
2007-10-15 17:48:57 +00:00
Chris Lattner
9eb7a829e6 add a new CreateStackTemporary helper method.
llvm-svn: 42994
2007-10-15 17:47:20 +00:00
Chris Lattner
9d5b131e70 implement promotion of BR_CC operands, fixing bisort on ppc.
llvm-svn: 42992
2007-10-15 17:16:12 +00:00
Chris Lattner
8555e69def updates from duncan
llvm-svn: 42991
2007-10-15 16:46:29 +00:00
Tanya Lattner
9486b19066 Fix run line.
llvm-svn: 42990
2007-10-15 16:35:13 +00:00
Devang Patel
80b1222274 New test.
llvm-svn: 42986
2007-10-15 15:41:07 +00:00
Devang Patel
bff4aea328 Achieve same result but use fewer lines of code.
llvm-svn: 42985
2007-10-15 15:31:35 +00:00
Neil Booth
9130551996 Fast-track obviously over-large and over-small exponents during decimal->
integer conversion.  In some such cases this makes us one or two orders
of magnitude faster than NetBSD's libc.  Glibc seems to have a similar
fast path.

Also, tighten up some upper bounds to save a bit of memory.

llvm-svn: 42984
2007-10-15 15:00:55 +00:00
Steve Naroff
66e9f331ba Added ASTContext::setObjcIdType/getObjcIdType(), set by Sema.
Also noticed ASTContext::BuiltinVaListType wasn't being initialized to the null type (so I set it).

llvm-svn: 42983
2007-10-15 14:41:52 +00:00
Duncan Sands
f6977d9842 Fix some typos. Call getTypeToTransformTo rather than
getTypeToExpandTo.  The difference is that
getTypeToExpandTo gives the final result of expansion
(eg: i128 -> i32 on a 32 bit machine) while
getTypeToTransformTo does just one step (i128 -> i64).

llvm-svn: 42982
2007-10-15 13:30:18 +00:00
Chris Lattner
3cfb56d489 One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.

One more significant change:  Implement the start of a legalizer that
just works on types.  This legalizer is designed to run before the 
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.

This design/impl has the following advantages:

1. When finished, this will *significantly* reduce the amount of code in
   LegalizeDAG.cpp.  It will remove all the code related to promotion and
   expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike 
   LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
   for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of 
   deallocating and reallocating the entire graph that points to some 
   mutated node.
5. The code nicely separates out handling of operations with invalid 
   results from operations with invalid operands, making some cases
   simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :), 
   allowing you to easily understand what legalize types is doing.

This is not yet done.  Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing.  However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine.  The
biggest issues are:

1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.

Hey, at least it is a step in the right direction :).  If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it.  If
this explodes it will tell you what needs to be implemented.  Help is 
certainly appreciated.

Once this goes in, we can do three things:

1. Add a new pass of dag combine between the "type legalizer" and "operation
   legalizer" passes.  This will let us catch some long-standing isel issues
   that we miss because operation legalization often obfuscates the dag with
   target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
   making it much smaller and simpler.  When that happens we can then 
   reimplement the core functionality left in it in a much more efficient and
   non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
   selectiondags maybe...

llvm-svn: 42981
2007-10-15 06:10:22 +00:00
Chris Lattner
b193517eed One xform performed by LegalizeDAG is transformation of "store of fp" to "store of int".
Make two changes:
1) only xform "store of f32" if i32 is a legal type for the target.
2) only xform "store of f64" if either i64 or i32 are legal for the target.
3) if i64 isn't legal, manually lower to 2 stores of i32 instead of letting a
   later pass of legalize do it.  This is ugly, but helps future changes I'm 
   about to commit.

llvm-svn: 42980
2007-10-15 05:46:06 +00:00
Chris Lattner
2b827fd70d avoid an APFloat copy.
llvm-svn: 42979
2007-10-15 05:34:10 +00:00
Chris Lattner
90e0b271df Add a (disabled by default) way to view the ID of a node.
llvm-svn: 42978
2007-10-15 05:32:43 +00:00
Chris Lattner
bfdebe33a0 remove dead enum, make setNodeId public.
llvm-svn: 42977
2007-10-15 05:30:55 +00:00
Chris Lattner
a2ebb9aadd Fix 80 col violation
llvm-svn: 42976
2007-10-15 05:30:27 +00:00
Steve Naroff
271643620b Teach the type checker about "id". This removes the following bogus warning...
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.m
t.m:29:18: warning: incompatible pointer types assigning 'id' to 'NSString *'
    resultString = [[NSString alloc] initWithFormat:0 arguments:0];
    ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

llvm-svn: 42975
2007-10-15 03:14:16 +00:00
Anders Carlsson
cbfc4b8824 Add support for Pascal strings.
llvm-svn: 42974
2007-10-15 02:50:23 +00:00
Anders Carlsson
b30f47a869 Fix a warning
llvm-svn: 42973
2007-10-15 02:50:04 +00:00
Dale Johannesen
207bd4d90e Handle PPC long double in CBackend.
llvm-svn: 42972
2007-10-15 01:05:37 +00:00
Steve Naroff
5d15254496 - Teach ObjcInterfaceDecl::lookupInstance/ClassMethod to look through protocols.
- Start looking up methods in the global method pools (for "id").
- Start integrating interface types into the type system.

llvm-svn: 42971
2007-10-14 23:13:51 +00:00
Chris Lattner
fbbe570994 remove misleading comment.
llvm-svn: 42970
2007-10-14 20:35:12 +00:00
Chris Lattner
ebe491ea9c If a target doesn't have HasMULHU or HasUMUL_LOHI, ExpandOp would return
without lo/hi set.  Fall through to making a libcall instead.

llvm-svn: 42969
2007-10-14 18:35:05 +00:00
Steve Naroff
ca0ecfe048 Add category lookup (removing a couple FIXME's).
Changed ObjcInterfaceDecl::ListCategories->CategoryList.

llvm-svn: 42968
2007-10-14 18:27:41 +00:00
Steve Naroff
e7ed06e6fc Fix -ast-dump for ObjC.
llvm-svn: 42967
2007-10-14 17:03:01 +00:00
Neil Booth
5fe658b21d Consolidate logic for creating NaNs. Silence compiler warning.
llvm-svn: 42966
2007-10-14 10:39:51 +00:00
Neil Booth
06077e7c3c Whether arithmetic is supported is a property of the semantics. Make it
so, and clean up the checks by putting them in an inline function.

llvm-svn: 42965
2007-10-14 10:29:28 +00:00
Neil Booth
4ed401b898 Separate out parsing of decimal number. Use this to only allocate
memory for the significand once up-front.  Also ignore insignificant
trailing zeroes; this saves unnecessary multiplications later.

llvm-svn: 42964
2007-10-14 10:16:12 +00:00
Evan Cheng
d8771e915c New test case.
llvm-svn: 42963
2007-10-14 10:15:03 +00:00
Evan Cheng
4099f4f91a Unbreak x86-64.
llvm-svn: 42962
2007-10-14 10:09:39 +00:00
Evan Cheng
8d6da9142c When coalescing an EXTRACT_SUBREG and the dst register is a physical register,
the source register will be coalesced to the super register of the LHS. Properly
merge in the live ranges of the resulting coalesced interval that were part of
the original source interval to the live interval of the super-register.

llvm-svn: 42961
2007-10-14 10:08:34 +00:00
Evan Cheng
cdf3609130 Revert 42908 for now.
llvm-svn: 42960
2007-10-14 05:57:21 +00:00
Dale Johannesen
2f6b6d6fb0 Fix type mismatch error in PPC Altivec (only causes
a problem when asserts are on).  From vecLib.

llvm-svn: 42959
2007-10-14 01:58:32 +00:00
Dale Johannesen
19db093b35 Disable some compile-time optimizations on PPC
long double.

llvm-svn: 42958
2007-10-14 01:56:47 +00:00
Steve Naroff
5811baf1a0 - Added Sema::AddFactoryMethodToGlobalPool and Sema::AddInstanceMethodToGlobalPool and DenseMaps. This will allow us to efficiently lookup a method from a selector given no type information (for the "id" data type).
- Fixed some funky "}
                    else {" indentation in Sema::ActOnAddMethodsToObjcDecl(). I'd prefer we stay away from this style...it wastes space and isn't any easier to read (from my perspective, at least:-)

- Changed Parser::ParseObjCInterfaceDeclList() to only call Action::ActOnAddMethodsToObjcDecl() when it actually has methods to add (since most interface have methods, this is a very minor cleanup).

llvm-svn: 42957
2007-10-14 00:58:41 +00:00
Gordon Henriksen
a699c4dc65 Fixing a typo. Found by Kevin André!
llvm-svn: 42956
2007-10-14 00:34:53 +00:00
Duncan Sands
29af26f147 Clarify that fastcc has a problem with nested function
trampolines, rather than with nested functions themselves.

llvm-svn: 42955
2007-10-13 07:38:37 +00:00
Chris Lattner
f47e30627a Enhance the truncstore optimization code to handle shifted
values and propagate demanded bits through them in simple cases.

This allows this code:
void foo(char *P) {
   strcpy(P, "abc");
}
to compile to:

_foo:
        ldrb r3, [r1]
        ldrb r2, [r1, #+1]
        ldrb r12, [r1, #+2]!
        ldrb r1, [r1, #+1]
        strb r1, [r0, #+3]
        strb r2, [r0, #+1]
        strb r12, [r0, #+2]
        strb r3, [r0]
        bx lr

instead of:

_foo:
        ldrb r3, [r1, #+3]
        ldrb r2, [r1, #+2]
        orr r3, r2, r3, lsl #8
        ldrb r2, [r1, #+1]
        ldrb r1, [r1]
        orr r2, r1, r2, lsl #8
        orr r3, r2, r3, lsl #16
        strb r3, [r0]
        mov r2, r3, lsr #24
        strb r2, [r0, #+3]
        mov r2, r3, lsr #16
        strb r2, [r0, #+2]
        mov r3, r3, lsr #8
        strb r3, [r0, #+1]
        bx lr

testcase here: test/CodeGen/ARM/truncstore-dag-combine.ll

This also helps occasionally for X86 and other cases not involving 
unaligned load/stores.

llvm-svn: 42954
2007-10-13 06:58:48 +00:00
Chris Lattner
2ce649ebea new testcase
llvm-svn: 42953
2007-10-13 06:56:18 +00:00
Chris Lattner
5e6fe054a2 Add a simple optimization to simplify the input to
truncate and truncstore instructions, based on the 
knowledge that they don't demand the top bits.

llvm-svn: 42952
2007-10-13 06:35:54 +00:00
Anders Carlsson
d5f857f2e5 Fix an incorrect assertion.
llvm-svn: 42951
2007-10-13 05:52:34 +00:00
Neil Booth
c799fe9ed9 If the power of 5 is exact, and the reciprocal exact, the error is zero not one half-ulps. This prevents an infinite loop in rare cases.
llvm-svn: 42950
2007-10-13 03:34:08 +00:00
Evan Cheng
f86204baf4 Fix test case.
llvm-svn: 42949
2007-10-13 03:14:06 +00:00
Evan Cheng
54bec86754 New tests.
llvm-svn: 42948
2007-10-13 03:10:54 +00:00
Evan Cheng
b63076504e Local spiller optimization:
Turn this:
movswl  %ax, %eax
movl    %eax, -36(%ebp)
xorl    %edi, -36(%ebp)
into
movswl  %ax, %eax
xorl    %edi, %eax
movl    %eax, -36(%ebp)
by unfolding the load / store xorl into an xorl and a store when we know the
value in the spill slot is available in a register. This doesn't change the
number of instructions but reduce the number of times memory is accessed.

Also unfold some load folding instructions and reuse the value when similar
situation presents itself.

llvm-svn: 42947
2007-10-13 02:50:24 +00:00
Evan Cheng
7082dcf605 Change unfoldMemoryOperand(). User is now responsible for passing in the
register used by the unfolded instructions. User can also specify whether to
unfold the load, the store, or both.

llvm-svn: 42946
2007-10-13 02:35:06 +00:00
Evan Cheng
9490e0d078 Optionally create a MachineInstr without default implicit operands.
llvm-svn: 42945
2007-10-13 02:23:01 +00:00
Chris Lattner
6a91cc03ad haha, my devious plot is complete:
$ clang rewrite.c -rewrite-test
prints:

int foo() {
        b:      foo();
f:      foo();
    foo();
}

for:

int foo() {
	b:	foo();
f:	foo();
    foo();
}

amazing.

llvm-svn: 42944
2007-10-13 00:46:29 +00:00
Anders Carlsson
a7408e742a Add __builtin_va_list definitions for x86_64 and ppc64.
llvm-svn: 42943
2007-10-13 00:45:48 +00:00
Chris Lattner
2a8ab05f5f With this I can now insert stuff before tabs, woo.
llvm-svn: 42942
2007-10-13 00:21:23 +00:00
Chris Lattner
58bad341bc Woo, tab deletion now works. Next lets see if we can
insert stuff.

llvm-svn: 42941
2007-10-13 00:17:04 +00:00
Chris Lattner
2fcf1b83c1 another step forward in rewriter stuff. This still has
some incredibly subtle details that I'm working on getting
right.

llvm-svn: 42940
2007-10-13 00:11:23 +00:00
Anders Carlsson
24ebce6fca Generate code for va_start and va_end.
llvm-svn: 42939
2007-10-12 23:56:29 +00:00
Fariborz Jahanian
fd0312ed79 Patch to check for duplicate method decls in protocols.
llvm-svn: 42938
2007-10-12 23:43:31 +00:00
Chris Lattner
bee82b0675 remove dead method with bogus comment.
llvm-svn: 42937
2007-10-12 23:18:19 +00:00
Fariborz Jahanian
ecfe4f1453 Check and diagnose that objective-c objects may not be statically allocated.
llvm-svn: 42936
2007-10-12 22:10:42 +00:00
Arnold Schwaighofer
e8d0bf2669 Correcting the corrections. Bad bad baaad emacs!
llvm-svn: 42935
2007-10-12 21:53:12 +00:00
Arnold Schwaighofer
1f0da1fefb Corrected many typing errors. And removed 'nest' parameter handling
for fastcc from X86CallingConv.td.  This means that nested functions
are not supported for calling convention 'fastcc'.

llvm-svn: 42934
2007-10-12 21:30:57 +00:00
Ted Kremenek
41362cea7b Added notion of '*' specified format width/specifiers when checking
printf format strings.  Added type checking to see if the matching
width/precision argument was of type 'int'.

Thanks to Anders Carlsson for reporting this missing feature.

llvm-svn: 42933
2007-10-12 20:51:52 +00:00
Dan Gohman
e0ad9ea7cd Fix this test to not depend on the assembly output containing something
that includes the string "st". This probably fixes the regression on
Darwin.

llvm-svn: 42932
2007-10-12 20:42:14 +00:00
Chris Lattner
2c06f7ea45 add a new SM::getDecomposedFileLoc method.
llvm-svn: 42931
2007-10-12 20:24:19 +00:00
Devang Patel
371e6ca690 Dest type is always i8 *. This allows some simplification.
Do not filter memmove.

llvm-svn: 42930
2007-10-12 20:10:21 +00:00
Devang Patel
da53e9c9c1 t
llvm-svn: 42929
2007-10-12 20:04:24 +00:00
Fariborz Jahanian
02fbb68e85 Fixed typo in comment.
llvm-svn: 42928
2007-10-12 19:53:08 +00:00
Gordon Henriksen
3fb03e4080 Fix ocaml bindings for picky linkers. :)
Thanks to Török Edvin for helping to track this down.

llvm-svn: 42927
2007-10-12 19:48:13 +00:00
Fariborz Jahanian
c7afeebb12 Fixed a @compatible_alias bug. In the process, discovered unnecessary 2ndry lookup
ok class names and streamlined this logic to do the lookup once.

llvm-svn: 42926
2007-10-12 19:38:20 +00:00
Duncan Sands
a6286bd502 Due to the new tail call optimization, trampolines can no
longer be created for fastcc functions.

llvm-svn: 42925
2007-10-12 19:37:31 +00:00
Dale Johannesen
61c574fc51 ppc long double. Implement fabs and fneg.
llvm-svn: 42924
2007-10-12 19:02:17 +00:00
Steve Naroff
b915146a5d Replace one FIXME with another. We handle protocols just fine now. The ObjC decl will only be 0 when we have an error on the ObjC decl. I would prefer we pass in a decl that is marked as invalid. I don't think this is critical to fix now, however I'd like us to be consistent. There are currently many places that don't mark the decl as invalid (which need to be fixed)...
llvm-svn: 42923
2007-10-12 18:49:25 +00:00
Evan Cheng
409fa443fc Update.
llvm-svn: 42922
2007-10-12 18:22:55 +00:00
Chris Lattner
e6f1c3813d don't use intptr_t without including it.
llvm-svn: 42921
2007-10-12 18:16:23 +00:00
Chris Lattner
ad618f66e6 Fix a bug in my patch last night that broke InstCombine/2007-10-12-Crash.ll
llvm-svn: 42920
2007-10-12 18:05:47 +00:00
Dale Johannesen
a1a4a9ebfa Implement i64->ppcf128 conversions.
llvm-svn: 42919
2007-10-12 17:52:03 +00:00
Chris Lattner
4c461477bd Make this compute the correct offset, handling alignment of the element
pointer correctly.

llvm-svn: 42918
2007-10-12 17:49:52 +00:00
Anders Carlsson
431ef632cb Add some more diagnostics for va_start, fix tests so they pass with these new diags.
llvm-svn: 42917
2007-10-12 17:48:41 +00:00
Evan Cheng
1410b8512c Did mean to leave this in. INSERT_SUBREG isn't being coalesced yet.
llvm-svn: 42916
2007-10-12 17:16:50 +00:00
Fariborz Jahanian
d52cd41630 Fixed a bug whereby, struct tag name matches a typedef/objc-class name
and hid them.

llvm-svn: 42915
2007-10-12 16:34:10 +00:00
Steve Naroff
b213da2a70 Temporary fix to test case. This area is currently under construction...test case will be changing again soon.
llvm-svn: 42914
2007-10-12 16:15:17 +00:00
Neil Booth
d502a82092 Remove duplicate comment.
llvm-svn: 42913
2007-10-12 16:05:57 +00:00
Neil Booth
b93d90e98c Implement correctly-rounded decimal->binary conversion, i.e. conversion
from user input strings.

Such conversions are more intricate and subtle than they may appear;
it is unlikely I have got it completely right first time.  I would
appreciate being informed of any bugs and incorrect roundings you
might discover.

llvm-svn: 42912
2007-10-12 16:02:31 +00:00
Neil Booth
e9dbe094aa Remove a field that was never used.
llvm-svn: 42911
2007-10-12 15:35:10 +00:00
Neil Booth
146fdb3eeb If we're trying to be arbitrary precision, unsigned char clearly won't cut it. Needed for dec->bin conversions.
llvm-svn: 42910
2007-10-12 15:33:27 +00:00
Neil Booth
7e74b17ad2 Don't attempt to mask no bits
llvm-svn: 42909
2007-10-12 15:31:31 +00:00
Dan Gohman
dc35bd79ca Change the names used for internal labels to use the current
function symbol name instead of a codegen-assigned function
number.

Thanks Evan! :-)

llvm-svn: 42908
2007-10-12 14:53:36 +00:00
Dan Gohman
e3583817ac Fix some corner cases with vectors in copyToRegs and copyFromRegs.
llvm-svn: 42907
2007-10-12 14:33:11 +00:00
Dan Gohman
4f056f3c10 Add support to SplitVectorOp for powi, where the second operand
is a scalar integer.

llvm-svn: 42906
2007-10-12 14:13:46 +00:00
Dan Gohman
8d978da3b0 Mark vector ctpop, cttz, and ctlz as Expand on x86.
llvm-svn: 42905
2007-10-12 14:09:42 +00:00
Dan Gohman
9013eaff9a Mark vector pow, ctpop, cttz, and ctlz as Expand on PowerPC.
llvm-svn: 42904
2007-10-12 14:08:57 +00:00
Evan Cheng
11330f7526 Restrict EXTRACT_SUBREG coalescing to avoid negative performance impact.
llvm-svn: 42903
2007-10-12 09:15:53 +00:00
Evan Cheng
f8e28b152a Doh.
llvm-svn: 42901
2007-10-12 09:10:27 +00:00
Evan Cheng
b83a379f4f EXTRACT_SUBREG test case.
llvm-svn: 42900
2007-10-12 09:03:31 +00:00
Evan Cheng
aa2d6ef81d EXTRACT_SUBREG coalescing support. The coalescer now treats EXTRACT_SUBREG like
(almost) a register copy. However, it always coalesced to the register of the
RHS (the super-register). All uses of the result of a EXTRACT_SUBREG are sub-
register uses which adds subtle complications to load folding, spiller rewrite,
etc.

llvm-svn: 42899
2007-10-12 08:50:34 +00:00
Evan Cheng
89d5916921 Some clean up.
llvm-svn: 42898
2007-10-12 08:45:27 +00:00
Evan Cheng
6fd54fd19c Cosmetic.
llvm-svn: 42897
2007-10-12 08:40:44 +00:00
Evan Cheng
2e3d609da6 Fix typos.
llvm-svn: 42896
2007-10-12 08:39:02 +00:00
Evan Cheng
09c0fe0a7f Fold load / store into MOV32to32_ and MOV16to16_.
llvm-svn: 42895
2007-10-12 08:38:01 +00:00
Evan Cheng
f8c23f074b Flag MOV32to32_ with EXTRACT_SUBREG. They should not be scheduled apart.
llvm-svn: 42894
2007-10-12 07:55:53 +00:00
Arnold Schwaighofer
9653e677d5 Added missing -march=x86 flag.
llvm-svn: 42893
2007-10-12 07:49:48 +00:00
Gabor Greif
5d8f7e0cc7 eliminate warning
llvm-svn: 42892
2007-10-12 07:44:54 +00:00
Chris Lattner
d8675e4915 Fix some 80 column violations.
Fix DecomposeSimpleLinearExpr to handle simple constants better.
Don't nuke gep(bitcast(allocation)) if the bitcast(allocation) will
fold the allocation.  This fixes PR1728 and Instcombine/malloc3.ll

llvm-svn: 42891
2007-10-12 05:30:59 +00:00
Chris Lattner
3e99eb25ee testcase for PR1728
llvm-svn: 42890
2007-10-12 05:29:53 +00:00
Chris Lattner
7119397fa1 make operator== work with non-equal sized bitvectors, as long as
the extra bits are all zeros.  This allows  "010" and "010000" to be
treated as equal.

llvm-svn: 42889
2007-10-12 03:48:59 +00:00
Dale Johannesen
05ff9e8cda PPC long double. Implement a couple more conversions.
llvm-svn: 42888
2007-10-12 01:37:08 +00:00
Chris Lattner
3ec1bad331 add comments.
llvm-svn: 42887
2007-10-12 00:37:26 +00:00
Ted Kremenek
6a6c08c319 Printf argument checking now supports dynamically-passed precision
specifiers.

llvm-svn: 42886
2007-10-12 00:11:27 +00:00
Dan Gohman
be37007e64 Add intrinsics for sin, cos, and pow. These use llvm_anyfloat_ty, and so
may be overloaded with vector types. And add a testcase for codegen for
these.

llvm-svn: 42885
2007-10-12 00:01:22 +00:00
Dan Gohman
2a7de41682 Codegen support for vector intrinsics.
Factor out the code that expands the "nasty scalar code" for unrolling
vectors into a separate routine, teach it how to handle mixed
vector/scalar operands, as seen in powi, and use it for several operators,
including sin, cos, powi, and pow.

Add support in SplitVectorOp for fpow, fpowi and for several unary
operators.

llvm-svn: 42884
2007-10-11 23:57:53 +00:00
Fariborz Jahanian
49c6425ee6 This patch implementa objective-c's @compatibilty-alias declaration.
llvm-svn: 42883
2007-10-11 23:42:27 +00:00
Dale Johannesen
6472eb63c2 Implement ppc long double->uint conversion.
Make ppc long double constants print.

llvm-svn: 42882
2007-10-11 23:32:15 +00:00
Dan Gohman
482732af9d Set ISD::FPOW to Expand.
llvm-svn: 42881
2007-10-11 23:21:31 +00:00
Dan Gohman
fd66486950 Add runtime library names for pow.
llvm-svn: 42880
2007-10-11 23:09:10 +00:00
Dan Gohman
daee002438 Add an ISD::FPOW node type.
llvm-svn: 42879
2007-10-11 23:06:37 +00:00
Dan Gohman
3554448947 Add an explicit target triple to make this test behave as expected on
non-Apple hosts. And use the count script instead of wc + grep.

llvm-svn: 42878
2007-10-11 23:04:36 +00:00
Ted Kremenek
3b74526054 Provided accessors to internal allocator for ImutAVLTree and ImmutableSet.
Added postfix ++,-- support for ImmutableSet::iterator.

llvm-svn: 42877
2007-10-11 21:51:04 +00:00
Dale Johannesen
62f65edc32 Add missing argument to PALIGNR
llvm-svn: 42874
2007-10-11 20:58:37 +00:00
Gabor Greif
cb6832efe0 Fix an assertion abort on sparc. malloc(0) is allowed to
return NULL.

llvm-svn: 42871
2007-10-11 19:40:35 +00:00
Arnold Schwaighofer
9ccea99165 Added tail call optimization to the x86 back end. It can be
enabled by passing -tailcallopt to llc.  The optimization is
performed if the following conditions are satisfied:
* caller/callee are fastcc
* elf/pic is disabled OR
  elf/pic enabled + callee is in module + callee has
  visibility protected or hidden

llvm-svn: 42870
2007-10-11 19:40:01 +00:00
Arnold Schwaighofer
29cfef59ff Adding myself
llvm-svn: 42869
2007-10-11 18:54:49 +00:00
Chris Lattner
16a0de468f Push the rewriting APIs along. Build a trivial client that replaces tabs
with x's for now.  The APIs are all unimplemented, so it doesn't do 
anything yet! :)

llvm-svn: 42868
2007-10-11 18:38:32 +00:00
Fariborz Jahanian
d797113659 Implemented parsing of objctive-c protocol conforming type used in
an identifier statement. Fixed up pretty priting to print this type 
correctly.

llvm-svn: 42866
2007-10-11 18:08:47 +00:00
Dale Johannesen
007aa378ad Next PPC long double bits. First cut at constants.
No compile-time support for constant operations yet,
just format transformations.  Make readers and
writers work.  Split constants into 2 doubles in
Legalize.

llvm-svn: 42865
2007-10-11 18:07:22 +00:00
Devang Patel
899cc56612 Lower memcpy if it makes sense.
llvm-svn: 42864
2007-10-11 17:21:57 +00:00
Chris Lattner
168d63b289 add RewriterTest.cpp to xcode project.
llvm-svn: 42863
2007-10-11 16:34:20 +00:00
Chris Lattner
e9ab4ca686 clarify
llvm-svn: 42862
2007-10-11 16:06:02 +00:00
Chris Lattner
bbd5530754 make bitvector &= do the right thing if vectors have mismatched length.
llvm-svn: 42860
2007-10-11 06:12:33 +00:00
Chris Lattner
fc668d1233 Add a new use_iterator::atEnd() method, which allows us to shrink
pred_iterator down to a single ivar.

llvm-svn: 42859
2007-10-11 04:18:11 +00:00
Chris Lattner
f709a1495d slightly simplify interface
llvm-svn: 42858
2007-10-11 03:36:41 +00:00
Anders Carlsson
87c149bf51 Add __builtin_va_start to the list of builtins, make __builtin_va_list available to builtin functions.
llvm-svn: 42857
2007-10-11 01:00:40 +00:00
Fariborz Jahanian
70e8f1024a Patch to create protocol conforming class types.
llvm-svn: 42856
2007-10-11 00:55:41 +00:00
Chris Lattner
e99c8329af add scafolding to play around with and bring up the code rewriter.
llvm-svn: 42855
2007-10-11 00:43:27 +00:00
Chris Lattner
5039ac74c7 update argument.
llvm-svn: 42854
2007-10-11 00:38:03 +00:00
Chris Lattner
3472aeedfd rename -parse-ast-view to -ast-view
llvm-svn: 42853
2007-10-11 00:37:43 +00:00
Chris Lattner
5e4c75f4ef rename -parse-ast-print to -ast-print
rename -parse-ast-dump to -ast-dump
remove -parse-ast, which is redundant with -fsyntax-only

llvm-svn: 42852
2007-10-11 00:18:28 +00:00
Ted Kremenek
41eee516d7 Added iterators to ImmutableSet.
llvm-svn: 42851
2007-10-11 00:14:49 +00:00
Ted Kremenek
6a97cf6d65 Added some doxygen comments to ImmutableSet.
llvm-svn: 42850
2007-10-10 23:47:03 +00:00
Chris Lattner
9c7a0361c0 Fix 80 col violations.
llvm-svn: 42849
2007-10-10 23:42:28 +00:00
Ted Kremenek
abd77cccb8 Removed uninformative assertions that catch problems that will
fire anyway at runtime due to a NULL dereference.

llvm-svn: 42848
2007-10-10 23:35:04 +00:00
Ted Kremenek
4d984579da Removed "height" of an AVL tree node from its Profile. This is
implicitly captured by using the addresses of its children in the
profile.

llvm-svn: 42847
2007-10-10 23:32:01 +00:00
Chris Lattner
7b4ab65c7d fix a bunch of regressions I introduced :(
llvm-svn: 42846
2007-10-10 23:31:03 +00:00
Steve Naroff
783a7a0698 Refinements to Sema::GetObjcIdType()...
- Cache the typedef, not the type (avoids importing AST/Type.h).
- Emit an error if "id" cannot be found.
- Comment the routine and add a FIXME to reconsider how we emulate GCC's new fangled behavior. This isn't a priority for now, since almost no code depends on having "id" built-in.
- Add a test.

llvm-svn: 42845
2007-10-10 23:24:43 +00:00
Ted Kremenek
a1cf09f51d Commented out header with no section body. Will write this eventually.
llvm-svn: 42844
2007-10-10 23:22:00 +00:00
Ted Kremenek
035b0cd34a Added some documentation on clang CFGs. It is very rough.
llvm-svn: 42843
2007-10-10 23:01:43 +00:00
Steve Naroff
7f549f1897 - Make sure default return/argument types (for methods) default to "id".
- Cache the "id" type in Sema...initialize ObjcIdType and TUScope (oops).
- Fix ActOnInstanceMessage to allow for "id" type receivers...still work to do (next).

llvm-svn: 42842
2007-10-10 21:53:07 +00:00
Chris Lattner
d2b8ce4259 avoid accessing off the end of identifiers.
llvm-svn: 42841
2007-10-10 20:59:57 +00:00
Anders Carlsson
db83d77c78 Emit a warning when the body of an if block is a NullStmt.
llvm-svn: 42840
2007-10-10 20:50:11 +00:00
Ted Kremenek
4479f86c0f Removed spurious forward declaration to a structure that will no longer be used.
llvm-svn: 42839
2007-10-10 20:45:34 +00:00
Chris Lattner
3ff2e69713 clang -E should not print tokens from the predefines buffer.
llvm-svn: 42838
2007-10-10 20:45:16 +00:00
Ted Kremenek
45f3bb8239 Added some doxygen comments to a few methods of ImutAVLTree.
llvm-svn: 42837
2007-10-10 20:44:21 +00:00
Hartmut Kaiser
3fa191b6b2 Updated VC++ build system.
llvm-svn: 42836
2007-10-10 19:50:45 +00:00
Hartmut Kaiser
04bd66bd43 Updated VC++ build system.
llvm-svn: 42835
2007-10-10 19:50:09 +00:00
Ted Kremenek
9e9dae0b57 Added idea for a simple C++ checker.
llvm-svn: 42834
2007-10-10 18:52:22 +00:00
Ted Kremenek
6c5107ced1 Added preliminary support for iterators in ImutAVLTree.
Implemented ImutAVLTree::isEqual.

llvm-svn: 42833
2007-10-10 18:11:16 +00:00
Chris Lattner
d9c9c919da Fix CodeGen/Generic/BasicInstrs.llx on sparc by marking divrem
illegal.  Thanks to gabor for pointing this out!

llvm-svn: 42832
2007-10-10 18:10:57 +00:00
Chris Lattner
a9839f73fb add an idea
llvm-svn: 42831
2007-10-10 18:08:07 +00:00
Chris Lattner
ed2a9eb820 resolve a fixme, by moving __builtin_va_list to a more logical
place and making it correctly parameterized on the target.

llvm-svn: 42830
2007-10-10 17:48:53 +00:00
Steve Naroff
8308f60d51 Fix a latent bug in MinimalActions (created by a recent name change).
llvm-svn: 42829
2007-10-10 17:45:44 +00:00
Steve Naroff
93eb5f1438 Remove Scope argument from ObjC actions that either don't need it or can now use TUScope.
Also improve a recently added comment.

llvm-svn: 42826
2007-10-10 17:32:04 +00:00
Ted Kremenek
0818f6e7e4 Renamed internal method "Create" of ImutAVLTree to "CreateNode".
llvm-svn: 42825
2007-10-10 16:27:33 +00:00
Duncan Sands
56ab90d3ad Correct swapped arguments to getConstant.
llvm-svn: 42824
2007-10-10 09:54:50 +00:00
Bill Wendling
f7c7ed2740 Fix 80-column violations
llvm-svn: 42823
2007-10-10 05:45:59 +00:00
Dale Johannesen
666323eacd Next PPC long double bits: ppcf128->i32 conversion.
Surprisingly complicated.
Adds getTargetNode for 2 outputs, no inputs (missing).

llvm-svn: 42822
2007-10-10 01:01:31 +00:00
Evan Cheng
a9830a04eb Bad choice of variable name.
llvm-svn: 42821
2007-10-10 00:11:40 +00:00
Evan Cheng
ad55a6079a Fix an extremely stupid bug that prevented first round of coalescing (physical registers only) from happening.
llvm-svn: 42820
2007-10-09 23:36:27 +00:00
Chris Lattner
5d45178179 Add a dummy for the id typedef. Steve, plz fill this in. :)
llvm-svn: 42819
2007-10-09 22:58:09 +00:00
Chris Lattner
1f1b0dbc28 Make a significant change to invert the control flow handling
predefined macros.  Previously, these were handled by the driver,
now they are handled by the preprocessor.

Some fallout of this:

1. Instead of preprocessing two buffers (the predefines, then the 
   main source file)  we now start preprocessing the main source 
   file and inject the predefines as a "psuedo #include" from the
   main source file.
2. #1 allows us to nuke the Lexer::IsMainFile flag and simplify
   Preprocessor::isInPrimaryFile.
3. The driver doesn't have to know about standard #defines, the
   preprocessor knows, which is nice for people wanting to define
   their own drivers.
4. This allows us to put normal tokens in the predefine buffer,
   for example a definition for __builtin_va_list that is 
   target-specific, and a typedef for id in objc.

llvm-svn: 42818
2007-10-09 22:10:18 +00:00
Steve Naroff
c62adb6d1a Make sure methods with no return type default to "id".
This fixes a crasher in Sema::MatchTwoMethodDeclarations(), identified by selector-overload.m (just added).

Added Action::ActOnTranslationUnitScope() and renamed Action::PopScope to ActOnPopScope.

Added a Translation Unit Scope instance variable to Sema (will be very useful to ObjC-related actions, since ObjC declarations are always file-scoped).

llvm-svn: 42817
2007-10-09 22:01:59 +00:00
Ted Kremenek
230c6cc516 Modified XCode project to contain...
ADT/DenseSet.h
ADT/ImmutableMap.h
ADT/ImmutableSet.h

llvm-svn: 42816
2007-10-09 21:49:49 +00:00
Chris Lattner
f5ea386698 Add new MemoryBuffer::getMemBufferCopy method.
llvm-svn: 42815
2007-10-09 21:46:38 +00:00
Devang Patel
1999d22b7f Fix indentation.
llvm-svn: 42814
2007-10-09 21:41:00 +00:00
Ted Kremenek
12bfa1ccbc Added implementation of immutable (functional) maps and sets, as
implemented on top of a functional AVL tree.  The AVL balancing code
is inspired by the OCaml implementation of Map, which also uses a functional
AVL tree.

Documentation is currently limited and cleanups are planned, but this code
compiles and has been tested.

llvm-svn: 42813
2007-10-09 21:38:09 +00:00
Devang Patel
2af23f976b Do not walk invalid iterator.
llvm-svn: 42812
2007-10-09 21:31:36 +00:00
Devang Patel
152f18f671 Recognize while(1) and avoid extra blocks.
llvm-svn: 42811
2007-10-09 20:51:27 +00:00
Devang Patel
f8a76755df new test
llvm-svn: 42810
2007-10-09 20:37:41 +00:00
Chris Lattner
87547e6c15 avoid a noop virtual method call on the hot scope poping path.
llvm-svn: 42809
2007-10-09 20:37:18 +00:00
Devang Patel
c1380400d5 Recognize "do {} while (0)" idiom and avoid extra basic blocks.
llvm-svn: 42808
2007-10-09 20:33:39 +00:00
Devang Patel
7ad0c2f1f9 Use LLVMFoldingBuilder
llvm-svn: 42807
2007-10-09 19:49:58 +00:00
Devang Patel
530f975cf0 Add LLVMFoldingBuilder
llvm-svn: 42806
2007-10-09 19:49:19 +00:00
Dan Gohman
850ff11022 Remove an unnecessary friend declaration.
llvm-svn: 42805
2007-10-09 18:39:48 +00:00
Fariborz Jahanian
eb2b34a9a5 Remove comment about protocols and namespace no longer relevant.
llvm-svn: 42804
2007-10-09 18:28:41 +00:00
Fariborz Jahanian
c8e7a93b02 Minor code clean up to make it more readable.
llvm-svn: 42803
2007-10-09 18:22:59 +00:00
Chris Lattner
516ca70f5d Update DeclKind enums to reflect ObjcProtocolDecl's inheritance change.
llvm-svn: 42802
2007-10-09 18:18:24 +00:00
Fariborz Jahanian
06f84f5f84 Remove addition of protocol names to declaration scopes, use a separate
DenseMap to keep track of such declarations and derive ObjcProtocolDecl
directyly from NamedScope.

llvm-svn: 42801
2007-10-09 18:03:53 +00:00
Chris Lattner
3c69f12cbc convert driver over to use Token::is/isNot APIs. fwew, all done.
llvm-svn: 42800
2007-10-09 18:03:42 +00:00
Chris Lattner
98c1f7cfde Switch lexer/pp over to new Token::is/isNot api
llvm-svn: 42799
2007-10-09 18:02:16 +00:00
Chris Lattner
0ef1352a94 swtich to Token::is/isNot
llvm-svn: 42798
2007-10-09 17:51:17 +00:00
Chris Lattner
feb00b6e12 switch more code to use Token::is/isNot where possible.
llvm-svn: 42797
2007-10-09 17:41:39 +00:00
Chris Lattner
76c7228ef9 switch some more of the parser over to using Token::is and isNot
llvm-svn: 42796
2007-10-09 17:33:22 +00:00
Chris Lattner
0ab032aa8f Add two new Token helper functions, "is" and "isNot". This allows us to write
stuff like this:

       // If we don't have a comma, it is either the end of the list (a ';') or
       // an error, bail out.
       if (Tok.isNot(tok::comma))
         break;
instead of:
       // If we don't have a comma, it is either the end of the list (a ';') or
       // an error, bail out.
       if (Tok.getKind() != tok::comma)
         break;

There is obviously no functionality change, but the code reads a bit better and is 
more terse.

llvm-svn: 42795
2007-10-09 17:23:58 +00:00
Fariborz Jahanian
f483847233 Added better comment about protocol list for class ObjcQualifiedInterfaceType.
llvm-svn: 42794
2007-10-09 17:14:13 +00:00
Chris Lattner
a55a2cc25c rename some "Parse" actions to "ActOn". Move code around in
ParseFunctionDefinition so that ActOnFunctionDefBody is always
called if ActOnStartOfFunctionDef is called.  This fixes a crash
reported by Nuno Lopes.

llvm-svn: 42793
2007-10-09 17:14:05 +00:00
Devang Patel
eac5948348 Use const& for RHS.
Use copy for LHS, because it is incremented using ++ operator.

llvm-svn: 42792
2007-10-09 17:10:59 +00:00
Devang Patel
49a44f3b52 Fix comment. Describe what it is, instead of how it is used.
llvm-svn: 42791
2007-10-09 17:08:50 +00:00
Fariborz Jahanian
cb995d8981 Prevent memory leak by not creating a category object when there is a
fatal error of category's undefined interface.

llvm-svn: 42790
2007-10-09 17:05:22 +00:00
Chris Lattner
fc16c0a026 update prototype, fixing build error
llvm-svn: 42789
2007-10-09 16:27:44 +00:00
Dan Gohman
66966403ce Pass argc by value, not by reference, since it isn't modified.
llvm-svn: 42788
2007-10-09 16:04:57 +00:00
Dan Gohman
e8c8ef5234 LowerIntegerDivOrRem no longer exists.
llvm-svn: 42787
2007-10-09 15:45:13 +00:00
Dan Gohman
51554bf30e Fix grammar in a comment.
llvm-svn: 42786
2007-10-09 15:44:37 +00:00
Dan Gohman
6d28778bfd This is done.
llvm-svn: 42785
2007-10-09 15:42:21 +00:00
Dan Gohman
678387a299 These two tests now require only two multiply instructions,
instead of four.

llvm-svn: 42784
2007-10-09 15:39:37 +00:00
Evan Cheng
82bc90ac60 Under 64-bit mode use LEA64_32r instead of LEA64r to save a byte.
llvm-svn: 42783
2007-10-09 07:14:53 +00:00
Chris Lattner
38d49f5d90 Fix problems where DenseMap used operator!= instead of correctly
calling the traits implementation of isEqual.

llvm-svn: 42782
2007-10-09 05:42:12 +00:00
Chris Lattner
5c50f59690 Change a #include into a forward declaration
llvm-svn: 42781
2007-10-09 03:40:30 +00:00
Bruno Cardoso Lopes
66d9572ced Position Independent Code (PIC) support [3]
llvm-svn: 42780
2007-10-09 03:15:11 +00:00
Bruno Cardoso Lopes
35d86e60b6 Position Independent Code (PIC) support [2]
- Added a function to hold the stack location 
  where GP must be stored during LowerCALL
- AsmPrinter now emits directives based on
  relocation type
- PIC_ set to default relocation type (same as GCC)

llvm-svn: 42779
2007-10-09 03:01:19 +00:00
Bruno Cardoso Lopes
5cef9cfd09 Position Independent Code (PIC) support [1]
- Modified instruction format to handle pseudo instructions
- Added LoadAddr SDNode to load symbols.

llvm-svn: 42778
2007-10-09 02:55:31 +00:00
Steve Naroff
8e748cb4e9 Remove 2 protocol related actions from MinimalActions (protocols shouldn't be recognized as types).
llvm-svn: 42777
2007-10-08 23:10:47 +00:00
Fariborz Jahanian
da6c012ee7 Added a new class for Interfaces qualified by protocol list.
Protocols are now sorted and made unique in the list.
Enhanced pretty printer for @interface (So, I can see the protocol list).

llvm-svn: 42776
2007-10-08 23:06:41 +00:00
Evan Cheng
3b3e6097a3 Update test.
llvm-svn: 42775
2007-10-08 22:20:32 +00:00
Evan Cheng
f5ec10b64c Bug fix. X86 was emitting redundant setcc and test instructions before a conditional move.
llvm-svn: 42774
2007-10-08 22:16:29 +00:00
Steve Naroff
b163154c2d Removed unused instance variable from FieldDecl.
llvm-svn: 42773
2007-10-08 21:56:47 +00:00
Chris Lattner
ba9dddb01e Rename FileVariable -> FileVar for consistency with its class name,
likewise block and param.  Reorder the layout of the Decl kind enum
so that the inheritance tree is reflected in the ordering.  This allows
trivial range comparisons to determine whether something is an instance
of some abstract class, making classof faster.

llvm-svn: 42772
2007-10-08 21:37:32 +00:00
Chris Lattner
15b7278931 add a comment.
llvm-svn: 42771
2007-10-08 21:36:22 +00:00
Chris Lattner
6776a8d359 Move identifierTable.h to the right folder.
llvm-svn: 42770
2007-10-08 21:35:59 +00:00
Dan Gohman
5942e5a5fb Call getFunctionNumber() instead of referencing FunctionNumber directly,
for consistency.

llvm-svn: 42769
2007-10-08 21:27:12 +00:00
Dan Gohman
ac546cc28f Mark the prefetch intrinsic as IntrWriteArgMem, instead of the
default of IntrWriteMem, to at least indicate that it doesn't
"capture" the argument pointer.

llvm-svn: 42768
2007-10-08 21:15:07 +00:00
Steve Naroff
71c3c1c715 Convert Selector Maps/Sets to use stronger typing (now that we have DenseMapInfo in IdentifierTable.h).
llvm-svn: 42767
2007-10-08 21:05:34 +00:00
Devang Patel
1166312e8b Code gen case statement ranges.
llvm-svn: 42766
2007-10-08 20:57:48 +00:00
Dan Gohman
a24b431b27 These two tests now require only three multiply instructions,
instead of four.

llvm-svn: 42765
2007-10-08 20:48:12 +00:00
Fariborz Jahanian
e90597f593 Several small patches to do pretty printing for objective-c top-level decls
(minimal printing), Derive ObjcClassDecl from Decl. Ted may want to 
take note of the change I made to CFGRecStmtDeclVisitor.h

llvm-svn: 42764
2007-10-08 18:53:38 +00:00
Chris Lattner
104c48ab8f Various improvements to the documentation, contributed by
Joshua Haberman!

llvm-svn: 42763
2007-10-08 18:42:45 +00:00
Dan Gohman
a160361c85 Migrate X86 and ARM from using X86ISD::{,I}DIV and ARMISD::MULHILO{U,S} to
use ISD::{S,U}DIVREM and ISD::{S,U}MUL_HIO. Move the lowering code
associated with these operators into target-independent in LegalizeDAG.cpp
and TargetLowering.cpp.

llvm-svn: 42762
2007-10-08 18:33:35 +00:00
Evan Cheng
18109c88c3 Allow x86 compare to be commutable by default.
llvm-svn: 42761
2007-10-08 18:27:46 +00:00
Gordon Henriksen
44dd8fbd26 C and Objective Caml bindings for PHINode::addIncoming etc.
llvm-svn: 42760
2007-10-08 18:14:39 +00:00
Dan Gohman
5c6d0c3b99 DAGCombiner support for UDIVREM/SDIVREM and UMUL_LOHI/SMUL_LOHI.
Check if one of the two results unneeded so see if a simpler operator
could bs used. Also check to see if each of the two computations could be
simplified if they were split into separate operators. Factor out the code
that calls visit() so that it can be used for this purpose.

llvm-svn: 42759
2007-10-08 17:57:15 +00:00
Evan Cheng
4c73befe28 LLVM does not use the old style simple isel any more.
llvm-svn: 42758
2007-10-08 17:54:24 +00:00
Evan Cheng
acc8b68e5f Remove debugging printf to get build going on x86-64.
llvm-svn: 42757
2007-10-08 17:49:43 +00:00
Fariborz Jahanian
092e34d15b Removed unnecessary base class from some of objective-c classes:
ObjcProtocolDecl is now derived from ScopedDecl. ObjcForwardProtocolDecl from Decl.
ObjcImplementationDecl fom NamedDecl.

llvm-svn: 42756
2007-10-08 17:35:11 +00:00
Dan Gohman
71f0d7d76e When we start enabling SMUL_LOHI/UMUL_LOHI or SDIVREM/UDIVREM in
target-indepenent lowering, don't use them on PowerPC.

llvm-svn: 42755
2007-10-08 17:28:24 +00:00
Fariborz Jahanian
4b2113c281 Return NULL on invalid protocol.
llvm-svn: 42754
2007-10-08 16:07:03 +00:00
Dan Gohman
b08c8bfe41 Add convenience overloads of SelectionDAG::getNode that take a SDVTList
and individual SDOperand operands.

llvm-svn: 42753
2007-10-08 15:49:58 +00:00
Dan Gohman
2c6a821fd7 Move the space in overview output for commands out of each of the
commands and into the common code.

llvm-svn: 42752
2007-10-08 15:45:12 +00:00
Dan Gohman
afedc063ab Simplify getIntPtrType, allowing it to work for arbitrary pointer sizes.
llvm-svn: 42751
2007-10-08 15:16:25 +00:00
Dan Gohman
5e79a6108f Use correct parentheses with the '&& "..."' idiom in an assert.
llvm-svn: 42750
2007-10-08 15:13:30 +00:00
Dan Gohman
fadf40a655 In -debug mode, dump SelectionDAGs both before and after the
optimization passes.

llvm-svn: 42749
2007-10-08 15:12:17 +00:00
Dan Gohman
ea3c73629f Fix grammar in a comment.
llvm-svn: 42748
2007-10-08 15:10:04 +00:00
Dan Gohman
13ab93efde Add explicit keywords.
llvm-svn: 42747
2007-10-08 15:08:41 +00:00
Neil Booth
49c6aab7b8 Use APInt::tcExtract. It's cleaner, and works :)
llvm-svn: 42746
2007-10-08 14:39:42 +00:00
Neil Booth
b618216e56 Add a new function tcExtract for extracting a bignum from an
arbitrary range of bits embedded in the middle of another bignum.
This kind of operation is desirable in many cases of software
floating point, e.g. converting bignum integers to floating point
numbers of fixed precision (you want to extract the precision most
significant bits).

Elsewhere, add an assertion, and exit the shift functions early if
the shift count is zero.

llvm-svn: 42745
2007-10-08 13:47:12 +00:00
Gordon Henriksen
acf684315e Fixed downrev Ocaml compatibility.
llvm-svn: 42744
2007-10-08 12:16:59 +00:00
Owen Anderson
74529b7d5f Begin the process of allowing DomTree on MBB's. Step One: template DomTreeNode by making it a typedef of a templated DomTreeNodeBase.
llvm-svn: 42743
2007-10-08 07:44:39 +00:00
Evan Cheng
21a58a72c5 Kill cycle of an live range is always the last use index + 1.
llvm-svn: 42742
2007-10-08 06:59:30 +00:00
Chris Lattner
bcd30bb0cd Allow passes to just pass up "FunctionPass(&ID)" instead of "FunctionPass((intptr_t)&ID)"
llvm-svn: 42741
2007-10-08 03:45:44 +00:00
Gordon Henriksen
783f7bbabd C and Objective Caml bindings for getFunction and getNamedGlobal. Also enhanced
the Objective Caml 'declare_*' functions to behave more or less like
getOrInsertFunction.

llvm-svn: 42740
2007-10-08 03:45:09 +00:00
Chris Lattner
b20757d578 disable this entirely: it is causing use of invalidated iterators and infinite looping.
llvm-svn: 42739
2007-10-07 22:00:31 +00:00
Chris Lattner
8dd66ab3b2 Fix many regressions on x86 by avoiding dereferencing the end iterator.
llvm-svn: 42738
2007-10-07 21:53:12 +00:00
Chris Lattner
7cdae91966 Finish off PR1723, by working around some strange compiler bug.
llvm-svn: 42737
2007-10-07 17:57:10 +00:00
Gordon Henriksen
751ebf7b9a C and Objective Caml bindings for GlobalVariable::isConstant.
llvm-svn: 42736
2007-10-07 17:31:42 +00:00
Neil Booth
03f58ab706 Add back convertFromSignExtendedInteger.
llvm-svn: 42735
2007-10-07 12:15:41 +00:00
Neil Booth
ba205229e7 Now that convertFromUnsignedParts has a sane, constant interface,
convertFromZeroExtendedInteger can be simplified as it doesn't need
to make a copy of the source bignum.

llvm-svn: 42734
2007-10-07 12:10:57 +00:00
Neil Booth
6c1c8588ae Reimplement convertFromUnsignedInteger so it is passed a const bignum.
It used to modify its argument in-place.

This interface is saner and the implementation more efficient.  It will
be needed for decimal->binary conversion.

llvm-svn: 42733
2007-10-07 12:07:53 +00:00
Neil Booth
5f00973393 convertFromInteger, as originally written, expected sign-extended
input.  APInt unfortunately zero-extends signed integers, so Dale
modified the function to expect zero-extended input.  Make this
assumption explicit in the function name.

llvm-svn: 42732
2007-10-07 11:45:55 +00:00
Chris Lattner
c330d008f4 remove unneeded #include
llvm-svn: 42731
2007-10-07 08:59:27 +00:00
Chris Lattner
ef6b136781 move IdentifierTable.h from liblex to libbasic.
llvm-svn: 42730
2007-10-07 08:58:51 +00:00
Neil Booth
d3985924f4 combineLostFractions does not need to be a member function
llvm-svn: 42729
2007-10-07 08:51:21 +00:00
Chris Lattner
4894f485c7 implement the Token class in the Lexer.cpp file instead of IdentifierInfo.cpp
llvm-svn: 42728
2007-10-07 08:47:24 +00:00
Chris Lattner
c43ddc84a3 improve layering:
Now instead of IdentifierInfo knowing anything about MacroInfo,
only the preprocessor knows.  This makes MacroInfo truly private
to the Lex library (and its direct clients) instead of being 
accessed in the Basic library.

llvm-svn: 42727
2007-10-07 08:44:20 +00:00
Chris Lattner
259716a6e1 change calls to getMacroInfo into hasMacroDefinition() where possible.
llvm-svn: 42726
2007-10-07 08:04:56 +00:00
Chris Lattner
d7b971bf3d add a hasMacroDefinition() method to IdentifierInfo, strength reduce a
call to getMacroInfo to call it.

llvm-svn: 42725
2007-10-07 07:57:27 +00:00
Chris Lattner
f49523d6ea update comment.
llvm-svn: 42724
2007-10-07 07:54:23 +00:00
Chris Lattner
ff067ce555 Remove the PPID bitfield from IdentifierInfo, shrinking it by a word
(because all bitfields now fit in 32 bits).  This shrinks the identifier
table for carbon.h from 1634428 to 1451424 bytes (12%) and has no impact 
on compile time.

llvm-svn: 42723
2007-10-07 07:52:34 +00:00
Chris Lattner
a441ca651f First step to fixing a long lived layering violation: this
moves the MacroInfo pointer to a side hash table (which currently 
lives in IdentifierTable.cpp).  This removes a pointer from 
Identifier info, but doesn't shrink it, as it requires a new bit 
be added.  This strange approach with the 'hasmacro' bit is needed
to not lose preprocessor performance.

llvm-svn: 42722
2007-10-07 07:09:52 +00:00
Chris Lattner
65cc87ffc2 The identifier shouldn't be added to the scope, the decl should.
This fixes strange assertions that just started triggering.

llvm-svn: 42721
2007-10-07 07:05:08 +00:00
Chris Lattner
65fc0f1fca classof isn't right. This is causing assertion failures somehow now.
llvm-svn: 42720
2007-10-07 07:04:41 +00:00
Chris Lattner
730160d32f Shrink the builtinID down by 3 bits, allowing all the bitfields to
fit in 32-bits, shrinking IdentifierInfo by a word.

This shrinks the total size of the identifier pool from 
1817264 to 1634428 bytes (11%) on carbon.h.

llvm-svn: 42719
2007-10-07 06:29:32 +00:00
Chris Lattner
d1cdee7d1f Rename ASTStreamers.* -> ASTConsumers.*
llvm-svn: 42718
2007-10-07 06:04:32 +00:00
Daniel Berlin
fb6a79cdd5 Some more problems noticed by Curtis
llvm-svn: 42717
2007-10-07 04:47:57 +00:00
Chris Lattner
5700fab189 simplify the interfaces to create selectors: getSelector can take any
number of arguments now and does the right thing, but the nullary/unary
accessors are preserved as convenience functions.  This allows us to
slightly simplify clients.

llvm-svn: 42716
2007-10-07 02:00:24 +00:00
Chris Lattner
f7f34d09e4 simplify some Selector interfaces.
llvm-svn: 42715
2007-10-07 01:33:16 +00:00
Chris Lattner
ee2d84133c move ImplementationClassInfo out of ASTContext into Sema.
llvm-svn: 42714
2007-10-07 01:13:46 +00:00
Gordon Henriksen
ffb4876cfb C and Objective Caml bindings for PATypeHolder.
llvm-svn: 42713
2007-10-07 00:13:35 +00:00
Chris Lattner
efc0b5e372 add comments.
llvm-svn: 42712
2007-10-06 23:30:21 +00:00
Chris Lattner
6a2b09ecd9 switch ObjcCategoryImplDecl over to being a NamedDecl, remove dead ctor argument.
llvm-svn: 42711
2007-10-06 23:12:31 +00:00
Chris Lattner
a4016555d2 introduce a new NamedDecl class, switch a couple of things over to using it.
NamedDecl is a Decl that has an IdentifierInfo (for example, ScopedDecl), 
but not ObjcMethodDecl.

Simplify some code in ActOnAddMethodsToObjcDecl, by doing the cast from 
DeclTy to Decl at the start of the method.

llvm-svn: 42710
2007-10-06 22:53:46 +00:00
Chris Lattner
18d3a13bef Every decl has a SourceLocation, move the location info into the Decl class instead of being in subclasses.
llvm-svn: 42709
2007-10-06 22:16:01 +00:00
Kevin
6261e98ea8 future notes & minor changes
llvm-svn: 42708
2007-10-06 21:28:47 +00:00
Gordon Henriksen
c3d661a0ee Bindings for the verifier.
llvm-svn: 42707
2007-10-06 21:00:36 +00:00
Chris Lattner
ae0ec1d09f simplify the interface to create ObjcClassDecl's.
llvm-svn: 42706
2007-10-06 20:08:36 +00:00
Chris Lattner
11eca782a3 simplify the interface for creating ObjcForwardProtocolDecl
llvm-svn: 42705
2007-10-06 20:05:59 +00:00
Chris Lattner
f0d15d470f add a missing ;
llvm-svn: 42704
2007-10-06 19:08:22 +00:00
Chris Lattner
5ccf60fc44 stub out some printing of objc decls.
llvm-svn: 42703
2007-10-06 18:52:10 +00:00
Gordon Henriksen
8689fa69e2 Deleting some unnecessary glue.
llvm-svn: 42702
2007-10-06 17:10:44 +00:00
Gordon Henriksen
fc560cef9a Adopting a uniform naming convention for type constructors in
bindings (part le deux).

llvm-svn: 42701
2007-10-06 16:56:09 +00:00
Anton Korobeynikov
67ac2de8bf Oops, I really wanted to commit this part also :)
llvm-svn: 42700
2007-10-06 16:39:43 +00:00
Anton Korobeynikov
c59496f737 Move merge code into new helper function.
llvm-svn: 42699
2007-10-06 16:17:49 +00:00
Gordon Henriksen
ed7beaa3fa Adopting a uniform naming convention for type constructors in bindings.
llvm-svn: 42698
2007-10-06 16:05:20 +00:00
Gordon Henriksen
1046c73d12 Adopting a uniform naming convention for constant constructors in bindings.
llvm-svn: 42697
2007-10-06 15:11:06 +00:00
Gordon Henriksen
7ce3176696 Adding C and Ocaml bindings for ConstantExpr.
llvm-svn: 42696
2007-10-06 14:29:36 +00:00
Anton Korobeynikov
8d8f94c278 Include DataTypes.h to provide intptr_t type. This fixes OpenBSD compilation of this file.
Inspired by Laurence Tratt's patch

llvm-svn: 42695
2007-10-06 13:07:11 +00:00
Evan Cheng
0de312dd7d Reapply 42677.
llvm-svn: 42692
2007-10-06 08:19:55 +00:00
Evan Cheng
8ff5335bb6 Oops. Forgot this.
llvm-svn: 42691
2007-10-06 08:09:29 +00:00
Neil Booth
32897f5eb0 Cleaner, more general exponent output.
llvm-svn: 42690
2007-10-06 07:29:25 +00:00
Chris Lattner
b2d486a357 speed up clang startup another 28% by avoiding std::vector<std::string>
for holding builtin target-specific macros.

llvm-svn: 42689
2007-10-06 06:57:34 +00:00
Chris Lattner
b5fc6fbcfc speed up clang startup time by about 23% by avoiding lots of
stringmap operations when there are no secondary targets.

llvm-svn: 42688
2007-10-06 06:29:41 +00:00
Chris Lattner
2a9bcb9ea7 silence warnings in no-assert build.
llvm-svn: 42687
2007-10-06 06:13:42 +00:00
Chris Lattner
82217bd155 revert evan's patch until the header is committed
llvm-svn: 42686
2007-10-06 06:08:17 +00:00
Chris Lattner
17b1330b04 fix grammaro
llvm-svn: 42685
2007-10-06 05:48:57 +00:00
Chris Lattner
a1513f7198 edits
llvm-svn: 42684
2007-10-06 05:42:47 +00:00
Chris Lattner
25d8a70dc3 fix accidental commit
llvm-svn: 42683
2007-10-06 05:38:32 +00:00
Chris Lattner
609ca3ec97 edits
llvm-svn: 42682
2007-10-06 05:30:19 +00:00
Chris Lattner
01607a94c0 various minor edits, e.g. & -> &amp;
llvm-svn: 42681
2007-10-06 05:23:00 +00:00
Kevin
eddf1f0966 New directory.
llvm-svn: 42680
2007-10-06 05:15:30 +00:00
Chris Lattner
48ce755498 add a warning.
llvm-svn: 42679
2007-10-06 05:13:47 +00:00
Chris Lattner
8c03979f91 minor edits
llvm-svn: 42678
2007-10-06 05:09:04 +00:00
Evan Cheng
f4b5d491df Added DAG xforms. e.g.
(vextract (v4f32 s2v (f32 load $addr)), 0) -> (f32 load $addr) 
(vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr)
Remove x86 specific patterns.

llvm-svn: 42677
2007-10-06 02:46:29 +00:00
Bill Wendling
bc03521fc9 Fix spacing issues.
llvm-svn: 42676
2007-10-06 01:56:01 +00:00
Bill Wendling
650dcf6027 Just say "No" to non-ASCII things.
llvm-svn: 42675
2007-10-06 01:53:09 +00:00
Bill Wendling
3ef6b60eeb Remove non-ASCII '
llvm-svn: 42674
2007-10-06 01:44:57 +00:00
Kevin
4fbcd6c01b 1. May fix encoding issues: server uses UTF; HTML file assumes Western (ISO 8859-1).
2. Added strict doctype.

Closing out tags like <br/> and <meta.../> may still be a problem (necessary for XHTML, but wrong for HTML)....

llvm-svn: 42673
2007-10-06 01:28:23 +00:00
Dale Johannesen
f864ac96d8 Next powerpc long double bits. Comparisons work,
although not well, and shortening FP converts.

llvm-svn: 42672
2007-10-06 01:24:11 +00:00
Dale Johannesen
bcfa7c1255 Make test work on non-x86 hosts.
llvm-svn: 42671
2007-10-06 01:22:39 +00:00
Neil Booth
c8b650ab14 Fix and clarify some comments.
llvm-svn: 42670
2007-10-06 00:43:45 +00:00
Neil Booth
0ea72a9a91 Generalize tcFullMultiply so that the operands can be of differing
part widths.  Also, return the number of parts actually required to
hold the result's value.
Remove an over-cautious condition from rounding of float->hex conversion.

llvm-svn: 42669
2007-10-06 00:24:48 +00:00
Gordon Henriksen
1d0d24c4fd Wrapping Value::dump.
llvm-svn: 42668
2007-10-06 00:08:49 +00:00
Gordon Henriksen
7330acdec7 Removing the silly CHelpers header by rolling wrap and unwrap into the C
bindings headers themselves, hidden behind #ifdef __cplusplus.

llvm-svn: 42666
2007-10-05 23:59:36 +00:00
Evan Cheng
5ee9cf6bca Test case for 3-address conversion.
llvm-svn: 42664
2007-10-05 23:33:09 +00:00
Ted Kremenek
8a7bf82206 Modifications to XCode project:
- Added include/Analysis/ExprDeclBitVector.h
- Added include/Analysis/ProgramEdge.h
- Removed include/Analysis/Visitors/DataflowStmtVisitor.h

llvm-svn: 42663
2007-10-05 23:32:54 +00:00
Ted Kremenek
fd8d8ca214 Removed DataflowStmtVisitor. It is no longer used, and is obsoleted
by newer visitor interfaces.

llvm-svn: 42662
2007-10-05 23:27:24 +00:00
Evan Cheng
1151ffde70 Commute x86 cmove instructions by swapping the operands and change the condition
to its inverse.
Testing this as llcbeta

llvm-svn: 42661
2007-10-05 23:13:21 +00:00
Evan Cheng
42a13757de This is done.
llvm-svn: 42656
2007-10-05 22:34:59 +00:00
Evan Cheng
484cab7a2f Enable convertToThreeAddress for X86 by default.
llvm-svn: 42655
2007-10-05 22:31:10 +00:00
Devang Patel
a69f987b66 Fix bug in updating dominance frontier after loop
unswitch when frontier includes basic blocks that 
are not inside loop.

llvm-svn: 42654
2007-10-05 22:29:34 +00:00
Evan Cheng
d3ccf00870 INC64_32r -> LEA64_32r is better than INC64_32r -> LEA32r, but it still can
cause performance degradation.

llvm-svn: 42653
2007-10-05 21:55:32 +00:00
Kevin
9f413446de A message on the main page about bulding clang.
llvm-svn: 42652
2007-10-05 21:44:03 +00:00
Kevin
aa4692883a new site -- the rest of it
llvm-svn: 42651
2007-10-05 21:18:52 +00:00
Kevin
32a4c17af9 new site
llvm-svn: 42650
2007-10-05 21:17:52 +00:00
Fariborz Jahanian
ea7a98d8d6 This is the first patch toward supporting protocol conforming
objective-c types. It also removes use of Scope* parameter in
getObjCProtocolDecl.

llvm-svn: 42649
2007-10-05 21:01:53 +00:00
Devang Patel
64a9ca7c58 Support case statement ranges.
llvm-svn: 42648
2007-10-05 20:54:07 +00:00
Evan Cheng
fa2c828687 In 64-bit mode, avoid using leal with 32-bit 32-bit address size, e.g.
leal 1(%ecx), %edi, which requires 67H prefix.

llvm-svn: 42647
2007-10-05 20:34:26 +00:00
Kevin
e5be925a22 Per request... about to make changes to the website.
llvm-svn: 42646
2007-10-05 20:31:57 +00:00
Chris Lattner
dadc762ac5 Implement DenseMapInfo for Selector, allowing use of DenseMap/DenseSet of
Selector's instead of requiring void* to be used.  I converted one use of
DenseSet<void*> over to use DenseSet<Selector> but the others should change
as well.

llvm-svn: 42645
2007-10-05 20:15:24 +00:00
Dale Johannesen
c0154c06d6 First round of ppc long double. call/return and
basic arithmetic works.
Rename RTLIB long double functions to distinguish
different flavors of long double; the lib functions
have different names, alas.

llvm-svn: 42644
2007-10-05 20:04:43 +00:00
Steve Naroff
e61bfa8bb4 Layering refinements for selectors (suggested by Chris). Specifics...
- Add SelectorTable, which enables us to remove MultiKeywordSelector from the public header.
- Remove FoldingSet from IdentifierInfo.h and Preprocessor.h.
- Remove Parser::ObjcGetUnarySelector and Parser::ObjcGetKeywordSelector, they are subsumed by SelectorTable.
- Add MultiKeywordSelector to IdentifierInfo.cpp.
- Move a bunch of selector related methods from ParseObjC.cpp to IdentifierInfo.cpp.
- Added some comments.

llvm-svn: 42643
2007-10-05 18:42:47 +00:00
Evan Cheng
aac0f8e351 Add support to convert more 64-bit instructions to 3-address instructions.
llvm-svn: 42642
2007-10-05 18:20:36 +00:00
Fariborz Jahanian
458f7114db Patch for 1) Checking for duplicate methods decls in intterface and category.
2) Use of the new DenseSet<t> abstractions instead of DenseMap<t,char>.

llvm-svn: 42641
2007-10-05 18:00:57 +00:00
Evan Cheng
97eba74a52 ADC and SBB uses EFLAGS.
llvm-svn: 42640
2007-10-05 17:59:57 +00:00
Chris Lattner
f85527e131 Mark count method const.
llvm-svn: 42639
2007-10-05 17:40:38 +00:00
Dan Gohman
43c29dce18 Change a few more spaces to tabs in assembly output.
llvm-svn: 42638
2007-10-05 15:58:41 +00:00
Dan Gohman
b074f23dff Change a space to a tab in the assembly output of a .globl directive
for consistency.

llvm-svn: 42637
2007-10-05 15:54:58 +00:00
Dan Gohman
12334acbfb Legalize support for MUL_LOHI and DIVREM.
llvm-svn: 42636
2007-10-05 14:17:22 +00:00
Dan Gohman
2682bb6df2 Fix a typo in a comment.
llvm-svn: 42635
2007-10-05 14:11:58 +00:00
Dan Gohman
1a77dfba15 Provide names for MUL_LOHI and DIVREM operators.
llvm-svn: 42634
2007-10-05 14:11:04 +00:00
Dan Gohman
3c2c1c3cce SMUL_LOHI and UMUL_LOHI are commutative.
llvm-svn: 42633
2007-10-05 14:09:33 +00:00
Dan Gohman
5b89b1ef8f Define target-indepenent SDNode types for multiply and divide that
produce two results.

llvm-svn: 42632
2007-10-05 14:07:56 +00:00
Duncan Sands
99452793ac Fix typo in comment.
llvm-svn: 42631
2007-10-05 10:37:00 +00:00
Evan Cheng
a8a9c15e30 Testing convertToThreeeAddress as X86 llcbeta.
llvm-svn: 42630
2007-10-05 08:04:01 +00:00
Daniel Berlin
f86366ec2d Fix intersectWithComplement bug noticed by Curtis Dunham
Optimize |= case for empty RHS

llvm-svn: 42629
2007-10-05 05:10:53 +00:00
Evan Cheng
90a4185b5f New test case.
llvm-svn: 42628
2007-10-05 01:44:22 +00:00
Evan Cheng
84d0ebc10a Chain producing nodes cannot be moved, not chain reading nodes.
llvm-svn: 42627
2007-10-05 01:42:35 +00:00
Evan Cheng
991cf47221 Oops. Didn't mean to leave this in.
llvm-svn: 42626
2007-10-05 01:39:40 +00:00
Evan Cheng
79e9713b11 If a node that defines a physical register that is expensive to copy. The
scheduler will try a number of tricks in order to avoid generating the
copies. This may not be possible in case the node produces a chain value
that prevent movement. Try unfolding the load from the node before to allow
it to be moved / cloned.

llvm-svn: 42625
2007-10-05 01:39:18 +00:00
Evan Cheng
a851e2b92e Added storeRegToAddr, loadRegFromAddr, and unfoldMemoryOperand's.
llvm-svn: 42624
2007-10-05 01:34:55 +00:00
Evan Cheng
6912b50958 Not needed any more.
llvm-svn: 42623
2007-10-05 01:34:14 +00:00
Evan Cheng
1ef9edce5f Forgot these.
llvm-svn: 42622
2007-10-05 01:33:45 +00:00
Evan Cheng
f4cf5dcdd2 - Added a few target hooks to generate load / store instructions from / to any
address (not just from / to frameindexes).
- Added target hooks to unfold load / store instructions / SDNodes into separate
load, data processing, store instructions / SDNodes.

llvm-svn: 42621
2007-10-05 01:32:41 +00:00
Evan Cheng
4852303bdb Add a variant of getTargetNode() that takes a vector of MVT::ValueType.
llvm-svn: 42620
2007-10-05 01:10:49 +00:00
Evan Cheng
fd11ef4665 Silence a warning.
llvm-svn: 42619
2007-10-05 01:09:32 +00:00
Devang Patel
da5d6bbc40 switch statement code gen.
llvm-svn: 42616
2007-10-04 23:45:31 +00:00
Daniel Berlin
f5009110bf Fix the previous bug a slightly different way (by modifying how find_next works)
llvm-svn: 42613
2007-10-04 21:27:17 +00:00
Daniel Berlin
c1973961c9 Fix off by one error in iterator
llvm-svn: 42612
2007-10-04 21:18:20 +00:00
Fariborz Jahanian
9081457cbf this patch accomodates clattner's comments on expression processing in @try-statement.
llvm-svn: 42611
2007-10-04 20:19:06 +00:00
Bill Wendling
eaa909f08e Support Objective C++ too.
llvm-svn: 42610
2007-10-04 18:47:25 +00:00
Bill Wendling
c20518d0df Added testcase for creation of metadata with null pointers.
llvm-svn: 42609
2007-10-04 18:46:06 +00:00
Fariborz Jahanian
76aff36d64 More tab removal activity.
llvm-svn: 42608
2007-10-04 17:06:28 +00:00
Chris Lattner
1f2b5f0e13 add a note.
llvm-svn: 42607
2007-10-04 15:47:27 +00:00
Bill Wendling
2fba4a85ea un-XFAIL this test.
llvm-svn: 42606
2007-10-04 09:33:08 +00:00
Daniel Berlin
ffffead7df It helps a lot when you check for the end of your list before randomly
dereferencing things.

llvm-svn: 42605
2007-10-04 05:29:36 +00:00
Daniel Berlin
2738730c0f Make SparseBitVector::set actually work properly when sets are not in ascending or descending order.
llvm-svn: 42604
2007-10-04 05:25:51 +00:00
Chris Lattner
01d7f489a9 minor cleanups, make code more defensive, less branchy in Selector ctor.
llvm-svn: 42603
2007-10-04 05:21:22 +00:00
Chris Lattner
0f26288998 fix an incorrect assertion
llvm-svn: 42602
2007-10-04 05:16:42 +00:00
Fariborz Jahanian
673414067b Fixed tabs in couple of sources.
llvm-svn: 42601
2007-10-04 00:45:27 +00:00
Fariborz Jahanian
c9cd8a185d Fixed all my recent test cases to have the RUN command and
fixed consequence of these changes in clang.

llvm-svn: 42600
2007-10-04 00:22:33 +00:00
Gordon Henriksen
14d7680b00 Do use the actual ocaml stdlib (not the install dir) to find the
caml/*.h headers.

llvm-svn: 42599
2007-10-04 00:07:50 +00:00
Neil Booth
8f1946fa22 Add APFloat -> hexadecimal string conversion, as per %a and %A in C99.
Useful for diagnostics and debugging.

llvm-svn: 42598
2007-10-03 22:26:02 +00:00
Chris Lattner
644e1b7a10 minor cleanup
llvm-svn: 42596
2007-10-03 22:03:06 +00:00
Chris Lattner
02cbd095dd move DeclObjc.h down to be alphabetically organized
llvm-svn: 42594
2007-10-03 21:56:39 +00:00
Owen Anderson
8313e75ea7 Completely merge the implementation details of DomTree and PostDomTree.
Also, add a FIXME for a bug in PostDomTree calculation I noticed while writing this,

llvm-svn: 42593
2007-10-03 21:25:45 +00:00
Owen Anderson
87337924d5 Add a GraphTraits partial specialization to make the inverse of an inverse be the same as the underlying graph.
llvm-svn: 42592
2007-10-03 21:24:38 +00:00
Devang Patel
3574759d85 Fix 80 col violation.
llvm-svn: 42591
2007-10-03 21:17:43 +00:00
Devang Patel
e192e32577 Refactor code in a separate method.
llvm-svn: 42590
2007-10-03 21:16:08 +00:00
Chris Lattner
99f6ab7e4c Add initial iterator support for folding set.
llvm-svn: 42589
2007-10-03 21:12:09 +00:00
Chris Lattner
f0e5011d21 Clarify that shifts that are too large are undefined.
llvm-svn: 42588
2007-10-03 21:01:14 +00:00
Steve Naroff
4810c3a1d6 Finish renaming ObjC declaration actions.
Add comments.
Switch to new indentation style for the Action class. Since many actions take many arguments, the new style will...
- make it easier to add/remove arguments without messing up the indentation...
- make it easier to add comments to each argument (see ActOnMethodDeclaration for an example)...
- in general, just makes it easier to see what is being passed.

The rest of Actions will be converted "lazily"...there is no immediate need to hack all the existing methods.

llvm-svn: 42587
2007-10-03 21:00:46 +00:00
Chris Lattner
8c41ed61d1 Simplify implementation of the FoldingSet circular list, a necessary step
to giving it iterators.

llvm-svn: 42586
2007-10-03 20:45:43 +00:00
Dan Gohman
c731c97fac Use empty() member functions when that's what's being tested for instead
of comparing begin() and end().

llvm-svn: 42585
2007-10-03 19:26:29 +00:00
Dan Gohman
8c43e41d9b Fix a using namespace llvm; in a header file.
llvm-svn: 42584
2007-10-03 19:04:09 +00:00
Bill Wendling
354504060c Temporarily XFAIL this test.
llvm-svn: 42583
2007-10-03 17:46:54 +00:00
Dale Johannesen
9d559cfff5 Tone down an overzealous optimization.
llvm-svn: 42582
2007-10-03 17:45:27 +00:00
Chris Lattner
87a3dbe743 remove extraneous tag
llvm-svn: 42581
2007-10-03 17:34:29 +00:00
Chris Lattner
6a6fb7f7b7 remove misleading documentation: LLVM has no atomic support yet.
llvm-svn: 42580
2007-10-03 17:33:51 +00:00
Chris Lattner
4bdb84fe53 add a note
llvm-svn: 42579
2007-10-03 17:10:03 +00:00
Tanya Lattner
30f65fe4a7 Fix PR1719, by not marking llvm.global.annotations internal.
llvm-svn: 42578
2007-10-03 17:05:40 +00:00
Fariborz Jahanian
6cc3803f0b Renamed getCatLoc() to getLocation() to be consistant for such
getter names.

llvm-svn: 42577
2007-10-03 16:23:52 +00:00
Neil Booth
1ca1f80b38 Tweak RoundAwayFromZero the bit number below which is truncated, and make
it const.

Preparation for APFloat -> hexadecimal string conversion.

llvm-svn: 42576
2007-10-03 15:16:41 +00:00
Gordon Henriksen
80f35e0d4c Regenerate.
llvm-svn: 42575
2007-10-03 12:07:14 +00:00
Gordon Henriksen
485739d801 Fixing a typo in configure.ac.
Patch by Adam Goode.

llvm-svn: 42574
2007-10-03 12:06:41 +00:00
Chris Lattner
4d4e9cdb62 add a note
llvm-svn: 42573
2007-10-03 06:10:59 +00:00
Chris Lattner
b511029eaf testcase for PR1647
llvm-svn: 42570
2007-10-03 05:29:07 +00:00
Chris Lattner
d66e0cd6c0 Fix PR1719, by not marking llvm.noinline internal.
llvm-svn: 42565
2007-10-03 03:59:15 +00:00
Chris Lattner
21ba176c4b Bill's example is still not enough to repro this, but it has other issues that
seem significant as well.

llvm-svn: 42564
2007-10-03 03:40:24 +00:00
Owen Anderson
b60f254975 Factor some code from the DomTree and PostDomTree calculate methods up into
each one's runOnFunction method.

llvm-svn: 42563
2007-10-03 03:20:17 +00:00
Ted Kremenek
88b7439a8c Fixed bug where intrusive_ptr_add_ref and intrusive_ptr_release were
not declared "static inline."

Removed member templates for operator= and copy constructor.  They simply
didn't work as expected.

Fixed reference counting bug when a smart pointer is assigned the
value of another smart pointer that refers to the same address.

llvm-svn: 42562
2007-10-03 00:48:55 +00:00
Steve Naroff
0c37b0cb5a Rename several ObjC action methods to use the "ActOn" prefix (still a few more to do).
Remove Action::ObjCStartCategoryInterface/ObjCFinishInterface - they are unused.
.

llvm-svn: 42559
2007-10-02 22:39:18 +00:00
Fariborz Jahanian
b75640c9f1 Unified SuperClass field name in an objective-c class.
llvm-svn: 42556
2007-10-02 22:12:45 +00:00
Fariborz Jahanian
b8d9e088a7 Unified such names as protocol references, instance methods and class methods
and their accessors in a variety of objective-c classes.

llvm-svn: 42555
2007-10-02 22:05:16 +00:00
Bill Wendling
3efc0758ae Another micro-opt.
llvm-svn: 42554
2007-10-02 21:49:31 +00:00
Steve Naroff
d174155204 Remove Action::ActOnImpleIvarVsClassIvars(), it is only called by Sema (not Parser).
Add Sema::CheckImplementationIvars() to replace the previous action.

llvm-svn: 42553
2007-10-02 21:43:37 +00:00
Bill Wendling
f214ff8701 Another missed optimization with LICM.
llvm-svn: 42552
2007-10-02 21:43:06 +00:00
Bill Wendling
855011e5c6 Small label changes.
llvm-svn: 42549
2007-10-02 21:02:53 +00:00
Bill Wendling
4eb7ca4b4c Now with source code.
llvm-svn: 42548
2007-10-02 21:01:16 +00:00
Bill Wendling
96ed3bb2d4 Now with LL code!
llvm-svn: 42547
2007-10-02 20:54:32 +00:00
Bill Wendling
9c4d61b523 Another missed optimization.
llvm-svn: 42546
2007-10-02 20:42:59 +00:00
Steve Naroff
f5a55c5a9f Rename ObjcInterfaceDecl::getIsForwardDecl() to isForwardDecl().
Rename ObjcProtocolDecl::getIsForwardProtoDecl() to isForwardDecl().
Rename ObjcInterfaceDecl::setIsForwardDecl() to setForwardDecl().
Rename ObjcProtocolDecl::setIsForwardProtoDecl() to setForwardDecl().

Two reasons:

#1: boolean predicates should start with "is".
#2: Since these two sets of methods represent the same concept, they should be named the same (polymorphism is good:-)

llvm-svn: 42545
2007-10-02 20:26:23 +00:00
Fariborz Jahanian
adf84f3f3c Previously, I warned those methods not implemented in implementation class/category.
Now, I also warn those class/categories which are incomplete because of this.

llvm-svn: 42544
2007-10-02 20:06:01 +00:00
Steve Naroff
c6814ea670 - Add ObjcInterfaceDecl::lookupInstanceMethod(), lookupClassMethod().
- Add ObjcMessageExpr::getSelector(), getClassName().
- Change Sema::getObjCInterfaceDecl() to simply take an IdentifierInfo (no Scope needed).
- Remove FIXME for printing ObjCMessageExpr's.

llvm-svn: 42543
2007-10-02 20:01:56 +00:00
Bill Wendling
88ea107fdb Micro-optimization -- missed LICM opportunity.
llvm-svn: 42542
2007-10-02 19:55:05 +00:00
Gordon Henriksen
a3fc412d82 Updating my credits entry.
llvm-svn: 42541
2007-10-02 18:04:24 +00:00
Dale Johannesen
dd89d2758e Document new sqrt and powi handling.
llvm-svn: 42540
2007-10-02 17:47:38 +00:00
Dale Johannesen
4d4e77af8e Rewrite sqrt and powi to use anyfloat. By popular demand.
llvm-svn: 42537
2007-10-02 17:43:59 +00:00
Fariborz Jahanian
19d765fa6c ObjcCategoryDecl Does not subclass from ScopedDecl any more.
Ted may want to take a look at the change I made at 
FGRecStmtDeclVisitor.h.

llvm-svn: 42535
2007-10-02 17:36:55 +00:00
Ted Kremenek
190b1ed4fc Moved ProgramEdge out out include/.../Analysis/PathSensitive to include/.../Analysis, as it is now used by the FlowSensitive subsystem as well.
Removed "Edge" nested class by CFG, as it is now subsumed by ProgramEdge.

Adjusted DataflowSolver and DataflowValues to use ProgramEdges instead
of CFG::Edge.

llvm-svn: 42534
2007-10-02 17:12:02 +00:00
Gordon Henriksen
da5d5b57bf Regenerate.
llvm-svn: 42533
2007-10-02 16:42:22 +00:00
Gordon Henriksen
3be1f10097 Providing --with-ocaml-libdir for ./configure. The default is the
stdlib if it's beneath --prefix, and is libdir/ocaml otherwise.

If someone has a better way than this to test whether $B is a path
within $A, I'd love to hear it:

  if test "$A" \< "$B" -a "$B" \< "${A}~"

llvm-svn: 42532
2007-10-02 16:42:10 +00:00
Fariborz Jahanian
89b8ef92be This patch introduces the ObjcCategoryImplDecl class and does the checking related to
unimplemented methods in category implementation.

llvm-svn: 42531
2007-10-02 16:38:50 +00:00
Ted Kremenek
a6d930a925 Added DenseMapInfo traits for ProgramEdges
llvm-svn: 42530
2007-10-02 16:38:05 +00:00
Gordon Henriksen
acc2a838fa Regenerate.
llvm-svn: 42529
2007-10-02 10:14:42 +00:00
Gordon Henriksen
61400d1192 Fixing (harmless) typos.
llvm-svn: 42528
2007-10-02 10:14:32 +00:00
Gordon Henriksen
e61dd67a2b Regenerate.
llvm-svn: 42527
2007-10-02 09:50:32 +00:00
Gordon Henriksen
d48f4598a4 Add explicit --enable-bindings option to configure.
llvm-svn: 42526
2007-10-02 09:50:18 +00:00
Steve Naroff
b6c0518d11 Use Identifier::getLength() instead of strlen() in Selector::getName() and MultiKeywordSelector::getName().
llvm-svn: 42524
2007-10-02 02:01:22 +00:00
Devang Patel
18c2fa7225 Fix test.
llvm-svn: 42522
2007-10-02 00:47:43 +00:00
Owen Anderson
888477339e Fix typo.
llvm-svn: 42521
2007-10-02 00:44:20 +00:00
Owen Anderson
d263cfa1c0 Mention memdep in the AA documentation.
llvm-svn: 42519
2007-10-02 00:43:25 +00:00
Devang Patel
0d4958f1b0 New test.
llvm-svn: 42517
2007-10-02 00:39:19 +00:00
Hartmut Kaiser
9f4dee8973 Added a missing #include.
llvm-svn: 42516
2007-10-02 00:36:52 +00:00
Tanya Lattner
cf316c2eb7 If the user did not check out LLVM and request it to be built, it should be a build error. This relies on the user having a successful build of LLVM, but the tests will fail if they dont.
llvm-svn: 42514
2007-10-02 00:19:27 +00:00
Steve Naroff
bf81db14c5 Add comment to ObjcClassDecl.
Move ObjcClassDecl to be next to ObjcForwardProtocolDecl. Since they are very similar, might want to unify their names (e.g. ObjcForwardClassDecl).
Change indentation of ObjcForwardProtocolDecl to conform to everything else in DeclObjC.h.

llvm-svn: 42513
2007-10-02 00:10:42 +00:00
Hartmut Kaiser
587cc42864 Updated VC++ build system.
llvm-svn: 42512
2007-10-01 23:57:52 +00:00
Evan Cheng
1f79ba6fe6 Refactor code to add load / store folded instructions -> register only
instructions reverse map.

llvm-svn: 42509
2007-10-01 23:44:33 +00:00
Dale Johannesen
b6c05b1f90 Fix stride computations for long double arrays.
llvm-svn: 42508
2007-10-01 23:08:35 +00:00
Steve Naroff
e5e25fae1d Add comments for ObjC Decl's.
Removed a constructor that was #if 0's out.
Added a FIXME for fariborz...categories shouldn't inherit from ScopedDecl.

llvm-svn: 42507
2007-10-01 22:54:34 +00:00
Dan Gohman
9765cc3bbb Move the code that emits the .file directives so that it runs after the
SourceFiles list is fully filled in so that it sees all of the files.

llvm-svn: 42506
2007-10-01 22:40:20 +00:00
Evan Cheng
89ca5b091f -pre-RA-sched=none, simple, simple-noitin are gone.
llvm-svn: 42505
2007-10-01 22:17:20 +00:00
Devang Patel
e595d107e6 PR 1603 test case.
llvm-svn: 42502
2007-10-01 21:22:57 +00:00
Evan Cheng
a3a67596f6 Remove simple scheduler.
llvm-svn: 42499
2007-10-01 20:44:07 +00:00
Ted Kremenek
fb4750b639 Migrated LiveVariables and UninitializedVariables to now use the
tracked BlkExpr information now maintained by the CFG class.

llvm-svn: 42498
2007-10-01 20:33:52 +00:00
Ted Kremenek
f2d4372ba9 CFG objects now internally store a (lazily created) map from block-level
expressions to IDs.  This is used by various dataflow analyses, but is
also useful for anyone querying a CFG to determine where an expression
is evaluated.

llvm-svn: 42495
2007-10-01 19:33:33 +00:00
Steve Naroff
67391b8a54 Move ObjC decls to DeclObjC.h, a new AST header.
Update clients and add to project file.

llvm-svn: 42494
2007-10-01 19:00:59 +00:00
Devang Patel
2a60ff1aeb Relax unsafe use check. If there is one unconditional use inside the loop then it is safe to promote value even if there is another conditional use inside the loop.
llvm-svn: 42493
2007-10-01 18:12:58 +00:00
Evan Cheng
a1b7e95039 Typo. X86comi doesn't read / write chain's.
llvm-svn: 42492
2007-10-01 18:12:48 +00:00
Fariborz Jahanian
ebb34d7141 Moved two bitfields back to top of class ObjcMethodDecl so they pack
with those in their base class. In response to clattner's 
September 30, 2007 12:54:49 AM PDT email.

llvm-svn: 42491
2007-10-01 17:19:59 +00:00
Fariborz Jahanian
f26702eb54 Took care of clatter's suggestions, dated.
September 30, 2007 12:36:58 AM PDT and
September 30, 2007 12:50:05 AM PDT

llvm-svn: 42490
2007-10-01 16:53:59 +00:00
Ted Kremenek
7f74e13535 Removed "hasImplicitControlFlow" from class CFG, and moved it to class Stmt
as a member function.  This function is no longer needed within the CFG
class, and logically belongs to the Stmt class as a predicate for a
Stmt instance.

llvm-svn: 42489
2007-10-01 16:34:52 +00:00
Dale Johannesen
28e19a48ce Add getABITypeSize, getABITypeSizeInBits
llvm-svn: 42488
2007-10-01 16:03:14 +00:00
Dan Gohman
9b943453f5 Add empty() member functions to a few container-like classes.
llvm-svn: 42487
2007-10-01 16:01:23 +00:00
Dale Johannesen
c0855f8a88 remove dup comment
llvm-svn: 42486
2007-09-30 19:08:12 +00:00
Fariborz Jahanian
a725bf7782 Unused ObjcProtoMethod is removed.
llvm-svn: 42485
2007-09-30 18:53:32 +00:00
Dale Johannesen
9150652b21 Constant fold int-to-long-double conversions;
use APFloat for int-to-float/double; use
round-to-nearest for these (implementation-defined,
seems to match gcc).

llvm-svn: 42484
2007-09-30 18:19:03 +00:00
Dale Johannesen
28a2c4a9c4 Simplify and fix signed int -> FP conversions.
llvm-svn: 42483
2007-09-30 18:17:01 +00:00
Gordon Henriksen
0b7cf862bc AsmPrinters overriding getAnalysisUsage should call super.
And not super's super, either.

llvm-svn: 42482
2007-09-30 13:39:29 +00:00
Chris Lattner
2b6abdce50 Add a new getLength() method to IdentifierInfo, which relies on a newly added
method to StringMapEntry.  Steve, please use this to remove the
strlen calls in selector processing.

llvm-svn: 42481
2007-09-30 08:32:27 +00:00
Chris Lattner
b06396c588 Add a helper useful when mapping from a map element to its hash node.
llvm-svn: 42480
2007-09-30 08:31:46 +00:00
Chris Lattner
6c44b9f145 Fix a bug I just introduced.
llvm-svn: 42479
2007-09-30 08:31:00 +00:00
Chris Lattner
90c26ba9de improve comment.
llvm-svn: 42478
2007-09-30 08:13:22 +00:00
Chris Lattner
4730430bd8 simplify an expression
llvm-svn: 42477
2007-09-30 08:01:04 +00:00
Owen Anderson
46ade4eb9b Template-ize more of the DomTree internal implementation details. Only the calculate() methods for DomTree and PostDomTree remain to be merged/template-ized.
llvm-svn: 42476
2007-09-30 04:17:16 +00:00
Chris Lattner
bd0079c603 document DenseSet.
llvm-svn: 42475
2007-09-30 00:58:59 +00:00
Chris Lattner
18a9273e61 Add a new DenseSet abstraction.
llvm-svn: 42474
2007-09-30 00:47:20 +00:00
Fariborz Jahanian
0886d252d7 This patch fixes all issues mentioned in clattner's feedback of
September 28, 2007 4:39:24 PM PDT
Please let me know if I missed anything.

llvm-svn: 42473
2007-09-29 18:24:58 +00:00
Fariborz Jahanian
ec7b3333e1 Code clean up. Moved couple of static functions to be private members of Sema class.
Avoiding passing a Sema object to these utility functions.

llvm-svn: 42472
2007-09-29 17:14:55 +00:00
Fariborz Jahanian
fa0667b547 Patch to remove use of has table for protocol name lookup. This patch mirrors my
previous patch to do the same for class name lookup using a hash table.

llvm-svn: 42471
2007-09-29 17:04:06 +00:00
Duncan Sands
7b908dda92 Add newline at end of file.
llvm-svn: 42470
2007-09-29 16:38:37 +00:00
Duncan Sands
f72ff0c379 Check that the second parameter of init_trampoline
can be resolved to a function.  This is required
for codegen and used by instcombine.

llvm-svn: 42469
2007-09-29 16:25:54 +00:00
Gordon Henriksen
f5aa229ede This is done already.
llvm-svn: 42467
2007-09-29 02:23:08 +00:00
Gordon Henriksen
37ca83d4e9 Collector is the base class for garbage collection code generators.
This version enhances the previous patch to add root initialization
as discussed here:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070910/053455.html

Collector gives its subclasses control over generic algorithms:

  unsigned NeededSafePoints; //< Bitmask of required safe points.
  bool CustomReadBarriers;   //< Default is to insert loads.
  bool CustomWriteBarriers;  //< Default is to insert stores.
  bool CustomRoots;          //< Default is to pass through to backend.
  bool InitRoots;            //< If set, roots are nulled during lowering.

It also has callbacks which collectors can hook:

  /// If any of the actions are set to Custom, this is expected to
  /// be overriden to create a transform to lower those actions to
  /// LLVM IR.
  virtual Pass *createCustomLoweringPass() const;

  /// beginAssembly/finishAssembly - Emit module metadata as
  /// assembly code.
  virtual void beginAssembly(Module &M, std::ostream &OS,
                             AsmPrinter &AP,
                             const TargetAsmInfo &TAI) const;
  virtual void finishAssembly(Module &M,
                              CollectorModuleMetadata &CMM,
                              std::ostream &OS, AsmPrinter &AP,
                              const TargetAsmInfo &TAI) const;  

Various other independent algorithms could be implemented, but were
not necessary for the initial two collectors. Some examples are
listed here:

http://llvm.org/docs/GarbageCollection.html#collector-algos

llvm-svn: 42466
2007-09-29 02:13:43 +00:00
Gordon Henriksen
6547e5a2bc Demoting CHelpers.h to include/llvm/Support.
llvm-svn: 42465
2007-09-29 01:38:42 +00:00
Fariborz Jahanian
343f7098db Removed use of hash table for class decls and do a name look up directly.
There is still an issue if doing ScopedLookup is an overkill and we can
just access the decl using the identifier.

llvm-svn: 42463
2007-09-29 00:54:24 +00:00
Daniel Berlin
342181c51d Switch to densemap rather than std::set
llvm-svn: 42462
2007-09-29 00:50:40 +00:00
Gordon Henriksen
2717f3bd60 Regenerate.
llvm-svn: 42461
2007-09-29 00:42:56 +00:00
Gordon Henriksen
da70a73f28 PR1601: etags not configured correctly
Resolving this by deleting vestigal etags remnants.

llvm-svn: 42460
2007-09-29 00:42:21 +00:00
Evan Cheng
5fb5a1f389 Enabling new condition code modeling scheme.
llvm-svn: 42459
2007-09-29 00:00:36 +00:00
Devang Patel
f96df8d777 Do not ignore packed member size while selecting union type.
llvm-svn: 42458
2007-09-28 23:54:26 +00:00
Dan Gohman
a90183e7d1 Teach SplitVectorOp how to split INSERT_VECTOR_ELT.
llvm-svn: 42457
2007-09-28 23:53:40 +00:00
Steve Naroff
92866f4fbb Add some comments to MultiKeywordSelector, make all methods private, add a friend, move some methods around.
llvm-svn: 42456
2007-09-28 23:39:26 +00:00
Ted Kremenek
1b61261a25 Added ProgramEdge.h, which defines ProgramEdge (and subclasses) that
encapsulate a program point within a CFG for use by our path-sensitive
dataflow solver.

llvm-svn: 42455
2007-09-28 23:15:21 +00:00
Tanya Lattner
586eb8ee47 Update how to release document.
Add release version to getting started guide.

llvm-svn: 42454
2007-09-28 22:50:54 +00:00
Evan Cheng
a5e595d23a If two instructions are both two-address code, favors (schedule closer to
terminator) the one that has a CopyToReg use. This fixes
2006-05-11-InstrSched.ll with -new-cc-modeling-scheme.

llvm-svn: 42453
2007-09-28 22:32:30 +00:00
Steve Naroff
8017506d9c Yesterday I discovered that 78% of all selectors in "Cocoa.h" take 0/1 argument.
This motivated implementing a devious clattner inspired solution:-)

This approach uses a small value "Selector" class to point to an IdentifierInfo for the 0/1 case. For multi-keyword selectors, we instantiate a MultiKeywordSelector object (previously known as SelectorInfo). Now, the incremental cost for selectors is only 24,800 for Cocoa.h! This saves 156,592 bytes, or 86%!! The size reduction is also the result of getting rid of the AST slot, which was not strictly necessary (we will associate a selector with it's method using another table...most likely in Sema).

This change was critical to make now, before we have too many clients.

I still need to add some comments to the Selector class...will likely add later today/tomorrow.

llvm-svn: 42452
2007-09-28 22:22:11 +00:00
Devang Patel
8ec4f837fa Do not codegen dummy block.
Dummy block is an empty block with no predecessors.

llvm-svn: 42451
2007-09-28 21:49:18 +00:00
Ted Kremenek
14851c3de3 Fixed bug where assignments to variables wrapped in parentheses would not
properly kill variables.  e.g:

(x) = 1;

llvm-svn: 42450
2007-09-28 21:29:33 +00:00
Ted Kremenek
a1c256dd0e Fixed UninitializedValues to properly propagate uninitialized "taint"
in assignment operations of the form +=, -=, *=, etc.

llvm-svn: 42449
2007-09-28 21:08:51 +00:00
Chris Lattner
8861abe6f2 really fix PR1581, thanks to Daniel Dunbar for pointing
this out.

llvm-svn: 42448
2007-09-28 20:50:50 +00:00
Ted Kremenek
a6ef56e6d2 DeadStores no longer reports warnings for stores to non-local variables.
llvm-svn: 42447
2007-09-28 20:48:41 +00:00
Ted Kremenek
0064ff47e6 Significant cleanups and bug-fixes to LiveVariables. Uses new refactored
ExprDeclBitVector class for defining dataflow state.

llvm-svn: 42446
2007-09-28 20:38:59 +00:00
Ted Kremenek
254c126c15 Refactored ExprDeclBitVector into two classes:
DeclBitVector
 ExprDeclBitVector (which subclasses the former)

DeclBitVector is for analyses that just want to track bitvector state
for declarations.

ExprDeclBitVector is for analyses that want to track bitvector state
for both both declarations and CFGBlock-level expressions.

llvm-svn: 42445
2007-09-28 20:12:10 +00:00
Chris Lattner
2be9ec5c91 Make Value::getNameLen not crash on an empty name, fixing PR1712.
llvm-svn: 42444
2007-09-28 20:09:40 +00:00
Evan Cheng
f72693f36e Remove a poor scheduling heuristic.
llvm-svn: 42443
2007-09-28 19:37:35 +00:00
Evan Cheng
038dcc5136 Trim some unneeded fields.
llvm-svn: 42442
2007-09-28 19:24:24 +00:00
Dale Johannesen
03d4ad9f03 Record latest work.
llvm-svn: 42441
2007-09-28 18:46:28 +00:00
Dale Johannesen
789b5a505b Fix long double -> uint64 conversion.
llvm-svn: 42440
2007-09-28 18:44:17 +00:00
Dale Johannesen
6bf69ed3cc minor long double related changes
llvm-svn: 42439
2007-09-28 18:06:58 +00:00
Ted Kremenek
483e305210 Fixed bug where declaration initializer expressions were not
traversed by the visitor.

llvm-svn: 42438
2007-09-28 17:55:50 +00:00
Ted Kremenek
07eff9a2fe Added iterator mechanism to iterator over the decls and expressions
tracked by an ExprDeclBitVector analysis.

llvm-svn: 42437
2007-09-28 17:55:22 +00:00
Fariborz Jahanian
b75db4cc8c Patch to warn on umimplemented methods coming from class's
protocols.

llvm-svn: 42436
2007-09-28 17:40:07 +00:00
Dan Gohman
25d506c41b Make the checks for DW_FORM_data4 consistent with the others, and
add more such code for DIEDwarfLabel::SizeOf and DIEObjectLabel::SizeOf.

llvm-svn: 42435
2007-09-28 16:50:28 +00:00
Dan Gohman
0d23d63b9e Use 32-bit data directives for DW_FORM_data4 format data, even on
targets with 64-bit addresses.

llvm-svn: 42434
2007-09-28 15:43:33 +00:00
Rafael Espindola
6c04ac1db0 Refactor the memcpy lowering for the x86 target.
The only generated code difference is that now we call memcpy when
the size of the array is unknown. This matches GCC behavior and is
better since the run time value can be arbitrarily large.

llvm-svn: 42433
2007-09-28 12:53:01 +00:00
Evan Cheng
1f516560d1 Stop inventing new words. :-)
llvm-svn: 42429
2007-09-28 01:35:02 +00:00
Owen Anderson
d0d5c11d18 Remove unneeded #include.
llvm-svn: 42428
2007-09-28 01:25:07 +00:00
Owen Anderson
0fbef94cd0 Have PostDomTree use the newly templated DFSPass.
llvm-svn: 42427
2007-09-28 01:23:47 +00:00
Evan Cheng
edfc5b2204 Pessimisively assume ADJCALLSTACKDOWN / ADJCALLSTACKUP (which becomes sub / add) clobbers EFLAGS.
llvm-svn: 42426
2007-09-28 01:19:48 +00:00
Dale Johannesen
25a00a63eb Add sqrt and powi intrinsics for long double.
llvm-svn: 42423
2007-09-28 01:08:20 +00:00
Dale Johannesen
1d1d0e7735 Don't do SRA for unions with long double fields.
Fixes a SWB crash.

llvm-svn: 42422
2007-09-28 00:21:38 +00:00
Ted Kremenek
f91d1c92ba Fixed several bugs in the propagation of "uninitialized value"
taintness across expressions.

Made "smart-culling" of taint propagation (for error reporting)
correctly handle conditional expressions and a few other edge cases.

llvm-svn: 42421
2007-09-28 00:09:38 +00:00
Owen Anderson
ee73e0b8cb Convert DFSPass into a templated friend function, in preparation for making it common to DomTree and PostDomTree.
llvm-svn: 42420
2007-09-27 23:23:00 +00:00
Dan Gohman
a1d46c7d0a TargetAsmInfo::getAddressSize() was incorrect for x86-64 and 64-bit targets
other than PPC64. Instead of fixing it, just remove it and fix all the
places that use it to use TargetData::getPointerSize() instead, as there
aren't very many. Most of the references were in DwarfWriter.cpp.

llvm-svn: 42419
2007-09-27 23:12:31 +00:00
Gordon Henriksen
613afce430 CollectorMetadata abstractly describes stack maps for a function.
It includes:

 - location and of each safe point in machine code (identified by a
   label)
 - location of each root within the stack frame (identified by an
   offset), including the metadata tag provided to llvm.gcroot in
   the user program
 - size of the stack frame (for collectors which want to cheat on
   stack crawling :)
 - and eventually will include liveness

It is to be populated by back-ends during code-generation.

CollectorModuleMetadata aggregates this information across the
entire module.

llvm-svn: 42418
2007-09-27 22:18:46 +00:00
Evan Cheng
99dc695da5 Use GR64 in 64-bit mode.
llvm-svn: 42417
2007-09-27 21:50:05 +00:00
Fariborz Jahanian
fa80e80da9 Patch to use case-stmt for keywords used as selectgor names.
llvm-svn: 42416
2007-09-27 19:52:15 +00:00
Gordon Henriksen
658c57eb66 My previous Registry.h header, as well as Collectors.h, which is the
registry for dynamically-loaded garbage collection compiler plugins.

llvm-svn: 42415
2007-09-27 19:34:27 +00:00
Gordon Henriksen
0076a6727e GarbageCollection.html is expanded to encompass the coming
capabilities. This is a major rewrite and is easier to read en toto
rather than patchwise.

llvm-svn: 42414
2007-09-27 19:31:36 +00:00
Evan Cheng
5a71402be6 Doh. Calls clobber EFLAGS.
llvm-svn: 42413
2007-09-27 19:01:55 +00:00
Fariborz Jahanian
f6546b38b2 Patch for method implementation. It populates ObjcImplementationDecl object with method implementation declarations .
It checks and warns on those methods declared in class interface and not implemented.

llvm-svn: 42412
2007-09-27 18:57:03 +00:00
Steve Naroff
65ca537b55 Fix bug in SelectorInfo::getName() - method buffer needs to be passed by reference.
llvm-svn: 42411
2007-09-27 18:52:21 +00:00
Evan Cheng
e6f92253f5 Avoid inserting a live register more than once.
llvm-svn: 42410
2007-09-27 18:46:06 +00:00
Ted Kremenek
b9ce295b0a Created new "ExprDeclBitVector" type bundle for dataflow analyses that need boolean
values associated with ScopedDecls and CFGBlock-level Exprs.  This is the common
boilerplate needed by UninitializedValues and LiveVariables.

Refactored UninitializedValues to use ExprDeclBitVector.

Shortened the string diagnostic for UninitializedValues.

llvm-svn: 42408
2007-09-27 18:20:22 +00:00
Tanya Lattner
0d675ee06e Couple of fixes to mention bunzip2 and make instructions more clear.
llvm-svn: 42407
2007-09-27 18:14:33 +00:00
Devang Patel
f68d3e1a0d While searching for appropriate place for temporaries, do not over-incerement iterator.
llvm-svn: 42406
2007-09-27 18:02:47 +00:00
Devang Patel
11611f876e Mention Loop Index Split
llvm-svn: 42405
2007-09-27 17:32:04 +00:00
Chris Lattner
d2bc9d8c77 new testcase for PR1708
llvm-svn: 42398
2007-09-27 15:47:16 +00:00
Daniel Berlin
a447de7065 Ignore redundant constraints
llvm-svn: 42397
2007-09-27 15:42:23 +00:00
Chris Lattner
cc61bf5e0c Fix some use of uninit variables issues, reported by Anton.
llvm-svn: 42396
2007-09-27 15:15:46 +00:00
Steve Naroff
f73590dbb1 Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits:
#1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable.

#2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%.

#3: It results in many API simplifications. Here are some highlights:

- Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages).
- Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo).
- Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured).

I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later.

Thanks to Chris for talking this through with me and suggesting this approach. 

llvm-svn: 42395
2007-09-27 14:38:14 +00:00
Nick Lewycky
3934961878 Build the correct range for loops with unusual bounds. Fix from Jay Foad.
llvm-svn: 42394
2007-09-27 14:12:54 +00:00
Bill Wendling
c9a8c74d28 No, really, it *is* SSSE3. ;-)
llvm-svn: 42393
2007-09-27 08:47:31 +00:00
Duncan Sands
a1779909ff SSSE3 -> SSE3. Reported by Alex Kellett.
llvm-svn: 42392
2007-09-27 08:24:36 +00:00
Duncan Sands
2f060736e2 Grammer fix reported by Alex Kellett.
llvm-svn: 42391
2007-09-27 08:24:02 +00:00
Evan Cheng
75439b3b78 Silence a compiler warning.
llvm-svn: 42389
2007-09-27 07:35:39 +00:00
Evan Cheng
bde499be60 Boogs.
llvm-svn: 42388
2007-09-27 07:29:27 +00:00
Evan Cheng
1ec79b41db Be smarter about which node to force schedule. Reduce # of duplications + copies; Added statistics.
llvm-svn: 42387
2007-09-27 07:09:03 +00:00
Gordon Henriksen
eb42c4e221 Remove debugging.
llvm-svn: 42385
2007-09-27 02:47:27 +00:00
Evan Cheng
cfd5f82890 Backtracking only when it won't create a cycle.
llvm-svn: 42384
2007-09-27 00:25:29 +00:00
Dale Johannesen
34aa41c475 Make temporaries explicit to avoid premature
destruction of compiler-created ones.

llvm-svn: 42383
2007-09-26 23:20:33 +00:00
Gordon Henriksen
43b66447f4 Updating LLVM.xcodeproj.
llvm-svn: 42382
2007-09-26 22:44:45 +00:00
Chris Lattner
e6d9ca5443 objc messages have side effects, return true from hasLocalSideEffect,
fixing:

VoidMethod.m:14:5: warning: expression result unused
    [Greeter hello];
    ^~~~~~~~~~~~~~~

llvm-svn: 42380
2007-09-26 22:06:30 +00:00
Evan Cheng
478134e5f4 Oops. Forgot this.
llvm-svn: 42377
2007-09-26 21:38:03 +00:00
Ted Kremenek
d80ee7d287 Added extra guard for null Stmt* when traversing the AST using VisitChildren.
Added assertion that Block-level statements should not be NULL.

llvm-svn: 42376
2007-09-26 21:36:20 +00:00
Evan Cheng
8e136a9dc4 - Move getPhysicalRegisterRegClass() from ScheduleDAG to MRegisterInfo.
- Added ability to emit cross class register copies to the BBRU scheduler.
- More aggressive backtracking.

llvm-svn: 42375
2007-09-26 21:36:17 +00:00
Neil Booth
0fa3ea79ac Whitespace cleanup.
llvm-svn: 42374
2007-09-26 21:35:05 +00:00
Neil Booth
9acbf5aaf9 Whitespace and compiler warning cleanup.
llvm-svn: 42373
2007-09-26 21:33:42 +00:00
Evan Cheng
8728c3376a - Added MRegisterInfo::getCrossCopyRegClass() hook. For register classes where reg to reg copies are not possible, this returns another register class which registers in the specified register class can be copied to (and copy back from).
- X86 copyRegToReg() now supports copying between EFLAGS and GR32 / GR64 registers.

llvm-svn: 42372
2007-09-26 21:31:07 +00:00
Evan Cheng
b93de587cb Some assemblers do not recognize aliases pushfd, pushfq, popfd, and popfq. Just emit them as pushf and popf.
llvm-svn: 42371
2007-09-26 21:28:00 +00:00
Ted Kremenek
5c50fd1add Fixed two bugs in CFG construction:
BUG 1) 

CFG failed to build for empty functions, or functions containing only
NullStmts or empty compound statements.

We now handle such cases, although now we cannot test for CFG
construction failure by asserting that the last block constructed is
not NULL (since it now may be).

BUG 2)

CFG construction segfaulted on some cases when walking the AST and not
taking into account that some children of a statement may be NULL.

llvm-svn: 42370
2007-09-26 21:23:31 +00:00
Dale Johannesen
b805d35d16 Modernize fabs.ll, add long double. Add tests
for direct codegen of fsin/fcos.

llvm-svn: 42369
2007-09-26 21:12:10 +00:00
Dale Johannesen
b6d56401aa Enable codegen for long double abs, sin, cos
llvm-svn: 42368
2007-09-26 21:10:55 +00:00
Gordon Henriksen
c23b66c58b Added C and Ocaml bindings for functions, basic blocks, and
instruction creation. No support yet for instruction introspection.

Also eliminated allocas from the Ocaml bindings for portability,
and avoided unnecessary casts.

llvm-svn: 42367
2007-09-26 20:56:12 +00:00
Ted Kremenek
0883fd5817 Removed option "-parse-ast-check" from clang driver. This is now implemented
using "-parse-ast -verify".

Updated all test cases (using a sed script) that invoked -parse-ast-check to
now use -parse-ast -verify.

Fixed a bug where using "-verify" instead of "-parse-ast-check" would not
correctly create the DiagClient needed to accumulate diagnostics.

llvm-svn: 42365
2007-09-26 20:14:22 +00:00
Ted Kremenek
a054c5bedd Moved "VerifyDiagnostics" variable declaration to right below ProgAction
declaration.  This is because this option is logically tightly connected
to the actions defined in ProgAction.

llvm-svn: 42364
2007-09-26 19:42:19 +00:00
Ted Kremenek
cbd2af8a0a Removed inclusion of <memory>, which is no longer needed since we
aren't used auto_ptr's anymore.

llvm-svn: 42363
2007-09-26 19:41:07 +00:00
Ted Kremenek
8742a45565 Refactored driver so that any action that is implemented using an
ASTConsumer can also be verified using the diagnostics checker.  From
the command line, users may activate diagnostic checking using the
"-verify" option.  For example, "clang -verify -warn-dead-stores"
checks if the warnings flagged by the dead store checker match those
in the comments.

Note that we still have the option "-parse-ast-check" for backwards
comptability with existing test cases.  This option is now equivalent to 
"-parse-ast -verify".

llvm-svn: 42362
2007-09-26 18:39:29 +00:00
Fariborz Jahanian
2a4dd316a0 This patch inserts ivars declared in @implementation in its object and verifies
that they conform(in type, name and numbers) to those declared in @interface. 
Test case highlights kind of checking we do here.

llvm-svn: 42360
2007-09-26 18:27:25 +00:00
Dale Johannesen
f04d37d3a9 Fix f80 UNDEF.
llvm-svn: 42359
2007-09-26 17:26:49 +00:00
Fariborz Jahanian
19529eec8a Removed a few TODOs on things which are done.
llvm-svn: 42358
2007-09-26 17:03:44 +00:00
Duncan Sands
755d9306a3 X86 -> X86-32 in appropriate places.
llvm-svn: 42357
2007-09-26 16:24:52 +00:00
Duncan Sands
47fc0a2a5f Various cleanups. Especially, EH is turned on by default!
llvm-svn: 42356
2007-09-26 15:59:54 +00:00
Chris Lattner
f13af33221 ok ok we get it. CBE and vectors don't like each other yet.
llvm-svn: 42355
2007-09-26 15:50:21 +00:00
Chris Lattner
4480f42166 be less redundantly redundant.
llvm-svn: 42354
2007-09-26 15:48:33 +00:00
Duncan Sands
0bcbceb647 Test the C front-end, not the C++ front-end.
llvm-svn: 42350
2007-09-26 07:28:20 +00:00
Chris Lattner
31d319dce7 make old crappy browsers produce less crappy output :)
llvm-svn: 42349
2007-09-26 06:38:59 +00:00
Evan Cheng
b4b352656a Typos: POPQ -> POPFQ, POPD -> POPFD.
llvm-svn: 42348
2007-09-26 06:38:29 +00:00
Chris Lattner
c9e7b8ec50 move PR1160 here.
llvm-svn: 42347
2007-09-26 06:29:31 +00:00
Evan Cheng
c1e4e3743b Allow copyRegToReg to emit cross register classes copies.
Tested with "make check"!

llvm-svn: 42346
2007-09-26 06:25:56 +00:00
Chris Lattner
fef69f5b4a move PR1264 here.
llvm-svn: 42345
2007-09-26 06:15:48 +00:00
Chris Lattner
d0382a8550 noone uses etags. Connected to PR1601
llvm-svn: 42344
2007-09-26 06:10:47 +00:00
Chris Lattner
828eb3b91f we support attribute(noinline) now :)
llvm-svn: 42343
2007-09-26 06:04:15 +00:00
Chris Lattner
8e06116b8a update bugs list
llvm-svn: 42342
2007-09-26 06:01:35 +00:00
Chris Lattner
4734a358fd now with more prose.
llvm-svn: 42341
2007-09-26 05:44:21 +00:00
Duncan Sands
9b626f0ada Test that local variables are aligned as the user requested.
llvm-svn: 42338
2007-09-26 04:04:29 +00:00
Evan Cheng
0a6f47cff9 Add pushf{d|q}, popf{d|q} to push and pop EFLAGS register.
llvm-svn: 42335
2007-09-26 01:29:06 +00:00
Chris Lattner
f7ab334803 Handle (int)1.0e40 as an i-c-e.
llvm-svn: 42334
2007-09-26 00:47:26 +00:00
Evan Cheng
9b7f0e6eb4 translateX86CC updates the last two operands.
llvm-svn: 42333
2007-09-26 00:45:55 +00:00
Anton Korobeynikov
e291f727e3 Correctly restore stack pointer after realignment in main() on Cygwin/Mingw32
llvm-svn: 42332
2007-09-26 00:13:34 +00:00
Daniel Berlin
08f8188adc Fix small bug in operator== for iterators
llvm-svn: 42331
2007-09-26 00:11:59 +00:00
Hartmut Kaiser
fcecf23d48 Updated VC++ build system.
llvm-svn: 42330
2007-09-25 23:32:45 +00:00
Dale Johannesen
17663f40b9 Remove no-longer-used variable.
llvm-svn: 42329
2007-09-25 23:32:20 +00:00
Dale Johannesen
e7439eff5a Make APFloat->int conversions deterministic even in
cases with undefined behavior.

llvm-svn: 42328
2007-09-25 23:07:07 +00:00
Ted Kremenek
a88f7bcea3 Updated XCode project to reflect that DataflowValues.h and DataflowSolver.h have
moved to include/clang/Analysis/FlowSensitive.

llvm-svn: 42327
2007-09-25 22:45:38 +00:00
Chris Lattner
ccc1b69a52 explain why not vector<bool>
llvm-svn: 42324
2007-09-25 22:37:50 +00:00
Evan Cheng
5321fa44f4 Missing load / store folding entries.
llvm-svn: 42323
2007-09-25 22:10:43 +00:00
Anton Korobeynikov
90910745bb Partly revert invalid r41774
llvm-svn: 42322
2007-09-25 21:52:30 +00:00
Ted Kremenek
39fc60f280 Moved "DataflowSolver.h" to the "include/" subtree. Adjusted client
code that uses the solver to reflect the new location.

Created "FlowSensitive" subdirectory in include/clang/Analysis to hold
header files relating to flow-sensitive analyses.  Moved
"DataflowValues.h" into this subdirectory.

llvm-svn: 42320
2007-09-25 21:00:24 +00:00
Fariborz Jahanian
e2017c1d1d Patch to make ObjcImplementationDecl derived from TypeDecl and supprt legacy
objective-c code with no @interface declaration.

llvm-svn: 42319
2007-09-25 21:00:20 +00:00
Bill Wendling
982d57da39 Grammar fix.
llvm-svn: 42318
2007-09-25 20:45:10 +00:00
Ted Kremenek
9c3fe8d2e8 Fixed broken English in comment.
llvm-svn: 42317
2007-09-25 20:37:28 +00:00
Dan Gohman
57211c5550 More explicit keywords.
llvm-svn: 42316
2007-09-25 20:27:06 +00:00
Duncan Sands
384f4bd878 Add a newline to the end of this file.
llvm-svn: 42314
2007-09-25 20:08:48 +00:00
Dan Gohman
06919e8ef2 Fix a typo in a comment.
llvm-svn: 42313
2007-09-25 19:37:26 +00:00
Evan Cheng
8ee1ecfc50 New style x87 cmp instructions.
llvm-svn: 42312
2007-09-25 19:08:02 +00:00
Fariborz Jahanian
bfe13c566c This patch introduces a new class to keep track of class implementation info. It also adds more
semantic checks for class and protocol declarations. Test cases are good indications of kind of 
checking being done in this patch.

llvm-svn: 42311
2007-09-25 18:38:09 +00:00
Ted Kremenek
558be36672 Added "CheckASTConsumer", a function that generalizes
"CheckDiagnostics" (used for -parse-ast-check) to check the
diagnostics of any ASTConsumer.

Reimplemented CheckDiagnostics to use CheckASTConsumer instead.

Added driver option -warn-dead-stores-check, which checks the
diagnostics generated by the DeadStores checker.  This is implemented
using CheckASTConsumer.111

llvm-svn: 42310
2007-09-25 18:37:20 +00:00
Devang Patel
7bba386f72 Handle multiple induction variables.
This fixes PR714.

llvm-svn: 42309
2007-09-25 18:24:48 +00:00
Dan Gohman
31599685c7 When both x/y and x%y are needed (x and y both scalar integer), compute
both results with a single div or idiv instruction. This uses new X86ISD
nodes for DIV and IDIV which are introduced during the legalize phase
so that the SelectionDAG's CSE can automatically eliminate redundant
computations.

llvm-svn: 42308
2007-09-25 18:23:27 +00:00
Ted Kremenek
2826f6e63f Changed command line options "-check-dead-stores" and
"-check-uninit-values" to "-warn-dead-stores" and
"-warn-uninit-values"

llvm-svn: 42307
2007-09-25 18:05:45 +00:00
Devang Patel
440d13b55b Do not reserve DOM check for GetElementPtrInst.
llvm-svn: 42306
2007-09-25 17:55:50 +00:00
Ted Kremenek
2af52eb454 Comment formatting changes. No real content changes.
llvm-svn: 42305
2007-09-25 17:53:38 +00:00
Ted Kremenek
67f6ea19d7 Minor comment changes.
llvm-svn: 42304
2007-09-25 17:51:05 +00:00
Dale Johannesen
97d4bf2c41 Some tests for APFloat conversions.
llvm-svn: 42303
2007-09-25 17:50:55 +00:00
Evan Cheng
6cb71f7fe0 Forgot to check in the changes. Fix test case so it doesn't break with any scheduling changes.
llvm-svn: 42302
2007-09-25 17:47:38 +00:00
Ted Kremenek
9716d61923 Removed "EverKilled" class in DeadStores checker; it is no longer used.
llvm-svn: 42301
2007-09-25 17:47:04 +00:00
Devang Patel
5e1651d270 doh..
llvm-svn: 42300
2007-09-25 17:43:08 +00:00
Devang Patel
87d7e8ebcb Add transformation to update loop interation space. Now,
for (i=A; i<N; i++) {
  if (i < X && i > Y)
    do_something();
}

is transformed into

U=min(N,X); L=max(A,Y);
for (i=L;i<U;i++)
  do_somethihg();                            

llvm-svn: 42299
2007-09-25 17:31:19 +00:00
Dale Johannesen
4f55d9fe0f Fix long double<->shorter FP type conversions
of zero, infinity, and NaNs.

llvm-svn: 42298
2007-09-25 17:25:00 +00:00
Dan Gohman
5e1a428344 Move the setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand) and
the check to see if the assembler supports .loc from X86TargetLowering
into the superclass TargetLowering.

llvm-svn: 42297
2007-09-25 15:10:49 +00:00
Duncan Sands
4a229e908a Fix spelling.
llvm-svn: 42296
2007-09-25 13:53:22 +00:00
Hartmut Kaiser
c173edd271 Updated VC++ build system
llvm-svn: 42295
2007-09-25 13:08:03 +00:00
Duncan Sands
734b861299 Add missing end-of-file newlines.
llvm-svn: 42294
2007-09-25 07:10:01 +00:00
Ted Kremenek
ad8bce02f0 Further refactored DataflowSolver. Now most code for the solver is shared
between forward and backward analyses, with trait classes being used
to implement the key differences in operations/functionality.

Converted the LiveVariables analysis to use the generic DataflowSolver.  This,
along with removing some extra functionality that was not needed, reduced
the code for LiveVariables by over half.

Modified Driver code to handle the updated interface to LiveVariables.

Modified the DeadStores checker to handle the update interface to
LiveVariables.

Updated DataflowValues (generic ADT to store dataflow values) to also
store values for blocks.  This is used by DeadStores.  Updated some comments.

llvm-svn: 42293
2007-09-25 04:31:27 +00:00
Ted Kremenek
7e839f10cf Added extra "constness" to parameter.
llvm-svn: 42292
2007-09-25 04:30:51 +00:00
Chris Lattner
70d1faa17d use the right rounding mode.
llvm-svn: 42291
2007-09-25 04:29:44 +00:00
Ted Kremenek
ce5568f568 Added PersistentMap, an ADT that implements a map data structure that
is persistent.  Adds/removals to a PersistentMap do not result in
a map being modified, but a new map being created.  This will be useful
for path-sensitive analyses.  

The current implementation mainly makes copies to implement this
functionality.  If the map turns out to be extensively used, this
implementation will be replaced with a more efficient one that uses
data sharing (see comments in PersistentMap.h for more information).

llvm-svn: 42290
2007-09-25 04:26:20 +00:00
Owen Anderson
5d913aa357 Fill in the sections about my contributions.
llvm-svn: 42286
2007-09-25 02:10:58 +00:00
Evan Cheng
e95f391ef1 Added support for new condition code modeling scheme (i.e. physical register dependency). These are a bunch of instructions that are duplicated so the x86 backend can support both the old and new schemes at the same time. They will be deleted after
all the kinks are worked out.

llvm-svn: 42285
2007-09-25 01:57:46 +00:00
Evan Cheng
5924bf7d3b Added major new capabilities to scheduler (only BURR for now) to support physical register dependency. The BURR scheduler can now backtrace and duplicate instructions in order to avoid "expensive / impossible to copy" values (e.g. status flag EFLAGS for x86) from being clobbered.
llvm-svn: 42284
2007-09-25 01:54:36 +00:00
Evan Cheng
8a7dec736d New temporary option -new-cc-modeling-scheme to test the new cc modeling scheme.
llvm-svn: 42283
2007-09-25 01:50:04 +00:00
Evan Cheng
43686dad3d Rename keyword "modify" -> "implicit".
llvm-svn: 42282
2007-09-25 01:48:59 +00:00
Dale Johannesen
0241bb57b2 When mixing SSE and x87 codegen, it's possible to
have situations where an SSE instruction turns into
multiple blocks, with the live range of an x87
register crossing them.  To do this correctly make
sure we examine all blocks when inserting
FP_REG_KILL.  PR 1697.  (This was exposed by my
fix for PR 1681, but the same thing could happen
mixing x87 long double with SSE.)

llvm-svn: 42281
2007-09-24 22:52:39 +00:00
Bill Wendling
d40e795c19 Don't execute dump unless NDEBUG isn't defined.
llvm-svn: 42280
2007-09-24 22:43:48 +00:00
Daniel Berlin
c82c9f078a Comment fixups
llvm-svn: 42279
2007-09-24 22:20:45 +00:00
Dan Gohman
1b2156fcae Add support on x86 for having Legalize lower ISD::LOCATION to ISD::DEBUG_LOC
instead of ISD::LABEL with a manual .debug_line entry when the assembler
supports .file and .loc directives.

llvm-svn: 42278
2007-09-24 21:54:14 +00:00
Dan Gohman
3165699e4b Don't emit .debug_line header data if there aren't any lines to put in it,
such as will happen when .loc directives are used.

llvm-svn: 42277
2007-09-24 21:43:52 +00:00
Dan Gohman
9b00c07be5 Move the Asm->EOL() call for EmitDebugARanges outside the #ifdef for
consistency with the other currently empty sections.

llvm-svn: 42276
2007-09-24 21:36:21 +00:00
Dan Gohman
0baf84b2e1 Add support for emitting .file directives to set up file numbers for
use with .loc directives.

llvm-svn: 42275
2007-09-24 21:32:18 +00:00
Dan Gohman
0cc9d1b93b Merge hasDotLoc and hasDotFile into hasDotLocAndDotFile since .loc and .file
aren't really usable without each other. 

llvm-svn: 42274
2007-09-24 21:09:53 +00:00
Dale Johannesen
5026f4ba93 float->int conversion rounds toward 0. Duh.
Fixes PR1698.

llvm-svn: 42273
2007-09-24 21:06:09 +00:00
Dan Gohman
bd8331da87 Add a routine for emitting .file directives, for setting up
file numbers to use with .loc directives.

llvm-svn: 42272
2007-09-24 20:58:13 +00:00
Bruno Cardoso Lopes
6d5ada23db Added "LoadEffective" pattern to handle stack locations.
Fixed some comments

llvm-svn: 42271
2007-09-24 20:15:11 +00:00
Devang Patel
9e30e1a3be Do not promote null values because it may be unsafe to do so.
llvm-svn: 42270
2007-09-24 20:02:42 +00:00
Daniel Berlin
5d7136a1df Implement offline variable substitution in order to reduce memory
and time usage.
Fixup operator == to make this work, and add a resize method to DenseMap
so we can resize our hashtable once we know how big it should be.

llvm-svn: 42269
2007-09-24 19:45:49 +00:00
Dan Gohman
071efe28bb Fix the syntax for the .loc directive in preparation for using it.
llvm-svn: 42268
2007-09-24 19:25:06 +00:00
Daniel Berlin
d746bbd908 Add section on bit containers.
(Not the most well written stuff in the universe :P)

llvm-svn: 42267
2007-09-24 17:52:25 +00:00
Tanya Lattner
583e27d755 XFAIL for llvm-gcc4.0
llvm-svn: 42266
2007-09-24 17:14:53 +00:00
Dan Gohman
82dcfd2dab The code that used the StartLabelId label was removed, so remove the
code that creates the label too.

llvm-svn: 42265
2007-09-24 16:44:26 +00:00
Dan Gohman
6002818999 Use the correct result value type instead of using getValueType(0)
in ExpandEXTRACT_VECTOR_ELT and SplitVectorOp. This fixes an abort
in the included testcase.

llvm-svn: 42264
2007-09-24 15:54:53 +00:00
Dan Gohman
f818ccd463 Fix a typo in a comment.
llvm-svn: 42263
2007-09-24 15:50:11 +00:00
Dan Gohman
75470c3bf1 explicit keywords.
llvm-svn: 42262
2007-09-24 15:48:49 +00:00
Dan Gohman
043689cf7d Remove an unnecessary static_cast.
llvm-svn: 42261
2007-09-24 15:46:02 +00:00
Ted Kremenek
962942f7a4 Added smart pointer class "IntrusiveSPtr" that handles reference
counted objects that maintain their own internal reference count.
This smart pointer implementation is compatible with LLVM-style
down-casting (see in llvm: include/llvm/Support/Casting.h).

Implemented "RefCounted", a base class that objects that wish to be
managed using IntrusiveSPtrs can subclass.

Reference counted objects are being targeted for use in path-sensitive
dataflow analyses where managing many live objects becomes difficult.

llvm-svn: 42260
2007-09-24 06:10:20 +00:00
Chris Lattner
5b5484db63 claim that "st" is from the 80-bit register file. This causes x87-using inline
asm to die with:

ScheduleDAG.cpp:269: failed assertion `false && "Couldn't find the register class"'

instead of:
failed assertion `RegMap->getRegClass(VReg) == RC && "Register class of operand and regclass of use don't agree!"'

yay.

llvm-svn: 42259
2007-09-24 05:27:37 +00:00
Chris Lattner
d05e44e74e If we see an invalid #ifdef directive, enter a conditional compilation region
so that we don't emit an error on the #endif.  Suggestion by Neil.

llvm-svn: 42258
2007-09-24 05:14:57 +00:00
Chris Lattner
7d98b23f1a When emitting .set directives, make sure the EH and Debug labels can't conflict.
llvm-svn: 42257
2007-09-24 03:35:37 +00:00
Owen Anderson
32eed1542e Fix typo.
llvm-svn: 42256
2007-09-24 02:33:22 +00:00
Owen Anderson
4f7c390939 Merge significant portions of the DomTree and PostDomTree implementations.
The two remaining unmerged parts are DFSPass, and the Calculate().

llvm-svn: 42255
2007-09-24 02:29:29 +00:00
Dale Johannesen
acbb26f125 Just use APFloat for const / const. Fixes
-1. / -0.

llvm-svn: 42254
2007-09-24 00:32:45 +00:00
Chris Lattner
071107120c Fix for 64-bit systems.
llvm-svn: 42253
2007-09-23 23:53:07 +00:00
Hartmut Kaiser
e675ff918b Fixed VC++ bitfield to unsigned/signed sign propagation issue.
llvm-svn: 42252
2007-09-23 23:39:51 +00:00
Owen Anderson
15efb43db7 Factor the calculation details for PostDomTree out of PostDominators.cpp and
into a separate header file.

Next step: merging PostDominatorCalculation.h with DominatorCalculation.h.

llvm-svn: 42251
2007-09-23 22:21:00 +00:00
Owen Anderson
da853a400f Move DFSPass back down into DominatorTree. I need to figure out what the difference is between it
and the PostDomTree version first.

llvm-svn: 42250
2007-09-23 22:16:38 +00:00
Owen Anderson
7888658c5f Fix header.
llvm-svn: 42249
2007-09-23 21:32:55 +00:00
Owen Anderson
84c357fc26 Factor the dominator tree calculation details out into DominatorCalculation.h. This
change is not useful in and of itself, but it lays the groundwork for combining
the dominator and postdominator implementations.

Also, factor a few methods that are common to DominatorTree and PostDominatorTree
into DominatorTreeBase.  Again, this will make merging the two calculation methods
simpler in the future.

llvm-svn: 42248
2007-09-23 21:31:44 +00:00
Dale Johannesen
ae4bb05103 Implementation of +sse -sse2 has changed; add
-sse to preserve intent of this test.

llvm-svn: 42247
2007-09-23 14:58:14 +00:00
Dale Johannesen
e36c400255 Fix PR 1681. When X86 target uses +sse -sse2,
keep f32 in SSE registers and f64 in x87.  This
is effectively a new codegen mode.
Change addLegalFPImmediate to permit float and
double variants to do different things.
Adjust callers.

llvm-svn: 42246
2007-09-23 14:52:20 +00:00
Gordon Henriksen
9af2d596ed Fix srcdir <> objdir builds with ocaml 2.10. Downrev versions don't care whether
'dir' exists in 'ocamldep -I dir ...', but recent ones demand that it actually
exists.

llvm-svn: 42245
2007-09-23 13:37:44 +00:00
Chris Lattner
0af0591143 fix syntax
llvm-svn: 42242
2007-09-22 23:41:15 +00:00
Gordon Henriksen
6ab5c57663 Regenerate.
llvm-svn: 42241
2007-09-22 21:36:59 +00:00
Gordon Henriksen
54fd757f4f Fix for srcdir <> objdir builds.
Thanks Bill.

llvm-svn: 42240
2007-09-22 21:36:22 +00:00
Chris Lattner
e48195e0f3 Fix PR1679, by printing GEP indices as signed values instead of unsigned.
llvm-svn: 42239
2007-09-22 20:16:48 +00:00
Chris Lattner
322abe3573 Use the APFloat routines to evaluate FP immediates as
integer constant expressions.  The only questionable
thing is that we now reject:

void foo() {
  switch (1) {
  case (int)1.0e10000:
    ;
  }
}

with:

t.c:5:13: error: case label does not reduce to an integer constant
  case (int)1.0e10000:
       ~~~~~^~~~~~~~~

GCC accepts this, emitting the pedwarn:
t.c:5: warning: floating constant exceeds range of 'double'

llvm-svn: 42238
2007-09-22 19:04:13 +00:00
Chris Lattner
9da7bc110a add comments.
llvm-svn: 42237
2007-09-22 18:48:32 +00:00
Chris Lattner
2dd003e807 further apfloat'ize the front-end, allowing codegen to pass
APFloat straight through to LLVM now.

llvm-svn: 42236
2007-09-22 18:47:25 +00:00
Chris Lattner
c2d09cfe75 work around bugs and missing features in apfloat.
llvm-svn: 42235
2007-09-22 18:38:30 +00:00
Chris Lattner
ec0a6d9be5 Use APFloat for the representation of FP immediates, ask the target
for *which* apfloat to use for a particular type.

llvm-svn: 42234
2007-09-22 18:29:59 +00:00
Bill Wendling
20e469e99b Validation fixes
llvm-svn: 42232
2007-09-22 10:17:08 +00:00
Bill Wendling
99dbd04c5d Validation fixes
llvm-svn: 42231
2007-09-22 10:13:39 +00:00
Bill Wendling
31e1e5e37a Validation fixes
llvm-svn: 42230
2007-09-22 10:07:00 +00:00
Bill Wendling
bdd6bd8236 Validation fixes
llvm-svn: 42229
2007-09-22 10:03:25 +00:00
Bill Wendling
370dac7346 Validation fixes
llvm-svn: 42228
2007-09-22 09:56:28 +00:00
Bill Wendling
beee622c4d Validation fixes
llvm-svn: 42227
2007-09-22 09:54:47 +00:00
Bill Wendling
8715e0c490 Validation fixes
llvm-svn: 42226
2007-09-22 09:39:19 +00:00
Bill Wendling
252570f0ad Validation fixes
llvm-svn: 42225
2007-09-22 09:23:55 +00:00
Bill Wendling
6637c57c54 Validation fixes
llvm-svn: 42224
2007-09-22 09:20:07 +00:00
Bill Wendling
6275c23755 Formatting changes.
llvm-svn: 42223
2007-09-22 09:16:44 +00:00
Chris Lattner
10671ad650 initialize isstore/isload fields in ctor, fixing PR1695
llvm-svn: 42222
2007-09-22 07:02:12 +00:00
Chris Lattner
5b95a171e2 fix bugs in the manual
llvm-svn: 42221
2007-09-22 03:17:52 +00:00
Neil Booth
a8d7269269 Handle storage complications of float->float conversions.
llvm-svn: 42220
2007-09-22 02:56:19 +00:00
Tanya Lattner
cf3e26fff2 Correct names.
llvm-svn: 42219
2007-09-22 00:03:01 +00:00
Fariborz Jahanian
7e5d533098 This patch adds to new things to clang:
1. Handles saving and checking on protocols used in an @interface declaration
2. Checks and saves class's super class.
3. Adds semantic check to category declarations.

llvm-svn: 42218
2007-09-22 00:01:35 +00:00
Tanya Lattner
08abc81a44 Fix typo.
llvm-svn: 42217
2007-09-22 00:01:26 +00:00
Tanya Lattner
0186a65ac7 One last fix to get name correct.
llvm-svn: 42216
2007-09-21 23:57:59 +00:00
Tanya Lattner
afcdaf58d4 Fix silly typo.
llvm-svn: 42215
2007-09-21 23:57:04 +00:00
Tanya Lattner
23dbd57214 Update annotation intrinsic with more details.
llvm-svn: 42214
2007-09-21 23:56:27 +00:00
Tanya Lattner
293c037336 Adding support for __builtin_annotation with an intrinsic called llvm.annotation. This is similar to llvm.var.annotation but is applied to expressions.
llvm-svn: 42211
2007-09-21 22:59:12 +00:00
Dale Johannesen
4230512f32 Change APFloat::convertFromInteger to take the incoming
bit width instead of number of words allocated, which
makes it actually work for int->APF conversions.
Adjust callers.  Add const to one of the APInt constructors
to prevent surprising match when called with const
argument.

llvm-svn: 42210
2007-09-21 22:09:37 +00:00
Devang Patel
361e52f39c Fix PR1692
llvm-svn: 42209
2007-09-21 21:18:19 +00:00
Owen Anderson
3e466535cf Fix CopyFrom for non-POD data types.
llvm-svn: 42208
2007-09-21 20:55:54 +00:00
Chris Lattner
87ce0bec91 #ifdef out unsafe tracing code, which fixes PR1689
llvm-svn: 42205
2007-09-21 18:30:39 +00:00
Chris Lattner
51ce795c92 don't read Block after it is freed. This fixes PR1684
llvm-svn: 42204
2007-09-21 18:25:53 +00:00
Chris Lattner
4b2ff02f72 Make case sorting deterministic by not depending on pointer
values.  Patch mostly by Gabor Greif for PR1682.

llvm-svn: 42203
2007-09-21 18:15:22 +00:00
Devang Patel
d331c8565f Add missing entry.
llvm-svn: 42202
2007-09-21 18:02:24 +00:00
Chris Lattner
af6912f980 gcroot testcase, patch by Eric Christopher.
llvm-svn: 42198
2007-09-21 17:48:39 +00:00
Chris Lattner
1af762f736 I cannot spell coalesce :)
llvm-svn: 42196
2007-09-21 17:43:52 +00:00
Chris Lattner
12477735f9 gcroot must take concrete types, not arbitrary types.
clean up intrinsic descriptions in langref a bit.

llvm-svn: 42194
2007-09-21 17:30:40 +00:00
Chris Lattner
b3d01d2f56 initialize SetCCResultContents, fixing PR1693
llvm-svn: 42193
2007-09-21 17:06:39 +00:00
Rafael Espindola
4730c04904 Don't add a default STACK_ALIGN (use the generic ABI alignment)
Implement calls to functions with byval arguments on X86

llvm-svn: 42192
2007-09-21 15:50:22 +00:00
Fariborz Jahanian
876e27dafa This patch instantiates objects for forward protocols and in general handles use of
protocols referenced in @protocol declarations.

llvm-svn: 42191
2007-09-21 15:40:54 +00:00
Dan Gohman
3bb3452dbc There is no {rsqrt,rcp}{p,s}d.
llvm-svn: 42190
2007-09-21 15:24:00 +00:00
Rafael Espindola
f065f0e2a1 small cleanup: use LowerMemArgument in LowerFastCCArguments also
llvm-svn: 42189
2007-09-21 14:55:38 +00:00
Chris Lattner
0a1fd10483 Initial hack at 2.1 release notes.
llvm-svn: 42186
2007-09-21 03:54:09 +00:00
Owen Anderson
46da2a6262 Add partial caching of non-local memory dependence queries. This provides a modest
speedup for GVN.

llvm-svn: 42185
2007-09-21 03:53:52 +00:00
Evan Cheng
1ff71872c2 Honor user-defined section specification of a global, ignores whether its initializer is null.
llvm-svn: 42182
2007-09-21 00:41:19 +00:00
Dale Johannesen
146a0ea071 Fix PR 1688. See comments there.
llvm-svn: 42181
2007-09-20 23:47:58 +00:00
Devang Patel
83cc3f8f51 Update aux. info associated with an instruction before erasing instruction.
llvm-svn: 42180
2007-09-20 23:45:50 +00:00
Devang Patel
d29f938335 Do not override user specified section.
llvm-svn: 42179
2007-09-20 23:07:37 +00:00
Devang Patel
6117a3b696 Don't increment invalid iterator.
llvm-svn: 42178
2007-09-20 23:01:50 +00:00
Hartmut Kaiser
3f5d492c70 Updated VC++ project files
llvm-svn: 42177
2007-09-20 21:54:10 +00:00
Ted Kremenek
8483a4ab05 Updated XCode project with locations of "Analysis" visitor header files.
llvm-svn: 42176
2007-09-20 21:47:32 +00:00
Ted Kremenek
24c624477e Updated header file inlcude to new location of
Analysis/Visitors/*Visitors.h files.

llvm-svn: 42175
2007-09-20 21:42:55 +00:00
Ted Kremenek
3b2050b322 Renamed "include/clang/Analysis/CFGVisitors" "<snip>/Analysis/Visitors".
"Visitors" is more general than "CFGVisitors", as we aren't just using
visitation useful for CFG analysis.

llvm-svn: 42174
2007-09-20 21:42:03 +00:00
Ted Kremenek
706df48fea Moved include/clang/Analysis/*Visitor.h to include/clang/Analysis/CFGVisitors.
We had enough visitors that it was cluttering the Analysis directory.

llvm-svn: 42173
2007-09-20 21:40:36 +00:00
Fariborz Jahanian
397d8de9ed Handle forward declaration of classes and prevent re-instantiation of
ObjcInterfaceClass Objects.

llvm-svn: 42172
2007-09-20 20:26:44 +00:00
Duncan Sands
416b9f0410 Testcase for PR1678.
llvm-svn: 42171
2007-09-20 18:56:24 +00:00
Evan Cheng
723dab1005 Disable if-conversion for this test.
llvm-svn: 42170
2007-09-20 18:06:22 +00:00
Evan Cheng
77d4771405 -enable-arm-if-conversion is gone.
llvm-svn: 42169
2007-09-20 18:03:23 +00:00
Fariborz Jahanian
a8bbc63c1f Match to do some semantic analysis on objective-c class decl.
1. Detect used of undeclared/forward declared super class.
2. Detect duplicate definition of a class.

llvm-svn: 42168
2007-09-20 17:54:07 +00:00
Dale Johannesen
cc7c475705 Fix dumb regression in constant folding (Regression/C/casts)
llvm-svn: 42165
2007-09-20 16:50:21 +00:00
Gordon Henriksen
d1e1645a4e Regenerate.
llvm-svn: 42164
2007-09-20 16:48:18 +00:00
Gordon Henriksen
1f982339e7 Incorporating review feedback for GC verifier patch.
llvm-svn: 42163
2007-09-20 16:47:41 +00:00
Dan Gohman
4dbc582a36 Fix several more entries in the x86 reload/remat folding tables.
llvm-svn: 42162
2007-09-20 14:17:21 +00:00
Hartmut Kaiser
8a43d50f40 Updated VC++ project files.
Disambiguated a variable.

llvm-svn: 42161
2007-09-20 13:35:09 +00:00
Gabor Greif
4a46052d30 use typenames equivalent to
(u)intval, because latter are not
present in older caml/mlvalues.h
(e.g. 2004/07/07, 1.48.6.1)

Using this as a workaround for now,
until --without-ocaml works
or we settle on a better solution

llvm-svn: 42160
2007-09-20 10:20:34 +00:00
Dale Johannesen
95be037d67 another long double buglet
llvm-svn: 42159
2007-09-20 01:27:54 +00:00
Nick Lewycky
e7be16a053 Excuse me.
llvm-svn: 42158
2007-09-20 00:57:00 +00:00
Nick Lewycky
eae7e7d00b Fix optimization. %x = sub %x, %y does not imply that %y is zero.
llvm-svn: 42157
2007-09-20 00:48:36 +00:00
Evan Cheng
8010320365 Enable if-conversion for ARM by default.
llvm-svn: 42156
2007-09-20 00:48:22 +00:00
Dale Johannesen
7d67e547b5 More long double fixes. x86_64 should build now.
llvm-svn: 42155
2007-09-19 23:55:34 +00:00
Evan Cheng
d0e360e16e Avoid referencing deleted instruction.
llvm-svn: 42153
2007-09-19 21:48:07 +00:00
Ted Kremenek
66d130a584 Added support to clang driver to view ASTs using GraphViz. This
functionality is still preliminary.

llvm-svn: 42152
2007-09-19 21:29:43 +00:00
Ted Kremenek
ebc5500e50 Previously GraphWriter assumed operator*() for node_iterator always
returned a reference type.  This patch allows operator*() to return a
non-reference type while still maintaining the old behavior when it
does return a reference type.

This patch was motivated when I tried to use "df_iterator" (see
llvm/ADT/DepthFirstIterator.h) as a "node_iterator", as df_iterator
does not return a reference type and thus we would get a compilation
error when trying to take the address of a temporary.

llvm-svn: 42151
2007-09-19 21:26:49 +00:00
Ted Kremenek
a8f4ef5846 Moved GraphTraits<Stmt*> to StmtGraphTraits.h. This allows consumers of Stmt.h not to have to pay the cost
of parsing the GraphTraits templates if they don't need that functionality.

Defined nodes_iterator for GraphTraits<Stmt*> to be based on llvm::df_iterator.

llvm-svn: 42150
2007-09-19 21:21:39 +00:00
Devang Patel
464276f831 Avoid unsafe promotion.
llvm-svn: 42149
2007-09-19 20:18:51 +00:00
Fariborz Jahanian
62fd2b4730 Patch to parse objective-c's @try-statement and @throw-statement.
llvm-svn: 42148
2007-09-19 19:14:32 +00:00
Evan Cheng
513874cf3c PSHUFDmi, etc. are actually folding a load, not a store.
llvm-svn: 42147
2007-09-19 19:02:47 +00:00
Ted Kremenek
a3d706a778 Added GraphTraits template specialization for Stmt* to treat ASTs like graphs.
llvm-svn: 42146
2007-09-19 18:18:40 +00:00
Ted Kremenek
ec55ce39a6 More refactoring: decl and expr regisitration now uses CFGRecStmtDeclVisitor.
llvm-svn: 42145
2007-09-19 18:00:03 +00:00
Ted Kremenek
5885a5b417 Added two new visitors that extend CFGStmtVisitor: CFGRecStmtVisitor and CFGRecStmtDeclVisitor.
The extended functionality of these visitors is that they automatically visit all statements in
an AST (no explicit recursion is required from subclasses), and the for the latter, decls are visited
as well.

llvm-svn: 42144
2007-09-19 17:59:28 +00:00
Dale Johannesen
b59d25fe54 Fix longdouble -> uint conversion.
llvm-svn: 42143
2007-09-19 17:53:26 +00:00
Chris Lattner
d79f3d51b1 reject things like "declare internal @foo"
llvm-svn: 42140
2007-09-19 17:14:45 +00:00
Steve Naroff
2cd263ff71 Remove SelectorTable/SelectorInfo, simply store all selectors in the central IdentifierTable.
Rationale:

We currently have a separate table to unique ObjC selectors. Since I don't need all the instance data in IdentifierInfo, I thought this would save space (and make more sense conceptually).

It turns out the cost of having duplicate entries for unary selectors (i.e. names without colons) outweighs the cost difference between the IdentifierInfo & SelectorInfo structures. Here is the data:

Two tables:

*** Selector/Identifier Stats:
# Selectors/Identifiers: 51635 
Bytes allocated:         1999824

One table:

*** Identifier Table Stats:
# Identifiers:   49500
Bytes allocated: 1990316

llvm-svn: 42139
2007-09-19 16:18:46 +00:00
Owen Anderson
c201cbc802 Add a flag to mark a dirty cache entry. This is not yet used, but will eventually
help non-local memdep caching.

llvm-svn: 42137
2007-09-19 16:13:57 +00:00
Dale Johannesen
f4bad97ea0 Fix some long double issues.
llvm-svn: 42133
2007-09-19 14:22:58 +00:00
Duncan Sands
d31649bc59 Improve comment.
llvm-svn: 42132
2007-09-19 10:25:38 +00:00
Duncan Sands
a38e527523 Partial fix for PR1678: correct some parts of constant
fold that were missed in the fix for PR1646.  Probably
this null/not-null logic should be factorized somewhere.

llvm-svn: 42131
2007-09-19 10:16:17 +00:00
Duncan Sands
56df7dec2b A global variable with external weak linkage can be null, while
an alias could alias such a global variable.

llvm-svn: 42130
2007-09-19 10:10:31 +00:00
Gabor Greif
ef858c9ff6 include alloca.h if available. this helps Solaris, but intnat and uintnat types are still undefined, causing errors
llvm-svn: 42129
2007-09-19 09:29:58 +00:00
Duncan Sands
4e426623f5 Testcase for PR1678.
llvm-svn: 42128
2007-09-19 07:43:17 +00:00
Steve Naroff
59155be0b2 Remove #include of config.h, it is no longer needed.
llvm-svn: 42126
2007-09-19 03:01:22 +00:00
Evan Cheng
0effc3a6b8 Use struct SDep instead of std::pair for SUnit pred and succ lists. First step
in tracking physical register output dependencies.

llvm-svn: 42125
2007-09-19 01:38:40 +00:00
Evan Cheng
17f589f76e Set CCR (EFLAGS) copy cost to -1, i.e. extremely expensive to copy.
llvm-svn: 42124
2007-09-19 01:36:39 +00:00
Evan Cheng
f73fb6261b Add CopyCost to TargetRegisterClass. This specifies the cost of copying a value
between two registers in the specific class.

llvm-svn: 42123
2007-09-19 01:35:01 +00:00
Devang Patel
69a55a38ed Relax loop ExitCondition predicate restriction.
llvm-svn: 42122
2007-09-19 00:28:47 +00:00
Devang Patel
455a53b7db Filter loops where split condition's false branch is not empty. For example
for (int i = 0; i < N; ++i) {
  if (i == somevalue)
    dosomething();
   else
    dosomethingelse();
}

llvm-svn: 42121
2007-09-19 00:15:16 +00:00
Devang Patel
4c238c451f Bail out early, before modifying anything.
llvm-svn: 42120
2007-09-19 00:11:01 +00:00
Devang Patel
31f2c8592c Work is incomplete. Loop is not modified at all right now.
llvm-svn: 42119
2007-09-19 00:08:13 +00:00
Devang Patel
ee35011d01 ooops...
llvm-svn: 42118
2007-09-18 23:58:14 +00:00
Steve Naroff
467e619a65 Remove alloca import...
llvm-svn: 42117
2007-09-18 23:56:42 +00:00
Steve Naroff
d54978ba8b Progress on message expressions...
- Add ObjcMessageExpr AST node and associated constructors.
- Add SourceLocation's to ActOnKeywordMessage/ActOnUnaryMessage API.
- Instantiate message expressions...
- Replace alloca usage with SmallString.

Next step, installing a correct type, among other tweaks...

llvm-svn: 42116
2007-09-18 23:55:05 +00:00
Ted Kremenek
fb9ea52a13 DataflowSolver now acccepts an "_Equal" template parameter that allows the user
to specify how two dataflow values should be compared for equality.  The default
is to use std::equal_to.

llvm-svn: 42115
2007-09-18 23:40:51 +00:00
Ted Kremenek
d51126b97e Fixed bug where getBitRef would incorrectly grab the bit from the
wrong bitvector.

llvm-svn: 42114
2007-09-18 23:30:45 +00:00
Ted Kremenek
9427b0e23b Changed solver to use "==" operator when comparing dataflow values
rather than a special "equal" method defined in the class for the
value.

llvm-svn: 42113
2007-09-18 23:30:21 +00:00
Evan Cheng
e7ff9da64b Clean up.
llvm-svn: 42112
2007-09-18 22:56:31 +00:00
Evan Cheng
e2e8f2d96b Fix a bogus splat xform:
shuffle <undef, undef, x, undef>, <undef, undef, undef, undef>, <2, 2, 2, 2>
!=
<undef, undef, x, undef>

llvm-svn: 42111
2007-09-18 21:54:37 +00:00
Ted Kremenek
8d4dcc5409 Minor performance fix in transfer function logic. Previously we
called VisitStmt, but VisitChildren is more direct and creates less
boilerplate logic.

llvm-svn: 42110
2007-09-18 21:47:41 +00:00
Ted Kremenek
271161078b More refactoring and code reduction.
llvm-svn: 42109
2007-09-18 21:43:18 +00:00
Gabor Greif
49122edc98 rename test, it is obviously misspelled
llvm-svn: 42108
2007-09-18 21:42:39 +00:00
Ted Kremenek
b1361eaaa7 Add overloaded versions of DataflowSolver::runOnBlock to simplify
invocation of the solver.

UninitializedValues checker now uses CFG::runOnAllBlocks to query the
computed dataflow values (tighter code).

llvm-svn: 42107
2007-09-18 21:08:21 +00:00
Ted Kremenek
360c3b4abb Added member template CFG::VisitBlockStmts to provide a succinct way
of visiting all block-level statements in a CFG.

Tightened implementation of UninitializedValues.

llvm-svn: 42106
2007-09-18 20:59:00 +00:00
Ted Kremenek
2bde624474 Additional comments and cosmetic cleanups.
llvm-svn: 42105
2007-09-18 20:44:03 +00:00
Fariborz Jahanian
867a7eb5cb Patch for object creation and handling of category declarations.
llvm-svn: 42104
2007-09-18 20:26:58 +00:00
Dale Johannesen
af12b57405 Prevent crash on long double.
llvm-svn: 42103
2007-09-18 18:36:59 +00:00
Ted Kremenek
df9a2a9f8b Moved TransferFunction object within DataflowSolver to be a instance
variable instead of a temporary.

llvm-svn: 42102
2007-09-18 18:17:19 +00:00
Gordon Henriksen
dc88c06732 Tests of the ocaml (and thus C) bindings for constants.
llvm-svn: 42101
2007-09-18 18:07:51 +00:00
Ted Kremenek
584e21a349 Modified DataFlowValues and DataflowSolver to associate dataflow value
with CFG *edges* instead of blocks.  This will fascilitate dataflow
analyses that are sensitive to block terminators, and also simplifies
some reasoning.

Updated UninitializedValues to comply to this new interface.

llvm-svn: 42099
2007-09-18 18:02:44 +00:00
Ted Kremenek
1d77d76837 Added type "CFG::Edge" to encapsulate the notion of directed-edges
within source-level CFGs.

llvm-svn: 42098
2007-09-18 18:01:15 +00:00
Dan Gohman
8cca8469de Move the entries for 64-bit CMP, IMUL, and a few others into the correct
tables so that they are eligible for reload/remat folding. And add
entries for JMP and CALL.

llvm-svn: 42094
2007-09-18 14:59:14 +00:00
Gordon Henriksen
37582f74cd Adding ocaml language bindings for the vmcore and bitwriter libraries. These are
built atop the C language bindings, and user programs can link with them as 
such:

  # Bytecode
  ocamlc -cc g++ llvm.cma llvmbitwriter.cma -o example example.ml
  # Native
  ocamlopt -cc g++ llvm.cmxa llvmbitwriter.cmxa -o example.opt example.ml

The vmcore.ml test exercises most/all of the APIs thus far bound. Unfortunately,
they're not yet numerous enough to write hello world. But:

  $ cat example.ml
  (* example.ml *)
  
  open Llvm
  open Llvm_bitwriter
  
  let _ =
    let filename = Sys.argv.(1) in
    let m = create_module filename in
    
    let v = make_int_constant i32_type 42 false in
    let g = define_global "hello_world" v m in
    
    if not (write_bitcode_file m filename) then exit 1;
    
    dispose_module m;

  $ ocamlc -cc g++ llvm.cma llvm_bitwriter.cma -o example example.ml
  File "example.ml", line 11, characters 6-7:
  Warning Y: unused variable g.
  $ ./example example.bc
  $ llvm-dis < example.bc
  ; ModuleID = '<stdin>'
  @hello_world = global i32 42            ; <i32*> [#uses=0]

The ocaml test cases provide effective tests for the C interfaces.

llvm-svn: 42093
2007-09-18 12:49:39 +00:00
Gordon Henriksen
4c7ca7d61e Regenerate.
llvm-svn: 42092
2007-09-18 12:27:13 +00:00
Gordon Henriksen
c0f56013e1 (no commit message)
llvm-svn: 42091
2007-09-18 12:26:59 +00:00
Gordon Henriksen
5c4d7b8052 (no commit message)
llvm-svn: 42090
2007-09-18 12:26:17 +00:00
Hartmut Kaiser
ae27fdc0f4 alloca.h doesn't exist on Windows.
llvm-svn: 42089
2007-09-18 12:16:59 +00:00
Gabor Greif
56c83140c1 alloca.h is needed on Solaris
llvm-svn: 42088
2007-09-18 11:01:25 +00:00
Gordon Henriksen
be6bd16418 Incorporating review feedback for GC verifier patch.
llvm-svn: 42087
2007-09-18 10:14:30 +00:00
Bill Wendling
e8c885f261 Don't pass back a reference to a temporary.
llvm-svn: 42086
2007-09-18 09:10:16 +00:00
Bill Wendling
a83fd8014d Update my entry.
llvm-svn: 42079
2007-09-18 05:28:19 +00:00
Bill Wendling
69833b61ac The exception handling function info should be reset for each new
function. The information isn't used heavily -- it's only used at the end
of exception handling emission -- so there's no need to cache it.

llvm-svn: 42078
2007-09-18 05:03:44 +00:00
Gordon Henriksen
76a0374b25 C bindings for libLLVMCore.a and libLLVMBitWriter.a.
- The naming prefix is LLVM.
- All types are represented using opaque references.
- Functions are not named LLVM{Type}{Method}; the names became
  unreadable goop. Instead, they are named LLVM{ImperativeSentence}.
- Where an attribute only appears once in the class hierarchy (e.g.,
  linkage only applies to values; parameter types only apply to
  function types), the class is omitted from identifiers for
  brevity. Tastes like methods.
- Strings are C strings or string/length tuples on a case-by-case
  basis.
- APIs which give the caller ownership of an object are not mapped
  (removeFromParent, certain constructor overloads). This keeps
  keep memory management as simple as possible.

For each library with bindings:

  llvm-c/<LIB>.h       - Declares the bindings.
  lib/<LIB>/<LIB>.cpp  - Implements the bindings.

So just link with the library of your choice and use the C header
instead of the C++ one.

llvm-svn: 42077
2007-09-18 03:18:57 +00:00
Gordon Henriksen
64e72c034a Fixing an comment in Module.h that refers to a nonexistent parameter.
Also adding some missing svn:ignores that've been bothering me.

llvm-svn: 42076
2007-09-18 02:09:34 +00:00
Devang Patel
fcda998ab2 Fix PR1657
llvm-svn: 42075
2007-09-18 01:54:42 +00:00
Bill Wendling
067f1d8e95 Objective-C was generating EH frame info like this:
"_-[NSString(local) isNullOrNil]".eh = 0
        .no_dead_strip  "_-[NSString(local) isNullOrNil]".eh

The ".eh" should be inside the quotes.

llvm-svn: 42074
2007-09-18 01:47:22 +00:00
Fariborz Jahanian
0c74e9d161 Uses more description name for method implementation kind argument.
Moves such argument as the last argument and uses defaul value.

llvm-svn: 42073
2007-09-18 00:25:23 +00:00
Hartmut Kaiser
a9deb50918 Updated VC++ project files after file rename.
llvm-svn: 42072
2007-09-17 23:33:12 +00:00
Bill Wendling
5752f692ed Add support for appending a suffix to the end of a mangled name.
llvm-svn: 42071
2007-09-17 22:39:32 +00:00
Fariborz Jahanian
cfacdae9a8 Patch to remove ObjcProtoMethodDecl and use ObjcMethodDecl
instead for @protocol method decls.

llvm-svn: 42070
2007-09-17 22:36:42 +00:00
Evan Cheng
ffd6995cc7 Bug fix and minor clean up of generated code.
llvm-svn: 42069
2007-09-17 22:26:41 +00:00
Devang Patel
00064e1bab Do not hide APInt::dump() inside #ifndef NDEBUG.
llvm-svn: 42068
2007-09-17 22:24:00 +00:00
Ted Kremenek
3c996d9a60 Bug fix to merging of data flow values (merge incorrectly made values
too "conservative").

Several revisions to UninitializedValues checker after testing.  We
now appear to be working correctly (probably some bugs still, but main
functionality appears to be there).  Implemented careful emitting of
warnings so that we wouldn't get a cascade of warnings for simply not
defining a single variable and using it everywhere.  This way the
warnings point closer to the root cause rather than "symptoms" from
using values derived from uninitialized variables.

llvm-svn: 42067
2007-09-17 21:59:08 +00:00
Tanya Lattner
613ccacb49 Fix broken default help strings for enable-shared, enable-static, and enable-fast-install. Regenerate configure script.
llvm-svn: 42066
2007-09-17 21:41:15 +00:00
Steve Naroff
c4657d00bb Add a comment and remove unused constructors.
llvm-svn: 42063
2007-09-17 21:26:50 +00:00
Ted Kremenek
fb5c46c740 Made driver flag --check-uninit-values more self-explanatory.
llvm-svn: 42062
2007-09-17 21:21:20 +00:00
Hartmut Kaiser
f696cfcf06 Fixed a VC++ issue related to bitmasks. As it turns out the compiler fills the unused bits of the word a bitmask is stored in with '1' (or randomly, I can't tell, I've seen '1' so far only), which creates wrong results in certain cases.
Please review.

llvm-svn: 42061
2007-09-17 21:11:08 +00:00
Fariborz Jahanian
39d641f526 Patch to add objective-c's @protocl type declaration.
llvm-svn: 42060
2007-09-17 21:07:36 +00:00
Steve Naroff
f0f2afce5a Finish defining Action API for message expressions.
llvm-svn: 42059
2007-09-17 21:01:15 +00:00
Devang Patel
267c07b51f Do not eliminate loop when it is invalid to do so. For example,
for(int i = 0; i < N; i++) {
	if ( i == XYZ) {
		A;
	else
		B;
	}
	C;
	D;
}

llvm-svn: 42058
2007-09-17 21:01:05 +00:00
Ted Kremenek
1abd5c9d8f Re-added UninitializedValues.cpp to the XCode project because the file was renamed.
llvm-svn: 42057
2007-09-17 20:52:52 +00:00
Ted Kremenek
d0b206fd98 Renamed file due to mispelling.
llvm-svn: 42056
2007-09-17 20:50:02 +00:00
Ted Kremenek
7e61e81bbf UninitialuzedValues now only tracks BlockVarDecls; obviating false positives with
globals and function parameters.

llvm-svn: 42055
2007-09-17 20:49:30 +00:00
Devang Patel
712dbe9d13 Skeleton for transformations to truncate loop's iteration space.
llvm-svn: 42054
2007-09-17 20:39:48 +00:00
Gordon Henriksen
a2f3e13cf4 Fix for PR1633: Verifier doesn't fully verify GC intrinsics
LLVM now enforces the following prototypes for the write barriers:

<ty>* @llvm.gcread(<ty2>*, <ty>**)
void @llvm.gcwrite(<ty>*, <ty2>*, <ty>**)

And for @llvm.gcroot, the first stack slot is verified to be an alloca or a 
bitcast of an alloca.

Fixes test/CodeGen/Generic/GC/lower_gcroot.ll, which violated these.

llvm-svn: 42051
2007-09-17 20:30:04 +00:00
Steve Naroff
486760aee3 - Refactored ObjcKeywordInfo into ObjcKeywordInfo, ObjcKeywordDecl, and ObjcKeywordMessage.
- Removed helper ObjcGetSelectorInfo(), moving the code directly into ObjcBuildMethodDeclaration().
- Many refinements to ParseObjCMessageExpression().
- Add ActOnMessageExpression().

Next step, finish the message actions and (finally) create/instantiate an ObjcMessageExpr AST.

llvm-svn: 42050
2007-09-17 20:25:27 +00:00
Dale Johannesen
ff7e443792 Remove RSTRegClass case from loadRegFromStackSlot
and storeRegToStackSlot.  Evan and I concluded this
should never be needed and it appears to be true.
(It if is needed, adjustment would be needed for
long double to work.)

llvm-svn: 42049
2007-09-17 20:15:38 +00:00
Devang Patel
9d1af9b63d Fix comment.
llvm-svn: 42048
2007-09-17 20:07:40 +00:00
Devang Patel
77ae4d358f This is not ideal but unbreaks build failure.
APInt::dump() is inside #ifndef NDEBUG, however SelectionDAG dump() routines are not.

llvm-svn: 42047
2007-09-17 20:03:03 +00:00
Ted Kremenek
dd3015375c More progress on UnitializedValues checker. We now have preliminary support
for reporting errors and running the checker.

llvm-svn: 42046
2007-09-17 19:59:27 +00:00
Dale Johannesen
a1336cf57e Implement x86 long double in jit (not really
complete, but common cases work)

llvm-svn: 42043
2007-09-17 18:44:13 +00:00
Chris Lattner
0625bd6472 Merge DenseMapKeyInfo & DenseMapValueInfo into DenseMapInfo
Add a new DenseMapInfo::isEqual method to allow clients to redefine
the equality predicate used when probing the hash table.

llvm-svn: 42042
2007-09-17 18:34:04 +00:00
Ted Kremenek
6f0751475a Split tracking of unitialized values for Decls and CFGBlock-level expressions.
llvm-svn: 42041
2007-09-17 18:31:23 +00:00
Daniel Berlin
bd590a8287 That's what i get for using carbon emacs in a terminal
llvm-svn: 42040
2007-09-17 18:05:59 +00:00
Daniel Berlin
28ae955181 Fix iterator so it doesn't sometimes report bits that aren't in the bitmap
llvm-svn: 42039
2007-09-17 18:04:21 +00:00
Dan Gohman
e903c1021f Add a utility function to SDOperand for testing if a value is unused.
llvm-svn: 42038
2007-09-17 17:44:31 +00:00
Evan Cheng
8070099fef X86ISD::TEST is dead.
llvm-svn: 42037
2007-09-17 17:42:53 +00:00
Chris Lattner
1406f7143b regenerate
llvm-svn: 42036
2007-09-17 17:40:48 +00:00
Dan Gohman
2ac2652779 Instcombine x-((x/y)*y) into a remainder operator.
llvm-svn: 42035
2007-09-17 17:31:57 +00:00
Ted Kremenek
789ea076a8 Removed "ObserverTy" from core DataflowValues types. The observer
mechanism can be implemented simply by affixing the Observer to an
analysis meta data, so it doesn't need to be a required type.  This
also permits analyses not to implement an Observer if it doesn't make
sense.

Changed "DataflowValues::MetaDataTy" to
"DataflowValues::AnalysisDataTy" to reflect that the type
enscapsulated the data associated with analyzing a given CFG.

Changed CFGStmtVisitor::BlockStmt_VisitImplicitControlFlowStmt(Stmt*)
to ...VisitImplicitControlFlowExpr(Expr*).  The type narrowing is more
precise and more useful to clients.

Added CFGStmtVisitor::BlockStmt_VisitExpr to reflect the visitation of
expressions at the block statement level.  This captures all implicit
control-flow statements as well as other expressions that are hoisted
to the block level (such as conditions for terminators and function
calls).  This is especially useful for dataflow analysis.

llvm-svn: 42034
2007-09-17 17:14:52 +00:00
Ted Kremenek
c3fddac8e7 Removed check for NULL CFG. Bad CFGs will fire an assertion failure
in the CFG builder logic.

llvm-svn: 42033
2007-09-17 17:10:02 +00:00
Gordon Henriksen
8f0e2f2329 Adding myself to credits.
llvm-svn: 42032
2007-09-17 17:04:44 +00:00
Ted Kremenek
cdc0bc45e4 When building CFGs we now (unconditionally) add an empty CFGBlock to the CFG
to serve as the entry block.  An empty entry block (just as with an
empty exit block, which we already have) simplifies building analyses on top
of CFGs with very little extra overhead.

llvm-svn: 42031
2007-09-17 16:18:02 +00:00
Ted Kremenek
186a669014 Added ASTConsumer.h to XCode project.
llvm-svn: 42030
2007-09-17 16:09:32 +00:00
Dan Gohman
3243e10ef0 Add 64-bit jmp instructions to the list of instructions that
can terminate a block with no fall-through.

llvm-svn: 42029
2007-09-17 15:19:08 +00:00
Steve Naroff
ed977473fe Fix a few 80 column violations.
llvm-svn: 42028
2007-09-17 15:07:43 +00:00
Dan Gohman
96aee15d33 Use xorl instead of xorq to enter a zero into a 64-bit register.
llvm-svn: 42027
2007-09-17 14:55:08 +00:00
Dan Gohman
863bdc332d Emit integer x<1 as x<=0, as comparisons with zero (now includeing
64-bit) can use test instead of cmp with an immediate.

llvm-svn: 42026
2007-09-17 14:49:27 +00:00
Steve Naroff
83763f2c40 Add const to debug hook...
llvm-svn: 42025
2007-09-17 14:49:06 +00:00
Dan Gohman
51d1929b9e Use "test reg,reg" in place of "cmp reg,0" for 64-bit operands. This was
previously only done for 32-bit and smaller operands.

llvm-svn: 42024
2007-09-17 14:35:24 +00:00
Steve Naroff
73d534a2e0 Add support for ObjC keyword selectors.
- Add SelectorInfo/SelectorTable classes, modeled after IdentifierInfo/IdentifierTable.
- Add SelectorTable instance to ASTContext, created lazily through ASTContext::getSelectorInfo().
- Add SelectorInfo slot to ObjcMethodDecl.
- Add helper function to derive a SelectorInfo from ObjcKeywordInfo.

Misc: Got the Decl stats stuff up and running again...it was missing support for ObjC AST's.
llvm-svn: 42023
2007-09-17 14:16:13 +00:00
Hartmut Kaiser
ffb47d0679 Fixed unterminated string issue.
llvm-svn: 42022
2007-09-17 12:29:55 +00:00
Duncan Sands
6d5da71288 Factor the trampoline transformation into a subroutine.
llvm-svn: 42021
2007-09-17 10:26:40 +00:00
Chris Lattner
699c2410a8 make var in anon namespace static. Use \n instead of std::endl.
llvm-svn: 42020
2007-09-17 06:16:32 +00:00
Dale Johannesen
7511e6b622 Implement x86 long double (uses host long double,
so only works on x86 target).

llvm-svn: 42019
2007-09-17 00:38:27 +00:00
Daniel Berlin
90aaa1dcf7 Fix bug in andersen's related to test_and_set.
Add operator == and != to SparseBitVector.
Simplify code for test_and_set

llvm-svn: 42018
2007-09-16 23:59:53 +00:00
Daniel Berlin
c637abee96 Fix a few bugs related to zero'ing of elements
llvm-svn: 42017
2007-09-16 22:31:47 +00:00
Daniel Berlin
ffce584d1c Rewrite of andersen's to be about 100x faster, cleaner, and begin to support field sensitivity
llvm-svn: 42016
2007-09-16 21:45:02 +00:00
Hartmut Kaiser
af2584fbaf Silenced a VC++ warning.
Updated VC++ project files.

llvm-svn: 42015
2007-09-16 21:35:35 +00:00
Chris Lattner
93c7f855e5 remove some obsolete interfaces.
llvm-svn: 42014
2007-09-16 19:47:56 +00:00
Chris Lattner
7ea6ca70f5 switch the llvm emitter to ASTConsumer interface.
llvm-svn: 42013
2007-09-16 19:46:59 +00:00
Chris Lattner
aadfe2f973 From Justin Handville:
"The ExpectedStr search was starting at the end of the comment string.
This patch starts the search at the beginning of the comment string.
After applying this patch, clang -parse-ast-check on negative test
case source files worked as expected."

llvm-svn: 42012
2007-09-16 19:27:16 +00:00
Chris Lattner
ac81722ff6 Fix html problem, patch by Justin Handville
llvm-svn: 42011
2007-09-16 19:25:23 +00:00
Chris Lattner
793d10ca38 fix some warnings, patch by Justin Handville
llvm-svn: 42010
2007-09-16 19:23:47 +00:00
Chris Lattner
81b7624c6f decl counting isn't implemented yet for objc. -stats probably crashes for it.
Patch by Justin Handville

llvm-svn: 42009
2007-09-16 19:23:04 +00:00
Bill Wendling
327e1a386c Follow-up to patch r41999. Make the conditional that emits the personality stub
match the conditional that turns on exception handling emittion in the asm
printer.

llvm-svn: 42008
2007-09-16 19:21:08 +00:00
Chris Lattner
b38b0ad095 Fix a GCC warning, patch by Justin Handville
llvm-svn: 42007
2007-09-16 19:12:45 +00:00
Chris Lattner
8ad0e6a484 fix warning.
llvm-svn: 42006
2007-09-16 19:11:53 +00:00
Dale Johannesen
7f724e9b94 Adjust per revew comments.
llvm-svn: 42002
2007-09-16 16:51:49 +00:00
Steve Naroff
2f742085f5 Fixes/tweaks that prevent "defaults-i.m" from compiling.
- Allow classnames as the receiver (removing a FIXME from ParseObjCMessageExpression).
- Added a FIXME to ParseObjCMessageExpression()...we need to return a message expr AST node!

llvm-svn: 42001
2007-09-16 16:16:00 +00:00
Steve Naroff
66356bda5d Rename statement actions (from Parse-prefix to ActOn-prefix).
llvm-svn: 42000
2007-09-16 14:56:35 +00:00
Bill Wendling
e5615156cc Only emit the personality function as a global value if the backend actually
supports it. This solves this error on the Darwin x86-64 platform:

$ cat testcase.ii
struct A {
  A();
};

A *bork() {
  return new A;
}
$ llvm-g++ -arch x86_64 -c testcase.ii
/var/tmp//cc3U8fd8.s:52:unknown section type: non_lazy_symbol_pointers
/var/tmp//cc3U8fd8.s:52:Rest of line ignored. 1st junk character valued 76 (L).
/var/tmp//cc3U8fd8.s:53:Unknown pseudo-op: .indirect_symbol
/var/tmp//cc3U8fd8.s:53:Rest of line ignored. 1st junk character valued 95 (_).

llvm-svn: 41999
2007-09-16 10:36:17 +00:00
Owen Anderson
4cd516b50b Be more careful when constant-folding PHI nodes.
llvm-svn: 41998
2007-09-16 08:04:16 +00:00
Steve Naroff
83895f7888 Rename expression actions (from Parse-prefix to ActOn-prefix).
llvm-svn: 41997
2007-09-16 03:34:24 +00:00
Hartmut Kaiser
6d100165ae Fixed a problem VC++ revealed in release mode. Please verify.
llvm-svn: 41996
2007-09-16 00:31:07 +00:00
Hartmut Kaiser
04bd2ef629 Fixed two problems VC++ revealed in release mode. Please verify.
llvm-svn: 41995
2007-09-16 00:28:28 +00:00
Hartmut Kaiser
0a6b11db24 Updated VC++ build system.
Silenced a couple of VC++ warnings.

llvm-svn: 41994
2007-09-16 00:04:22 +00:00
Chris Lattner
254987c411 switch the various CFG-based stuff over to using ASTConsumer interface,
this eliminates their dependence on the preprocessor and eliminates some
duplicated code.

llvm-svn: 41993
2007-09-15 23:21:08 +00:00
Chris Lattner
09c39db0c4 convert ast printer and dumper ocver to ASTConsumer interface,
genericizing them and eliminating boilerplate code.

llvm-svn: 41992
2007-09-15 23:02:28 +00:00
Chris Lattner
75e0c8cf4c add a new ASTConsumer consumer to simplify stuff in the driver.
Switch -parse-ast over to it.

llvm-svn: 41991
2007-09-15 22:56:56 +00:00
Chris Lattner
e27d865e36 Initial checkin of rewriter interface. It is just stubbed out for now.
llvm-svn: 41990
2007-09-15 22:21:22 +00:00
Chris Lattner
5a4e9d2666 pretty print some nodes more nicely.
llvm-svn: 41989
2007-09-15 21:49:37 +00:00
Chris Lattner
1cf7bb15ea fix comment
llvm-svn: 41988
2007-09-15 21:48:50 +00:00
Steve Naroff
30d242c99f Start converting Action methods from Parse-prefix to ActOn-prefix.
The previous naming scheme was confusing, since it resulted in both the Parser and Action modules having methods with the same name. In addition, the Action module never does any parsing...

llvm-svn: 41986
2007-09-15 18:49:24 +00:00
Fariborz Jahanian
29f99d7142 Couple of new classes for objective-c's @protocol typings.
llvm-svn: 41985
2007-09-15 18:27:26 +00:00
Chris Lattner
dd76f2f4ab remove obsolete tests.
llvm-svn: 41984
2007-09-15 17:38:04 +00:00
Chris Lattner
4f230451e1 Fix PR1666, SPASS with the CBE and 254.gap with the CBE.
GCC optimizes away things like ptr < NULL  to false.  To "fix" this,
have the CBE emit casts of pointers to intptr_t when doing relational
pointer comparisons.

llvm-svn: 41983
2007-09-15 06:51:03 +00:00
Chris Lattner
6ad68c220a New testcase for PR1662. GCC trees are horrible :(
llvm-svn: 41979
2007-09-15 05:46:41 +00:00
Dan Gohman
48ea03d169 Add patterns for SHLD64* and SHRD64*.
llvm-svn: 41975
2007-09-14 23:17:45 +00:00
Ted Kremenek
15d3b38ff2 Added several files to XCode project file...
Analysis/DataflowSolver.h
    Analysis/UnintializedValues.cpp
    include/clang/Analysis/CFGVarDeclVisitor.h
    include/clang/Analysis/DataflowValues.h
    include/clang/Analysis/UninitializedValues.h

llvm-svn: 41974
2007-09-14 23:13:28 +00:00
Steve Naroff
2e688fde14 Rename Action::ParseRecordBody() to ProcessFieldDecls(), and add a visibility argument.
Remove Action::ObjcAddVisibilityToIvars(). No need for an extra API when it is trivial to add this info to the previous hook.

In general, I want to start migrating away from having Actions prefixed with "Parse" (which is confusing, since the Action API doesn't do any parsing, per se).

llvm-svn: 41973
2007-09-14 23:09:53 +00:00
Chris Lattner
6395e5060d fix a gcc warning: comparison between signed and unsigned integer expressions
llvm-svn: 41972
2007-09-14 22:57:00 +00:00
Owen Anderson
3454dd3750 Remove RLE from the headers, since the pass itself is gone now.
llvm-svn: 41971
2007-09-14 22:54:46 +00:00
Ted Kremenek
5746d06a5d Prototype implementation of new template-based dataflow solver.
Preliminary implementation of UninitializedValues, which is based on
new solver (doesn't work yet, but compiles).

llvm-svn: 41970
2007-09-14 22:49:21 +00:00
Owen Anderson
8d0cb881e5 Remove RLE. It is subsumed by GVN.
llvm-svn: 41968
2007-09-14 22:33:52 +00:00
Dale Johannesen
98d3a08d8f Remove the assumption that FP's are either float or
double from some of the many places in the optimizers
it appears, and do something reasonable with x86
long double.
Make APInt::dump() public, remove newline, use it to
dump ConstantSDNode's.
Allow APFloats in FoldingSet.
Expand X86 backend handling of long doubles (conversions
to/from int, mostly).

llvm-svn: 41967
2007-09-14 22:26:36 +00:00
Steve Naroff
db47ee203a Several improvement to Sema::ParseRecordBody()...
- Adding a safer prologue. The previous prologue would accept a null and therefore assume we had an interface (which was incorrect).
- Fixed FieldDecl's classof method. This allowed me to simplify some unnecessary casting.
- When diagnosing errors, make sure the FieldDecl/EnclosingDecl are marked as invalid. In addition, don't delete the field...rather, add all fields to the enclosing decl. Memory management can/should be done elsewhere. This code was never "upgraded" to the recently added invalid decl strategy.

llvm-svn: 41964
2007-09-14 22:20:54 +00:00
Evan Cheng
483e1ce16e Add implicit def of EFLAGS on those instructions that may modify flags.
llvm-svn: 41962
2007-09-14 21:48:26 +00:00
Fariborz Jahanian
f3287bf871 Patch to store ivars into interface class object.
llvm-svn: 41961
2007-09-14 21:08:27 +00:00
Dan Gohman
14cf78cde5 And an FoldingSetImpl::NodeID::AddInteger overload for int64_t, to avoid
ambiguity.

llvm-svn: 41960
2007-09-14 20:48:42 +00:00
Dan Gohman
c519c38629 Add explicit triples to avoid default behavior that varies by host.
llvm-svn: 41959
2007-09-14 20:37:18 +00:00
Dan Gohman
9da02f5ee2 Remove isReg, isImm, and isMBB, and change all their users to use
isRegister, isImmediate, and isMachineBasicBlock, which are equivalent,
and more popular.

llvm-svn: 41958
2007-09-14 20:33:02 +00:00
Dan Gohman
a7b26e6bb3 Change "tmp." to "tmp" for temporaries created by ScalarEvolutionExpander
for consistency with many other transforms.

llvm-svn: 41957
2007-09-14 20:11:40 +00:00
Dan Gohman
58c468fb09 Remove spurious consts. This fixes warnings with compilers that
are strict about such things.

llvm-svn: 41956
2007-09-14 20:08:19 +00:00
Fariborz Jahanian
aefb23092c Semantic analysis for objective-c ivars.
llvm-svn: 41954
2007-09-14 16:27:55 +00:00
Rafael Espindola
272f7304f0 Add support for functions with byval arguments on x86
llvm-svn: 41953
2007-09-14 15:48:13 +00:00
Chris Lattner
5d13fb538f Fix a logic error in ValueIsOnlyUsedLocallyOrStoredToOneGlobal that caused
miscompilation of 188.ammp.  Reject select and bitcast in 
ValueIsOnlyUsedLocallyOrStoredToOneGlobal because RewriteHeapSROALoadUser can't handle it.

llvm-svn: 41950
2007-09-14 03:41:21 +00:00
Chris Lattner
d9111b88d1 silence a bogus gcc warning.
llvm-svn: 41949
2007-09-14 03:07:24 +00:00
Steve Naroff
1d4b5eaeab Now that the dust has settled on the Decl refactoring, I noticed FieldDecl didn't need NextDeclarator. As a result, I'm removing it.
Removing both slots (NextDeclarator/Next) end up reducing the size of fields/ivars by 40%.

llvm-svn: 41948
2007-09-14 02:20:46 +00:00
Evan Cheng
5196f617a1 Fix comments.
llvm-svn: 41947
2007-09-14 01:57:02 +00:00
Tanya Lattner
36a6fcd327 Change to 2.2svn.
llvm-svn: 41941
2007-09-14 01:24:13 +00:00
Bill Wendling
264d4813c7 Temporary reverting r41817
(http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070910/053370.html). It's
causing SPASS to fail.

llvm-svn: 41938
2007-09-14 01:13:55 +00:00
Steve Naroff
a23cc79654 Move Decl::NextDeclarator (w/ setters/getters) down to ScopedDecl/FieldDecl.
Decl is now svelte:-)

llvm-svn: 41935
2007-09-13 23:52:58 +00:00
Steve Naroff
9def2b15c1 Phase 2 of making the Decl class more lightweight...
Move Identifier/Loc instance variables (and associated getters/setters) down from Decl to ScopedDecl/FieldDecl.

Objc AST's can now inherit from Decl without getting instance variables and types that are C specific. For now, I am keeping NextDeclarator, since I believe it may be useful to ObjC. If not, it can be moved later.

llvm-svn: 41934
2007-09-13 21:41:19 +00:00
Chris Lattner
011f91b5b2 Teach GlobalLoadUsesSimpleEnoughForHeapSRA and the SROA rewriter how to handle
a limited form of PHI nodes.  This finally fixes PR1639, speeding 179.art up
from 7.84s to 3.13s on PPC.

llvm-svn: 41933
2007-09-13 21:31:36 +00:00
Fariborz Jahanian
6812cbb230 Patch for collecting ivars before running action on them.
llvm-svn: 41932
2007-09-13 20:56:13 +00:00
Steve Naroff
9324db12b2 Add "ScopedDecl" AST, used by ValueDecl and TypeDecl.
This allows us to sink the "Next" field, which isn't used by FieldDecl and ObjcIvarDecl.

llvm-svn: 41931
2007-09-13 18:10:37 +00:00
Chris Lattner
ba98f89388 be tolerant of PHI nodes when rewriting heap SROA code. This is a step
along the way of PR1639

llvm-svn: 41930
2007-09-13 18:00:31 +00:00
Chris Lattner
f315d4f1a7 refactor some code, no functionality change. On the path to PR1639
llvm-svn: 41929
2007-09-13 17:29:05 +00:00
Chris Lattner
6eed0e7366 Make ValueIsOnlyUsedLocallyOrStoredToOneGlobal smart enough to see through
bitcasts and phis.  This is a step to fixing PR1639.

llvm-svn: 41928
2007-09-13 16:37:20 +00:00
Chris Lattner
2d2892ee6e Make AllUsesOfLoadedValueWillTrapIfNull strong enough to see through PHI
nodes.  This is the first step of the fix for PR1639.

llvm-svn: 41927
2007-09-13 16:30:19 +00:00
Chris Lattner
d3d8aca074 update to match llvm mainline api
llvm-svn: 41926
2007-09-13 06:19:18 +00:00
Chris Lattner
3fd6bf8275 remove dead enum value.
llvm-svn: 41925
2007-09-13 06:18:04 +00:00
Chris Lattner
6ff85b2e5a Make single-argument ctors explicit to avoid tricky bugs :)
llvm-svn: 41924
2007-09-13 06:15:57 +00:00
Chris Lattner
7955bbd9fd Fix build problems on Cygwin (PR1652), patch by Patrick Walton.
llvm-svn: 41923
2007-09-13 06:09:48 +00:00
1900 changed files with 119122 additions and 97432 deletions

View File

@@ -1,800 +0,0 @@
//===--- ASTContext.cpp - Context to hold long-lived AST nodes ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ASTContext interface.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;
enum FloatingRank {
FloatRank, DoubleRank, LongDoubleRank
};
ASTContext::~ASTContext() {
// Deallocate all the types.
while (!Types.empty()) {
if (FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(Types.back())) {
// Destroy the object, but don't call delete. These are malloc'd.
FT->~FunctionTypeProto();
free(FT);
} else {
delete Types.back();
}
Types.pop_back();
}
}
void ASTContext::PrintStats() const {
fprintf(stderr, "*** AST Context Stats:\n");
fprintf(stderr, " %d types total.\n", (int)Types.size());
unsigned NumBuiltin = 0, NumPointer = 0, NumArray = 0, NumFunctionP = 0;
unsigned NumVector = 0, NumComplex = 0;
unsigned NumFunctionNP = 0, NumTypeName = 0, NumTagged = 0, NumReference = 0;
unsigned NumTagStruct = 0, NumTagUnion = 0, NumTagEnum = 0, NumTagClass = 0;
for (unsigned i = 0, e = Types.size(); i != e; ++i) {
Type *T = Types[i];
if (isa<BuiltinType>(T))
++NumBuiltin;
else if (isa<PointerType>(T))
++NumPointer;
else if (isa<ReferenceType>(T))
++NumReference;
else if (isa<ComplexType>(T))
++NumComplex;
else if (isa<ArrayType>(T))
++NumArray;
else if (isa<VectorType>(T))
++NumVector;
else if (isa<FunctionTypeNoProto>(T))
++NumFunctionNP;
else if (isa<FunctionTypeProto>(T))
++NumFunctionP;
else if (isa<TypedefType>(T))
++NumTypeName;
else if (TagType *TT = dyn_cast<TagType>(T)) {
++NumTagged;
switch (TT->getDecl()->getKind()) {
default: assert(0 && "Unknown tagged type!");
case Decl::Struct: ++NumTagStruct; break;
case Decl::Union: ++NumTagUnion; break;
case Decl::Class: ++NumTagClass; break;
case Decl::Enum: ++NumTagEnum; break;
}
} else {
assert(0 && "Unknown type!");
}
}
fprintf(stderr, " %d builtin types\n", NumBuiltin);
fprintf(stderr, " %d pointer types\n", NumPointer);
fprintf(stderr, " %d reference types\n", NumReference);
fprintf(stderr, " %d complex types\n", NumComplex);
fprintf(stderr, " %d array types\n", NumArray);
fprintf(stderr, " %d vector types\n", NumVector);
fprintf(stderr, " %d function types with proto\n", NumFunctionP);
fprintf(stderr, " %d function types with no proto\n", NumFunctionNP);
fprintf(stderr, " %d typename (typedef) types\n", NumTypeName);
fprintf(stderr, " %d tagged types\n", NumTagged);
fprintf(stderr, " %d struct types\n", NumTagStruct);
fprintf(stderr, " %d union types\n", NumTagUnion);
fprintf(stderr, " %d class types\n", NumTagClass);
fprintf(stderr, " %d enum types\n", NumTagEnum);
fprintf(stderr, "Total bytes = %d\n", int(NumBuiltin*sizeof(BuiltinType)+
NumPointer*sizeof(PointerType)+NumArray*sizeof(ArrayType)+
NumComplex*sizeof(ComplexType)+NumVector*sizeof(VectorType)+
NumFunctionP*sizeof(FunctionTypeProto)+
NumFunctionNP*sizeof(FunctionTypeNoProto)+
NumTypeName*sizeof(TypedefType)+NumTagged*sizeof(TagType)));
}
void ASTContext::InitBuiltinType(QualType &R, BuiltinType::Kind K) {
Types.push_back((R = QualType(new BuiltinType(K),0)).getTypePtr());
}
void ASTContext::InitBuiltinTypes() {
assert(VoidTy.isNull() && "Context reinitialized?");
// C99 6.2.5p19.
InitBuiltinType(VoidTy, BuiltinType::Void);
// C99 6.2.5p2.
InitBuiltinType(BoolTy, BuiltinType::Bool);
// C99 6.2.5p3.
if (Target.isCharSigned(SourceLocation()))
InitBuiltinType(CharTy, BuiltinType::Char_S);
else
InitBuiltinType(CharTy, BuiltinType::Char_U);
// C99 6.2.5p4.
InitBuiltinType(SignedCharTy, BuiltinType::SChar);
InitBuiltinType(ShortTy, BuiltinType::Short);
InitBuiltinType(IntTy, BuiltinType::Int);
InitBuiltinType(LongTy, BuiltinType::Long);
InitBuiltinType(LongLongTy, BuiltinType::LongLong);
// C99 6.2.5p6.
InitBuiltinType(UnsignedCharTy, BuiltinType::UChar);
InitBuiltinType(UnsignedShortTy, BuiltinType::UShort);
InitBuiltinType(UnsignedIntTy, BuiltinType::UInt);
InitBuiltinType(UnsignedLongTy, BuiltinType::ULong);
InitBuiltinType(UnsignedLongLongTy, BuiltinType::ULongLong);
// C99 6.2.5p10.
InitBuiltinType(FloatTy, BuiltinType::Float);
InitBuiltinType(DoubleTy, BuiltinType::Double);
InitBuiltinType(LongDoubleTy, BuiltinType::LongDouble);
// C99 6.2.5p11.
FloatComplexTy = getComplexType(FloatTy);
DoubleComplexTy = getComplexType(DoubleTy);
LongDoubleComplexTy = getComplexType(LongDoubleTy);
}
//===----------------------------------------------------------------------===//
// Type Sizing and Analysis
//===----------------------------------------------------------------------===//
/// getTypeSize - Return the size of the specified type, in bits. This method
/// does not work on incomplete types.
std::pair<uint64_t, unsigned>
ASTContext::getTypeInfo(QualType T, SourceLocation L) {
T = T.getCanonicalType();
uint64_t Size;
unsigned Align;
switch (T->getTypeClass()) {
case Type::TypeName: assert(0 && "Not a canonical type!");
case Type::FunctionNoProto:
case Type::FunctionProto:
default:
assert(0 && "Incomplete types have no size!");
case Type::VariableArray:
assert(0 && "VLAs not implemented yet!");
case Type::ConstantArray: {
ConstantArrayType *CAT = cast<ConstantArrayType>(T);
std::pair<uint64_t, unsigned> EltInfo =
getTypeInfo(CAT->getElementType(), L);
Size = EltInfo.first*CAT->getSize().getZExtValue();
Align = EltInfo.second;
break;
}
case Type::Vector: {
std::pair<uint64_t, unsigned> EltInfo =
getTypeInfo(cast<VectorType>(T)->getElementType(), L);
Size = EltInfo.first*cast<VectorType>(T)->getNumElements();
// FIXME: Vector alignment is not the alignment of its elements.
Align = EltInfo.second;
break;
}
case Type::Builtin: {
// FIXME: need to use TargetInfo to derive the target specific sizes. This
// implementation will suffice for play with vector support.
switch (cast<BuiltinType>(T)->getKind()) {
default: assert(0 && "Unknown builtin type!");
case BuiltinType::Void:
assert(0 && "Incomplete types have no size!");
case BuiltinType::Bool: Target.getBoolInfo(Size, Align, L); break;
case BuiltinType::Char_S:
case BuiltinType::Char_U:
case BuiltinType::UChar:
case BuiltinType::SChar: Target.getCharInfo(Size, Align, L); break;
case BuiltinType::UShort:
case BuiltinType::Short: Target.getShortInfo(Size, Align, L); break;
case BuiltinType::UInt:
case BuiltinType::Int: Target.getIntInfo(Size, Align, L); break;
case BuiltinType::ULong:
case BuiltinType::Long: Target.getLongInfo(Size, Align, L); break;
case BuiltinType::ULongLong:
case BuiltinType::LongLong: Target.getLongLongInfo(Size, Align, L); break;
case BuiltinType::Float: Target.getFloatInfo(Size, Align, L); break;
case BuiltinType::Double: Target.getDoubleInfo(Size, Align, L); break;
case BuiltinType::LongDouble: Target.getLongDoubleInfo(Size, Align,L);break;
}
break;
}
case Type::Pointer: Target.getPointerInfo(Size, Align, L); break;
case Type::Reference:
// "When applied to a reference or a reference type, the result is the size
// of the referenced type." C++98 5.3.3p2: expr.sizeof.
// FIXME: This is wrong for struct layout!
return getTypeInfo(cast<ReferenceType>(T)->getReferenceeType(), L);
case Type::Complex: {
// Complex types have the same alignment as their elements, but twice the
// size.
std::pair<uint64_t, unsigned> EltInfo =
getTypeInfo(cast<ComplexType>(T)->getElementType(), L);
Size = EltInfo.first*2;
Align = EltInfo.second;
break;
}
case Type::Tagged:
TagType *TT = cast<TagType>(T);
if (RecordType *RT = dyn_cast<RecordType>(TT)) {
const RecordLayout &Layout = getRecordLayout(RT->getDecl(), L);
Size = Layout.getSize();
Align = Layout.getAlignment();
} else if (EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl())) {
return getTypeInfo(ED->getIntegerType(), L);
} else {
assert(0 && "Unimplemented type sizes!");
}
break;
}
assert(Align && (Align & (Align-1)) == 0 && "Alignment must be power of 2");
return std::make_pair(Size, Align);
}
/// getRecordLayout - Get or compute information about the layout of the
/// specified record (struct/union/class), which indicates its size and field
/// position information.
const RecordLayout &ASTContext::getRecordLayout(const RecordDecl *D,
SourceLocation L) {
assert(D->isDefinition() && "Cannot get layout of forward declarations!");
// Look up this layout, if already laid out, return what we have.
const RecordLayout *&Entry = RecordLayoutInfo[D];
if (Entry) return *Entry;
// Allocate and assign into RecordLayoutInfo here. The "Entry" reference can
// be invalidated (dangle) if the RecordLayoutInfo hashtable is inserted into.
RecordLayout *NewEntry = new RecordLayout();
Entry = NewEntry;
uint64_t *FieldOffsets = new uint64_t[D->getNumMembers()];
uint64_t RecordSize = 0;
unsigned RecordAlign = 8; // Default alignment = 1 byte = 8 bits.
if (D->getKind() != Decl::Union) {
// Layout each field, for now, just sequentially, respecting alignment. In
// the future, this will need to be tweakable by targets.
for (unsigned i = 0, e = D->getNumMembers(); i != e; ++i) {
const FieldDecl *FD = D->getMember(i);
std::pair<uint64_t, unsigned> FieldInfo = getTypeInfo(FD->getType(), L);
uint64_t FieldSize = FieldInfo.first;
unsigned FieldAlign = FieldInfo.second;
// Round up the current record size to the field's alignment boundary.
RecordSize = (RecordSize+FieldAlign-1) & ~(FieldAlign-1);
// Place this field at the current location.
FieldOffsets[i] = RecordSize;
// Reserve space for this field.
RecordSize += FieldSize;
// Remember max struct/class alignment.
RecordAlign = std::max(RecordAlign, FieldAlign);
}
// Finally, round the size of the total struct up to the alignment of the
// struct itself.
RecordSize = (RecordSize+RecordAlign-1) & ~(RecordAlign-1);
} else {
// Union layout just puts each member at the start of the record.
for (unsigned i = 0, e = D->getNumMembers(); i != e; ++i) {
const FieldDecl *FD = D->getMember(i);
std::pair<uint64_t, unsigned> FieldInfo = getTypeInfo(FD->getType(), L);
uint64_t FieldSize = FieldInfo.first;
unsigned FieldAlign = FieldInfo.second;
// Round up the current record size to the field's alignment boundary.
RecordSize = std::max(RecordSize, FieldSize);
// Place this field at the start of the record.
FieldOffsets[i] = 0;
// Remember max struct/class alignment.
RecordAlign = std::max(RecordAlign, FieldAlign);
}
}
NewEntry->SetLayout(RecordSize, RecordAlign, FieldOffsets);
return *NewEntry;
}
//===----------------------------------------------------------------------===//
// Type creation/memoization methods
//===----------------------------------------------------------------------===//
/// getComplexType - Return the uniqued reference to the type for a complex
/// number with the specified element type.
QualType ASTContext::getComplexType(QualType T) {
// Unique pointers, to guarantee there is only one pointer of a particular
// structure.
llvm::FoldingSetNodeID ID;
ComplexType::Profile(ID, T);
void *InsertPos = 0;
if (ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(CT, 0);
// If the pointee type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getComplexType(T.getCanonicalType());
// Get the new insert position for the node we care about.
ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
ComplexType *New = new ComplexType(T, Canonical);
Types.push_back(New);
ComplexTypes.InsertNode(New, InsertPos);
return QualType(New, 0);
}
/// getPointerType - Return the uniqued reference to the type for a pointer to
/// the specified type.
QualType ASTContext::getPointerType(QualType T) {
// Unique pointers, to guarantee there is only one pointer of a particular
// structure.
llvm::FoldingSetNodeID ID;
PointerType::Profile(ID, T);
void *InsertPos = 0;
if (PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(PT, 0);
// If the pointee type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getPointerType(T.getCanonicalType());
// Get the new insert position for the node we care about.
PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
PointerType *New = new PointerType(T, Canonical);
Types.push_back(New);
PointerTypes.InsertNode(New, InsertPos);
return QualType(New, 0);
}
/// getReferenceType - Return the uniqued reference to the type for a reference
/// to the specified type.
QualType ASTContext::getReferenceType(QualType T) {
// Unique pointers, to guarantee there is only one pointer of a particular
// structure.
llvm::FoldingSetNodeID ID;
ReferenceType::Profile(ID, T);
void *InsertPos = 0;
if (ReferenceType *RT = ReferenceTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(RT, 0);
// If the referencee type isn't canonical, this won't be a canonical type
// either, so fill in the canonical type field.
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getReferenceType(T.getCanonicalType());
// Get the new insert position for the node we care about.
ReferenceType *NewIP = ReferenceTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
ReferenceType *New = new ReferenceType(T, Canonical);
Types.push_back(New);
ReferenceTypes.InsertNode(New, InsertPos);
return QualType(New, 0);
}
/// getConstantArrayType - Return the unique reference to the type for an
/// array of the specified element type.
QualType ASTContext::getConstantArrayType(QualType EltTy,
const llvm::APInt &ArySize,
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals) {
llvm::FoldingSetNodeID ID;
ConstantArrayType::Profile(ID, EltTy, ArySize);
void *InsertPos = 0;
if (ConstantArrayType *ATP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(ATP, 0);
// If the element type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!EltTy->isCanonical()) {
Canonical = getConstantArrayType(EltTy.getCanonicalType(), ArySize,
ASM, EltTypeQuals);
// Get the new insert position for the node we care about.
ConstantArrayType *NewIP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
ConstantArrayType *New = new ConstantArrayType(EltTy, Canonical, ArySize,
ASM, EltTypeQuals);
ArrayTypes.InsertNode(New, InsertPos);
Types.push_back(New);
return QualType(New, 0);
}
/// getVariableArrayType - Returns a non-unique reference to the type for a
/// variable array of the specified element type.
QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts,
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals) {
// Since we don't unique expressions, it isn't possible to unique VLA's.
ArrayType *New = new VariableArrayType(EltTy, QualType(), NumElts,
ASM, EltTypeQuals);
Types.push_back(New);
return QualType(New, 0);
}
/// getVectorType - Return the unique reference to a vector type of
/// the specified element type and size. VectorType must be a built-in type.
QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts) {
BuiltinType *baseType;
baseType = dyn_cast<BuiltinType>(vecType.getCanonicalType().getTypePtr());
assert(baseType != 0 && "getVectorType(): Expecting a built-in type");
// Check if we've already instantiated a vector of this type.
llvm::FoldingSetNodeID ID;
VectorType::Profile(ID, vecType, NumElts, Type::Vector);
void *InsertPos = 0;
if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(VTP, 0);
// If the element type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!vecType->isCanonical()) {
Canonical = getVectorType(vecType.getCanonicalType(), NumElts);
// Get the new insert position for the node we care about.
VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
VectorType *New = new VectorType(vecType, NumElts, Canonical);
VectorTypes.InsertNode(New, InsertPos);
Types.push_back(New);
return QualType(New, 0);
}
/// getOCUVectorType - Return the unique reference to an OCU vector type of
/// the specified element type and size. VectorType must be a built-in type.
QualType ASTContext::getOCUVectorType(QualType vecType, unsigned NumElts) {
BuiltinType *baseType;
baseType = dyn_cast<BuiltinType>(vecType.getCanonicalType().getTypePtr());
assert(baseType != 0 && "getOCUVectorType(): Expecting a built-in type");
// Check if we've already instantiated a vector of this type.
llvm::FoldingSetNodeID ID;
VectorType::Profile(ID, vecType, NumElts, Type::OCUVector);
void *InsertPos = 0;
if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(VTP, 0);
// If the element type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!vecType->isCanonical()) {
Canonical = getOCUVectorType(vecType.getCanonicalType(), NumElts);
// Get the new insert position for the node we care about.
VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
OCUVectorType *New = new OCUVectorType(vecType, NumElts, Canonical);
VectorTypes.InsertNode(New, InsertPos);
Types.push_back(New);
return QualType(New, 0);
}
/// getFunctionTypeNoProto - Return a K&R style C function type like 'int()'.
///
QualType ASTContext::getFunctionTypeNoProto(QualType ResultTy) {
// Unique functions, to guarantee there is only one function of a particular
// structure.
llvm::FoldingSetNodeID ID;
FunctionTypeNoProto::Profile(ID, ResultTy);
void *InsertPos = 0;
if (FunctionTypeNoProto *FT =
FunctionTypeNoProtos.FindNodeOrInsertPos(ID, InsertPos))
return QualType(FT, 0);
QualType Canonical;
if (!ResultTy->isCanonical()) {
Canonical = getFunctionTypeNoProto(ResultTy.getCanonicalType());
// Get the new insert position for the node we care about.
FunctionTypeNoProto *NewIP =
FunctionTypeNoProtos.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
FunctionTypeNoProto *New = new FunctionTypeNoProto(ResultTy, Canonical);
Types.push_back(New);
FunctionTypeProtos.InsertNode(New, InsertPos);
return QualType(New, 0);
}
/// getFunctionType - Return a normal function type with a typed argument
/// list. isVariadic indicates whether the argument list includes '...'.
QualType ASTContext::getFunctionType(QualType ResultTy, QualType *ArgArray,
unsigned NumArgs, bool isVariadic) {
// Unique functions, to guarantee there is only one function of a particular
// structure.
llvm::FoldingSetNodeID ID;
FunctionTypeProto::Profile(ID, ResultTy, ArgArray, NumArgs, isVariadic);
void *InsertPos = 0;
if (FunctionTypeProto *FTP =
FunctionTypeProtos.FindNodeOrInsertPos(ID, InsertPos))
return QualType(FTP, 0);
// Determine whether the type being created is already canonical or not.
bool isCanonical = ResultTy->isCanonical();
for (unsigned i = 0; i != NumArgs && isCanonical; ++i)
if (!ArgArray[i]->isCanonical())
isCanonical = false;
// If this type isn't canonical, get the canonical version of it.
QualType Canonical;
if (!isCanonical) {
llvm::SmallVector<QualType, 16> CanonicalArgs;
CanonicalArgs.reserve(NumArgs);
for (unsigned i = 0; i != NumArgs; ++i)
CanonicalArgs.push_back(ArgArray[i].getCanonicalType());
Canonical = getFunctionType(ResultTy.getCanonicalType(),
&CanonicalArgs[0], NumArgs,
isVariadic);
// Get the new insert position for the node we care about.
FunctionTypeProto *NewIP =
FunctionTypeProtos.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
// FunctionTypeProto objects are not allocated with new because they have a
// variable size array (for parameter types) at the end of them.
FunctionTypeProto *FTP =
(FunctionTypeProto*)malloc(sizeof(FunctionTypeProto) +
NumArgs*sizeof(QualType));
new (FTP) FunctionTypeProto(ResultTy, ArgArray, NumArgs, isVariadic,
Canonical);
Types.push_back(FTP);
FunctionTypeProtos.InsertNode(FTP, InsertPos);
return QualType(FTP, 0);
}
/// getTypedefType - Return the unique reference to the type for the
/// specified typename decl.
QualType ASTContext::getTypedefType(TypedefDecl *Decl) {
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
QualType Canonical = Decl->getUnderlyingType().getCanonicalType();
Decl->TypeForDecl = new TypedefType(Decl, Canonical);
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
}
/// getObjcInterfaceType - Return the unique reference to the type for the
/// specified ObjC interface decl.
QualType ASTContext::getObjcInterfaceType(ObjcInterfaceDecl *Decl) {
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
Decl->TypeForDecl = new ObjcInterfaceType(Decl);
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
}
/// getTypeOfExpr - Unlike many "get<Type>" functions, we can't unique
/// TypeOfExpr AST's (since expression's are never shared). For example,
/// multiple declarations that refer to "typeof(x)" all contain different
/// DeclRefExpr's. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
QualType ASTContext::getTypeOfExpr(Expr *tofExpr) {
QualType Canonical = tofExpr->getType().getCanonicalType();
TypeOfExpr *toe = new TypeOfExpr(tofExpr, Canonical);
Types.push_back(toe);
return QualType(toe, 0);
}
/// getTypeOfType - Unlike many "get<Type>" functions, we don't unique
/// TypeOfType AST's. The only motivation to unique these nodes would be
/// memory savings. Since typeof(t) is fairly uncommon, space shouldn't be
/// an issue. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
QualType ASTContext::getTypeOfType(QualType tofType) {
QualType Canonical = tofType.getCanonicalType();
TypeOfType *tot = new TypeOfType(tofType, Canonical);
Types.push_back(tot);
return QualType(tot, 0);
}
/// getTagDeclType - Return the unique reference to the type for the
/// specified TagDecl (struct/union/class/enum) decl.
QualType ASTContext::getTagDeclType(TagDecl *Decl) {
// The decl stores the type cache.
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
Decl->TypeForDecl = new TagType(Decl, QualType());
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
}
/// getSizeType - Return the unique type for "size_t" (C99 7.17), the result
/// of the sizeof operator (C99 6.5.3.4p4). The value is target dependent and
/// needs to agree with the definition in <stddef.h>.
QualType ASTContext::getSizeType() const {
// On Darwin, size_t is defined as a "long unsigned int".
// FIXME: should derive from "Target".
return UnsignedLongTy;
}
/// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?)
/// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
QualType ASTContext::getPointerDiffType() const {
// On Darwin, ptrdiff_t is defined as a "int". This seems like a bug...
// FIXME: should derive from "Target".
return IntTy;
}
/// getIntegerRank - Return an integer conversion rank (C99 6.3.1.1p1). This
/// routine will assert if passed a built-in type that isn't an integer or enum.
static int getIntegerRank(QualType t) {
if (const TagType *TT = dyn_cast<TagType>(t.getCanonicalType())) {
assert(TT->getDecl()->getKind() == Decl::Enum && "not an int or enum");
return 4;
}
const BuiltinType *BT = cast<BuiltinType>(t.getCanonicalType());
switch (BT->getKind()) {
default:
assert(0 && "getIntegerRank(): not a built-in integer");
case BuiltinType::Bool:
return 1;
case BuiltinType::Char_S:
case BuiltinType::Char_U:
case BuiltinType::SChar:
case BuiltinType::UChar:
return 2;
case BuiltinType::Short:
case BuiltinType::UShort:
return 3;
case BuiltinType::Int:
case BuiltinType::UInt:
return 4;
case BuiltinType::Long:
case BuiltinType::ULong:
return 5;
case BuiltinType::LongLong:
case BuiltinType::ULongLong:
return 6;
}
}
/// getFloatingRank - Return a relative rank for floating point types.
/// This routine will assert if passed a built-in type that isn't a float.
static int getFloatingRank(QualType T) {
T = T.getCanonicalType();
if (ComplexType *CT = dyn_cast<ComplexType>(T))
return getFloatingRank(CT->getElementType());
switch (cast<BuiltinType>(T)->getKind()) {
default: assert(0 && "getFloatingPointRank(): not a floating type");
case BuiltinType::Float: return FloatRank;
case BuiltinType::Double: return DoubleRank;
case BuiltinType::LongDouble: return LongDoubleRank;
}
}
/// getFloatingTypeOfSizeWithinDomain - Returns a real floating
/// point or a complex type (based on typeDomain/typeSize).
/// 'typeDomain' is a real floating point or complex type.
/// 'typeSize' is a real floating point or complex type.
QualType ASTContext::getFloatingTypeOfSizeWithinDomain(
QualType typeSize, QualType typeDomain) const {
if (typeDomain->isComplexType()) {
switch (getFloatingRank(typeSize)) {
default: assert(0 && "getFloatingRank(): illegal value for rank");
case FloatRank: return FloatComplexTy;
case DoubleRank: return DoubleComplexTy;
case LongDoubleRank: return LongDoubleComplexTy;
}
}
if (typeDomain->isRealFloatingType()) {
switch (getFloatingRank(typeSize)) {
default: assert(0 && "getFloatingRank(): illegal value for rank");
case FloatRank: return FloatTy;
case DoubleRank: return DoubleTy;
case LongDoubleRank: return LongDoubleTy;
}
}
assert(0 && "getFloatingTypeOfSizeWithinDomain(): illegal domain");
}
/// compareFloatingType - Handles 3 different combos:
/// float/float, float/complex, complex/complex.
/// If lt > rt, return 1. If lt == rt, return 0. If lt < rt, return -1.
int ASTContext::compareFloatingType(QualType lt, QualType rt) {
if (getFloatingRank(lt) == getFloatingRank(rt))
return 0;
if (getFloatingRank(lt) > getFloatingRank(rt))
return 1;
return -1;
}
// maxIntegerType - Returns the highest ranked integer type. Handles 3 case:
// unsigned/unsigned, signed/signed, signed/unsigned. C99 6.3.1.8p1.
QualType ASTContext::maxIntegerType(QualType lhs, QualType rhs) {
if (lhs == rhs) return lhs;
bool t1Unsigned = lhs->isUnsignedIntegerType();
bool t2Unsigned = rhs->isUnsignedIntegerType();
if ((t1Unsigned && t2Unsigned) || (!t1Unsigned && !t2Unsigned))
return getIntegerRank(lhs) >= getIntegerRank(rhs) ? lhs : rhs;
// We have two integer types with differing signs
QualType unsignedType = t1Unsigned ? lhs : rhs;
QualType signedType = t1Unsigned ? rhs : lhs;
if (getIntegerRank(unsignedType) >= getIntegerRank(signedType))
return unsignedType;
else {
// FIXME: Need to check if the signed type can represent all values of the
// unsigned type. If it can, then the result is the signed type.
// If it can't, then the result is the unsigned version of the signed type.
// Should probably add a helper that returns a signed integer type from
// an unsigned (and vice versa). C99 6.3.1.8.
return signedType;
}
}
// getCFConstantStringType - Return the type used for constant CFStrings.
QualType ASTContext::getCFConstantStringType() {
if (!CFConstantStringTypeDecl) {
CFConstantStringTypeDecl = new RecordDecl(Decl::Struct, SourceLocation(),
&Idents.get("__builtin_CFString"),
0);
QualType FieldTypes[4];
// const int *isa;
FieldTypes[0] = getPointerType(IntTy.getQualifiedType(QualType::Const));
// int flags;
FieldTypes[1] = IntTy;
// const char *str;
FieldTypes[2] = getPointerType(CharTy.getQualifiedType(QualType::Const));
// long length;
FieldTypes[3] = LongTy;
// Create fields
FieldDecl *FieldDecls[4];
for (unsigned i = 0; i < 4; ++i)
FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i], 0);
CFConstantStringTypeDecl->defineBody(FieldDecls, 4);
}
return getTagDeclType(CFConstantStringTypeDecl);
}

View File

@@ -1,172 +0,0 @@
//===--- Builtins.cpp - Builtin function implementation -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements various things for builtin functions.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/Builtins.h"
#include "clang/AST/ASTContext.h"
#include "clang/Lex/IdentifierTable.h"
#include "clang/Basic/TargetInfo.h"
using namespace clang;
static const Builtin::Info BuiltinInfo[] = {
{ "not a builtin function", 0, 0 },
#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS },
#include "clang/AST/Builtins.def"
};
const Builtin::Info &Builtin::Context::GetRecord(unsigned ID) const {
if (ID < Builtin::FirstTSBuiltin)
return BuiltinInfo[ID];
assert(ID - Builtin::FirstTSBuiltin < NumTSRecords && "Invalid builtin ID!");
return TSRecords[ID - Builtin::FirstTSBuiltin];
}
/// InitializeBuiltins - Mark the identifiers for all the builtins with their
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
/// such.
void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
const TargetInfo &Target) {
// Step #1: mark all target-independent builtins with their ID's.
for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i)
Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
// Step #2: handle target builtins.
std::vector<const char *> NonPortableBuiltins;
Target.getTargetBuiltins(TSRecords, NumTSRecords, NonPortableBuiltins);
// Step #2a: Register target-specific builtins.
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
Table.get(TSRecords[i].Name).setBuiltinID(i+Builtin::FirstTSBuiltin);
// Step #2b: Mark non-portable builtins as such.
for (unsigned i = 0, e = NonPortableBuiltins.size(); i != e; ++i)
Table.get(NonPortableBuiltins[i]).setNonPortableBuiltin(true);
}
/// DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the
/// pointer over the consumed characters. This returns the resultant type.
static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context) {
// Modifiers.
bool Long = false, LongLong = false, Signed = false, Unsigned = false;
// Read the modifiers first.
bool Done = false;
while (!Done) {
switch (*Str++) {
default: Done = true; --Str; break;
case 'S':
assert(!Unsigned && "Can't use both 'S' and 'U' modifiers!");
assert(!Signed && "Can't use 'S' modifier multiple times!");
Signed = true;
break;
case 'U':
assert(!Signed && "Can't use both 'S' and 'U' modifiers!");
assert(!Unsigned && "Can't use 'S' modifier multiple times!");
Unsigned = true;
break;
case 'L':
assert(!LongLong && "Can't have LLL modifier");
if (Long)
LongLong = true;
else
Long = true;
break;
}
}
QualType Type;
// Read the base type.
switch (*Str++) {
default: assert(0 && "Unknown builtin type letter!");
case 'v':
assert(!Long && !Signed && !Unsigned && "Bad modifiers used with 'v'!");
Type = Context.VoidTy;
break;
case 'f':
assert(!Long && !Signed && !Unsigned && "Bad modifiers used with 'f'!");
Type = Context.FloatTy;
break;
case 'd':
assert(!LongLong && !Signed && !Unsigned && "Bad modifiers used with 'd'!");
if (Long)
Type = Context.LongDoubleTy;
else
Type = Context.DoubleTy;
break;
case 's':
assert(!LongLong && "Bad modifiers used with 's'!");
if (Unsigned)
Type = Context.UnsignedShortTy;
else
Type = Context.ShortTy;
break;
case 'i':
if (Long)
Type = Unsigned ? Context.UnsignedLongTy : Context.LongTy;
else if (LongLong)
Type = Unsigned ? Context.UnsignedLongLongTy : Context.LongLongTy;
else if (Unsigned)
Type = Context.UnsignedIntTy;
else
Type = Context.IntTy; // default is signed.
break;
case 'c':
assert(!Long && !LongLong && "Bad modifiers used with 'c'!");
if (Signed)
Type = Context.SignedCharTy;
else if (Unsigned)
Type = Context.UnsignedCharTy;
else
Type = Context.CharTy;
break;
case 'F':
Type = Context.getCFConstantStringType();
break;
}
Done = false;
while (!Done) {
switch (*Str++) {
default: Done = true; --Str; break;
case '*':
Type = Context.getPointerType(Type);
break;
case 'C':
Type = Type.getQualifiedType(QualType::Const);
break;
}
}
return Type;
}
/// GetBuiltinType - Return the type for the specified builtin.
QualType Builtin::Context::GetBuiltinType(unsigned id, ASTContext &Context)const{
const char *TypeStr = GetRecord(id).Type;
llvm::SmallVector<QualType, 8> ArgTypes;
QualType ResType = DecodeTypeFromStr(TypeStr, Context);
while (TypeStr[0] && TypeStr[0] != '.')
ArgTypes.push_back(DecodeTypeFromStr(TypeStr, Context));
assert((TypeStr[0] != '.' || TypeStr[1] == 0) &&
"'.' should only occur at end of builtin type list!");
// handle untyped/variadic arguments "T c99Style();" or "T cppStyle(...);".
if (ArgTypes.size() == 0 && TypeStr[0] == '.')
return Context.getFunctionTypeNoProto(ResType);
return Context.getFunctionType(ResType, &ArgTypes[0], ArgTypes.size(),
TypeStr[0] == '.');
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,201 +0,0 @@
//===--- Decl.cpp - Declaration AST Node Implementation -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Decl class and subclasses.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/Decl.h"
#include "clang/Lex/IdentifierTable.h"
using namespace clang;
// temporary statistics gathering
static unsigned nFuncs = 0;
static unsigned nBlockVars = 0;
static unsigned nFileVars = 0;
static unsigned nParmVars = 0;
static unsigned nSUC = 0;
static unsigned nEnumConst = 0;
static unsigned nEnumDecls = 0;
static unsigned nTypedef = 0;
static unsigned nFieldDecls = 0;
static unsigned nInterfaceDecls = 0;
static bool StatSwitch = false;
bool Decl::CollectingStats(bool enable) {
if (enable) StatSwitch = true;
return StatSwitch;
}
void Decl::PrintStats() {
fprintf(stderr, "*** Decl Stats:\n");
fprintf(stderr, " %d decls total.\n",
int(nFuncs+nBlockVars+nFileVars+nParmVars+nFieldDecls+nSUC+
nEnumDecls+nEnumConst+nTypedef));
fprintf(stderr, " %d function decls, %d each (%d bytes)\n",
nFuncs, (int)sizeof(FunctionDecl), int(nFuncs*sizeof(FunctionDecl)));
fprintf(stderr, " %d block variable decls, %d each (%d bytes)\n",
nBlockVars, (int)sizeof(BlockVarDecl),
int(nBlockVars*sizeof(BlockVarDecl)));
fprintf(stderr, " %d file variable decls, %d each (%d bytes)\n",
nFileVars, (int)sizeof(FileVarDecl),
int(nFileVars*sizeof(FileVarDecl)));
fprintf(stderr, " %d parameter variable decls, %d each (%d bytes)\n",
nParmVars, (int)sizeof(ParmVarDecl),
int(nParmVars*sizeof(ParmVarDecl)));
fprintf(stderr, " %d field decls, %d each (%d bytes)\n",
nFieldDecls, (int)sizeof(FieldDecl),
int(nFieldDecls*sizeof(FieldDecl)));
fprintf(stderr, " %d struct/union/class decls, %d each (%d bytes)\n",
nSUC, (int)sizeof(RecordDecl),
int(nSUC*sizeof(RecordDecl)));
fprintf(stderr, " %d enum decls, %d each (%d bytes)\n",
nEnumDecls, (int)sizeof(EnumDecl),
int(nEnumDecls*sizeof(EnumDecl)));
fprintf(stderr, " %d enum constant decls, %d each (%d bytes)\n",
nEnumConst, (int)sizeof(EnumConstantDecl),
int(nEnumConst*sizeof(EnumConstantDecl)));
fprintf(stderr, " %d typedef decls, %d each (%d bytes)\n",
nTypedef, (int)sizeof(TypedefDecl),int(nTypedef*sizeof(TypedefDecl)));
fprintf(stderr, "Total bytes = %d\n",
int(nFuncs*sizeof(FunctionDecl)+nBlockVars*sizeof(BlockVarDecl)+
nFileVars*sizeof(FileVarDecl)+nParmVars*sizeof(ParmVarDecl)+
nFieldDecls*sizeof(FieldDecl)+nSUC*sizeof(RecordDecl)+
nEnumDecls*sizeof(EnumDecl)+nEnumConst*sizeof(EnumConstantDecl)+
nTypedef*sizeof(TypedefDecl)));
}
void Decl::addDeclKind(const Kind k) {
switch (k) {
case Typedef:
nTypedef++;
break;
case Function:
nFuncs++;
break;
case BlockVariable:
nBlockVars++;
break;
case FileVariable:
nFileVars++;
break;
case ParmVariable:
nParmVars++;
break;
case EnumConstant:
nEnumConst++;
break;
case Field:
nFieldDecls++;
break;
case Struct:
case Union:
case Class:
nSUC++;
break;
case Enum:
nEnumDecls++;
break;
case ObjcInterface:
nInterfaceDecls++;
break;
}
}
// Out-of-line virtual method providing a home for Decl.
Decl::~Decl() {
}
const char *Decl::getName() const {
if (const IdentifierInfo *II = getIdentifier())
return II->getName();
return "";
}
FunctionDecl::~FunctionDecl() {
delete[] ParamInfo;
}
unsigned FunctionDecl::getNumParams() const {
return cast<FunctionTypeProto>(getType().getTypePtr())->getNumArgs();
}
void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) {
assert(ParamInfo == 0 && "Already has param info!");
assert(NumParams == getNumParams() && "Parameter count mismatch!");
// Zero params -> null pointer.
if (NumParams) {
ParamInfo = new ParmVarDecl*[NumParams];
memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
}
}
/// defineBody - When created, RecordDecl's correspond to a forward declared
/// record. This method is used to mark the decl as being defined, with the
/// specified contents.
void RecordDecl::defineBody(FieldDecl **members, unsigned numMembers) {
assert(!isDefinition() && "Cannot redefine record!");
setDefinition(true);
NumMembers = numMembers;
if (numMembers) {
Members = new FieldDecl*[numMembers];
memcpy(Members, members, numMembers*sizeof(Decl*));
}
}
FieldDecl* RecordDecl::getMember(IdentifierInfo *name) {
if (Members == 0 || NumMembers < 0)
return 0;
// linear search. When C++ classes come along, will likely need to revisit.
for (int i = 0; i < NumMembers; ++i) {
if (Members[i]->getIdentifier() == name)
return Members[i];
}
return 0;
}
void ObjcMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo,
unsigned NumParams) {
assert(ParamInfo == 0 && "Already has param info!");
// Zero params -> null pointer.
if (NumParams) {
ParamInfo = new ParmVarDecl*[NumParams];
memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
NumMethodParams = NumParams;
}
}
ObjcMethodDecl::~ObjcMethodDecl() {
delete[] ParamInfo;
}
/// addObjcMethods - Insert instance and methods declarations into
/// ObjcInterfaceDecl's InsMethods and ClsMethods fields.
///
void ObjcInterfaceDecl::ObjcAddMethods(ObjcMethodDecl **insMethods,
unsigned numInsMembers,
ObjcMethodDecl **clsMethods,
unsigned numClsMembers) {
NumInsMethods = numInsMembers;
if (numInsMembers) {
InsMethods = new ObjcMethodDecl*[numInsMembers];
memcpy(InsMethods, insMethods, numInsMembers*sizeof(ObjcMethodDecl*));
}
NumClsMethods = numClsMembers;
if (numClsMembers) {
ClsMethods = new ObjcMethodDecl*[numClsMembers];
memcpy(ClsMethods, clsMethods, numClsMembers*sizeof(ObjcMethodDecl*));
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +0,0 @@
//===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Ted Kremenek and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the subclesses of Expr class declared in ExprCXX.h
//
//===----------------------------------------------------------------------===//
#include "clang/AST/ExprCXX.h"
using namespace clang;
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
// CXXCastExpr
Stmt::child_iterator CXXCastExpr::child_begin() {
return reinterpret_cast<Stmt**>(&Op);
}
Stmt::child_iterator CXXCastExpr::child_end() {
return child_begin()+1;
}
// CXXBoolLiteralExpr
Stmt::child_iterator CXXBoolLiteralExpr::child_begin() { return NULL; }
Stmt::child_iterator CXXBoolLiteralExpr::child_end() { return NULL; }

View File

@@ -1,22 +0,0 @@
##===- clang/AST/Makefile ----------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Chris Lattner and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements the AST library for the C-Language front-end.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LIBRARYNAME := clangAST
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
include $(LEVEL)/Makefile.common

View File

@@ -1,169 +0,0 @@
//===--- Stmt.cpp - Statement AST Node Implementation ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Stmt class and statement subclasses.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/Stmt.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Lex/IdentifierTable.h"
using namespace clang;
static struct StmtClassNameTable {
const char *Name;
unsigned Counter;
unsigned Size;
} StmtClassInfo[Stmt::lastExprConstant+1];
static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
static bool Initialized = false;
if (Initialized)
return StmtClassInfo[E];
// Intialize the table on the first use.
Initialized = true;
#define STMT(N, CLASS, PARENT) \
StmtClassInfo[N].Name = #CLASS; \
StmtClassInfo[N].Size = sizeof(CLASS);
#include "clang/AST/StmtNodes.def"
return StmtClassInfo[E];
}
const char *Stmt::getStmtClassName() const {
return getStmtInfoTableEntry(sClass).Name;
}
void Stmt::PrintStats() {
// Ensure the table is primed.
getStmtInfoTableEntry(Stmt::NullStmtClass);
unsigned sum = 0;
fprintf(stderr, "*** Stmt/Expr Stats:\n");
for (int i = 0; i != Stmt::lastExprConstant+1; i++) {
if (StmtClassInfo[i].Name == 0) continue;
sum += StmtClassInfo[i].Counter;
}
fprintf(stderr, " %d stmts/exprs total.\n", sum);
sum = 0;
for (int i = 0; i != Stmt::lastExprConstant+1; i++) {
if (StmtClassInfo[i].Name == 0) continue;
fprintf(stderr, " %d %s, %d each (%d bytes)\n",
StmtClassInfo[i].Counter, StmtClassInfo[i].Name,
StmtClassInfo[i].Size,
StmtClassInfo[i].Counter*StmtClassInfo[i].Size);
sum += StmtClassInfo[i].Counter*StmtClassInfo[i].Size;
}
fprintf(stderr, "Total bytes = %d\n", sum);
}
void Stmt::addStmtClass(StmtClass s) {
++getStmtInfoTableEntry(s).Counter;
}
static bool StatSwitch = false;
bool Stmt::CollectingStats(bool enable) {
if (enable) StatSwitch = true;
return StatSwitch;
}
const char *LabelStmt::getName() const {
return getID()->getName();
}
// This is defined here to avoid polluting Stmt.h with importing Expr.h
SourceRange ReturnStmt::getSourceRange() const {
if (RetExpr)
return SourceRange(RetLoc, RetExpr->getLocEnd());
else
return SourceRange(RetLoc);
}
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
// DeclStmt
Stmt::child_iterator DeclStmt::child_begin() { return NULL; }
Stmt::child_iterator DeclStmt::child_end() { return NULL; }
// NullStmt
Stmt::child_iterator NullStmt::child_begin() { return NULL; }
Stmt::child_iterator NullStmt::child_end() { return NULL; }
// CompoundStmt
Stmt::child_iterator CompoundStmt::child_begin() { return &Body[0]; }
Stmt::child_iterator CompoundStmt::child_end() { return &Body[0]+Body.size(); }
// CaseStmt
Stmt::child_iterator CaseStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator CaseStmt::child_end() { return &SubExprs[END_EXPR]; }
// DefaultStmt
Stmt::child_iterator DefaultStmt::child_begin() { return &SubStmt; }
Stmt::child_iterator DefaultStmt::child_end() { return &SubStmt+1; }
// LabelStmt
Stmt::child_iterator LabelStmt::child_begin() { return &SubStmt; }
Stmt::child_iterator LabelStmt::child_end() { return &SubStmt+1; }
// IfStmt
Stmt::child_iterator IfStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator IfStmt::child_end() { return &SubExprs[0]+END_EXPR; }
// SwitchStmt
Stmt::child_iterator SwitchStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator SwitchStmt::child_end() { return &SubExprs[0]+END_EXPR; }
// WhileStmt
Stmt::child_iterator WhileStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator WhileStmt::child_end() { return &SubExprs[0]+END_EXPR; }
// DoStmt
Stmt::child_iterator DoStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator DoStmt::child_end() { return &SubExprs[0]+END_EXPR; }
// ForStmt
Stmt::child_iterator ForStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator ForStmt::child_end() { return &SubExprs[0]+END_EXPR; }
// GotoStmt
Stmt::child_iterator GotoStmt::child_begin() { return NULL; }
Stmt::child_iterator GotoStmt::child_end() { return NULL; }
// IndirectGotoStmt
Stmt::child_iterator IndirectGotoStmt::child_begin() {
return reinterpret_cast<Stmt**>(&Target);
}
Stmt::child_iterator IndirectGotoStmt::child_end() { return child_begin()+1; }
// ContinueStmt
Stmt::child_iterator ContinueStmt::child_begin() { return NULL; }
Stmt::child_iterator ContinueStmt::child_end() { return NULL; }
// BreakStmt
Stmt::child_iterator BreakStmt::child_begin() { return NULL; }
Stmt::child_iterator BreakStmt::child_end() { return NULL; }
// ReturnStmt
Stmt::child_iterator ReturnStmt::child_begin() {
if (RetExpr) return reinterpret_cast<Stmt**>(&RetExpr);
else return NULL;
}
Stmt::child_iterator ReturnStmt::child_end() {
if (RetExpr) return reinterpret_cast<Stmt**>(&RetExpr)+1;
else return NULL;
}

View File

@@ -1,443 +0,0 @@
//===--- StmtDumper.cpp - Dumping implementation for Stmt ASTs ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Stmt::dump/Stmt::print methods, which dump out the
// AST in a form that exposes type details and other fields.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Decl.h"
#include "clang/AST/ExprCXX.h"
#include "clang/Lex/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/Compiler.h"
#include <cstdio>
using namespace clang;
//===----------------------------------------------------------------------===//
// StmtDumper Visitor
//===----------------------------------------------------------------------===//
namespace {
class VISIBILITY_HIDDEN StmtDumper : public StmtVisitor<StmtDumper> {
SourceManager *SM;
FILE *F;
unsigned IndentLevel;
/// MaxDepth - When doing a normal dump (not dumpAll) we only want to dump
/// the first few levels of an AST. This keeps track of how many ast levels
/// are left.
unsigned MaxDepth;
/// LastLocFilename/LastLocLine - Keep track of the last location we print
/// out so that we can print out deltas from then on out.
const char *LastLocFilename;
unsigned LastLocLine;
public:
StmtDumper(SourceManager *sm, FILE *f, unsigned maxDepth)
: SM(sm), F(f), IndentLevel(0-1), MaxDepth(maxDepth) {
LastLocFilename = "";
LastLocLine = ~0U;
}
void DumpSubTree(Stmt *S) {
// Prune the recursion if not using dump all.
if (MaxDepth == 0) return;
++IndentLevel;
if (S) {
Visit(S);
// Print out children.
Stmt::child_iterator CI = S->child_begin(), CE = S->child_end();
if (CI != CE) {
while (CI != CE) {
fprintf(F, "\n");
DumpSubTree(*CI++);
}
}
fprintf(F, ")");
} else {
Indent();
fprintf(F, "<<<NULL>>>");
}
--IndentLevel;
}
void DumpDeclarator(Decl *D);
void Indent() const {
for (int i = 0, e = IndentLevel; i < e; ++i)
fprintf(F, " ");
}
void DumpType(QualType T) {
fprintf(F, "'%s'", T.getAsString().c_str());
// If the type is directly a typedef, strip off typedefness to give at
// least one level of concreteness.
if (TypedefType *TDT = dyn_cast<TypedefType>(T))
fprintf(F, ":'%s'", TDT->LookThroughTypedefs().getAsString().c_str());
}
void DumpStmt(const Stmt *Node) {
Indent();
fprintf(F, "(%s %p", Node->getStmtClassName(), (void*)Node);
DumpSourceRange(Node);
}
void DumpExpr(const Expr *Node) {
DumpStmt(Node);
fprintf(F, " ");
DumpType(Node->getType());
}
void DumpSourceRange(const Stmt *Node);
void DumpLocation(SourceLocation Loc);
// Stmts.
void VisitStmt(Stmt *Node);
void VisitDeclStmt(DeclStmt *Node);
void VisitLabelStmt(LabelStmt *Node);
void VisitGotoStmt(GotoStmt *Node);
// Exprs
void VisitExpr(Expr *Node);
void VisitDeclRefExpr(DeclRefExpr *Node);
void VisitPreDefinedExpr(PreDefinedExpr *Node);
void VisitCharacterLiteral(CharacterLiteral *Node);
void VisitIntegerLiteral(IntegerLiteral *Node);
void VisitFloatingLiteral(FloatingLiteral *Node);
void VisitStringLiteral(StringLiteral *Str);
void VisitUnaryOperator(UnaryOperator *Node);
void VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node);
void VisitMemberExpr(MemberExpr *Node);
void VisitOCUVectorElementExpr(OCUVectorElementExpr *Node);
void VisitBinaryOperator(BinaryOperator *Node);
void VisitCompoundAssignOperator(CompoundAssignOperator *Node);
void VisitAddrLabelExpr(AddrLabelExpr *Node);
void VisitTypesCompatibleExpr(TypesCompatibleExpr *Node);
// C++
void VisitCXXCastExpr(CXXCastExpr *Node);
void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node);
// ObjC
void VisitObjCEncodeExpr(ObjCEncodeExpr *Node);
};
}
//===----------------------------------------------------------------------===//
// Utilities
//===----------------------------------------------------------------------===//
void StmtDumper::DumpLocation(SourceLocation Loc) {
SourceLocation PhysLoc = SM->getPhysicalLoc(Loc);
// The general format we print out is filename:line:col, but we drop pieces
// that haven't changed since the last loc printed.
const char *Filename = SM->getSourceName(PhysLoc);
unsigned LineNo = SM->getLineNumber(PhysLoc);
if (strcmp(Filename, LastLocFilename) != 0) {
fprintf(stderr, "%s:%u:%u", Filename, LineNo, SM->getColumnNumber(PhysLoc));
LastLocFilename = Filename;
LastLocLine = LineNo;
} else if (LineNo != LastLocLine) {
fprintf(stderr, "line:%u:%u", LineNo, SM->getColumnNumber(PhysLoc));
LastLocLine = LineNo;
} else {
fprintf(stderr, "col:%u", SM->getColumnNumber(PhysLoc));
}
}
void StmtDumper::DumpSourceRange(const Stmt *Node) {
// Can't translate locations if a SourceManager isn't available.
if (SM == 0) return;
// TODO: If the parent expression is available, we can print a delta vs its
// location.
SourceRange R = Node->getSourceRange();
fprintf(stderr, " <");
DumpLocation(R.Begin());
if (R.Begin() != R.End()) {
fprintf(stderr, ", ");
DumpLocation(R.End());
}
fprintf(stderr, ">");
// <t2.c:123:421[blah], t2.c:412:321>
}
//===----------------------------------------------------------------------===//
// Stmt printing methods.
//===----------------------------------------------------------------------===//
void StmtDumper::VisitStmt(Stmt *Node) {
DumpStmt(Node);
}
void StmtDumper::DumpDeclarator(Decl *D) {
// FIXME: Need to complete/beautify this... this code simply shows the
// nodes are where they need to be.
if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
fprintf(F, "\"typedef %s %s\"",
localType->getUnderlyingType().getAsString().c_str(),
localType->getName());
} else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
fprintf(F, "\"");
// Emit storage class for vardecls.
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
switch (V->getStorageClass()) {
default: assert(0 && "Unknown storage class!");
case VarDecl::None: break;
case VarDecl::Extern: fprintf(F, "extern "); break;
case VarDecl::Static: fprintf(F, "static "); break;
case VarDecl::Auto: fprintf(F, "auto "); break;
case VarDecl::Register: fprintf(F, "register "); break;
}
}
std::string Name = VD->getName();
VD->getType().getAsStringInternal(Name);
fprintf(F, "%s", Name.c_str());
// If this is a vardecl with an initializer, emit it.
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
if (V->getInit()) {
fprintf(F, " =\n");
DumpSubTree(V->getInit());
}
}
fprintf(F, "\"");
} else {
// FIXME: "struct x;"
assert(0 && "Unexpected decl");
}
}
void StmtDumper::VisitDeclStmt(DeclStmt *Node) {
DumpStmt(Node);
fprintf(F, "\n");
for (Decl *D = Node->getDecl(); D; D = D->getNextDeclarator()) {
++IndentLevel;
Indent();
fprintf(F, "%p ", (void*)D);
DumpDeclarator(D);
if (D->getNextDeclarator())
fprintf(F, "\n");
--IndentLevel;
}
}
void StmtDumper::VisitLabelStmt(LabelStmt *Node) {
DumpStmt(Node);
fprintf(F, " '%s'\n", Node->getName());
}
void StmtDumper::VisitGotoStmt(GotoStmt *Node) {
DumpStmt(Node);
fprintf(F, " '%s':%p", Node->getLabel()->getName(), (void*)Node->getLabel());
}
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
void StmtDumper::VisitExpr(Expr *Node) {
DumpExpr(Node);
}
void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
DumpExpr(Node);
fprintf(F, " ");
switch (Node->getDecl()->getKind()) {
case Decl::Function: fprintf(F,"FunctionDecl"); break;
case Decl::BlockVariable: fprintf(F,"BlockVariable"); break;
case Decl::FileVariable: fprintf(F,"FileVariable"); break;
case Decl::ParmVariable: fprintf(F,"ParmVariable"); break;
case Decl::EnumConstant: fprintf(F,"EnumConstant"); break;
case Decl::Typedef: fprintf(F,"Typedef"); break;
case Decl::Struct: fprintf(F,"Struct"); break;
case Decl::Union: fprintf(F,"Union"); break;
case Decl::Class: fprintf(F,"Class"); break;
case Decl::Enum: fprintf(F,"Enum"); break;
case Decl::ObjcInterface: fprintf(F,"ObjcInterface"); break;
case Decl::ObjcClass: fprintf(F,"ObjcClass"); break;
default: fprintf(F,"Decl"); break;
}
fprintf(F, "='%s' %p", Node->getDecl()->getName(), (void*)Node->getDecl());
}
void StmtDumper::VisitPreDefinedExpr(PreDefinedExpr *Node) {
DumpExpr(Node);
switch (Node->getIdentType()) {
default:
assert(0 && "unknown case");
case PreDefinedExpr::Func:
fprintf(F, " __func__");
break;
case PreDefinedExpr::Function:
fprintf(F, " __FUNCTION__");
break;
case PreDefinedExpr::PrettyFunction:
fprintf(F, " __PRETTY_FUNCTION__");
break;
}
}
void StmtDumper::VisitCharacterLiteral(CharacterLiteral *Node) {
DumpExpr(Node);
fprintf(F, " %d", Node->getValue());
}
void StmtDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
DumpExpr(Node);
bool isSigned = Node->getType()->isSignedIntegerType();
fprintf(F, " %s", Node->getValue().toString(10, isSigned).c_str());
}
void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
DumpExpr(Node);
fprintf(F, " %f", Node->getValue());
}
void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
DumpExpr(Str);
// FIXME: this doesn't print wstrings right.
fprintf(F, " %s\"", Str->isWide() ? "L" : "");
for (unsigned i = 0, e = Str->getByteLength(); i != e; ++i) {
switch (char C = Str->getStrData()[i]) {
default:
if (isprint(C))
fputc(C, F);
else
fprintf(F, "\\%03o", C);
break;
// Handle some common ones to make dumps prettier.
case '\\': fprintf(F, "\\\\"); break;
case '"': fprintf(F, "\\\""); break;
case '\n': fprintf(F, "\\n"); break;
case '\t': fprintf(F, "\\t"); break;
case '\a': fprintf(F, "\\a"); break;
case '\b': fprintf(F, "\\b"); break;
}
}
fprintf(F, "\"");
}
void StmtDumper::VisitUnaryOperator(UnaryOperator *Node) {
DumpExpr(Node);
fprintf(F, " %s '%s'", Node->isPostfix() ? "postfix" : "prefix",
UnaryOperator::getOpcodeStr(Node->getOpcode()));
}
void StmtDumper::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) {
DumpExpr(Node);
fprintf(F, " %s ", Node->isSizeOf() ? "sizeof" : "alignof");
DumpType(Node->getArgumentType());
}
void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
DumpExpr(Node);
fprintf(F, " %s%s %p", Node->isArrow() ? "->" : ".",
Node->getMemberDecl()->getName(), (void*)Node->getMemberDecl());
}
void StmtDumper::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) {
DumpExpr(Node);
fprintf(F, " %s", Node->getAccessor().getName());
}
void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
DumpExpr(Node);
fprintf(F, " '%s'", BinaryOperator::getOpcodeStr(Node->getOpcode()));
}
void StmtDumper::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
DumpExpr(Node);
fprintf(F, " '%s' ComputeTy=",
BinaryOperator::getOpcodeStr(Node->getOpcode()));
DumpType(Node->getComputationType());
}
// GNU extensions.
void StmtDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
DumpExpr(Node);
fprintf(F, " %s %p", Node->getLabel()->getName(), (void*)Node->getLabel());
}
void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
DumpExpr(Node);
fprintf(F, " ");
DumpType(Node->getArgType1());
fprintf(F, " ");
DumpType(Node->getArgType2());
}
//===----------------------------------------------------------------------===//
// C++ Expressions
//===----------------------------------------------------------------------===//
void StmtDumper::VisitCXXCastExpr(CXXCastExpr *Node) {
DumpExpr(Node);
fprintf(F, " %s", CXXCastExpr::getOpcodeStr(Node->getOpcode()));
}
void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
DumpExpr(Node);
fprintf(F, " %s", Node->getValue() ? "true" : "false");
}
//===----------------------------------------------------------------------===//
// Obj-C Expressions
//===----------------------------------------------------------------------===//
void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
DumpExpr(Node);
fprintf(F, " ");
DumpType(Node->getEncodedType());
}
//===----------------------------------------------------------------------===//
// Stmt method implementations
//===----------------------------------------------------------------------===//
/// dump - This does a local dump of the specified AST fragment. It dumps the
/// specified node and a few nodes underneath it, but not the whole subtree.
/// This is useful in a debugger.
void Stmt::dump(SourceManager &SM) const {
StmtDumper P(&SM, stderr, 4);
P.DumpSubTree(const_cast<Stmt*>(this));
fprintf(stderr, "\n");
}
/// dump - This does a local dump of the specified AST fragment. It dumps the
/// specified node and a few nodes underneath it, but not the whole subtree.
/// This is useful in a debugger.
void Stmt::dump() const {
StmtDumper P(0, stderr, 4);
P.DumpSubTree(const_cast<Stmt*>(this));
fprintf(stderr, "\n");
}
/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
void Stmt::dumpAll(SourceManager &SM) const {
StmtDumper P(&SM, stderr, ~0U);
P.DumpSubTree(const_cast<Stmt*>(this));
fprintf(stderr, "\n");
}
/// dumpAll - This does a dump of the specified AST fragment and all subtrees.
void Stmt::dumpAll() const {
StmtDumper P(0, stderr, ~0U);
P.DumpSubTree(const_cast<Stmt*>(this));
fprintf(stderr, "\n");
}

View File

@@ -1,620 +0,0 @@
//===--- StmtPrinter.cpp - Printing implementation for Stmt ASTs ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Stmt::dumpPretty/Stmt::printPretty methods, which
// pretty print the AST back out to C code.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/Decl.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/Lex/IdentifierTable.h"
#include "llvm/Support/Compiler.h"
#include <iostream>
#include <iomanip>
using namespace clang;
//===----------------------------------------------------------------------===//
// StmtPrinter Visitor
//===----------------------------------------------------------------------===//
namespace {
class VISIBILITY_HIDDEN StmtPrinter : public StmtVisitor<StmtPrinter> {
std::ostream &OS;
unsigned IndentLevel;
clang::PrinterHelper* Helper;
public:
StmtPrinter(std::ostream &os, PrinterHelper* helper) :
OS(os), IndentLevel(0), Helper(helper) {}
void PrintStmt(Stmt *S, int SubIndent = 1) {
IndentLevel += SubIndent;
if (S && isa<Expr>(S)) {
// If this is an expr used in a stmt context, indent and newline it.
Indent();
Visit(S);
OS << ";\n";
} else if (S) {
Visit(S);
} else {
Indent() << "<<<NULL STATEMENT>>>\n";
}
IndentLevel -= SubIndent;
}
void PrintRawCompoundStmt(CompoundStmt *S);
void PrintRawDecl(Decl *D);
void PrintRawIfStmt(IfStmt *If);
void PrintExpr(Expr *E) {
if (E)
Visit(E);
else
OS << "<null expr>";
}
std::ostream &Indent(int Delta = 0) const {
for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
OS << " ";
return OS;
}
bool PrintOffsetOfDesignator(Expr *E);
void VisitUnaryOffsetOf(UnaryOperator *Node);
void Visit(Stmt* S) {
if (Helper && Helper->handledStmt(S,OS))
return;
else StmtVisitor<StmtPrinter>::Visit(S);
}
void VisitStmt(Stmt *Node);
#define STMT(N, CLASS, PARENT) \
void Visit##CLASS(CLASS *Node);
#include "clang/AST/StmtNodes.def"
};
}
//===----------------------------------------------------------------------===//
// Stmt printing methods.
//===----------------------------------------------------------------------===//
void StmtPrinter::VisitStmt(Stmt *Node) {
Indent() << "<<unknown stmt type>>\n";
}
/// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
/// with no newline after the }.
void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
OS << "{\n";
for (CompoundStmt::body_iterator I = Node->body_begin(), E = Node->body_end();
I != E; ++I)
PrintStmt(*I);
Indent() << "}";
}
void StmtPrinter::PrintRawDecl(Decl *D) {
// FIXME: Need to complete/beautify this... this code simply shows the
// nodes are where they need to be.
if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
OS << "typedef " << localType->getUnderlyingType().getAsString();
OS << " " << localType->getName();
} else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
// Emit storage class for vardecls.
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
switch (V->getStorageClass()) {
default: assert(0 && "Unknown storage class!");
case VarDecl::None: break;
case VarDecl::Extern: OS << "extern "; break;
case VarDecl::Static: OS << "static "; break;
case VarDecl::Auto: OS << "auto "; break;
case VarDecl::Register: OS << "register "; break;
}
}
std::string Name = VD->getName();
VD->getType().getAsStringInternal(Name);
OS << Name;
// If this is a vardecl with an initializer, emit it.
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
if (V->getInit()) {
OS << " = ";
PrintExpr(V->getInit());
}
}
} else {
// FIXME: "struct x;"
assert(0 && "Unexpected decl");
}
}
void StmtPrinter::VisitNullStmt(NullStmt *Node) {
Indent() << ";\n";
}
void StmtPrinter::VisitDeclStmt(DeclStmt *Node) {
for (Decl *D = Node->getDecl(); D; D = D->getNextDeclarator()) {
Indent();
PrintRawDecl(D);
OS << ";\n";
}
}
void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) {
Indent();
PrintRawCompoundStmt(Node);
OS << "\n";
}
void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
Indent(-1) << "case ";
PrintExpr(Node->getLHS());
if (Node->getRHS()) {
OS << " ... ";
PrintExpr(Node->getRHS());
}
OS << ":\n";
PrintStmt(Node->getSubStmt(), 0);
}
void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) {
Indent(-1) << "default:\n";
PrintStmt(Node->getSubStmt(), 0);
}
void StmtPrinter::VisitLabelStmt(LabelStmt *Node) {
Indent(-1) << Node->getName() << ":\n";
PrintStmt(Node->getSubStmt(), 0);
}
void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
OS << "if ";
PrintExpr(If->getCond());
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
OS << ' ';
PrintRawCompoundStmt(CS);
OS << (If->getElse() ? ' ' : '\n');
} else {
OS << '\n';
PrintStmt(If->getThen());
if (If->getElse()) Indent();
}
if (Stmt *Else = If->getElse()) {
OS << "else";
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
OS << ' ';
PrintRawCompoundStmt(CS);
OS << '\n';
} else if (IfStmt *ElseIf = dyn_cast<IfStmt>(Else)) {
OS << ' ';
PrintRawIfStmt(ElseIf);
} else {
OS << '\n';
PrintStmt(If->getElse());
}
}
}
void StmtPrinter::VisitIfStmt(IfStmt *If) {
Indent();
PrintRawIfStmt(If);
}
void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
Indent() << "switch (";
PrintExpr(Node->getCond());
OS << ")";
// Pretty print compoundstmt bodies (very common).
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
OS << " ";
PrintRawCompoundStmt(CS);
OS << "\n";
} else {
OS << "\n";
PrintStmt(Node->getBody());
}
}
void StmtPrinter::VisitSwitchCase(SwitchCase*) {
assert(0 && "SwitchCase is an abstract class");
}
void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
Indent() << "while (";
PrintExpr(Node->getCond());
OS << ")\n";
PrintStmt(Node->getBody());
}
void StmtPrinter::VisitDoStmt(DoStmt *Node) {
Indent() << "do\n";
PrintStmt(Node->getBody());
Indent() << "while ";
PrintExpr(Node->getCond());
OS << ";\n";
}
void StmtPrinter::VisitForStmt(ForStmt *Node) {
Indent() << "for (";
if (Node->getInit()) {
if (DeclStmt *DS = dyn_cast<DeclStmt>(Node->getInit()))
PrintRawDecl(DS->getDecl());
else
PrintExpr(cast<Expr>(Node->getInit()));
}
OS << "; ";
if (Node->getCond())
PrintExpr(Node->getCond());
OS << "; ";
if (Node->getInc())
PrintExpr(Node->getInc());
OS << ")\n";
PrintStmt(Node->getBody());
}
void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
Indent() << "goto " << Node->getLabel()->getName() << ";\n";
}
void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
Indent() << "goto *";
PrintExpr(Node->getTarget());
OS << ";\n";
}
void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
Indent() << "continue;\n";
}
void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
Indent() << "break;\n";
}
void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
Indent() << "return";
if (Node->getRetValue()) {
OS << " ";
PrintExpr(Node->getRetValue());
}
OS << ";\n";
}
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
void StmtPrinter::VisitExpr(Expr *Node) {
OS << "<<unknown expr type>>";
}
void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
OS << Node->getDecl()->getName();
}
void StmtPrinter::VisitPreDefinedExpr(PreDefinedExpr *Node) {
switch (Node->getIdentType()) {
default:
assert(0 && "unknown case");
case PreDefinedExpr::Func:
OS << "__func__";
break;
case PreDefinedExpr::Function:
OS << "__FUNCTION__";
break;
case PreDefinedExpr::PrettyFunction:
OS << "__PRETTY_FUNCTION__";
break;
}
}
void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
// FIXME should print an L for wchar_t constants
unsigned value = Node->getValue();
switch (value) {
case '\\':
OS << "'\\\\'";
break;
case '\'':
OS << "'\\''";
break;
case '\a':
// TODO: K&R: the meaning of '\\a' is different in traditional C
OS << "'\\a'";
break;
case '\b':
OS << "'\\b'";
break;
// Nonstandard escape sequence.
/*case '\e':
OS << "'\\e'";
break;*/
case '\f':
OS << "'\\f'";
break;
case '\n':
OS << "'\\n'";
break;
case '\r':
OS << "'\\r'";
break;
case '\t':
OS << "'\\t'";
break;
case '\v':
OS << "'\\v'";
break;
default:
if (isprint(value) && value < 256) {
OS << "'" << (char)value << "'";
} else if (value < 256) {
OS << "'\\x" << std::hex << value << std::dec << "'";
} else {
// FIXME what to really do here?
OS << value;
}
}
}
void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
bool isSigned = Node->getType()->isSignedIntegerType();
OS << Node->getValue().toString(10, isSigned);
// Emit suffixes. Integer literals are always a builtin integer type.
switch (cast<BuiltinType>(Node->getType().getCanonicalType())->getKind()) {
default: assert(0 && "Unexpected type for integer literal!");
case BuiltinType::Int: break; // no suffix.
case BuiltinType::UInt: OS << 'U'; break;
case BuiltinType::Long: OS << 'L'; break;
case BuiltinType::ULong: OS << "UL"; break;
case BuiltinType::LongLong: OS << "LL"; break;
case BuiltinType::ULongLong: OS << "ULL"; break;
}
}
void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
// FIXME: print value more precisely.
OS << Node->getValue();
}
void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
PrintExpr(Node->getSubExpr());
OS << "i";
}
void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
if (Str->isWide()) OS << 'L';
OS << '"';
// FIXME: this doesn't print wstrings right.
for (unsigned i = 0, e = Str->getByteLength(); i != e; ++i) {
switch (Str->getStrData()[i]) {
default: OS << Str->getStrData()[i]; break;
// Handle some common ones to make dumps prettier.
case '\\': OS << "\\\\"; break;
case '"': OS << "\\\""; break;
case '\n': OS << "\\n"; break;
case '\t': OS << "\\t"; break;
case '\a': OS << "\\a"; break;
case '\b': OS << "\\b"; break;
}
}
OS << '"';
}
void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
OS << "(";
PrintExpr(Node->getSubExpr());
OS << ")";
}
void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
if (!Node->isPostfix()) {
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
// Print a space if this is an "identifier operator" like sizeof or __real.
switch (Node->getOpcode()) {
default: break;
case UnaryOperator::SizeOf:
case UnaryOperator::AlignOf:
case UnaryOperator::Real:
case UnaryOperator::Imag:
case UnaryOperator::Extension:
OS << ' ';
break;
}
}
PrintExpr(Node->getSubExpr());
if (Node->isPostfix())
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
}
bool StmtPrinter::PrintOffsetOfDesignator(Expr *E) {
if (isa<CompoundLiteralExpr>(E)) {
// Base case, print the type and comma.
OS << E->getType().getAsString() << ", ";
return true;
} else if (ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
PrintOffsetOfDesignator(ASE->getLHS());
OS << "[";
PrintExpr(ASE->getRHS());
OS << "]";
return false;
} else {
MemberExpr *ME = cast<MemberExpr>(E);
bool IsFirst = PrintOffsetOfDesignator(ME->getBase());
OS << (IsFirst ? "" : ".") << ME->getMemberDecl()->getName();
return false;
}
}
void StmtPrinter::VisitUnaryOffsetOf(UnaryOperator *Node) {
OS << "__builtin_offsetof(";
PrintOffsetOfDesignator(Node->getSubExpr());
OS << ")";
}
void StmtPrinter::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) {
OS << (Node->isSizeOf() ? "sizeof(" : "__alignof(");
OS << Node->getArgumentType().getAsString() << ")";
}
void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {
PrintExpr(Node->getLHS());
OS << "[";
PrintExpr(Node->getRHS());
OS << "]";
}
void StmtPrinter::VisitCallExpr(CallExpr *Call) {
PrintExpr(Call->getCallee());
OS << "(";
for (unsigned i = 0, e = Call->getNumArgs(); i != e; ++i) {
if (i) OS << ", ";
PrintExpr(Call->getArg(i));
}
OS << ")";
}
void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
PrintExpr(Node->getBase());
OS << (Node->isArrow() ? "->" : ".");
FieldDecl *Field = Node->getMemberDecl();
assert(Field && "MemberExpr should alway reference a field!");
OS << Field->getName();
}
void StmtPrinter::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) {
PrintExpr(Node->getBase());
OS << ".";
OS << Node->getAccessor().getName();
}
void StmtPrinter::VisitCastExpr(CastExpr *Node) {
OS << "(" << Node->getType().getAsString() << ")";
PrintExpr(Node->getSubExpr());
}
void StmtPrinter::VisitCompoundLiteralExpr(CompoundLiteralExpr *Node) {
OS << "(" << Node->getType().getAsString() << ")";
PrintExpr(Node->getInitializer());
}
void StmtPrinter::VisitImplicitCastExpr(ImplicitCastExpr *Node) {
// No need to print anything, simply forward to the sub expression.
PrintExpr(Node->getSubExpr());
}
void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
PrintExpr(Node->getLHS());
OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
PrintExpr(Node->getRHS());
}
void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
PrintExpr(Node->getLHS());
OS << " " << BinaryOperator::getOpcodeStr(Node->getOpcode()) << " ";
PrintExpr(Node->getRHS());
}
void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
PrintExpr(Node->getCond());
OS << " ? ";
PrintExpr(Node->getLHS());
OS << " : ";
PrintExpr(Node->getRHS());
}
// GNU extensions.
void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
OS << "&&" << Node->getLabel()->getName();
}
void StmtPrinter::VisitStmtExpr(StmtExpr *E) {
OS << "(";
PrintRawCompoundStmt(E->getSubStmt());
OS << ")";
}
void StmtPrinter::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
OS << "__builtin_types_compatible_p(";
OS << Node->getArgType1().getAsString() << ",";
OS << Node->getArgType2().getAsString() << ")";
}
void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
OS << "__builtin_choose_expr(";
PrintExpr(Node->getCond());
OS << ", ";
PrintExpr(Node->getLHS());
OS << ", ";
PrintExpr(Node->getRHS());
OS << ")";
}
void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
OS << "{ ";
for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
if (i) OS << ", ";
PrintExpr(Node->getInit(i));
}
OS << " }";
}
// C++
void StmtPrinter::VisitCXXCastExpr(CXXCastExpr *Node) {
OS << CXXCastExpr::getOpcodeStr(Node->getOpcode()) << '<';
OS << Node->getDestType().getAsString() << ">(";
PrintExpr(Node->getSubExpr());
OS << ")";
}
void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
OS << (Node->getValue() ? "true" : "false");
}
// Obj-C
void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
OS << "@";
VisitStringLiteral(Node->getString());
}
void StmtPrinter::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
OS << "@encode(";
OS << Node->getEncodedType().getAsString() << ")";
}
//===----------------------------------------------------------------------===//
// Stmt method implementations
//===----------------------------------------------------------------------===//
void Stmt::dumpPretty() const {
// FIXME: eliminate use of <iostream>
printPretty(std::cerr);
}
void Stmt::printPretty(std::ostream &OS, PrinterHelper* Helper) const {
if (this == 0) {
OS << "<NULL>";
return;
}
StmtPrinter P(OS, Helper);
P.Visit(const_cast<Stmt*>(this));
}
//===----------------------------------------------------------------------===//
// PrinterHelper
//===----------------------------------------------------------------------===//
// Implement virtual destructor.
PrinterHelper::~PrinterHelper() {}

View File

@@ -1,857 +0,0 @@
//===--- Type.cpp - Type representation and manipulation ------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements type-related functionality.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/IdentifierTable.h"
#include "clang/AST/Type.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/Support/Streams.h"
#include "llvm/ADT/StringExtras.h"
#include <sstream>
using namespace clang;
Type::~Type() {}
/// isVoidType - Helper method to determine if this is the 'void' type.
bool Type::isVoidType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Void;
return false;
}
bool Type::isObjectType() const {
if (isa<FunctionType>(CanonicalType))
return false;
else if (CanonicalType->isIncompleteType())
return false;
else
return true;
}
bool Type::isDerivedType() const {
switch (CanonicalType->getTypeClass()) {
case Pointer:
case VariableArray:
case ConstantArray:
case FunctionProto:
case FunctionNoProto:
case Reference:
return true;
case Tagged: {
const TagType *TT = cast<TagType>(CanonicalType);
const Decl::Kind Kind = TT->getDecl()->getKind();
return Kind == Decl::Struct || Kind == Decl::Union;
}
default:
return false;
}
}
bool Type::isStructureType() const {
if (const RecordType *RT = dyn_cast<RecordType>(this))
if (RT->getDecl()->getKind() == Decl::Struct)
return true;
return false;
}
bool Type::isUnionType() const {
if (const RecordType *RT = dyn_cast<RecordType>(this))
if (RT->getDecl()->getKind() == Decl::Union)
return true;
return false;
}
bool Type::isComplexType() const {
return isa<ComplexType>(CanonicalType);
}
const BuiltinType *Type::getAsBuiltinType() const {
// If this is directly a builtin type, return it.
if (const BuiltinType *BTy = dyn_cast<BuiltinType>(this))
return BTy;
// If this is a typedef for a builtin type, strip the typedef off without
// losing all typedef information.
if (isa<BuiltinType>(CanonicalType))
return cast<BuiltinType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const FunctionType *Type::getAsFunctionType() const {
// If this is directly a function type, return it.
if (const FunctionType *FTy = dyn_cast<FunctionType>(this))
return FTy;
// If this is a typedef for a function type, strip the typedef off without
// losing all typedef information.
if (isa<FunctionType>(CanonicalType))
return cast<FunctionType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const PointerType *Type::getAsPointerType() const {
// If this is directly a pointer type, return it.
if (const PointerType *PTy = dyn_cast<PointerType>(this))
return PTy;
// If this is a typedef for a pointer type, strip the typedef off without
// losing all typedef information.
if (isa<PointerType>(CanonicalType))
return cast<PointerType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const ReferenceType *Type::getAsReferenceType() const {
// If this is directly a reference type, return it.
if (const ReferenceType *RTy = dyn_cast<ReferenceType>(this))
return RTy;
// If this is a typedef for a reference type, strip the typedef off without
// losing all typedef information.
if (isa<ReferenceType>(CanonicalType))
return cast<ReferenceType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const ArrayType *Type::getAsArrayType() const {
// If this is directly an array type, return it.
if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
return ATy;
// If this is a typedef for an array type, strip the typedef off without
// losing all typedef information.
if (isa<ArrayType>(CanonicalType))
return cast<ArrayType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const ConstantArrayType *Type::getAsConstantArrayType() const {
// If this is directly a constant array type, return it.
if (const ConstantArrayType *ATy = dyn_cast<ConstantArrayType>(this))
return ATy;
// If this is a typedef for an array type, strip the typedef off without
// losing all typedef information.
if (isa<ConstantArrayType>(CanonicalType))
return cast<ConstantArrayType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const VariableArrayType *Type::getAsVariableArrayType() const {
// If this is directly a variable array type, return it.
if (const VariableArrayType *ATy = dyn_cast<VariableArrayType>(this))
return ATy;
// If this is a typedef for an array type, strip the typedef off without
// losing all typedef information.
if (isa<VariableArrayType>(CanonicalType))
return cast<VariableArrayType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
/// isVariablyModifiedType (C99 6.7.5.2p2) - Return true for variable array
/// types that have a non-constant expression. This does not include "[]".
bool Type::isVariablyModifiedType() const {
if (const VariableArrayType *VAT = getAsVariableArrayType()) {
if (VAT->getSizeExpr())
return true;
}
return false;
}
const VariableArrayType *Type::getAsVariablyModifiedType() const {
if (const VariableArrayType *VAT = getAsVariableArrayType()) {
if (VAT->getSizeExpr())
return VAT;
}
return 0;
}
const RecordType *Type::getAsRecordType() const {
// If this is directly a reference type, return it.
if (const RecordType *RTy = dyn_cast<RecordType>(this))
return RTy;
// If this is a typedef for an record type, strip the typedef off without
// losing all typedef information.
if (isa<RecordType>(CanonicalType))
return cast<RecordType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const RecordType *Type::getAsStructureType() const {
// If this is directly a structure type, return it.
if (const RecordType *RT = dyn_cast<RecordType>(this)) {
if (RT->getDecl()->getKind() == Decl::Struct)
return RT;
}
// If this is a typedef for a structure type, strip the typedef off without
// losing all typedef information.
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
if (RT->getDecl()->getKind() == Decl::Struct)
return cast<RecordType>(cast<TypedefType>(this)->LookThroughTypedefs());
}
return 0;
}
const RecordType *Type::getAsUnionType() const {
// If this is directly a union type, return it.
if (const RecordType *RT = dyn_cast<RecordType>(this)) {
if (RT->getDecl()->getKind() == Decl::Union)
return RT;
}
// If this is a typedef for a union type, strip the typedef off without
// losing all typedef information.
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
if (RT->getDecl()->getKind() == Decl::Union)
return cast<RecordType>(cast<TypedefType>(this)->LookThroughTypedefs());
}
return 0;
}
const ComplexType *Type::getAsComplexType() const {
// Are we directly a complex type?
if (const ComplexType *CTy = dyn_cast<ComplexType>(this))
return CTy;
// If this is a typedef for a complex type, strip the typedef off without
// losing all typedef information.
if (isa<ComplexType>(CanonicalType))
return cast<ComplexType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const VectorType *Type::getAsVectorType() const {
// Are we directly a vector type?
if (const VectorType *VTy = dyn_cast<VectorType>(this))
return VTy;
// If this is a typedef for a vector type, strip the typedef off without
// losing all typedef information.
if (isa<VectorType>(CanonicalType))
return cast<VectorType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
const OCUVectorType *Type::getAsOCUVectorType() const {
// Are we directly an OpenCU vector type?
if (const OCUVectorType *VTy = dyn_cast<OCUVectorType>(this))
return VTy;
// If this is a typedef for an OpenCU vector type, strip the typedef off
// without losing all typedef information.
if (isa<OCUVectorType>(CanonicalType))
return cast<OCUVectorType>(cast<TypedefType>(this)->LookThroughTypedefs());
return 0;
}
bool Type::builtinTypesAreCompatible(QualType lhs, QualType rhs) {
const BuiltinType *lBuiltin = lhs->getAsBuiltinType();
const BuiltinType *rBuiltin = rhs->getAsBuiltinType();
return lBuiltin->getKind() == rBuiltin->getKind();
}
// C99 6.2.7p1: If both are complete types, then the following additional
// requirements apply...FIXME (handle compatibility across source files).
bool Type::tagTypesAreCompatible(QualType lhs, QualType rhs) {
TagDecl *ldecl = cast<TagType>(lhs.getCanonicalType())->getDecl();
TagDecl *rdecl = cast<TagType>(rhs.getCanonicalType())->getDecl();
if (ldecl->getKind() == Decl::Struct && rdecl->getKind() == Decl::Struct) {
if (ldecl->getIdentifier() == rdecl->getIdentifier())
return true;
}
if (ldecl->getKind() == Decl::Union && rdecl->getKind() == Decl::Union) {
if (ldecl->getIdentifier() == rdecl->getIdentifier())
return true;
}
return false;
}
bool Type::pointerTypesAreCompatible(QualType lhs, QualType rhs) {
// C99 6.7.5.1p2: For two pointer types to be compatible, both shall be
// identically qualified and both shall be pointers to compatible types.
if (lhs.getQualifiers() != rhs.getQualifiers())
return false;
QualType ltype = cast<PointerType>(lhs.getCanonicalType())->getPointeeType();
QualType rtype = cast<PointerType>(rhs.getCanonicalType())->getPointeeType();
return typesAreCompatible(ltype, rtype);
}
// C++ 5.17p6: When the left opperand of an assignment operator denotes a
// reference to T, the operation assigns to the object of type T denoted by the
// reference.
bool Type::referenceTypesAreCompatible(QualType lhs, QualType rhs) {
QualType ltype = lhs;
if (lhs->isReferenceType())
ltype = cast<ReferenceType>(lhs.getCanonicalType())->getReferenceeType();
QualType rtype = rhs;
if (rhs->isReferenceType())
rtype = cast<ReferenceType>(rhs.getCanonicalType())->getReferenceeType();
return typesAreCompatible(ltype, rtype);
}
bool Type::functionTypesAreCompatible(QualType lhs, QualType rhs) {
const FunctionType *lbase = cast<FunctionType>(lhs.getCanonicalType());
const FunctionType *rbase = cast<FunctionType>(rhs.getCanonicalType());
const FunctionTypeProto *lproto = dyn_cast<FunctionTypeProto>(lbase);
const FunctionTypeProto *rproto = dyn_cast<FunctionTypeProto>(rbase);
// first check the return types (common between C99 and K&R).
if (!typesAreCompatible(lbase->getResultType(), rbase->getResultType()))
return false;
if (lproto && rproto) { // two C99 style function prototypes
unsigned lproto_nargs = lproto->getNumArgs();
unsigned rproto_nargs = rproto->getNumArgs();
if (lproto_nargs != rproto_nargs)
return false;
// both prototypes have the same number of arguments.
if ((lproto->isVariadic() && !rproto->isVariadic()) ||
(rproto->isVariadic() && !lproto->isVariadic()))
return false;
// The use of ellipsis agree...now check the argument types.
for (unsigned i = 0; i < lproto_nargs; i++)
if (!typesAreCompatible(lproto->getArgType(i), rproto->getArgType(i)))
return false;
return true;
}
if (!lproto && !rproto) // two K&R style function decls, nothing to do.
return true;
// we have a mixture of K&R style with C99 prototypes
const FunctionTypeProto *proto = lproto ? lproto : rproto;
if (proto->isVariadic())
return false;
// FIXME: Each parameter type T in the prototype must be compatible with the
// type resulting from applying the usual argument conversions to T.
return true;
}
bool Type::arrayTypesAreCompatible(QualType lhs, QualType rhs) {
QualType ltype = cast<ArrayType>(lhs.getCanonicalType())->getElementType();
QualType rtype = cast<ArrayType>(rhs.getCanonicalType())->getElementType();
if (!typesAreCompatible(ltype, rtype))
return false;
// FIXME: If both types specify constant sizes, then the sizes must also be
// the same. Even if the sizes are the same, GCC produces an error.
return true;
}
/// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible,
/// both shall have the identically qualified version of a compatible type.
/// C99 6.2.7p1: Two types have compatible types if their types are the
/// same. See 6.7.[2,3,5] for additional rules.
bool Type::typesAreCompatible(QualType lhs, QualType rhs) {
QualType lcanon = lhs.getCanonicalType();
QualType rcanon = rhs.getCanonicalType();
// If two types are identical, they are are compatible
if (lcanon == rcanon)
return true;
// If the canonical type classes don't match, they can't be compatible
if (lcanon->getTypeClass() != rcanon->getTypeClass())
return false;
switch (lcanon->getTypeClass()) {
case Type::Pointer:
return pointerTypesAreCompatible(lcanon, rcanon);
case Type::Reference:
return referenceTypesAreCompatible(lcanon, rcanon);
case Type::ConstantArray:
case Type::VariableArray:
return arrayTypesAreCompatible(lcanon, rcanon);
case Type::FunctionNoProto:
case Type::FunctionProto:
return functionTypesAreCompatible(lcanon, rcanon);
case Type::Tagged: // handle structures, unions
return tagTypesAreCompatible(lcanon, rcanon);
case Type::Builtin:
return builtinTypesAreCompatible(lcanon, rcanon);
default:
assert(0 && "unexpected type");
}
return true; // should never get here...
}
bool Type::isIntegerType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongLong;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
if (TT->getDecl()->getKind() == Decl::Enum)
return true;
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isIntegerType();
return false;
}
bool Type::isEnumeralType() const {
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
return TT->getDecl()->getKind() == Decl::Enum;
return false;
}
bool Type::isBooleanType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Bool;
return false;
}
bool Type::isCharType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() == BuiltinType::Char_U ||
BT->getKind() == BuiltinType::UChar ||
BT->getKind() == BuiltinType::Char_S;
return false;
}
/// isSignedIntegerType - Return true if this is an integer type that is
/// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
/// an enum decl which has a signed representation, or a vector of signed
/// integer element type.
bool Type::isSignedIntegerType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
return BT->getKind() >= BuiltinType::Char_S &&
BT->getKind() <= BuiltinType::LongLong;
}
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
if (const EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl()))
return ED->getIntegerType()->isSignedIntegerType();
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isSignedIntegerType();
return false;
}
/// isUnsignedIntegerType - Return true if this is an integer type that is
/// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
/// decl which has an unsigned representation, or a vector of unsigned integer
/// element type.
bool Type::isUnsignedIntegerType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::ULongLong;
}
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
if (const EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl()))
return ED->getIntegerType()->isUnsignedIntegerType();
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isUnsignedIntegerType();
return false;
}
bool Type::isFloatingType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Float &&
BT->getKind() <= BuiltinType::LongDouble;
if (const ComplexType *CT = dyn_cast<ComplexType>(CanonicalType))
return CT->getElementType()->isFloatingType();
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isFloatingType();
return false;
}
bool Type::isRealFloatingType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Float &&
BT->getKind() <= BuiltinType::LongDouble;
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isRealFloatingType();
return false;
}
bool Type::isRealType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongDouble;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
return TT->getDecl()->getKind() == Decl::Enum;
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isRealType();
return false;
}
bool Type::isArithmeticType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() != BuiltinType::Void;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
if (TT->getDecl()->getKind() == Decl::Enum)
return true;
return isa<ComplexType>(CanonicalType) || isa<VectorType>(CanonicalType);
}
bool Type::isScalarType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() != BuiltinType::Void;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
if (TT->getDecl()->getKind() == Decl::Enum)
return true;
return false;
}
return isa<PointerType>(CanonicalType) || isa<ComplexType>(CanonicalType) ||
isa<VectorType>(CanonicalType);
}
bool Type::isAggregateType() const {
if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
if (TT->getDecl()->getKind() == Decl::Struct)
return true;
return false;
}
return CanonicalType->getTypeClass() == ConstantArray ||
CanonicalType->getTypeClass() == VariableArray;
}
// The only variable size types are auto arrays within a function. Structures
// cannot contain a VLA member. They can have a flexible array member, however
// the structure is still constant size (C99 6.7.2.1p16).
bool Type::isConstantSizeType(ASTContext &Ctx, SourceLocation *loc) const {
if (isa<VariableArrayType>(CanonicalType))
return false;
return true;
}
/// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
/// - a type that can describe objects, but which lacks information needed to
/// determine its size.
bool Type::isIncompleteType() const {
switch (CanonicalType->getTypeClass()) {
default: return false;
case Builtin:
// Void is the only incomplete builtin type. Per C99 6.2.5p19, it can never
// be completed.
return isVoidType();
case Tagged:
// A tagged type (struct/union/enum/class) is incomplete if the decl is a
// forward declaration, but not a full definition (C99 6.2.5p22).
return !cast<TagType>(CanonicalType)->getDecl()->isDefinition();
case VariableArray:
// An array of unknown size is an incomplete type (C99 6.2.5p22).
return cast<VariableArrayType>(CanonicalType)->getSizeExpr() == 0;
}
}
bool Type::isPromotableIntegerType() const {
const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType);
if (!BT) return false;
switch (BT->getKind()) {
case BuiltinType::Bool:
case BuiltinType::Char_S:
case BuiltinType::Char_U:
case BuiltinType::SChar:
case BuiltinType::UChar:
case BuiltinType::Short:
case BuiltinType::UShort:
return true;
default:
return false;
}
}
const char *BuiltinType::getName() const {
switch (getKind()) {
default: assert(0 && "Unknown builtin type!");
case Void: return "void";
case Bool: return "_Bool";
case Char_S: return "char";
case Char_U: return "char";
case SChar: return "signed char";
case Short: return "short";
case Int: return "int";
case Long: return "long";
case LongLong: return "long long";
case UChar: return "unsigned char";
case UShort: return "unsigned short";
case UInt: return "unsigned int";
case ULong: return "unsigned long";
case ULongLong: return "unsigned long long";
case Float: return "float";
case Double: return "double";
case LongDouble: return "long double";
}
}
void FunctionTypeProto::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
arg_type_iterator ArgTys,
unsigned NumArgs, bool isVariadic) {
ID.AddPointer(Result.getAsOpaquePtr());
for (unsigned i = 0; i != NumArgs; ++i)
ID.AddPointer(ArgTys[i].getAsOpaquePtr());
ID.AddInteger(isVariadic);
}
void FunctionTypeProto::Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getResultType(), arg_type_begin(), NumArgs, isVariadic());
}
/// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
/// potentially looking through *all* consequtive typedefs. This returns the
/// sum of the type qualifiers, so if you have:
/// typedef const int A;
/// typedef volatile A B;
/// looking through the typedefs for B will give you "const volatile A".
///
QualType TypedefType::LookThroughTypedefs() const {
// Usually, there is only a single level of typedefs, be fast in that case.
QualType FirstType = getDecl()->getUnderlyingType();
if (!isa<TypedefType>(FirstType))
return FirstType;
// Otherwise, do the fully general loop.
unsigned TypeQuals = 0;
const TypedefType *TDT = this;
while (1) {
QualType CurType = TDT->getDecl()->getUnderlyingType();
TypeQuals |= CurType.getQualifiers();
TDT = dyn_cast<TypedefType>(CurType);
if (TDT == 0)
return QualType(CurType.getTypePtr(), TypeQuals);
}
}
bool RecordType::classof(const Type *T) {
if (const TagType *TT = dyn_cast<TagType>(T))
return isa<RecordDecl>(TT->getDecl());
return false;
}
//===----------------------------------------------------------------------===//
// Type Printing
//===----------------------------------------------------------------------===//
void QualType::dump(const char *msg) const {
std::string R = "foo";
getAsStringInternal(R);
if (msg)
fprintf(stderr, "%s: %s\n", msg, R.c_str());
else
fprintf(stderr, "%s\n", R.c_str());
}
static void AppendTypeQualList(std::string &S, unsigned TypeQuals) {
// Note: funkiness to ensure we get a space only between quals.
bool NonePrinted = true;
if (TypeQuals & QualType::Const)
S += "const", NonePrinted = false;
if (TypeQuals & QualType::Volatile)
S += (NonePrinted+" volatile"), NonePrinted = false;
if (TypeQuals & QualType::Restrict)
S += (NonePrinted+" restrict"), NonePrinted = false;
}
void QualType::getAsStringInternal(std::string &S) const {
if (isNull()) {
S += "NULL TYPE\n";
return;
}
// Print qualifiers as appropriate.
unsigned TQ = getQualifiers();
if (TQ) {
std::string TQS;
AppendTypeQualList(TQS, TQ);
if (!S.empty())
S = TQS + ' ' + S;
else
S = TQS;
}
getTypePtr()->getAsStringInternal(S);
}
void BuiltinType::getAsStringInternal(std::string &S) const {
if (S.empty()) {
S = getName();
} else {
// Prefix the basic type, e.g. 'int X'.
S = ' ' + S;
S = getName() + S;
}
}
void ComplexType::getAsStringInternal(std::string &S) const {
ElementType->getAsStringInternal(S);
S = "_Complex " + S;
}
void PointerType::getAsStringInternal(std::string &S) const {
S = '*' + S;
// Handle things like 'int (*A)[4];' correctly.
// FIXME: this should include vectors, but vectors use attributes I guess.
if (isa<ArrayType>(PointeeType.getTypePtr()))
S = '(' + S + ')';
PointeeType.getAsStringInternal(S);
}
void ReferenceType::getAsStringInternal(std::string &S) const {
S = '&' + S;
// Handle things like 'int (&A)[4];' correctly.
// FIXME: this should include vectors, but vectors use attributes I guess.
if (isa<ArrayType>(ReferenceeType.getTypePtr()))
S = '(' + S + ')';
ReferenceeType.getAsStringInternal(S);
}
void ConstantArrayType::getAsStringInternal(std::string &S) const {
S += '[';
S += llvm::utostr(getSize().getZExtValue());
S += ']';
getElementType().getAsStringInternal(S);
}
void VariableArrayType::getAsStringInternal(std::string &S) const {
S += '[';
if (getIndexTypeQualifier()) {
AppendTypeQualList(S, getIndexTypeQualifier());
S += ' ';
}
if (getSizeModifier() == Static)
S += "static";
else if (getSizeModifier() == Star)
S += '*';
if (getSizeExpr()) {
std::ostringstream s;
getSizeExpr()->printPretty(s);
S += s.str();
}
S += ']';
getElementType().getAsStringInternal(S);
}
void VectorType::getAsStringInternal(std::string &S) const {
S += " __attribute__((vector_size(";
// FIXME: should multiply by element size somehow.
S += llvm::utostr_32(NumElements*4); // convert back to bytes.
S += ")))";
ElementType.getAsStringInternal(S);
}
void OCUVectorType::getAsStringInternal(std::string &S) const {
S += " __attribute__((ocu_vector_type(";
S += llvm::utostr_32(NumElements);
S += ")))";
ElementType.getAsStringInternal(S);
}
void TypeOfExpr::getAsStringInternal(std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typeof(e) X'.
InnerString = ' ' + InnerString;
std::ostringstream s;
getUnderlyingExpr()->printPretty(s);
InnerString = "typeof(" + s.str() + ")" + InnerString;
}
void TypeOfType::getAsStringInternal(std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typeof(t) X'.
InnerString = ' ' + InnerString;
std::string Tmp;
getUnderlyingType().getAsStringInternal(Tmp);
InnerString = "typeof(" + Tmp + ")" + InnerString;
}
void FunctionTypeNoProto::getAsStringInternal(std::string &S) const {
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!S.empty())
S = "(" + S + ")";
S += "()";
getResultType().getAsStringInternal(S);
}
void FunctionTypeProto::getAsStringInternal(std::string &S) const {
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!S.empty())
S = "(" + S + ")";
S += "(";
std::string Tmp;
for (unsigned i = 0, e = getNumArgs(); i != e; ++i) {
if (i) S += ", ";
getArgType(i).getAsStringInternal(Tmp);
S += Tmp;
Tmp.clear();
}
if (isVariadic()) {
if (getNumArgs())
S += ", ";
S += "...";
} else if (getNumArgs() == 0) {
// Do not emit int() if we have a proto, emit 'int(void)'.
S += "void";
}
S += ")";
getResultType().getAsStringInternal(S);
}
void TypedefType::getAsStringInternal(std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;
InnerString = getDecl()->getIdentifier()->getName() + InnerString;
}
void ObjcInterfaceType::getAsStringInternal(std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;
InnerString = getDecl()->getIdentifier()->getName() + InnerString;
}
void TagType::getAsStringInternal(std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;
const char *Kind = getDecl()->getKindName();
const char *ID;
if (const IdentifierInfo *II = getDecl()->getIdentifier())
ID = II->getName();
else
ID = "<anonymous>";
InnerString = std::string(Kind) + " " + ID + InnerString;
}

View File

@@ -1,98 +0,0 @@
//==- DeadStores.cpp - Check for stores to dead variables --------*- C++ -*-==//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Ted Kremenek and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This files defines a DeadStores, a flow-sensitive checker that looks for
// stores to variables that are no longer live.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/Expr.h"
#include "clang/Analysis/LocalCheckers.h"
#include "clang/Analysis/LiveVariables.h"
#include "clang/AST/CFG.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/AST/ASTContext.h"
using namespace clang;
namespace {
class DeadStoreObserver : public LiveVariablesObserver {
Preprocessor& PP;
ASTContext Ctx;
public:
DeadStoreObserver(Preprocessor& pp) :
PP(pp), Ctx(PP.getSourceManager(), PP.getTargetInfo(),
PP.getIdentifierTable()) {
}
virtual ~DeadStoreObserver() {}
virtual void ObserveStmt(Stmt* S, LiveVariables& L, llvm::BitVector& Live) {
if (BinaryOperator* B = dyn_cast<BinaryOperator>(S)) {
// Is this an assignment?
if (!B->isAssignmentOp())
return;
// Is this an assignment to a variable?
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(B->getLHS()))
// Is the variable live?
if (!L.isLive(Live,cast<VarDecl>(DR->getDecl()))) {
SourceRange R = B->getRHS()->getSourceRange();
PP.getDiagnostics().Report(DR->getSourceRange().Begin(),
diag::warn_dead_store, 0, 0,
&R,1);
}
}
else if(DeclStmt* DS = dyn_cast<DeclStmt>(S)) {
// Iterate through the decls. Warn if any of them (which have
// initializers) are not live.
for (VarDecl* V = cast<VarDecl>(DS->getDecl()); V != NULL ;
V = cast_or_null<VarDecl>(V->getNextDeclarator()))
if (Expr* E = V->getInit())
if (!L.isLive(Live,V))
// Special case: check for initializations with constants.
//
// e.g. : int x = 0;
//
// If x is EVER assigned a new value later, don't issue
// a warning. This is because such initialization can be
// due to defensive programming.
if (!E->isConstantExpr(Ctx,NULL) ||
L.getVarInfo(V).Kills.size() == 0) {
// Flag a warning.
SourceRange R = E->getSourceRange();
PP.getDiagnostics().Report(V->getLocation(),
diag::warn_dead_store, 0, 0,
&R,1);
}
}
}
};
} // end anonymous namespace
namespace clang {
void CheckDeadStores(CFG& cfg, LiveVariables& L, Preprocessor& PP) {
DeadStoreObserver A(PP);
for (CFG::iterator I = cfg.begin(), E = cfg.end(); I != E; ++I)
L.runOnBlock(&(*I),&A);
}
void CheckDeadStores(CFG& cfg, Preprocessor& PP) {
LiveVariables L;
L.runOnCFG(cfg);
CheckDeadStores(cfg,L,PP);
}
} // end namespace clang

View File

@@ -1,474 +0,0 @@
//==- LiveVariables.cpp - Live Variable Analysis for Source CFGs -*- C++ --*-==//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Ted Kremenek and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements Live Variables analysis for source-level CFGs.
//
//===----------------------------------------------------------------------===//
#include "clang/Analysis/LiveVariables.h"
#include "clang/Basic/SourceManager.h"
#include "clang/AST/Expr.h"
#include "clang/AST/CFG.h"
#include "clang/Analysis/DataflowStmtVisitor.h"
#include "clang/Lex/IdentifierTable.h"
#include "llvm/ADT/SmallPtrSet.h"
#include <string.h>
#include <stdio.h>
using namespace clang;
//===----------------------------------------------------------------------===//
// RegisterDecls - Utility class to create VarInfo objects for all
// Decls referenced in a function.
//
namespace {
class RegisterDecls : public StmtVisitor<RegisterDecls,void> {
LiveVariables& L;
const CFG& cfg;
public:
RegisterDecls(LiveVariables& l, const CFG& c)
: L(l), cfg(c) {}
void VisitStmt(Stmt* S);
void VisitDeclRefExpr(DeclRefExpr* DR);
void VisitDeclStmt(DeclStmt* DS);
void Register(Decl* D);
void RegisterDeclChain(Decl* D);
void RegisterUsedDecls();
};
void RegisterDecls::VisitStmt(Stmt* S) {
for (Stmt::child_iterator I = S->child_begin(),E = S->child_end(); I != E;++I)
Visit(*I);
}
void RegisterDecls::VisitDeclRefExpr(DeclRefExpr* DR) {
RegisterDeclChain(DR->getDecl());
}
void RegisterDecls::VisitDeclStmt(DeclStmt* DS) {
RegisterDeclChain(DS->getDecl());
}
void RegisterDecls::RegisterDeclChain(Decl* D) {
for (; D != NULL ; D = D->getNextDeclarator())
Register(D);
}
void RegisterDecls::Register(Decl* D) {
if (VarDecl* V = dyn_cast<VarDecl>(D)) {
LiveVariables::VPair& VP = L.getVarInfoMap()[V];
VP.V.AliveBlocks.resize(cfg.getNumBlockIDs());
VP.Idx = L.getNumDecls()++;
}
}
void RegisterDecls::RegisterUsedDecls() {
for (CFG::const_iterator BI = cfg.begin(), BE = cfg.end(); BI != BE; ++BI)
for (CFGBlock::const_iterator SI=BI->begin(),SE = BI->end();SI != SE;++SI)
Visit(const_cast<Stmt*>(*SI));
}
} // end anonymous namespace
//===----------------------------------------------------------------------===//
// WorkList - Data structure representing the liveness algorithm worklist.
//
namespace {
class WorkListTy {
typedef llvm::SmallPtrSet<const CFGBlock*,20> BlockSet;
BlockSet wlist;
public:
void enqueue(const CFGBlock* B) { wlist.insert(B); }
const CFGBlock* dequeue() {
assert (!wlist.empty());
const CFGBlock* B = *wlist.begin();
wlist.erase(B);
return B;
}
bool isEmpty() const { return wlist.empty(); }
};
} // end anonymous namespace
//===----------------------------------------------------------------------===//
// TFuncs
//
namespace {
class LivenessTFuncs : public DataflowStmtVisitor<LivenessTFuncs,
dataflow::backward_analysis_tag> {
LiveVariables& L;
llvm::BitVector Live;
llvm::BitVector KilledAtLeastOnce;
Stmt* CurrentStmt;
const CFGBlock* CurrentBlock;
bool blockPreviouslyProcessed;
LiveVariablesObserver* Observer;
public:
LivenessTFuncs(LiveVariables& l, LiveVariablesObserver* A = NULL)
: L(l), CurrentStmt(NULL), CurrentBlock(NULL),
blockPreviouslyProcessed(false), Observer(A) {
Live.resize(l.getNumDecls());
KilledAtLeastOnce.resize(l.getNumDecls());
}
void VisitDeclRefExpr(DeclRefExpr* DR);
void VisitBinaryOperator(BinaryOperator* B);
void VisitAssign(BinaryOperator* B);
void VisitDeclStmt(DeclStmt* DS);
void VisitUnaryOperator(UnaryOperator* U);
void ObserveStmt(Stmt* S);
unsigned getIdx(const VarDecl* D) {
LiveVariables::VarInfoMap& V = L.getVarInfoMap();
LiveVariables::VarInfoMap::iterator I = V.find(D);
assert (I != V.end());
return I->second.Idx;
}
bool ProcessBlock(const CFGBlock* B);
llvm::BitVector* getBlockEntryLiveness(const CFGBlock* B);
LiveVariables::VarInfo& KillVar(VarDecl* D);
};
void LivenessTFuncs::ObserveStmt(Stmt* S) {
if (Observer) Observer->ObserveStmt(S,L,Live);
}
void LivenessTFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
// Register a use of the variable.
if (VarDecl* V = dyn_cast<VarDecl>(DR->getDecl()))
Live.set(getIdx(V));
}
void LivenessTFuncs::VisitBinaryOperator(BinaryOperator* B) {
if (B->isAssignmentOp()) VisitAssign(B);
else VisitStmt(B);
}
void LivenessTFuncs::VisitUnaryOperator(UnaryOperator* U) {
switch (U->getOpcode()) {
case UnaryOperator::PostInc:
case UnaryOperator::PostDec:
case UnaryOperator::PreInc:
case UnaryOperator::PreDec:
case UnaryOperator::AddrOf:
// Walk through the subexpressions, blasting through ParenExprs until
// we either find a DeclRefExpr or some non-DeclRefExpr expression.
for (Stmt* S = U->getSubExpr() ; ; ) {
if (ParenExpr* P = dyn_cast<ParenExpr>(S)) {
S = P->getSubExpr();
continue;
}
else if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(S)) {
// Treat the --/++/& operator as a kill.
LiveVariables::VarInfo& V =
KillVar(cast<VarDecl>(DR->getDecl()));
if (!blockPreviouslyProcessed)
V.AddKill(CurrentStmt,DR);
VisitDeclRefExpr(DR);
}
else Visit(S);
break;
}
break;
default:
Visit(U->getSubExpr());
break;
}
}
LiveVariables::VarInfo& LivenessTFuncs::KillVar(VarDecl* D) {
LiveVariables::VarInfoMap::iterator I = L.getVarInfoMap().find(D);
assert (I != L.getVarInfoMap().end() &&
"Declaration not managed by variable map in LiveVariables");
// Mark the variable dead, and remove the current block from
// the set of blocks where the variable may be alive the entire time.
Live.reset(I->second.Idx);
I->second.V.AliveBlocks.reset(CurrentBlock->getBlockID());
return I->second.V;
}
void LivenessTFuncs::VisitAssign(BinaryOperator* B) {
// Check if we are assigning to a variable.
Stmt* LHS = B->getLHS();
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS)) {
LiveVariables::VarInfo& V = KillVar(cast<VarDecl>(DR->getDecl()));
// We only need to register kills once, so we check if this block
// has been previously processed.
if (!blockPreviouslyProcessed)
V.AddKill(CurrentStmt,DR);
if (B->getOpcode() != BinaryOperator::Assign)
Visit(LHS);
}
else
Visit(LHS);
Visit(B->getRHS());
}
void LivenessTFuncs::VisitDeclStmt(DeclStmt* DS) {
// Declarations effectively "kill" a variable since they cannot possibly
// be live before they are declared. Declarations, however, are not kills
// in the sense that the value is obliterated, so we do not register
// DeclStmts as a "kill site" for a variable.
for (Decl* D = DS->getDecl(); D != NULL ; D = D->getNextDeclarator())
KillVar(cast<VarDecl>(D));
}
llvm::BitVector* LivenessTFuncs::getBlockEntryLiveness(const CFGBlock* B) {
LiveVariables::BlockLivenessMap& BMap = L.getLiveAtBlockEntryMap();
LiveVariables::BlockLivenessMap::iterator I = BMap.find(B);
return (I == BMap.end()) ? NULL : &(I->second);
}
bool LivenessTFuncs::ProcessBlock(const CFGBlock* B) {
CurrentBlock = B;
Live.reset();
KilledAtLeastOnce.reset();
// Check if this block has been previously processed.
LiveVariables::BlockLivenessMap& BMap = L.getLiveAtBlockEntryMap();
LiveVariables::BlockLivenessMap::iterator BI = BMap.find(B);
blockPreviouslyProcessed = BI != BMap.end();
// Merge liveness information from all predecessors.
for (CFGBlock::const_succ_iterator I=B->succ_begin(),E=B->succ_end();I!=E;++I)
if (llvm::BitVector* V = getBlockEntryLiveness(*I))
Live |= *V;
if (Observer)
Observer->ObserveBlockExit(B,L,Live);
// Tentatively mark all variables alive at the end of the current block
// as being alive during the whole block. We then cull these out as
// we process the statements of this block.
for (LiveVariables::VarInfoMap::iterator
I=L.getVarInfoMap().begin(), E=L.getVarInfoMap().end(); I != E; ++I)
if (Live[I->second.Idx])
I->second.V.AliveBlocks.set(B->getBlockID());
// Visit the statements in reverse order;
VisitBlock(B);
// Compare the computed "Live" values with what we already have
// for the entry to this block.
bool hasChanged = false;
if (!blockPreviouslyProcessed) {
// We have not previously calculated liveness information for this block.
// Lazily instantiate a bitvector, and copy the bits from Live.
hasChanged = true;
llvm::BitVector& V = BMap[B];
V.resize(L.getNumDecls());
V = Live;
}
else if (BI->second != Live) {
hasChanged = true;
BI->second = Live;
}
return hasChanged;
}
} // end anonymous namespace
//===----------------------------------------------------------------------===//
// runOnCFG - Method to run the actual liveness computation.
//
void LiveVariables::runOnCFG(const CFG& cfg, LiveVariablesObserver* Observer) {
// Scan a CFG for DeclRefStmts. For each one, create a VarInfo object.
{
RegisterDecls R(*this,cfg);
R.RegisterUsedDecls();
}
// Create the worklist and enqueue the exit block.
WorkListTy WorkList;
WorkList.enqueue(&cfg.getExit());
// Create the state for transfer functions.
LivenessTFuncs TF(*this,Observer);
// Process the worklist until it is empty.
while (!WorkList.isEmpty()) {
const CFGBlock* B = WorkList.dequeue();
if (TF.ProcessBlock(B))
for (CFGBlock::const_pred_iterator I = B->pred_begin(), E = B->pred_end();
I != E; ++I)
WorkList.enqueue(*I);
}
// Go through each block and reserve a bitvector. This is needed if
// a block was never visited by the worklist algorithm.
for (CFG::const_iterator I = cfg.begin(), E = cfg.end(); I != E; ++I)
LiveAtBlockEntryMap[&(*I)].resize(NumDecls);
}
void LiveVariables::runOnBlock(const CFGBlock* B,
LiveVariablesObserver* Observer)
{
LivenessTFuncs TF(*this,Observer);
TF.ProcessBlock(B);
}
//===----------------------------------------------------------------------===//
// liveness queries
//
bool LiveVariables::isLive(const CFGBlock* B, const VarDecl* D) const {
BlockLivenessMap::const_iterator I = LiveAtBlockEntryMap.find(B);
assert (I != LiveAtBlockEntryMap.end());
VarInfoMap::const_iterator VI = VarInfos.find(D);
assert (VI != VarInfos.end());
return I->second[VI->second.Idx];
}
bool LiveVariables::isLive(llvm::BitVector& Live, const VarDecl* D) const {
VarInfoMap::const_iterator VI = VarInfos.find(D);
assert (VI != VarInfos.end());
return Live[VI->second.Idx];
}
bool LiveVariables::KillsVar(const Stmt* S, const VarDecl* D) const {
VarInfoMap::const_iterator VI = VarInfos.find(D);
assert (VI != VarInfos.end());
for (VarInfo::KillsSet::const_iterator
I = VI->second.V.Kills.begin(), E = VI->second.V.Kills.end(); I!=E;++I)
if (I->first == S)
return true;
return false;
}
LiveVariables::VarInfo& LiveVariables::getVarInfo(const VarDecl* D) {
VarInfoMap::iterator VI = VarInfos.find(D);
assert (VI != VarInfos.end());
return VI->second.V;
}
const LiveVariables::VarInfo& LiveVariables::getVarInfo(const VarDecl* D) const{
return const_cast<LiveVariables*>(this)->getVarInfo(D);
}
//===----------------------------------------------------------------------===//
// Defaults for LiveVariablesObserver
void LiveVariablesObserver::ObserveStmt(Stmt* S, LiveVariables& L,
llvm::BitVector& V) {}
void LiveVariablesObserver::ObserveBlockExit(const CFGBlock* B,
LiveVariables& L,
llvm::BitVector& V) {}
//===----------------------------------------------------------------------===//
// printing liveness state for debugging
//
void LiveVariables::dumpLiveness(const llvm::BitVector& V,
SourceManager& SM) const {
for (VarInfoMap::iterator I = VarInfos.begin(), E=VarInfos.end(); I!=E; ++I) {
if (V[I->second.Idx]) {
SourceLocation PhysLoc = SM.getPhysicalLoc(I->first->getLocation());
fprintf(stderr, " %s <%s:%u:%u>\n",
I->first->getIdentifier()->getName(),
SM.getSourceName(PhysLoc),
SM.getLineNumber(PhysLoc),
SM.getColumnNumber(PhysLoc));
}
}
}
void LiveVariables::dumpBlockLiveness(SourceManager& M) const {
for (BlockLivenessMap::iterator I = LiveAtBlockEntryMap.begin(),
E = LiveAtBlockEntryMap.end();
I != E; ++I) {
fprintf(stderr,
"\n[ B%d (live variables at block entry) ]\n",
I->first->getBlockID());
dumpLiveness(I->second,M);
}
fprintf(stderr,"\n");
}
void LiveVariables::dumpVarLiveness(SourceManager& SM) const {
for (VarInfoMap::iterator I = VarInfos.begin(), E=VarInfos.end(); I!=E; ++I) {
SourceLocation PhysLoc = SM.getPhysicalLoc(I->first->getLocation());
fprintf(stderr, "[ %s <%s:%u:%u> ]\n",
I->first->getIdentifier()->getName(),
SM.getSourceName(PhysLoc),
SM.getLineNumber(PhysLoc),
SM.getColumnNumber(PhysLoc));
I->second.V.Dump(SM);
}
}
void LiveVariables::VarInfo::Dump(SourceManager& SM) const {
fprintf(stderr," Blocks Alive:");
for (unsigned i = 0; i < AliveBlocks.size(); ++i) {
if (i % 5 == 0)
fprintf(stderr,"\n ");
fprintf(stderr," B%d", i);
}
fprintf(stderr,"\n Kill Sites:\n");
for (KillsSet::const_iterator I = Kills.begin(), E = Kills.end(); I!=E; ++I) {
SourceLocation PhysLoc =
SM.getPhysicalLoc(I->second->getSourceRange().Begin());
fprintf(stderr, " <%s:%u:%u>\n",
SM.getSourceName(PhysLoc),
SM.getLineNumber(PhysLoc),
SM.getColumnNumber(PhysLoc));
}
fprintf(stderr,"\n");
}

View File

@@ -1,22 +0,0 @@
##===- clang/CodeGen/Makefile ------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Ted Kremenek and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements analyses built on top of source-level CFGs.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LIBRARYNAME := clangAnalysis
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
include $(LEVEL)/Makefile.common

View File

@@ -1,145 +0,0 @@
//===--- Diagnostic.cpp - C Language Family Diagnostic Handling -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Diagnostic-related interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceLocation.h"
#include <cassert>
using namespace clang;
/// Flag values for diagnostics.
enum {
// Diagnostic classes.
NOTE = 0x01,
WARNING = 0x02,
EXTENSION = 0x03,
ERROR = 0x04,
class_mask = 0x07
};
/// DiagnosticFlags - A set of flags, or'd together, that describe the
/// diagnostic.
static unsigned char DiagnosticFlags[] = {
#define DIAG(ENUM,FLAGS,DESC) FLAGS,
#include "clang/Basic/DiagnosticKinds.def"
0
};
/// getDiagClass - Return the class field of the diagnostic.
///
static unsigned getDiagClass(unsigned DiagID) {
assert(DiagID < diag::NUM_DIAGNOSTICS && "Diagnostic ID out of range!");
return DiagnosticFlags[DiagID] & class_mask;
}
/// DiagnosticText - An english message to print for the diagnostic. These
/// should be localized.
static const char * const DiagnosticText[] = {
#define DIAG(ENUM,FLAGS,DESC) DESC,
#include "clang/Basic/DiagnosticKinds.def"
0
};
Diagnostic::Diagnostic(DiagnosticClient &client) : Client(client) {
WarningsAsErrors = false;
WarnOnExtensions = false;
ErrorOnExtensions = false;
// Clear all mappings, setting them to MAP_DEFAULT.
memset(DiagMappings, 0, sizeof(DiagMappings));
ErrorOccurred = false;
NumDiagnostics = 0;
NumErrors = 0;
}
/// isNoteWarningOrExtension - Return true if the unmapped diagnostic level of
/// the specified diagnostic ID is a Note, Warning, or Extension.
bool Diagnostic::isNoteWarningOrExtension(unsigned DiagID) {
return getDiagClass(DiagID) < ERROR;
}
/// getDescription - Given a diagnostic ID, return a description of the
/// issue.
const char *Diagnostic::getDescription(unsigned DiagID) {
assert(DiagID < diag::NUM_DIAGNOSTICS && "Diagnostic ID out of range!");
return DiagnosticText[DiagID];
}
/// getDiagnosticLevel - Based on the way the client configured the Diagnostic
/// object, classify the specified diagnostic ID into a Level, consumable by
/// the DiagnosticClient.
Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
unsigned DiagClass = getDiagClass(DiagID);
// Specific non-error diagnostics may be mapped to various levels from ignored
// to error.
if (DiagClass < ERROR) {
switch (getDiagnosticMapping((diag::kind)DiagID)) {
case diag::MAP_DEFAULT: break;
case diag::MAP_IGNORE: return Ignored;
case diag::MAP_WARNING: DiagClass = WARNING; break;
case diag::MAP_ERROR: DiagClass = ERROR; break;
}
}
// Map diagnostic classes based on command line argument settings.
if (DiagClass == EXTENSION) {
if (ErrorOnExtensions)
DiagClass = ERROR;
else if (WarnOnExtensions)
DiagClass = WARNING;
else
return Ignored;
}
// If warnings are to be treated as errors, indicate this as such.
if (DiagClass == WARNING && WarningsAsErrors)
DiagClass = ERROR;
switch (DiagClass) {
default: assert(0 && "Unknown diagnostic class!");
case NOTE: return Diagnostic::Note;
case WARNING: return Diagnostic::Warning;
case ERROR: return Diagnostic::Error;
}
}
/// Report - Issue the message to the client. If the client wants us to stop
/// compilation, return true, otherwise return false. DiagID is a member of
/// the diag::kind enum.
void Diagnostic::Report(SourceLocation Pos, unsigned DiagID,
const std::string *Strs, unsigned NumStrs,
const SourceRange *Ranges, unsigned NumRanges) {
// Figure out the diagnostic level of this message.
Diagnostic::Level DiagLevel = getDiagnosticLevel(DiagID);
// If the client doesn't care about this message, don't issue it.
if (DiagLevel == Diagnostic::Ignored)
return;
if (DiagLevel >= Diagnostic::Error) {
ErrorOccurred = true;
++NumErrors;
}
// Are we going to ignore this diagnosic?
if (Client.IgnoreDiagnostic(DiagLevel, Pos))
return;
// Finally, report it.
Client.HandleDiagnostic(DiagLevel, Pos, (diag::kind)DiagID, Strs, NumStrs,
Ranges, NumRanges);
++NumDiagnostics;
}
DiagnosticClient::~DiagnosticClient() {}

View File

@@ -1,172 +0,0 @@
//===--- FileManager.cpp - File System Probing and Caching ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the FileManager interface.
//
//===----------------------------------------------------------------------===//
//
// TODO: This should index all interesting directories with dirent calls.
// getdirentries ?
// opendir/readdir_r/closedir ?
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/FileManager.h"
#include "llvm/ADT/SmallString.h"
#include <iostream>
using namespace clang;
// FIXME: Enhance libsystem to support inode and other fields.
#include <sys/stat.h>
#if defined(_MSC_VER)
#define S_ISDIR(s) (_S_IFDIR & s)
#endif
/// NON_EXISTANT_DIR - A special value distinct from null that is used to
/// represent a dir name that doesn't exist on the disk.
#define NON_EXISTANT_DIR reinterpret_cast<DirectoryEntry*>((intptr_t)-1)
/// getDirectory - Lookup, cache, and verify the specified directory. This
/// returns null if the directory doesn't exist.
///
const DirectoryEntry *FileManager::getDirectory(const char *NameStart,
const char *NameEnd) {
++NumDirLookups;
llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =
DirEntries.GetOrCreateValue(NameStart, NameEnd);
// See if there is already an entry in the map.
if (NamedDirEnt.getValue())
return NamedDirEnt.getValue() == NON_EXISTANT_DIR
? 0 : NamedDirEnt.getValue();
++NumDirCacheMisses;
// By default, initialize it to invalid.
NamedDirEnt.setValue(NON_EXISTANT_DIR);
// Get the null-terminated directory name as stored as the key of the
// DirEntries map.
const char *InterndDirName = NamedDirEnt.getKeyData();
// Check to see if the directory exists.
struct stat StatBuf;
if (stat(InterndDirName, &StatBuf) || // Error stat'ing.
!S_ISDIR(StatBuf.st_mode)) // Not a directory?
return 0;
// It exists. See if we have already opened a directory with the same inode.
// This occurs when one dir is symlinked to another, for example.
DirectoryEntry &UDE =
UniqueDirs[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)];
NamedDirEnt.setValue(&UDE);
if (UDE.getName()) // Already have an entry with this inode, return it.
return &UDE;
// Otherwise, we don't have this directory yet, add it. We use the string
// key from the DirEntries map as the string.
UDE.Name = InterndDirName;
return &UDE;
}
/// NON_EXISTANT_FILE - A special value distinct from null that is used to
/// represent a filename that doesn't exist on the disk.
#define NON_EXISTANT_FILE reinterpret_cast<FileEntry*>((intptr_t)-1)
/// getFile - Lookup, cache, and verify the specified file. This returns null
/// if the file doesn't exist.
///
const FileEntry *FileManager::getFile(const char *NameStart,
const char *NameEnd) {
++NumFileLookups;
// See if there is already an entry in the map.
llvm::StringMapEntry<FileEntry *> &NamedFileEnt =
FileEntries.GetOrCreateValue(NameStart, NameEnd);
// See if there is already an entry in the map.
if (NamedFileEnt.getValue())
return NamedFileEnt.getValue() == NON_EXISTANT_FILE
? 0 : NamedFileEnt.getValue();
++NumFileCacheMisses;
// By default, initialize it to invalid.
NamedFileEnt.setValue(NON_EXISTANT_FILE);
// Figure out what directory it is in. If the string contains a / in it,
// strip off everything after it.
// FIXME: this logic should be in sys::Path.
const char *SlashPos = NameEnd-1;
while (SlashPos >= NameStart && SlashPos[0] != '/')
--SlashPos;
const DirectoryEntry *DirInfo;
if (SlashPos < NameStart) {
// Use the current directory if file has no path component.
const char *Name = ".";
DirInfo = getDirectory(Name, Name+1);
} else if (SlashPos == NameEnd-1)
return 0; // If filename ends with a /, it's a directory.
else
DirInfo = getDirectory(NameStart, SlashPos);
if (DirInfo == 0) // Directory doesn't exist, file can't exist.
return 0;
// Get the null-terminated file name as stored as the key of the
// FileEntries map.
const char *InterndFileName = NamedFileEnt.getKeyData();
// FIXME: Use the directory info to prune this, before doing the stat syscall.
// FIXME: This will reduce the # syscalls.
// Nope, there isn't. Check to see if the file exists.
struct stat StatBuf;
//std::cerr << "STATING: " << Filename;
if (stat(InterndFileName, &StatBuf) || // Error stat'ing.
S_ISDIR(StatBuf.st_mode)) { // A directory?
// If this file doesn't exist, we leave a null in FileEntries for this path.
//std::cerr << ": Not existing\n";
return 0;
}
//std::cerr << ": exists\n";
// It exists. See if we have already opened a directory with the same inode.
// This occurs when one dir is symlinked to another, for example.
FileEntry &UFE = UniqueFiles[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)];
NamedFileEnt.setValue(&UFE);
if (UFE.getName()) // Already have an entry with this inode, return it.
return &UFE;
// Otherwise, we don't have this directory yet, add it.
// FIXME: Change the name to be a char* that points back to the 'FileEntries'
// key.
UFE.Name = InterndFileName;
UFE.Size = StatBuf.st_size;
UFE.ModTime = StatBuf.st_mtime;
UFE.Dir = DirInfo;
UFE.UID = NextFileUID++;
return &UFE;
}
void FileManager::PrintStats() const {
std::cerr << "\n*** File Manager Stats:\n";
std::cerr << UniqueFiles.size() << " files found, "
<< UniqueDirs.size() << " dirs found.\n";
std::cerr << NumDirLookups << " dir lookups, "
<< NumDirCacheMisses << " dir cache misses.\n";
std::cerr << NumFileLookups << " file lookups, "
<< NumFileCacheMisses << " file cache misses.\n";
//std::cerr << PagesMapped << BytesOfPagesMapped << FSLookups;
}

View File

@@ -1,22 +0,0 @@
##===- clang/Basic/Makefile --------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Chris Lattner and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements the Basic library for the C-Language front-end.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LIBRARYNAME := clangBasic
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
include $(LEVEL)/Makefile.common

View File

@@ -1,409 +0,0 @@
//===--- SourceManager.cpp - Track and cache source files -----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the SourceManager interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/FileManager.h"
#include "llvm/Config/config.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Path.h"
#include <algorithm>
#include <iostream>
#include <fcntl.h>
using namespace clang;
using namespace SrcMgr;
using llvm::MemoryBuffer;
SourceManager::~SourceManager() {
for (std::map<const FileEntry *, FileInfo>::iterator I = FileInfos.begin(),
E = FileInfos.end(); I != E; ++I) {
delete I->second.Buffer;
delete[] I->second.SourceLineCache;
}
for (std::list<InfoRec>::iterator I = MemBufferInfos.begin(),
E = MemBufferInfos.end(); I != E; ++I) {
delete I->second.Buffer;
delete[] I->second.SourceLineCache;
}
}
// FIXME: REMOVE THESE
#include <unistd.h>
#include <sys/types.h>
#if !defined(_MSC_VER)
#include <sys/uio.h>
#include <sys/fcntl.h>
#else
#include <io.h>
#endif
#include <cerrno>
static const MemoryBuffer *ReadFileFast(const FileEntry *FileEnt) {
#if 0
// FIXME: Reintroduce this and zap this function once the common llvm stuff
// is fast for the small case.
return MemoryBuffer::getFile(FileEnt->getName(), strlen(FileEnt->getName()),
FileEnt->getSize());
#endif
// If the file is larger than some threshold, use 'read', otherwise use mmap.
if (FileEnt->getSize() >= 4096*4)
return MemoryBuffer::getFile(FileEnt->getName(), strlen(FileEnt->getName()),
0, FileEnt->getSize());
MemoryBuffer *SB = MemoryBuffer::getNewUninitMemBuffer(FileEnt->getSize(),
FileEnt->getName());
char *BufPtr = const_cast<char*>(SB->getBufferStart());
#if defined(LLVM_ON_WIN32)
int FD = ::open(FileEnt->getName(), O_RDONLY|O_BINARY);
#else
int FD = ::open(FileEnt->getName(), O_RDONLY);
#endif
if (FD == -1) {
delete SB;
return 0;
}
unsigned BytesLeft = FileEnt->getSize();
while (BytesLeft) {
ssize_t NumRead = ::read(FD, BufPtr, BytesLeft);
if (NumRead != -1) {
BytesLeft -= NumRead;
BufPtr += NumRead;
} else if (errno == EINTR) {
// try again
} else {
// error reading.
close(FD);
delete SB;
return 0;
}
}
close(FD);
return SB;
}
/// getFileInfo - Create or return a cached FileInfo for the specified file.
///
const InfoRec *
SourceManager::getInfoRec(const FileEntry *FileEnt) {
assert(FileEnt && "Didn't specify a file entry to use?");
// Do we already have information about this file?
std::map<const FileEntry *, FileInfo>::iterator I =
FileInfos.lower_bound(FileEnt);
if (I != FileInfos.end() && I->first == FileEnt)
return &*I;
// Nope, get information.
const MemoryBuffer *File = ReadFileFast(FileEnt);
if (File == 0)
return 0;
const InfoRec &Entry =
*FileInfos.insert(I, std::make_pair(FileEnt, FileInfo()));
FileInfo &Info = const_cast<FileInfo &>(Entry.second);
Info.Buffer = File;
Info.SourceLineCache = 0;
Info.NumLines = 0;
return &Entry;
}
/// createMemBufferInfoRec - Create a new info record for the specified memory
/// buffer. This does no caching.
const InfoRec *
SourceManager::createMemBufferInfoRec(const MemoryBuffer *Buffer) {
// Add a new info record to the MemBufferInfos list and return it.
FileInfo FI;
FI.Buffer = Buffer;
FI.SourceLineCache = 0;
FI.NumLines = 0;
MemBufferInfos.push_back(InfoRec(0, FI));
return &MemBufferInfos.back();
}
/// createFileID - Create a new fileID for the specified InfoRec and include
/// position. This works regardless of whether the InfoRec corresponds to a
/// file or some other input source.
unsigned SourceManager::createFileID(const InfoRec *File,
SourceLocation IncludePos) {
// If FileEnt is really large (e.g. it's a large .i file), we may not be able
// to fit an arbitrary position in the file in the FilePos field. To handle
// this, we create one FileID for each chunk of the file that fits in a
// FilePos field.
unsigned FileSize = File->second.Buffer->getBufferSize();
if (FileSize+1 < (1 << SourceLocation::FilePosBits)) {
FileIDs.push_back(FileIDInfo::get(IncludePos, 0, File));
assert(FileIDs.size() < (1 << SourceLocation::FileIDBits) &&
"Ran out of file ID's!");
return FileIDs.size();
}
// Create one FileID for each chunk of the file.
unsigned Result = FileIDs.size()+1;
unsigned ChunkNo = 0;
while (1) {
FileIDs.push_back(FileIDInfo::get(IncludePos, ChunkNo++, File));
if (FileSize+1 < (1 << SourceLocation::FilePosBits)) break;
FileSize -= (1 << SourceLocation::FilePosBits);
}
assert(FileIDs.size() < (1 << SourceLocation::FileIDBits) &&
"Ran out of file ID's!");
return Result;
}
/// getInstantiationLoc - Return a new SourceLocation that encodes the fact
/// that a token from physloc PhysLoc should actually be referenced from
/// InstantiationLoc.
SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc,
SourceLocation InstantLoc) {
// The specified source location may be a mapped location, due to a macro
// instantiation or #line directive. Strip off this information to find out
// where the characters are actually located.
PhysLoc = getPhysicalLoc(PhysLoc);
// Resolve InstantLoc down to a real logical location.
InstantLoc = getLogicalLoc(InstantLoc);
// If the last macro id is close to the currently requested location, try to
// reuse it. This implements a small cache.
for (int i = MacroIDs.size()-1, e = MacroIDs.size()-6; i >= 0 && i != e; --i){
MacroIDInfo &LastOne = MacroIDs[i];
// The instanitation point and source physloc have to exactly match to reuse
// (for now). We could allow "nearby" instantiations in the future.
if (LastOne.getInstantiationLoc() != InstantLoc ||
LastOne.getPhysicalLoc().getFileID() != PhysLoc.getFileID())
continue;
// Check to see if the physloc of the token came from near enough to reuse.
int PhysDelta = PhysLoc.getRawFilePos() -
LastOne.getPhysicalLoc().getRawFilePos();
if (SourceLocation::isValidMacroPhysOffs(PhysDelta))
return SourceLocation::getMacroLoc(i, PhysDelta, 0);
}
MacroIDs.push_back(MacroIDInfo::get(InstantLoc, PhysLoc));
return SourceLocation::getMacroLoc(MacroIDs.size()-1, 0, 0);
}
/// getCharacterData - Return a pointer to the start of the specified location
/// in the appropriate MemoryBuffer.
const char *SourceManager::getCharacterData(SourceLocation SL) const {
// Note that this is a hot function in the getSpelling() path, which is
// heavily used by -E mode.
SL = getPhysicalLoc(SL);
return getFileInfo(SL.getFileID())->Buffer->getBufferStart() +
getFullFilePos(SL);
}
/// getColumnNumber - Return the column # for the specified file position.
/// this is significantly cheaper to compute than the line number. This returns
/// zero if the column number isn't known.
unsigned SourceManager::getColumnNumber(SourceLocation Loc) const {
unsigned FileID = Loc.getFileID();
if (FileID == 0) return 0;
unsigned FilePos = getFullFilePos(Loc);
const MemoryBuffer *Buffer = getBuffer(FileID);
const char *Buf = Buffer->getBufferStart();
unsigned LineStart = FilePos;
while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
--LineStart;
return FilePos-LineStart+1;
}
/// getSourceName - This method returns the name of the file or buffer that
/// the SourceLocation specifies. This can be modified with #line directives,
/// etc.
const char *SourceManager::getSourceName(SourceLocation Loc) const {
unsigned FileID = Loc.getFileID();
if (FileID == 0) return "";
return getFileInfo(FileID)->Buffer->getBufferIdentifier();
}
static void ComputeLineNumbers(FileInfo *FI) DISABLE_INLINE;
static void ComputeLineNumbers(FileInfo *FI) {
const MemoryBuffer *Buffer = FI->Buffer;
// Find the file offsets of all of the *physical* source lines. This does
// not look at trigraphs, escaped newlines, or anything else tricky.
std::vector<unsigned> LineOffsets;
// Line #1 starts at char 0.
LineOffsets.push_back(0);
const unsigned char *Buf = (const unsigned char *)Buffer->getBufferStart();
const unsigned char *End = (const unsigned char *)Buffer->getBufferEnd();
unsigned Offs = 0;
while (1) {
// Skip over the contents of the line.
// TODO: Vectorize this? This is very performance sensitive for programs
// with lots of diagnostics and in -E mode.
const unsigned char *NextBuf = (const unsigned char *)Buf;
while (*NextBuf != '\n' && *NextBuf != '\r' && *NextBuf != '\0')
++NextBuf;
Offs += NextBuf-Buf;
Buf = NextBuf;
if (Buf[0] == '\n' || Buf[0] == '\r') {
// If this is \n\r or \r\n, skip both characters.
if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1])
++Offs, ++Buf;
++Offs, ++Buf;
LineOffsets.push_back(Offs);
} else {
// Otherwise, this is a null. If end of file, exit.
if (Buf == End) break;
// Otherwise, skip the null.
++Offs, ++Buf;
}
}
LineOffsets.push_back(Offs);
// Copy the offsets into the FileInfo structure.
FI->NumLines = LineOffsets.size();
FI->SourceLineCache = new unsigned[LineOffsets.size()];
std::copy(LineOffsets.begin(), LineOffsets.end(), FI->SourceLineCache);
}
/// getLineNumber - Given a SourceLocation, return the physical line number
/// for the position indicated. This requires building and caching a table of
/// line offsets for the MemoryBuffer, so this is not cheap: use only when
/// about to emit a diagnostic.
unsigned SourceManager::getLineNumber(SourceLocation Loc) {
unsigned FileID = Loc.getFileID();
if (FileID == 0) return 0;
FileInfo *FileInfo;
if (LastLineNoFileIDQuery == FileID)
FileInfo = LastLineNoFileInfo;
else
FileInfo = getFileInfo(FileID);
// If this is the first use of line information for this buffer, compute the
/// SourceLineCache for it on demand.
if (FileInfo->SourceLineCache == 0)
ComputeLineNumbers(FileInfo);
// Okay, we know we have a line number table. Do a binary search to find the
// line number that this character position lands on.
unsigned *SourceLineCache = FileInfo->SourceLineCache;
unsigned *SourceLineCacheStart = SourceLineCache;
unsigned *SourceLineCacheEnd = SourceLineCache + FileInfo->NumLines;
unsigned QueriedFilePos = getFullFilePos(Loc)+1;
// If the previous query was to the same file, we know both the file pos from
// that query and the line number returned. This allows us to narrow the
// search space from the entire file to something near the match.
if (LastLineNoFileIDQuery == FileID) {
if (QueriedFilePos >= LastLineNoFilePos) {
SourceLineCache = SourceLineCache+LastLineNoResult-1;
// The query is likely to be nearby the previous one. Here we check to
// see if it is within 5, 10 or 20 lines. It can be far away in cases
// where big comment blocks and vertical whitespace eat up lines but
// contribute no tokens.
if (SourceLineCache+5 < SourceLineCacheEnd) {
if (SourceLineCache[5] > QueriedFilePos)
SourceLineCacheEnd = SourceLineCache+5;
else if (SourceLineCache+10 < SourceLineCacheEnd) {
if (SourceLineCache[10] > QueriedFilePos)
SourceLineCacheEnd = SourceLineCache+10;
else if (SourceLineCache+20 < SourceLineCacheEnd) {
if (SourceLineCache[20] > QueriedFilePos)
SourceLineCacheEnd = SourceLineCache+20;
}
}
}
} else {
SourceLineCacheEnd = SourceLineCache+LastLineNoResult+1;
}
}
// If the spread is large, do a "radix" test as our initial guess, based on
// the assumption that lines average to approximately the same length.
// NOTE: This is currently disabled, as it does not appear to be profitable in
// initial measurements.
if (0 && SourceLineCacheEnd-SourceLineCache > 20) {
unsigned FileLen = FileInfo->SourceLineCache[FileInfo->NumLines-1];
// Take a stab at guessing where it is.
unsigned ApproxPos = FileInfo->NumLines*QueriedFilePos / FileLen;
// Check for -10 and +10 lines.
unsigned LowerBound = std::max(int(ApproxPos-10), 0);
unsigned UpperBound = std::min(ApproxPos+10, FileLen);
// If the computed lower bound is less than the query location, move it in.
if (SourceLineCache < SourceLineCacheStart+LowerBound &&
SourceLineCacheStart[LowerBound] < QueriedFilePos)
SourceLineCache = SourceLineCacheStart+LowerBound;
// If the computed upper bound is greater than the query location, move it.
if (SourceLineCacheEnd > SourceLineCacheStart+UpperBound &&
SourceLineCacheStart[UpperBound] >= QueriedFilePos)
SourceLineCacheEnd = SourceLineCacheStart+UpperBound;
}
unsigned *Pos
= std::lower_bound(SourceLineCache, SourceLineCacheEnd, QueriedFilePos);
unsigned LineNo = Pos-SourceLineCacheStart;
LastLineNoFileIDQuery = FileID;
LastLineNoFileInfo = FileInfo;
LastLineNoFilePos = QueriedFilePos;
LastLineNoResult = LineNo;
return LineNo;
}
/// PrintStats - Print statistics to stderr.
///
void SourceManager::PrintStats() const {
std::cerr << "\n*** Source Manager Stats:\n";
std::cerr << FileInfos.size() << " files mapped, " << MemBufferInfos.size()
<< " mem buffers mapped, " << FileIDs.size()
<< " file ID's allocated.\n";
std::cerr << " " << FileIDs.size() << " normal buffer FileID's, "
<< MacroIDs.size() << " macro expansion FileID's.\n";
unsigned NumLineNumsComputed = 0;
unsigned NumFileBytesMapped = 0;
for (std::map<const FileEntry *, FileInfo>::const_iterator I =
FileInfos.begin(), E = FileInfos.end(); I != E; ++I) {
NumLineNumsComputed += I->second.SourceLineCache != 0;
NumFileBytesMapped += I->second.Buffer->getBufferSize();
}
std::cerr << NumFileBytesMapped << " bytes of files mapped, "
<< NumLineNumsComputed << " files with line #'s computed.\n";
}

View File

@@ -1,248 +0,0 @@
//===--- TargetInfo.cpp - Information about Target machine ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the TargetInfo and TargetInfoImpl interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/AST/Builtins.h"
#include "llvm/ADT/StringMap.h"
#include <set>
using namespace clang;
void TargetInfoImpl::ANCHOR() {} // out-of-line virtual method for class.
/// DiagnoseNonPortability - When a use of a non-portable target feature is
/// used, this method emits the diagnostic and marks the translation unit as
/// non-portable.
void TargetInfo::DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind) {
NonPortable = true;
if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind);
}
/// GetTargetDefineMap - Get the set of target #defines in an associative
/// collection for easy lookup.
static void GetTargetDefineMap(const TargetInfoImpl *Target,
llvm::StringMap<std::string> &Map) {
std::vector<std::string> PrimaryDefines;
Target->getTargetDefines(PrimaryDefines);
while (!PrimaryDefines.empty()) {
std::string &PrimDefineStr = PrimaryDefines.back();
const char *Str = PrimDefineStr.c_str();
const char *StrEnd = Str+PrimDefineStr.size();
if (const char *Equal = strchr(Str, '=')) {
// Split at the '='.
std::string &Entry = Map.GetOrCreateValue(Str, Equal).getValue();
Entry = std::string(Equal+1, StrEnd);
} else {
// Remember "macroname=1".
std::string &Entry = Map.GetOrCreateValue(Str, StrEnd).getValue();
Entry = "1";
}
PrimaryDefines.pop_back();
}
}
/// getTargetDefines - Appends the target-specific #define values for this
/// target set to the specified buffer.
void TargetInfo::getTargetDefines(std::vector<char> &Buffer) {
// This is tricky in the face of secondary targets. Specifically,
// target-specific #defines that are present and identical across all
// secondary targets are turned into #defines, #defines that are present in
// the primary target but are missing or different in the secondary targets
// are turned into #define_target, and #defines that are not defined in the
// primary, but are defined in a secondary are turned into
// #define_other_target. This allows the preprocessor to correctly track uses
// of target-specific macros.
// Get the set of primary #defines.
llvm::StringMap<std::string> PrimaryDefines;
GetTargetDefineMap(PrimaryTarget, PrimaryDefines);
// If we have no secondary targets, be a bit more efficient.
if (SecondaryTargets.empty()) {
for (llvm::StringMap<std::string>::iterator I =
PrimaryDefines.begin(), E = PrimaryDefines.end(); I != E; ++I) {
// If this define is non-portable, turn it into #define_target, otherwise
// just use #define.
const char *Command = "#define ";
Buffer.insert(Buffer.end(), Command, Command+strlen(Command));
// Insert "defname defvalue\n".
const char *KeyStart = I->getKeyData();
const char *KeyEnd = KeyStart + I->getKeyLength();
Buffer.insert(Buffer.end(), KeyStart, KeyEnd);
Buffer.push_back(' ');
Buffer.insert(Buffer.end(), I->getValue().begin(), I->getValue().end());
Buffer.push_back('\n');
}
return;
}
// Get the sets of secondary #defines.
llvm::StringMap<std::string> *SecondaryDefines
= new llvm::StringMap<std::string>[SecondaryTargets.size()];
for (unsigned i = 0, e = SecondaryTargets.size(); i != e; ++i)
GetTargetDefineMap(SecondaryTargets[i], SecondaryDefines[i]);
// Loop over all defines in the primary target, processing them until we run
// out.
for (llvm::StringMap<std::string>::iterator PDI =
PrimaryDefines.begin(), E = PrimaryDefines.end(); PDI != E; ++PDI) {
std::string DefineName(PDI->getKeyData(),
PDI->getKeyData() + PDI->getKeyLength());
std::string DefineValue = PDI->getValue();
// Check to see whether all secondary targets have this #define and whether
// it is to the same value. Remember if not, but remove the #define from
// their collection in any case if they have it.
bool isPortable = true;
for (unsigned i = 0, e = SecondaryTargets.size(); i != e; ++i) {
llvm::StringMap<std::string>::iterator I =
SecondaryDefines[i].find(&DefineName[0],
&DefineName[0]+DefineName.size());
if (I == SecondaryDefines[i].end()) {
// Secondary target doesn't have this #define.
isPortable = false;
} else {
// Secondary target has this define, remember if it disagrees.
if (isPortable)
isPortable = I->getValue() == DefineValue;
// Remove it from the secondary target unconditionally.
SecondaryDefines[i].erase(I);
}
}
// If this define is non-portable, turn it into #define_target, otherwise
// just use #define.
const char *Command = isPortable ? "#define " : "#define_target ";
Buffer.insert(Buffer.end(), Command, Command+strlen(Command));
// Insert "defname defvalue\n".
Buffer.insert(Buffer.end(), DefineName.begin(), DefineName.end());
Buffer.push_back(' ');
Buffer.insert(Buffer.end(), DefineValue.begin(), DefineValue.end());
Buffer.push_back('\n');
}
// Now that all of the primary target's defines have been handled and removed
// from the secondary target's define sets, go through the remaining secondary
// target's #defines and taint them.
for (unsigned i = 0, e = SecondaryTargets.size(); i != e; ++i) {
llvm::StringMap<std::string> &Defs = SecondaryDefines[i];
while (!Defs.empty()) {
const char *DefStart = Defs.begin()->getKeyData();
const char *DefEnd = DefStart + Defs.begin()->getKeyLength();
// Insert "#define_other_target defname".
const char *Command = "#define_other_target ";
Buffer.insert(Buffer.end(), Command, Command+strlen(Command));
Buffer.insert(Buffer.end(), DefStart, DefEnd);
Buffer.push_back('\n');
// If any other secondary targets have this same define, remove it from
// them to avoid duplicate #define_other_target directives.
for (unsigned j = i+1; j != e; ++j) {
llvm::StringMap<std::string>::iterator I =
SecondaryDefines[j].find(DefStart, DefEnd);
if (I != SecondaryDefines[j].end())
SecondaryDefines[j].erase(I);
}
Defs.erase(Defs.begin());
}
}
delete[] SecondaryDefines;
}
/// ComputeWCharWidth - Determine the width of the wchar_t type for the primary
/// target, diagnosing whether this is non-portable across the secondary
/// targets.
void TargetInfo::ComputeWCharInfo(SourceLocation Loc) {
PrimaryTarget->getWCharInfo(WCharWidth, WCharAlign);
// Check whether this is portable across the secondary targets if the T-U is
// portable so far.
for (unsigned i = 0, e = SecondaryTargets.size(); i != e; ++i) {
unsigned Width, Align;
SecondaryTargets[i]->getWCharInfo(Width, Align);
if (Width != WCharWidth || Align != WCharAlign)
return DiagnoseNonPortability(Loc, diag::port_wchar_t);
}
}
/// getTargetBuiltins - Return information about target-specific builtins for
/// the current primary target, and info about which builtins are non-portable
/// across the current set of primary and secondary targets.
void TargetInfo::getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords,
std::vector<const char *> &NPortable) const {
// Get info about what actual builtins we will expose.
PrimaryTarget->getTargetBuiltins(Records, NumRecords);
if (SecondaryTargets.empty()) return;
// Compute the set of non-portable builtins.
// Start by computing a mapping from the primary target's builtins to their
// info records for efficient lookup.
llvm::StringMap<const Builtin::Info*> PrimaryRecs;
for (unsigned i = 0, e = NumRecords; i != e; ++i) {
const char *BIName = Records[i].Name;
PrimaryRecs.GetOrCreateValue(BIName, BIName+strlen(BIName)).getValue()
= Records+i;
}
for (unsigned i = 0, e = SecondaryTargets.size(); i != e; ++i) {
// Get the builtins for this secondary target.
const Builtin::Info *Records2nd;
unsigned NumRecords2nd;
SecondaryTargets[i]->getTargetBuiltins(Records2nd, NumRecords2nd);
// Remember all of the secondary builtin names.
std::set<std::string> BuiltinNames2nd;
for (unsigned j = 0, e = NumRecords2nd; j != e; ++j) {
BuiltinNames2nd.insert(Records2nd[j].Name);
// Check to see if the primary target has this builtin.
llvm::StringMap<const Builtin::Info*>::iterator I =
PrimaryRecs.find(Records2nd[j].Name,
Records2nd[j].Name+strlen(Records2nd[j].Name));
if (I != PrimaryRecs.end()) {
const Builtin::Info *PrimBI = I->getValue();
// If does. If they are not identical, mark the builtin as being
// non-portable.
if (Records2nd[j] != *PrimBI)
NPortable.push_back(PrimBI->Name);
} else {
// The primary target doesn't have this, it is non-portable.
NPortable.push_back(Records2nd[j].Name);
}
}
// Now that we checked all the secondary builtins, check to see if the
// primary target has any builtins that the secondary one doesn't. If so,
// then those are non-portable.
for (unsigned j = 0, e = NumRecords; j != e; ++j) {
if (!BuiltinNames2nd.count(Records[j].Name))
NPortable.push_back(Records[j].Name);
}
}
}

View File

@@ -1,28 +0,0 @@
//===--- TokenKinds.cpp - Token Kinds Support -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the TokenKind enum and support functions.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/TokenKinds.h"
#include <cassert>
using namespace clang;
static const char * const TokNames[] = {
#define TOK(X) #X,
#define KEYWORD(X,Y) #X,
#include "clang/Basic/TokenKinds.def"
0
};
const char *tok::getTokenName(enum TokenKind Kind) {
assert(Kind < tok::NUM_TOKENS);
return TokNames[Kind];
}

View File

@@ -1,52 +0,0 @@
//===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Anders Carlsson and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Builtin calls as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Builtins.h"
#include "clang/AST/Expr.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
using namespace clang;
using namespace CodeGen;
RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
switch (BuiltinID) {
default:
if (getContext().BuiltinInfo.isLibFunction(BuiltinID))
return EmitCallExpr(CGM.getBuiltinLibFunction(BuiltinID), E);
fprintf(stderr, "Unimplemented builtin!!\n");
E->dump(getContext().SourceMgr);
// Unknown builtin, for now just dump it out and return undef.
if (hasAggregateLLVMType(E->getType()))
return RValue::getAggregate(CreateTempAlloca(ConvertType(E->getType())));
return RValue::get(llvm::UndefValue::get(ConvertType(E->getType())));
case Builtin::BI__builtin___CFStringMakeConstantString: {
const Expr *Arg = E->getArg(0);
while (const ParenExpr *PE = dyn_cast<ParenExpr>(Arg))
Arg = PE->getSubExpr();
const StringLiteral *Literal = cast<StringLiteral>(Arg);
std::string S(Literal->getStrData(), Literal->getByteLength());
return RValue::get(CGM.GetAddrOfConstantCFString(S));
}
}
return RValue::get(0);
}

View File

@@ -1,128 +0,0 @@
//===--- CGDecl.cpp - Emit LLVM Code for declarations ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Decl nodes as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "clang/AST/AST.h"
#include "llvm/Type.h"
using namespace clang;
using namespace CodeGen;
void CodeGenFunction::EmitDecl(const Decl &D) {
switch (D.getKind()) {
default: assert(0 && "Unknown decl kind!");
case Decl::FileVariable:
assert(0 && "Should not see file-scope variables inside a function!");
case Decl::ParmVariable:
assert(0 && "Parmdecls should not be in declstmts!");
case Decl::Typedef: // typedef int X;
case Decl::Function: // void X();
case Decl::Struct: // struct X;
case Decl::Union: // union X;
case Decl::Class: // class X;
case Decl::Enum: // enum X;
// None of these decls require codegen support.
return;
case Decl::BlockVariable:
return EmitBlockVarDecl(cast<BlockVarDecl>(D));
case Decl::EnumConstant:
return EmitEnumConstantDecl(cast<EnumConstantDecl>(D));
}
}
void CodeGenFunction::EmitEnumConstantDecl(const EnumConstantDecl &D) {
assert(0 && "FIXME: Enum constant decls not implemented yet!");
}
/// EmitBlockVarDecl - This method handles emission of any variable declaration
/// inside a function, including static vars etc.
void CodeGenFunction::EmitBlockVarDecl(const BlockVarDecl &D) {
switch (D.getStorageClass()) {
case VarDecl::Static:
assert(0 && "FIXME: local static vars not implemented yet");
case VarDecl::Extern:
assert(0 && "FIXME: should call up to codegenmodule");
default:
assert((D.getStorageClass() == VarDecl::None ||
D.getStorageClass() == VarDecl::Auto ||
D.getStorageClass() == VarDecl::Register) &&
"Unknown storage class");
return EmitLocalBlockVarDecl(D);
}
}
/// EmitLocalBlockVarDecl - Emit code and set up an entry in LocalDeclMap for a
/// variable declaration with auto, register, or no storage class specifier.
/// These turn into simple stack objects.
void CodeGenFunction::EmitLocalBlockVarDecl(const BlockVarDecl &D) {
QualType Ty = D.getCanonicalType();
llvm::Value *DeclPtr;
if (Ty->isConstantSizeType(getContext())) {
// A normal fixed sized variable becomes an alloca in the entry block.
const llvm::Type *LTy = ConvertType(Ty);
// TODO: Alignment
DeclPtr = CreateTempAlloca(LTy, D.getName());
} else {
// TODO: Create a dynamic alloca.
assert(0 && "FIXME: Local VLAs not implemented yet");
}
llvm::Value *&DMEntry = LocalDeclMap[&D];
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
DMEntry = DeclPtr;
// If this local has an initializer, emit it now.
if (const Expr *Init = D.getInit()) {
if (!hasAggregateLLVMType(Init->getType())) {
llvm::Value *V = EmitScalarExpr(Init);
Builder.CreateStore(V, DeclPtr, D.getType().isVolatileQualified());
} else if (Init->getType()->isComplexType()) {
EmitComplexExprIntoAddr(Init, DeclPtr, D.getType().isVolatileQualified());
} else {
EmitAggExpr(Init, DeclPtr, D.getType().isVolatileQualified());
}
}
}
/// Emit an alloca for the specified parameter and set up LocalDeclMap.
void CodeGenFunction::EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg) {
QualType Ty = D.getCanonicalType();
llvm::Value *DeclPtr;
if (!Ty->isConstantSizeType(getContext())) {
// Variable sized values always are passed by-reference.
DeclPtr = Arg;
} else {
// A fixed sized first class variable becomes an alloca in the entry block.
const llvm::Type *LTy = ConvertType(Ty);
if (LTy->isFirstClassType()) {
// TODO: Alignment
DeclPtr = new llvm::AllocaInst(LTy, 0, std::string(D.getName())+".addr",
AllocaInsertPt);
// Store the initial value into the alloca.
Builder.CreateStore(Arg, DeclPtr);
} else {
// Otherwise, if this is an aggregate, just use the input pointer.
DeclPtr = Arg;
}
Arg->setName(D.getName());
}
llvm::Value *&DMEntry = LocalDeclMap[&D];
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
DMEntry = DeclPtr;
}

View File

@@ -1,451 +0,0 @@
//===--- CGExpr.cpp - Emit LLVM Code from Expressions ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Expr nodes as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
#include "clang/Lex/IdentifierTable.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Support/MathExtras.h"
using namespace clang;
using namespace CodeGen;
//===--------------------------------------------------------------------===//
// Miscellaneous Helper Methods
//===--------------------------------------------------------------------===//
/// CreateTempAlloca - This creates a alloca and inserts it into the entry
/// block.
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(const llvm::Type *Ty,
const char *Name) {
return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
}
/// EvaluateExprAsBool - Perform the usual unary conversions on the specified
/// expression and compare the result against zero, returning an Int1Ty value.
llvm::Value *CodeGenFunction::EvaluateExprAsBool(const Expr *E) {
QualType BoolTy = getContext().BoolTy;
if (!E->getType()->isComplexType())
return EmitScalarConversion(EmitScalarExpr(E), E->getType(), BoolTy);
return EmitComplexToScalarConversion(EmitComplexExpr(E), E->getType(),BoolTy);
}
/// EmitAnyExpr - Emit code to compute the specified expression which can have
/// any type. The result is returned as an RValue struct. If this is an
/// aggregate expression, the aggloc/agglocvolatile arguments indicate where
/// the result should be returned.
RValue CodeGenFunction::EmitAnyExpr(const Expr *E, llvm::Value *AggLoc,
bool isAggLocVolatile) {
if (!hasAggregateLLVMType(E->getType()))
return RValue::get(EmitScalarExpr(E));
else if (E->getType()->isComplexType())
return RValue::getComplex(EmitComplexExpr(E));
EmitAggExpr(E, AggLoc, isAggLocVolatile);
return RValue::getAggregate(AggLoc);
}
//===----------------------------------------------------------------------===//
// LValue Expression Emission
//===----------------------------------------------------------------------===//
/// EmitLValue - Emit code to compute a designator that specifies the location
/// of the expression.
///
/// This can return one of two things: a simple address or a bitfield
/// reference. In either case, the LLVM Value* in the LValue structure is
/// guaranteed to be an LLVM pointer type.
///
/// If this returns a bitfield reference, nothing about the pointee type of
/// the LLVM value is known: For example, it may not be a pointer to an
/// integer.
///
/// If this returns a normal address, and if the lvalue's C type is fixed
/// size, this method guarantees that the returned pointer type will point to
/// an LLVM type of the same size of the lvalue's type. If the lvalue has a
/// variable length type, this is not possible.
///
LValue CodeGenFunction::EmitLValue(const Expr *E) {
switch (E->getStmtClass()) {
default: {
fprintf(stderr, "Unimplemented lvalue expr!\n");
E->dump(getContext().SourceMgr);
llvm::Type *Ty = llvm::PointerType::get(ConvertType(E->getType()));
return LValue::MakeAddr(llvm::UndefValue::get(Ty));
}
case Expr::DeclRefExprClass: return EmitDeclRefLValue(cast<DeclRefExpr>(E));
case Expr::ParenExprClass:return EmitLValue(cast<ParenExpr>(E)->getSubExpr());
case Expr::PreDefinedExprClass:
return EmitPreDefinedLValue(cast<PreDefinedExpr>(E));
case Expr::StringLiteralClass:
return EmitStringLiteralLValue(cast<StringLiteral>(E));
case Expr::UnaryOperatorClass:
return EmitUnaryOpLValue(cast<UnaryOperator>(E));
case Expr::ArraySubscriptExprClass:
return EmitArraySubscriptExpr(cast<ArraySubscriptExpr>(E));
case Expr::OCUVectorElementExprClass:
return EmitOCUVectorElementExpr(cast<OCUVectorElementExpr>(E));
}
}
/// EmitLoadOfLValue - Given an expression that represents a value lvalue,
/// this method emits the address of the lvalue, then loads the result as an
/// rvalue, returning the rvalue.
RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
if (LV.isSimple()) {
llvm::Value *Ptr = LV.getAddress();
const llvm::Type *EltTy =
cast<llvm::PointerType>(Ptr->getType())->getElementType();
// Simple scalar l-value.
if (EltTy->isFirstClassType())
return RValue::get(Builder.CreateLoad(Ptr, "tmp"));
assert(ExprType->isFunctionType() && "Unknown scalar value");
return RValue::get(Ptr);
}
if (LV.isVectorElt()) {
llvm::Value *Vec = Builder.CreateLoad(LV.getVectorAddr(), "tmp");
return RValue::get(Builder.CreateExtractElement(Vec, LV.getVectorIdx(),
"vecext"));
}
// If this is a reference to a subset of the elements of a vector, either
// shuffle the input or extract/insert them as appropriate.
if (LV.isOCUVectorElt())
return EmitLoadOfOCUElementLValue(LV, ExprType);
assert(0 && "Bitfield ref not impl!");
}
// If this is a reference to a subset of the elements of a vector, either
// shuffle the input or extract/insert them as appropriate.
RValue CodeGenFunction::EmitLoadOfOCUElementLValue(LValue LV,
QualType ExprType) {
llvm::Value *Vec = Builder.CreateLoad(LV.getOCUVectorAddr(), "tmp");
unsigned EncFields = LV.getOCUVectorElts();
// If the result of the expression is a non-vector type, we must be
// extracting a single element. Just codegen as an extractelement.
const VectorType *ExprVT = ExprType->getAsVectorType();
if (!ExprVT) {
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(0, EncFields);
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
return RValue::get(Builder.CreateExtractElement(Vec, Elt, "tmp"));
}
// If the source and destination have the same number of elements, use a
// vector shuffle instead of insert/extracts.
unsigned NumResultElts = ExprVT->getNumElements();
unsigned NumSourceElts =
cast<llvm::VectorType>(Vec->getType())->getNumElements();
if (NumResultElts == NumSourceElts) {
llvm::SmallVector<llvm::Constant*, 4> Mask;
for (unsigned i = 0; i != NumResultElts; ++i) {
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields);
Mask.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx));
}
llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size());
Vec = Builder.CreateShuffleVector(Vec,
llvm::UndefValue::get(Vec->getType()),
MaskV, "tmp");
return RValue::get(Vec);
}
// Start out with an undef of the result type.
llvm::Value *Result = llvm::UndefValue::get(ConvertType(ExprType));
// Extract/Insert each element of the result.
for (unsigned i = 0; i != NumResultElts; ++i) {
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields);
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
Elt = Builder.CreateExtractElement(Vec, Elt, "tmp");
llvm::Value *OutIdx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
Result = Builder.CreateInsertElement(Result, Elt, OutIdx, "tmp");
}
return RValue::get(Result);
}
/// EmitStoreThroughLValue - Store the specified rvalue into the specified
/// lvalue, where both are guaranteed to the have the same type, and that type
/// is 'Ty'.
void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
QualType Ty) {
if (!Dst.isSimple()) {
if (Dst.isVectorElt()) {
// Read/modify/write the vector, inserting the new element.
// FIXME: Volatility.
llvm::Value *Vec = Builder.CreateLoad(Dst.getVectorAddr(), "tmp");
Vec = Builder.CreateInsertElement(Vec, Src.getScalarVal(),
Dst.getVectorIdx(), "vecins");
Builder.CreateStore(Vec, Dst.getVectorAddr());
return;
}
// If this is an update of elements of a vector, insert them as appropriate.
if (Dst.isOCUVectorElt())
return EmitStoreThroughOCUComponentLValue(Src, Dst, Ty);
assert(0 && "FIXME: Don't support store to bitfield yet");
}
llvm::Value *DstAddr = Dst.getAddress();
assert(Src.isScalar() && "Can't emit an agg store with this method");
// FIXME: Handle volatility etc.
const llvm::Type *SrcTy = Src.getScalarVal()->getType();
const llvm::Type *AddrTy =
cast<llvm::PointerType>(DstAddr->getType())->getElementType();
if (AddrTy != SrcTy)
DstAddr = Builder.CreateBitCast(DstAddr, llvm::PointerType::get(SrcTy),
"storetmp");
Builder.CreateStore(Src.getScalarVal(), DstAddr);
}
void CodeGenFunction::EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst,
QualType Ty) {
// This access turns into a read/modify/write of the vector. Load the input
// value now.
llvm::Value *Vec = Builder.CreateLoad(Dst.getOCUVectorAddr(), "tmp");
// FIXME: Volatility.
unsigned EncFields = Dst.getOCUVectorElts();
llvm::Value *SrcVal = Src.getScalarVal();
if (const VectorType *VTy = Ty->getAsVectorType()) {
unsigned NumSrcElts = VTy->getNumElements();
// Extract/Insert each element.
for (unsigned i = 0; i != NumSrcElts; ++i) {
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
Elt = Builder.CreateExtractElement(SrcVal, Elt, "tmp");
unsigned Idx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields);
llvm::Value *OutIdx = llvm::ConstantInt::get(llvm::Type::Int32Ty, Idx);
Vec = Builder.CreateInsertElement(Vec, Elt, OutIdx, "tmp");
}
} else {
// If the Src is a scalar (not a vector) it must be updating one element.
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(0, EncFields);
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp");
}
Builder.CreateStore(Vec, Dst.getOCUVectorAddr());
}
LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
const Decl *D = E->getDecl();
if (isa<BlockVarDecl>(D) || isa<ParmVarDecl>(D)) {
llvm::Value *V = LocalDeclMap[D];
assert(V && "BlockVarDecl not entered in LocalDeclMap?");
return LValue::MakeAddr(V);
} else if (isa<FunctionDecl>(D) || isa<FileVarDecl>(D)) {
return LValue::MakeAddr(CGM.GetAddrOfGlobalDecl(D));
}
assert(0 && "Unimp declref");
}
LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
// __extension__ doesn't affect lvalue-ness.
if (E->getOpcode() == UnaryOperator::Extension)
return EmitLValue(E->getSubExpr());
assert(E->getOpcode() == UnaryOperator::Deref &&
"'*' is the only unary operator that produces an lvalue");
return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()));
}
LValue CodeGenFunction::EmitStringLiteralLValue(const StringLiteral *E) {
assert(!E->isWide() && "FIXME: Wide strings not supported yet!");
const char *StrData = E->getStrData();
unsigned Len = E->getByteLength();
// FIXME: Can cache/reuse these within the module.
llvm::Constant *C=llvm::ConstantArray::get(std::string(StrData, StrData+Len));
// Create a global variable for this.
C = new llvm::GlobalVariable(C->getType(), true,
llvm::GlobalValue::InternalLinkage,
C, ".str", CurFn->getParent());
llvm::Constant *Zero = llvm::Constant::getNullValue(llvm::Type::Int32Ty);
llvm::Constant *Zeros[] = { Zero, Zero };
C = llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2);
return LValue::MakeAddr(C);
}
LValue CodeGenFunction::EmitPreDefinedLValue(const PreDefinedExpr *E) {
std::string FunctionName(CurFuncDecl->getName());
std::string GlobalVarName;
switch (E->getIdentType()) {
default:
assert(0 && "unknown pre-defined ident type");
case PreDefinedExpr::Func:
GlobalVarName = "__func__.";
break;
case PreDefinedExpr::Function:
GlobalVarName = "__FUNCTION__.";
break;
case PreDefinedExpr::PrettyFunction:
// FIXME:: Demangle C++ method names
GlobalVarName = "__PRETTY_FUNCTION__.";
break;
}
GlobalVarName += CurFuncDecl->getName();
// FIXME: Can cache/reuse these within the module.
llvm::Constant *C=llvm::ConstantArray::get(FunctionName);
// Create a global variable for this.
C = new llvm::GlobalVariable(C->getType(), true,
llvm::GlobalValue::InternalLinkage,
C, GlobalVarName, CurFn->getParent());
llvm::Constant *Zero = llvm::Constant::getNullValue(llvm::Type::Int32Ty);
llvm::Constant *Zeros[] = { Zero, Zero };
C = llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2);
return LValue::MakeAddr(C);
}
LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
// The index must always be an integer, which is not an aggregate. Emit it.
llvm::Value *Idx = EmitScalarExpr(E->getIdx());
// If the base is a vector type, then we are forming a vector element lvalue
// with this subscript.
if (E->getLHS()->getType()->isVectorType()) {
// Emit the vector as an lvalue to get its address.
LValue LHS = EmitLValue(E->getLHS());
assert(LHS.isSimple() && "Can only subscript lvalue vectors here!");
// FIXME: This should properly sign/zero/extend or truncate Idx to i32.
return LValue::MakeVectorElt(LHS.getAddress(), Idx);
}
// The base must be a pointer, which is not an aggregate. Emit it.
llvm::Value *Base = EmitScalarExpr(E->getBase());
// Extend or truncate the index type to 32 or 64-bits.
QualType IdxTy = E->getIdx()->getType();
bool IdxSigned = IdxTy->isSignedIntegerType();
unsigned IdxBitwidth = cast<llvm::IntegerType>(Idx->getType())->getBitWidth();
if (IdxBitwidth != LLVMPointerWidth)
Idx = Builder.CreateIntCast(Idx, llvm::IntegerType::get(LLVMPointerWidth),
IdxSigned, "idxprom");
// We know that the pointer points to a type of the correct size, unless the
// size is a VLA.
if (!E->getType()->isConstantSizeType(getContext()))
assert(0 && "VLA idx not implemented");
return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"));
}
LValue CodeGenFunction::
EmitOCUVectorElementExpr(const OCUVectorElementExpr *E) {
// Emit the base vector as an l-value.
LValue Base = EmitLValue(E->getBase());
assert(Base.isSimple() && "Can only subscript lvalue vectors here!");
return LValue::MakeOCUVectorElt(Base.getAddress(),
E->getEncodedElementAccess());
}
//===--------------------------------------------------------------------===//
// Expression Emission
//===--------------------------------------------------------------------===//
RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) {
if (const ImplicitCastExpr *IcExpr =
dyn_cast<const ImplicitCastExpr>(E->getCallee()))
if (const DeclRefExpr *DRExpr =
dyn_cast<const DeclRefExpr>(IcExpr->getSubExpr()))
if (const FunctionDecl *FDecl =
dyn_cast<const FunctionDecl>(DRExpr->getDecl()))
if (unsigned builtinID = FDecl->getIdentifier()->getBuiltinID())
return EmitBuiltinExpr(builtinID, E);
llvm::Value *Callee = EmitScalarExpr(E->getCallee());
return EmitCallExpr(Callee, E);
}
RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, const CallExpr *E) {
// The callee type will always be a pointer to function type, get the function
// type.
QualType CalleeTy = E->getCallee()->getType();
CalleeTy = cast<PointerType>(CalleeTy.getCanonicalType())->getPointeeType();
// Get information about the argument types.
FunctionTypeProto::arg_type_iterator ArgTyIt = 0, ArgTyEnd = 0;
// Calling unprototyped functions provides no argument info.
if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(CalleeTy)) {
ArgTyIt = FTP->arg_type_begin();
ArgTyEnd = FTP->arg_type_end();
}
llvm::SmallVector<llvm::Value*, 16> Args;
// Handle struct-return functions by passing a pointer to the location that
// we would like to return into.
if (hasAggregateLLVMType(E->getType())) {
// Create a temporary alloca to hold the result of the call. :(
Args.push_back(CreateTempAlloca(ConvertType(E->getType())));
// FIXME: set the stret attribute on the argument.
}
for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
QualType ArgTy = E->getArg(i)->getType();
if (!hasAggregateLLVMType(ArgTy)) {
// Scalar argument is passed by-value.
Args.push_back(EmitScalarExpr(E->getArg(i)));
} else if (ArgTy->isComplexType()) {
// Make a temporary alloca to pass the argument.
llvm::Value *DestMem = CreateTempAlloca(ConvertType(ArgTy));
EmitComplexExprIntoAddr(E->getArg(i), DestMem, false);
Args.push_back(DestMem);
} else {
llvm::Value *DestMem = CreateTempAlloca(ConvertType(ArgTy));
EmitAggExpr(E->getArg(i), DestMem, false);
Args.push_back(DestMem);
}
}
llvm::Value *V = Builder.CreateCall(Callee, &Args[0], &Args[0]+Args.size());
if (V->getType() != llvm::Type::VoidTy)
V->setName("call");
else if (E->getType()->isComplexType())
return RValue::getComplex(LoadComplexFromAddr(Args[0], false));
else if (hasAggregateLLVMType(E->getType()))
// Struct return.
return RValue::getAggregate(Args[0]);
return RValue::get(V);
}

View File

@@ -1,194 +0,0 @@
//===--- CGExprAgg.cpp - Emit LLVM Code from Aggregate Expressions --------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Aggregate Expr nodes as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/Support/Compiler.h"
using namespace clang;
using namespace CodeGen;
//===----------------------------------------------------------------------===//
// Aggregate Expression Emitter
//===----------------------------------------------------------------------===//
namespace {
class VISIBILITY_HIDDEN AggExprEmitter : public StmtVisitor<AggExprEmitter> {
CodeGenFunction &CGF;
llvm::LLVMBuilder &Builder;
llvm::Value *DestPtr;
bool VolatileDest;
public:
AggExprEmitter(CodeGenFunction &cgf, llvm::Value *destPtr, bool volatileDest)
: CGF(cgf), Builder(CGF.Builder),
DestPtr(destPtr), VolatileDest(volatileDest) {
}
//===--------------------------------------------------------------------===//
// Utilities
//===--------------------------------------------------------------------===//
/// EmitAggLoadOfLValue - Given an expression with aggregate type that
/// represents a value lvalue, this method emits the address of the lvalue,
/// then loads the result into DestPtr.
void EmitAggLoadOfLValue(const Expr *E);
void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr,
QualType EltTy);
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
void VisitStmt(Stmt *S) {
fprintf(stderr, "Unimplemented agg expr!\n");
S->dump(CGF.getContext().SourceMgr);
}
void VisitParenExpr(ParenExpr *PE) { Visit(PE->getSubExpr()); }
// l-values.
void VisitDeclRefExpr(DeclRefExpr *DRE) { return EmitAggLoadOfLValue(DRE); }
// case Expr::ArraySubscriptExprClass:
// Operators.
// case Expr::UnaryOperatorClass:
// case Expr::ImplicitCastExprClass:
// case Expr::CastExprClass:
// case Expr::CallExprClass:
void VisitStmtExpr(const StmtExpr *E);
void VisitBinaryOperator(const BinaryOperator *BO);
void VisitBinAssign(const BinaryOperator *E);
void VisitConditionalOperator(const ConditionalOperator *CO);
// case Expr::ChooseExprClass:
};
} // end anonymous namespace.
//===----------------------------------------------------------------------===//
// Utilities
//===----------------------------------------------------------------------===//
void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr,
llvm::Value *SrcPtr, QualType Ty) {
assert(!Ty->isComplexType() && "Shouldn't happen for complex");
// Aggregate assignment turns into llvm.memcpy.
const llvm::Type *BP = llvm::PointerType::get(llvm::Type::Int8Ty);
if (DestPtr->getType() != BP)
DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
if (SrcPtr->getType() != BP)
SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp");
// Get size and alignment info for this aggregate.
std::pair<uint64_t, unsigned> TypeInfo =
CGF.getContext().getTypeInfo(Ty, SourceLocation());
// FIXME: Handle variable sized types.
const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth);
llvm::Value *MemCpyOps[4] = {
DestPtr, SrcPtr,
llvm::ConstantInt::get(IntPtr, TypeInfo.first),
llvm::ConstantInt::get(llvm::Type::Int32Ty, TypeInfo.second)
};
Builder.CreateCall(CGF.CGM.getMemCpyFn(), MemCpyOps, MemCpyOps+4);
}
/// EmitAggLoadOfLValue - Given an expression with aggregate type that
/// represents a value lvalue, this method emits the address of the lvalue,
/// then loads the result into DestPtr.
void AggExprEmitter::EmitAggLoadOfLValue(const Expr *E) {
LValue LV = CGF.EmitLValue(E);
assert(LV.isSimple() && "Can't have aggregate bitfield, vector, etc");
llvm::Value *SrcPtr = LV.getAddress();
// If the result is ignored, don't copy from the value.
if (DestPtr == 0)
// FIXME: If the source is volatile, we must read from it.
return;
EmitAggregateCopy(DestPtr, SrcPtr, E->getType());
}
//===----------------------------------------------------------------------===//
// Visitor Methods
//===----------------------------------------------------------------------===//
void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) {
CGF.EmitCompoundStmt(*E->getSubStmt(), true, DestPtr, VolatileDest);
}
void AggExprEmitter::VisitBinaryOperator(const BinaryOperator *E) {
fprintf(stderr, "Unimplemented aggregate binary expr!\n");
E->dump(CGF.getContext().SourceMgr);
}
void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) {
assert(E->getLHS()->getType().getCanonicalType() ==
E->getRHS()->getType().getCanonicalType() && "Invalid assignment");
LValue LHS = CGF.EmitLValue(E->getLHS());
// Codegen the RHS so that it stores directly into the LHS.
CGF.EmitAggExpr(E->getRHS(), LHS.getAddress(), false /*FIXME: VOLATILE LHS*/);
// If the result of the assignment is used, copy the RHS there also.
if (DestPtr) {
assert(0 && "FIXME: Chained agg assignment not implemented yet");
}
}
void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) {
llvm::BasicBlock *LHSBlock = new llvm::BasicBlock("cond.?");
llvm::BasicBlock *RHSBlock = new llvm::BasicBlock("cond.:");
llvm::BasicBlock *ContBlock = new llvm::BasicBlock("cond.cont");
llvm::Value *Cond = CGF.EvaluateExprAsBool(E->getCond());
Builder.CreateCondBr(Cond, LHSBlock, RHSBlock);
CGF.EmitBlock(LHSBlock);
// Handle the GNU extension for missing LHS.
assert(E->getLHS() && "Must have LHS for aggregate value");
Visit(E->getLHS());
Builder.CreateBr(ContBlock);
LHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(RHSBlock);
Visit(E->getRHS());
Builder.CreateBr(ContBlock);
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
}
//===----------------------------------------------------------------------===//
// Entry Points into this File
//===----------------------------------------------------------------------===//
/// EmitAggExpr - Emit the computation of the specified expression of
/// aggregate type. The result is computed into DestPtr. Note that if
/// DestPtr is null, the value of the aggregate expression is not needed.
void CodeGenFunction::EmitAggExpr(const Expr *E, llvm::Value *DestPtr,
bool VolatileDest) {
assert(E && hasAggregateLLVMType(E->getType()) &&
"Invalid aggregate expression to emit");
AggExprEmitter(*this, DestPtr, VolatileDest).Visit(const_cast<Expr*>(E));
}

View File

@@ -1,532 +0,0 @@
//===--- CGExprComplex.cpp - Emit LLVM Code for Complex Exprs -------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Expr nodes with complex types as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Compiler.h"
using namespace clang;
using namespace CodeGen;
//===----------------------------------------------------------------------===//
// Complex Expression Emitter
//===----------------------------------------------------------------------===//
typedef CodeGenFunction::ComplexPairTy ComplexPairTy;
namespace {
class VISIBILITY_HIDDEN ComplexExprEmitter
: public StmtVisitor<ComplexExprEmitter, ComplexPairTy> {
CodeGenFunction &CGF;
llvm::LLVMBuilder &Builder;
public:
ComplexExprEmitter(CodeGenFunction &cgf) : CGF(cgf), Builder(CGF.Builder) {
}
//===--------------------------------------------------------------------===//
// Utilities
//===--------------------------------------------------------------------===//
/// EmitLoadOfLValue - Given an expression with complex type that represents a
/// value l-value, this method emits the address of the l-value, then loads
/// and returns the result.
ComplexPairTy EmitLoadOfLValue(const Expr *E) {
LValue LV = CGF.EmitLValue(E);
// FIXME: Volatile
return EmitLoadOfComplex(LV.getAddress(), false);
}
/// EmitLoadOfComplex - Given a pointer to a complex value, emit code to load
/// the real and imaginary pieces.
ComplexPairTy EmitLoadOfComplex(llvm::Value *SrcPtr, bool isVolatile);
/// EmitStoreOfComplex - Store the specified real/imag parts into the
/// specified value pointer.
void EmitStoreOfComplex(ComplexPairTy Val, llvm::Value *ResPtr, bool isVol);
/// EmitComplexToComplexCast - Emit a cast from complex value Val to DestType.
ComplexPairTy EmitComplexToComplexCast(ComplexPairTy Val, QualType SrcType,
QualType DestType);
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
ComplexPairTy VisitStmt(Stmt *S) {
S->dump(CGF.getContext().SourceMgr);
assert(0 && "Stmt can't have complex result type!");
return ComplexPairTy();
}
ComplexPairTy VisitExpr(Expr *S);
ComplexPairTy VisitParenExpr(ParenExpr *PE) { return Visit(PE->getSubExpr());}
ComplexPairTy VisitImaginaryLiteral(const ImaginaryLiteral *IL);
// l-values.
ComplexPairTy VisitDeclRefExpr(const Expr *E) { return EmitLoadOfLValue(E); }
ComplexPairTy VisitArraySubscriptExpr(Expr *E) { return EmitLoadOfLValue(E); }
ComplexPairTy VisitMemberExpr(const Expr *E) { return EmitLoadOfLValue(E); }
// FIXME: CompoundLiteralExpr
ComplexPairTy EmitCast(Expr *Op, QualType DestTy);
ComplexPairTy VisitImplicitCastExpr(ImplicitCastExpr *E) {
// Unlike for scalars, we don't have to worry about function->ptr demotion
// here.
return EmitCast(E->getSubExpr(), E->getType());
}
ComplexPairTy VisitCastExpr(CastExpr *E) {
return EmitCast(E->getSubExpr(), E->getType());
}
ComplexPairTy VisitCallExpr(const CallExpr *E);
ComplexPairTy VisitStmtExpr(const StmtExpr *E);
// Operators.
ComplexPairTy VisitPrePostIncDec(const UnaryOperator *E,
bool isInc, bool isPre);
ComplexPairTy VisitUnaryPostDec(const UnaryOperator *E) {
return VisitPrePostIncDec(E, false, false);
}
ComplexPairTy VisitUnaryPostInc(const UnaryOperator *E) {
return VisitPrePostIncDec(E, true, false);
}
ComplexPairTy VisitUnaryPreDec(const UnaryOperator *E) {
return VisitPrePostIncDec(E, false, true);
}
ComplexPairTy VisitUnaryPreInc(const UnaryOperator *E) {
return VisitPrePostIncDec(E, true, true);
}
ComplexPairTy VisitUnaryDeref(const Expr *E) { return EmitLoadOfLValue(E); }
ComplexPairTy VisitUnaryPlus (const UnaryOperator *E) {
return Visit(E->getSubExpr());
}
ComplexPairTy VisitUnaryMinus (const UnaryOperator *E);
ComplexPairTy VisitUnaryNot (const UnaryOperator *E);
// LNot,SizeOf,AlignOf,Real,Imag never return complex.
ComplexPairTy VisitUnaryExtension(const UnaryOperator *E) {
return Visit(E->getSubExpr());
}
struct BinOpInfo {
ComplexPairTy LHS;
ComplexPairTy RHS;
QualType Ty; // Computation Type.
};
BinOpInfo EmitBinOps(const BinaryOperator *E);
ComplexPairTy EmitCompoundAssign(const CompoundAssignOperator *E,
ComplexPairTy (ComplexExprEmitter::*Func)
(const BinOpInfo &));
ComplexPairTy EmitBinAdd(const BinOpInfo &Op);
ComplexPairTy EmitBinSub(const BinOpInfo &Op);
ComplexPairTy EmitBinMul(const BinOpInfo &Op);
ComplexPairTy EmitBinDiv(const BinOpInfo &Op);
ComplexPairTy VisitBinMul(const BinaryOperator *E) {
return EmitBinMul(EmitBinOps(E));
}
ComplexPairTy VisitBinAdd(const BinaryOperator *E) {
return EmitBinAdd(EmitBinOps(E));
}
ComplexPairTy VisitBinSub(const BinaryOperator *E) {
return EmitBinSub(EmitBinOps(E));
}
ComplexPairTy VisitBinDiv(const BinaryOperator *E) {
return EmitBinDiv(EmitBinOps(E));
}
// Compound assignments.
ComplexPairTy VisitBinAddAssign(const CompoundAssignOperator *E) {
return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd);
}
ComplexPairTy VisitBinSubAssign(const CompoundAssignOperator *E) {
return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinSub);
}
ComplexPairTy VisitBinMulAssign(const CompoundAssignOperator *E) {
return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinMul);
}
ComplexPairTy VisitBinDivAssign(const CompoundAssignOperator *E) {
return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv);
}
// GCC rejects rem/and/or/xor for integer complex.
// Logical and/or always return int, never complex.
// No comparisons produce a complex result.
ComplexPairTy VisitBinAssign (const BinaryOperator *E);
ComplexPairTy VisitBinComma (const BinaryOperator *E);
ComplexPairTy VisitConditionalOperator(const ConditionalOperator *CO);
ComplexPairTy VisitChooseExpr(ChooseExpr *CE);
};
} // end anonymous namespace.
//===----------------------------------------------------------------------===//
// Utilities
//===----------------------------------------------------------------------===//
/// EmitLoadOfComplex - Given an RValue reference for a complex, emit code to
/// load the real and imaginary pieces, returning them as Real/Imag.
ComplexPairTy ComplexExprEmitter::EmitLoadOfComplex(llvm::Value *SrcPtr,
bool isVolatile) {
llvm::Constant *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
llvm::Constant *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1);
llvm::SmallString<64> Name(SrcPtr->getNameStart(),
SrcPtr->getNameStart()+SrcPtr->getNameLen());
Name += ".realp";
llvm::Value *Ops[] = {Zero, Zero};
llvm::Value *RealPtr = Builder.CreateGEP(SrcPtr, Ops, Ops+2, Name.c_str());
Name.pop_back(); // .realp -> .real
llvm::Value *Real = Builder.CreateLoad(RealPtr, isVolatile, Name.c_str());
Name.resize(Name.size()-4); // .real -> .imagp
Name += "imagp";
Ops[1] = One; // { Ops = { Zero, One }
llvm::Value *ImagPtr = Builder.CreateGEP(SrcPtr, Ops, Ops+2, Name.c_str());
Name.pop_back(); // .imagp -> .imag
llvm::Value *Imag = Builder.CreateLoad(ImagPtr, isVolatile, Name.c_str());
return ComplexPairTy(Real, Imag);
}
/// EmitStoreOfComplex - Store the specified real/imag parts into the
/// specified value pointer.
void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy Val, llvm::Value *Ptr,
bool isVolatile) {
llvm::Constant *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
llvm::Constant *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1);
llvm::Value *Ops[] = {Zero, Zero};
llvm::Value *RealPtr = Builder.CreateGEP(Ptr, Ops, Ops+2, "real");
Ops[1] = One; // { Ops = { Zero, One }
llvm::Value *ImagPtr = Builder.CreateGEP(Ptr, Ops, Ops+2, "imag");
Builder.CreateStore(Val.first, RealPtr, isVolatile);
Builder.CreateStore(Val.second, ImagPtr, isVolatile);
}
//===----------------------------------------------------------------------===//
// Visitor Methods
//===----------------------------------------------------------------------===//
ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) {
fprintf(stderr, "Unimplemented complex expr!\n");
E->dump(CGF.getContext().SourceMgr);
const llvm::Type *EltTy =
CGF.ConvertType(E->getType()->getAsComplexType()->getElementType());
llvm::Value *U = llvm::UndefValue::get(EltTy);
return ComplexPairTy(U, U);
}
ComplexPairTy ComplexExprEmitter::
VisitImaginaryLiteral(const ImaginaryLiteral *IL) {
llvm::Value *Imag = CGF.EmitScalarExpr(IL->getSubExpr());
return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
}
ComplexPairTy ComplexExprEmitter::VisitCallExpr(const CallExpr *E) {
return CGF.EmitCallExpr(E).getComplexVal();
}
ComplexPairTy ComplexExprEmitter::VisitStmtExpr(const StmtExpr *E) {
return CGF.EmitCompoundStmt(*E->getSubStmt(), true).getComplexVal();
}
/// EmitComplexToComplexCast - Emit a cast from complex value Val to DestType.
ComplexPairTy ComplexExprEmitter::EmitComplexToComplexCast(ComplexPairTy Val,
QualType SrcType,
QualType DestType) {
// Get the src/dest element type.
SrcType = cast<ComplexType>(SrcType.getCanonicalType())->getElementType();
DestType = cast<ComplexType>(DestType.getCanonicalType())->getElementType();
// C99 6.3.1.6: When a value of complextype is converted to another
// complex type, both the real and imaginary parts followthe conversion
// rules for the corresponding real types.
Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType);
Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType);
return Val;
}
ComplexPairTy ComplexExprEmitter::EmitCast(Expr *Op, QualType DestTy) {
// Two cases here: cast from (complex to complex) and (scalar to complex).
if (Op->getType()->isComplexType())
return EmitComplexToComplexCast(Visit(Op), Op->getType(), DestTy);
// C99 6.3.1.7: When a value of real type is converted to a complex type, the
// real part of the complex result value is determined by the rules of
// conversion to the corresponding real type and the imaginary part of the
// complex result value is a positive zero or an unsigned zero.
llvm::Value *Elt = CGF.EmitScalarExpr(Op);
// Convert the input element to the element type of the complex.
DestTy = cast<ComplexType>(DestTy.getCanonicalType())->getElementType();
Elt = CGF.EmitScalarConversion(Elt, Op->getType(), DestTy);
// Return (realval, 0).
return ComplexPairTy(Elt, llvm::Constant::getNullValue(Elt->getType()));
}
ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
bool isInc, bool isPre) {
LValue LV = CGF.EmitLValue(E->getSubExpr());
// FIXME: Handle volatile!
ComplexPairTy InVal = EmitLoadOfComplex(LV.getAddress(), false);
uint64_t AmountVal = isInc ? 1 : -1;
llvm::Value *NextVal;
if (isa<llvm::IntegerType>(InVal.first->getType()))
NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal);
else
NextVal = llvm::ConstantFP::get(InVal.first->getType(),
static_cast<double>(AmountVal));
// Add the inc/dec to the real part.
NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec");
ComplexPairTy IncVal(NextVal, InVal.second);
// Store the updated result through the lvalue.
EmitStoreOfComplex(IncVal, LV.getAddress(), false); /* FIXME: Volatile */
// If this is a postinc, return the value read from memory, otherwise use the
// updated value.
return isPre ? IncVal : InVal;
}
ComplexPairTy ComplexExprEmitter::VisitUnaryMinus(const UnaryOperator *E) {
ComplexPairTy Op = Visit(E->getSubExpr());
llvm::Value *ResR = Builder.CreateNeg(Op.first, "neg.r");
llvm::Value *ResI = Builder.CreateNeg(Op.second, "neg.i");
return ComplexPairTy(ResR, ResI);
}
ComplexPairTy ComplexExprEmitter::VisitUnaryNot(const UnaryOperator *E) {
// ~(a+ib) = a + i*-b
ComplexPairTy Op = Visit(E->getSubExpr());
llvm::Value *ResI = Builder.CreateNeg(Op.second, "conj.i");
return ComplexPairTy(Op.first, ResI);
}
ComplexPairTy ComplexExprEmitter::EmitBinAdd(const BinOpInfo &Op) {
llvm::Value *ResR = Builder.CreateAdd(Op.LHS.first, Op.RHS.first, "add.r");
llvm::Value *ResI = Builder.CreateAdd(Op.LHS.second, Op.RHS.second, "add.i");
return ComplexPairTy(ResR, ResI);
}
ComplexPairTy ComplexExprEmitter::EmitBinSub(const BinOpInfo &Op) {
llvm::Value *ResR = Builder.CreateSub(Op.LHS.first, Op.RHS.first, "sub.r");
llvm::Value *ResI = Builder.CreateSub(Op.LHS.second, Op.RHS.second, "sub.i");
return ComplexPairTy(ResR, ResI);
}
ComplexPairTy ComplexExprEmitter::EmitBinMul(const BinOpInfo &Op) {
llvm::Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first, "mul.rl");
llvm::Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,"mul.rr");
llvm::Value *ResR = Builder.CreateSub(ResRl, ResRr, "mul.r");
llvm::Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first, "mul.il");
llvm::Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second, "mul.ir");
llvm::Value *ResI = Builder.CreateAdd(ResIl, ResIr, "mul.i");
return ComplexPairTy(ResR, ResI);
}
ComplexPairTy ComplexExprEmitter::EmitBinDiv(const BinOpInfo &Op) {
llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second;
llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second;
// (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd))
llvm::Value *Tmp1 = Builder.CreateMul(LHSr, RHSr, "tmp"); // a*c
llvm::Value *Tmp2 = Builder.CreateMul(LHSi, RHSi, "tmp"); // b*d
llvm::Value *Tmp3 = Builder.CreateAdd(Tmp1, Tmp2, "tmp"); // ac+bd
llvm::Value *Tmp4 = Builder.CreateMul(RHSr, RHSr, "tmp"); // c*c
llvm::Value *Tmp5 = Builder.CreateMul(RHSi, RHSi, "tmp"); // d*d
llvm::Value *Tmp6 = Builder.CreateAdd(Tmp4, Tmp5, "tmp"); // cc+dd
llvm::Value *Tmp7 = Builder.CreateMul(LHSi, RHSr, "tmp"); // b*c
llvm::Value *Tmp8 = Builder.CreateMul(LHSr, RHSi, "tmp"); // a*d
llvm::Value *Tmp9 = Builder.CreateSub(Tmp7, Tmp8, "tmp"); // bc-ad
llvm::Value *DSTr, *DSTi;
if (Tmp3->getType()->isFloatingPoint()) {
DSTr = Builder.CreateFDiv(Tmp3, Tmp6, "tmp");
DSTi = Builder.CreateFDiv(Tmp9, Tmp6, "tmp");
} else {
if (Op.Ty->getAsComplexType()->getElementType()->isUnsignedIntegerType()) {
DSTr = Builder.CreateUDiv(Tmp3, Tmp6, "tmp");
DSTi = Builder.CreateUDiv(Tmp9, Tmp6, "tmp");
} else {
DSTr = Builder.CreateSDiv(Tmp3, Tmp6, "tmp");
DSTi = Builder.CreateSDiv(Tmp9, Tmp6, "tmp");
}
}
return ComplexPairTy(DSTr, DSTi);
}
ComplexExprEmitter::BinOpInfo
ComplexExprEmitter::EmitBinOps(const BinaryOperator *E) {
BinOpInfo Ops;
Ops.LHS = Visit(E->getLHS());
Ops.RHS = Visit(E->getRHS());
Ops.Ty = E->getType();
return Ops;
}
// Compound assignments.
ComplexPairTy ComplexExprEmitter::
EmitCompoundAssign(const CompoundAssignOperator *E,
ComplexPairTy (ComplexExprEmitter::*Func)(const BinOpInfo&)){
QualType LHSTy = E->getLHS()->getType(), RHSTy = E->getRHS()->getType();
// Load the LHS and RHS operands.
LValue LHSLV = CGF.EmitLValue(E->getLHS());
BinOpInfo OpInfo;
OpInfo.Ty = E->getComputationType();
// We know the LHS is a complex lvalue.
OpInfo.LHS = EmitLoadOfComplex(LHSLV.getAddress(), false);// FIXME: Volatile.
OpInfo.LHS = EmitComplexToComplexCast(OpInfo.LHS, LHSTy, OpInfo.Ty);
// It is possible for the RHS to be complex or scalar.
OpInfo.RHS = EmitCast(E->getRHS(), OpInfo.Ty);
// Expand the binary operator.
ComplexPairTy Result = (this->*Func)(OpInfo);
// Truncate the result back to the LHS type.
Result = EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy);
// Store the result value into the LHS lvalue.
EmitStoreOfComplex(Result, LHSLV.getAddress(), false); // FIXME: VOLATILE
return Result;
}
ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) {
assert(E->getLHS()->getType().getCanonicalType() ==
E->getRHS()->getType().getCanonicalType() && "Invalid assignment");
// Emit the RHS.
ComplexPairTy Val = Visit(E->getRHS());
// Compute the address to store into.
LValue LHS = CGF.EmitLValue(E->getLHS());
// Store into it.
// FIXME: Volatility!
EmitStoreOfComplex(Val, LHS.getAddress(), false);
return Val;
}
ComplexPairTy ComplexExprEmitter::VisitBinComma(const BinaryOperator *E) {
CGF.EmitStmt(E->getLHS());
return Visit(E->getRHS());
}
ComplexPairTy ComplexExprEmitter::
VisitConditionalOperator(const ConditionalOperator *E) {
llvm::BasicBlock *LHSBlock = new llvm::BasicBlock("cond.?");
llvm::BasicBlock *RHSBlock = new llvm::BasicBlock("cond.:");
llvm::BasicBlock *ContBlock = new llvm::BasicBlock("cond.cont");
llvm::Value *Cond = CGF.EvaluateExprAsBool(E->getCond());
Builder.CreateCondBr(Cond, LHSBlock, RHSBlock);
CGF.EmitBlock(LHSBlock);
// Handle the GNU extension for missing LHS.
assert(E->getLHS() && "Must have LHS for complex value");
ComplexPairTy LHS = Visit(E->getLHS());
Builder.CreateBr(ContBlock);
LHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(RHSBlock);
ComplexPairTy RHS = Visit(E->getRHS());
Builder.CreateBr(ContBlock);
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
// Create a PHI node for the real part.
llvm::PHINode *RealPN = Builder.CreatePHI(LHS.first->getType(), "cond.r");
RealPN->reserveOperandSpace(2);
RealPN->addIncoming(LHS.first, LHSBlock);
RealPN->addIncoming(RHS.first, RHSBlock);
// Create a PHI node for the imaginary part.
llvm::PHINode *ImagPN = Builder.CreatePHI(LHS.first->getType(), "cond.i");
ImagPN->reserveOperandSpace(2);
ImagPN->addIncoming(LHS.second, LHSBlock);
ImagPN->addIncoming(RHS.second, RHSBlock);
return ComplexPairTy(RealPN, ImagPN);
}
ComplexPairTy ComplexExprEmitter::VisitChooseExpr(ChooseExpr *E) {
llvm::APSInt CondVal(32);
bool IsConst = E->getCond()->isIntegerConstantExpr(CondVal, CGF.getContext());
assert(IsConst && "Condition of choose expr must be i-c-e"); IsConst=IsConst;
// Emit the LHS or RHS as appropriate.
return Visit(CondVal != 0 ? E->getLHS() : E->getRHS());
}
//===----------------------------------------------------------------------===//
// Entry Point into this File
//===----------------------------------------------------------------------===//
/// EmitComplexExpr - Emit the computation of the specified expression of
/// complex type, ignoring the result.
ComplexPairTy CodeGenFunction::EmitComplexExpr(const Expr *E) {
assert(E && E->getType()->isComplexType() &&
"Invalid complex expression to emit");
return ComplexExprEmitter(*this).Visit(const_cast<Expr*>(E));
}
/// EmitComplexExprIntoAddr - Emit the computation of the specified expression
/// of complex type, storing into the specified Value*.
void CodeGenFunction::EmitComplexExprIntoAddr(const Expr *E,
llvm::Value *DestAddr,
bool DestIsVolatile) {
assert(E && E->getType()->isComplexType() &&
"Invalid complex expression to emit");
ComplexExprEmitter Emitter(*this);
ComplexPairTy Val = Emitter.Visit(const_cast<Expr*>(E));
Emitter.EmitStoreOfComplex(Val, DestAddr, DestIsVolatile);
}
/// LoadComplexFromAddr - Load a complex number from the specified address.
ComplexPairTy CodeGenFunction::LoadComplexFromAddr(llvm::Value *SrcAddr,
bool SrcIsVolatile) {
return ComplexExprEmitter(*this).EmitLoadOfComplex(SrcAddr, SrcIsVolatile);
}

View File

@@ -1,920 +0,0 @@
//===--- CGExprScalar.cpp - Emit LLVM Code for Scalar Exprs ---------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Expr nodes with scalar LLVM types as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/Support/Compiler.h"
using namespace clang;
using namespace CodeGen;
using llvm::Value;
//===----------------------------------------------------------------------===//
// Scalar Expression Emitter
//===----------------------------------------------------------------------===//
struct BinOpInfo {
Value *LHS;
Value *RHS;
QualType Ty; // Computation Type.
const BinaryOperator *E;
};
namespace {
class VISIBILITY_HIDDEN ScalarExprEmitter
: public StmtVisitor<ScalarExprEmitter, Value*> {
CodeGenFunction &CGF;
llvm::LLVMBuilder &Builder;
public:
ScalarExprEmitter(CodeGenFunction &cgf) : CGF(cgf), Builder(CGF.Builder) {
}
//===--------------------------------------------------------------------===//
// Utilities
//===--------------------------------------------------------------------===//
const llvm::Type *ConvertType(QualType T) { return CGF.ConvertType(T); }
LValue EmitLValue(const Expr *E) { return CGF.EmitLValue(E); }
Value *EmitLoadOfLValue(LValue LV, QualType T) {
return CGF.EmitLoadOfLValue(LV, T).getScalarVal();
}
/// EmitLoadOfLValue - Given an expression with complex type that represents a
/// value l-value, this method emits the address of the l-value, then loads
/// and returns the result.
Value *EmitLoadOfLValue(const Expr *E) {
// FIXME: Volatile
return EmitLoadOfLValue(EmitLValue(E), E->getType());
}
/// EmitConversionToBool - Convert the specified expression value to a
/// boolean (i1) truth value. This is equivalent to "Val != 0".
Value *EmitConversionToBool(Value *Src, QualType DstTy);
/// EmitScalarConversion - Emit a conversion from the specified type to the
/// specified destination type, both of which are LLVM scalar types.
Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy);
/// EmitComplexToScalarConversion - Emit a conversion from the specified
/// complex type to the specified destination type, where the destination
/// type is an LLVM scalar type.
Value *EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
QualType SrcTy, QualType DstTy);
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
Value *VisitStmt(Stmt *S) {
S->dump(CGF.getContext().SourceMgr);
assert(0 && "Stmt can't have complex result type!");
return 0;
}
Value *VisitExpr(Expr *S);
Value *VisitParenExpr(ParenExpr *PE) { return Visit(PE->getSubExpr()); }
// Leaves.
Value *VisitIntegerLiteral(const IntegerLiteral *E) {
return llvm::ConstantInt::get(E->getValue());
}
Value *VisitFloatingLiteral(const FloatingLiteral *E) {
double V = E->getValue();
// FIXME: Change this when FloatingLiteral uses an APFloat internally.
const llvm::Type *Ty = ConvertType(E->getType());
if (Ty == llvm::Type::FloatTy)
return llvm::ConstantFP::get(Ty, llvm::APFloat((float)V));
assert(Ty == llvm::Type::DoubleTy && "Unknown float type!");
return llvm::ConstantFP::get(Ty, llvm::APFloat((double)V));
}
Value *VisitCharacterLiteral(const CharacterLiteral *E) {
return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
}
Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
return llvm::ConstantInt::get(ConvertType(E->getType()),
E->typesAreCompatible());
}
Value *VisitSizeOfAlignOfTypeExpr(const SizeOfAlignOfTypeExpr *E) {
return EmitSizeAlignOf(E->getArgumentType(), E->getType(), E->isSizeOf());
}
// l-values.
Value *VisitDeclRefExpr(DeclRefExpr *E) {
if (const EnumConstantDecl *EC = dyn_cast<EnumConstantDecl>(E->getDecl()))
return llvm::ConstantInt::get(EC->getInitVal());
return EmitLoadOfLValue(E);
}
Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E);
Value *VisitMemberExpr(Expr *E) { return EmitLoadOfLValue(E); }
Value *VisitOCUVectorElementExpr(Expr *E) { return EmitLoadOfLValue(E); }
Value *VisitStringLiteral(Expr *E) { return EmitLValue(E).getAddress(); }
Value *VisitPreDefinedExpr(Expr *E) { return EmitLValue(E).getAddress(); }
// FIXME: CompoundLiteralExpr
Value *VisitImplicitCastExpr(const ImplicitCastExpr *E);
Value *VisitCastExpr(const CastExpr *E) {
return EmitCastExpr(E->getSubExpr(), E->getType());
}
Value *EmitCastExpr(const Expr *E, QualType T);
Value *VisitCallExpr(const CallExpr *E) {
return CGF.EmitCallExpr(E).getScalarVal();
}
Value *VisitStmtExpr(const StmtExpr *E);
// Unary Operators.
Value *VisitPrePostIncDec(const UnaryOperator *E, bool isInc, bool isPre);
Value *VisitUnaryPostDec(const UnaryOperator *E) {
return VisitPrePostIncDec(E, false, false);
}
Value *VisitUnaryPostInc(const UnaryOperator *E) {
return VisitPrePostIncDec(E, true, false);
}
Value *VisitUnaryPreDec(const UnaryOperator *E) {
return VisitPrePostIncDec(E, false, true);
}
Value *VisitUnaryPreInc(const UnaryOperator *E) {
return VisitPrePostIncDec(E, true, true);
}
Value *VisitUnaryAddrOf(const UnaryOperator *E) {
return EmitLValue(E->getSubExpr()).getAddress();
}
Value *VisitUnaryDeref(const Expr *E) { return EmitLoadOfLValue(E); }
Value *VisitUnaryPlus(const UnaryOperator *E) {
return Visit(E->getSubExpr());
}
Value *VisitUnaryMinus (const UnaryOperator *E);
Value *VisitUnaryNot (const UnaryOperator *E);
Value *VisitUnaryLNot (const UnaryOperator *E);
Value *VisitUnarySizeOf (const UnaryOperator *E) {
return EmitSizeAlignOf(E->getSubExpr()->getType(), E->getType(), true);
}
Value *VisitUnaryAlignOf (const UnaryOperator *E) {
return EmitSizeAlignOf(E->getSubExpr()->getType(), E->getType(), false);
}
Value *EmitSizeAlignOf(QualType TypeToSize, QualType RetType,
bool isSizeOf);
Value *VisitUnaryReal (const UnaryOperator *E);
Value *VisitUnaryImag (const UnaryOperator *E);
Value *VisitUnaryExtension(const UnaryOperator *E) {
return Visit(E->getSubExpr());
}
// Binary Operators.
Value *EmitMul(const BinOpInfo &Ops) {
return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
}
Value *EmitDiv(const BinOpInfo &Ops);
Value *EmitRem(const BinOpInfo &Ops);
Value *EmitAdd(const BinOpInfo &Ops);
Value *EmitSub(const BinOpInfo &Ops);
Value *EmitShl(const BinOpInfo &Ops);
Value *EmitShr(const BinOpInfo &Ops);
Value *EmitAnd(const BinOpInfo &Ops) {
return Builder.CreateAnd(Ops.LHS, Ops.RHS, "and");
}
Value *EmitXor(const BinOpInfo &Ops) {
return Builder.CreateXor(Ops.LHS, Ops.RHS, "xor");
}
Value *EmitOr (const BinOpInfo &Ops) {
return Builder.CreateOr(Ops.LHS, Ops.RHS, "or");
}
BinOpInfo EmitBinOps(const BinaryOperator *E);
Value *EmitCompoundAssign(const CompoundAssignOperator *E,
Value *(ScalarExprEmitter::*F)(const BinOpInfo &));
// Binary operators and binary compound assignment operators.
#define HANDLEBINOP(OP) \
Value *VisitBin ## OP(const BinaryOperator *E) { \
return Emit ## OP(EmitBinOps(E)); \
} \
Value *VisitBin ## OP ## Assign(const CompoundAssignOperator *E) { \
return EmitCompoundAssign(E, &ScalarExprEmitter::Emit ## OP); \
}
HANDLEBINOP(Mul);
HANDLEBINOP(Div);
HANDLEBINOP(Rem);
HANDLEBINOP(Add);
// (Sub) - Sub is handled specially below for ptr-ptr subtract.
HANDLEBINOP(Shl);
HANDLEBINOP(Shr);
HANDLEBINOP(And);
HANDLEBINOP(Xor);
HANDLEBINOP(Or);
#undef HANDLEBINOP
Value *VisitBinSub(const BinaryOperator *E);
Value *VisitBinSubAssign(const CompoundAssignOperator *E) {
return EmitCompoundAssign(E, &ScalarExprEmitter::EmitSub);
}
// Comparisons.
Value *EmitCompare(const BinaryOperator *E, unsigned UICmpOpc,
unsigned SICmpOpc, unsigned FCmpOpc);
#define VISITCOMP(CODE, UI, SI, FP) \
Value *VisitBin##CODE(const BinaryOperator *E) { \
return EmitCompare(E, llvm::ICmpInst::UI, llvm::ICmpInst::SI, \
llvm::FCmpInst::FP); }
VISITCOMP(LT, ICMP_ULT, ICMP_SLT, FCMP_OLT);
VISITCOMP(GT, ICMP_UGT, ICMP_SGT, FCMP_OGT);
VISITCOMP(LE, ICMP_ULE, ICMP_SLE, FCMP_OLE);
VISITCOMP(GE, ICMP_UGE, ICMP_SGE, FCMP_OGE);
VISITCOMP(EQ, ICMP_EQ , ICMP_EQ , FCMP_OEQ);
VISITCOMP(NE, ICMP_NE , ICMP_NE , FCMP_UNE);
#undef VISITCOMP
Value *VisitBinAssign (const BinaryOperator *E);
Value *VisitBinLAnd (const BinaryOperator *E);
Value *VisitBinLOr (const BinaryOperator *E);
Value *VisitBinComma (const BinaryOperator *E);
// Other Operators.
Value *VisitConditionalOperator(const ConditionalOperator *CO);
Value *VisitChooseExpr(ChooseExpr *CE);
Value *VisitObjCStringLiteral(const ObjCStringLiteral *E) {
return CGF.EmitObjCStringLiteral(E);
}
};
} // end anonymous namespace.
//===----------------------------------------------------------------------===//
// Utilities
//===----------------------------------------------------------------------===//
/// EmitConversionToBool - Convert the specified expression value to a
/// boolean (i1) truth value. This is equivalent to "Val != 0".
Value *ScalarExprEmitter::EmitConversionToBool(Value *Src, QualType SrcType) {
assert(SrcType->isCanonical() && "EmitScalarConversion strips typedefs");
if (SrcType->isRealFloatingType()) {
// Compare against 0.0 for fp scalars.
llvm::Value *Zero = llvm::Constant::getNullValue(Src->getType());
return Builder.CreateFCmpUNE(Src, Zero, "tobool");
}
assert((SrcType->isIntegerType() || SrcType->isPointerType()) &&
"Unknown scalar type to convert");
// Because of the type rules of C, we often end up computing a logical value,
// then zero extending it to int, then wanting it as a logical value again.
// Optimize this common case.
if (llvm::ZExtInst *ZI = dyn_cast<llvm::ZExtInst>(Src)) {
if (ZI->getOperand(0)->getType() == llvm::Type::Int1Ty) {
Value *Result = ZI->getOperand(0);
ZI->eraseFromParent();
return Result;
}
}
// Compare against an integer or pointer null.
llvm::Value *Zero = llvm::Constant::getNullValue(Src->getType());
return Builder.CreateICmpNE(Src, Zero, "tobool");
}
/// EmitScalarConversion - Emit a conversion from the specified type to the
/// specified destination type, both of which are LLVM scalar types.
Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
QualType DstType) {
SrcType = SrcType.getCanonicalType();
DstType = DstType.getCanonicalType();
if (SrcType == DstType) return Src;
if (DstType->isVoidType()) return 0;
// Handle conversions to bool first, they are special: comparisons against 0.
if (DstType->isBooleanType())
return EmitConversionToBool(Src, SrcType);
const llvm::Type *DstTy = ConvertType(DstType);
// Ignore conversions like int -> uint.
if (Src->getType() == DstTy)
return Src;
// Handle pointer conversions next: pointers can only be converted to/from
// other pointers and integers.
if (isa<PointerType>(DstType)) {
// The source value may be an integer, or a pointer.
if (isa<llvm::PointerType>(Src->getType()))
return Builder.CreateBitCast(Src, DstTy, "conv");
assert(SrcType->isIntegerType() && "Not ptr->ptr or int->ptr conversion?");
return Builder.CreateIntToPtr(Src, DstTy, "conv");
}
if (isa<PointerType>(SrcType)) {
// Must be an ptr to int cast.
assert(isa<llvm::IntegerType>(DstTy) && "not ptr->int?");
return Builder.CreateIntToPtr(Src, DstTy, "conv");
}
// Finally, we have the arithmetic types: real int/float.
if (isa<llvm::IntegerType>(Src->getType())) {
bool InputSigned = SrcType->isSignedIntegerType();
if (isa<llvm::IntegerType>(DstTy))
return Builder.CreateIntCast(Src, DstTy, InputSigned, "conv");
else if (InputSigned)
return Builder.CreateSIToFP(Src, DstTy, "conv");
else
return Builder.CreateUIToFP(Src, DstTy, "conv");
}
assert(Src->getType()->isFloatingPoint() && "Unknown real conversion");
if (isa<llvm::IntegerType>(DstTy)) {
if (DstType->isSignedIntegerType())
return Builder.CreateFPToSI(Src, DstTy, "conv");
else
return Builder.CreateFPToUI(Src, DstTy, "conv");
}
assert(DstTy->isFloatingPoint() && "Unknown real conversion");
if (DstTy->getTypeID() < Src->getType()->getTypeID())
return Builder.CreateFPTrunc(Src, DstTy, "conv");
else
return Builder.CreateFPExt(Src, DstTy, "conv");
}
/// EmitComplexToScalarConversion - Emit a conversion from the specified
/// complex type to the specified destination type, where the destination
/// type is an LLVM scalar type.
Value *ScalarExprEmitter::
EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
QualType SrcTy, QualType DstTy) {
// Get the source element type.
SrcTy = cast<ComplexType>(SrcTy.getCanonicalType())->getElementType();
// Handle conversions to bool first, they are special: comparisons against 0.
if (DstTy->isBooleanType()) {
// Complex != 0 -> (Real != 0) | (Imag != 0)
Src.first = EmitScalarConversion(Src.first, SrcTy, DstTy);
Src.second = EmitScalarConversion(Src.second, SrcTy, DstTy);
return Builder.CreateOr(Src.first, Src.second, "tobool");
}
// C99 6.3.1.7p2: "When a value of complex type is converted to a real type,
// the imaginary part of the complex value is discarded and the value of the
// real part is converted according to the conversion rules for the
// corresponding real type.
return EmitScalarConversion(Src.first, SrcTy, DstTy);
}
//===----------------------------------------------------------------------===//
// Visitor Methods
//===----------------------------------------------------------------------===//
Value *ScalarExprEmitter::VisitExpr(Expr *E) {
fprintf(stderr, "Unimplemented scalar expr!\n");
E->dump(CGF.getContext().SourceMgr);
if (E->getType()->isVoidType())
return 0;
return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
}
Value *ScalarExprEmitter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
// Emit subscript expressions in rvalue context's. For most cases, this just
// loads the lvalue formed by the subscript expr. However, we have to be
// careful, because the base of a vector subscript is occasionally an rvalue,
// so we can't get it as an lvalue.
if (!E->getBase()->getType()->isVectorType())
return EmitLoadOfLValue(E);
// Handle the vector case. The base must be a vector, the index must be an
// integer value.
Value *Base = Visit(E->getBase());
Value *Idx = Visit(E->getIdx());
// FIXME: Convert Idx to i32 type.
return Builder.CreateExtractElement(Base, Idx, "vecext");
}
/// VisitImplicitCastExpr - Implicit casts are the same as normal casts, but
/// also handle things like function to pointer-to-function decay, and array to
/// pointer decay.
Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) {
const Expr *Op = E->getSubExpr();
// If this is due to array->pointer conversion, emit the array expression as
// an l-value.
if (Op->getType()->isArrayType()) {
// FIXME: For now we assume that all source arrays map to LLVM arrays. This
// will not true when we add support for VLAs.
Value *V = EmitLValue(Op).getAddress(); // Bitfields can't be arrays.
assert(isa<llvm::PointerType>(V->getType()) &&
isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType())
->getElementType()) &&
"Doesn't support VLAs yet!");
llvm::Constant *Idx0 = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
llvm::Value *Ops[] = {Idx0, Idx0};
return Builder.CreateGEP(V, Ops, Ops+2, "arraydecay");
}
return EmitCastExpr(Op, E->getType());
}
// VisitCastExpr - Emit code for an explicit or implicit cast. Implicit casts
// have to handle a more broad range of conversions than explicit casts, as they
// handle things like function to ptr-to-function decay etc.
Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy) {
// Handle cases where the source is an non-complex type.
if (!E->getType()->isComplexType()) {
Value *Src = Visit(const_cast<Expr*>(E));
// Use EmitScalarConversion to perform the conversion.
return EmitScalarConversion(Src, E->getType(), DestTy);
}
// Handle cases where the source is a complex type.
return EmitComplexToScalarConversion(CGF.EmitComplexExpr(E), E->getType(),
DestTy);
}
Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) {
return CGF.EmitCompoundStmt(*E->getSubStmt(), true).getScalarVal();
}
//===----------------------------------------------------------------------===//
// Unary Operators
//===----------------------------------------------------------------------===//
Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
bool isInc, bool isPre) {
LValue LV = EmitLValue(E->getSubExpr());
// FIXME: Handle volatile!
Value *InVal = CGF.EmitLoadOfLValue(LV, // false
E->getSubExpr()->getType()).getScalarVal();
int AmountVal = isInc ? 1 : -1;
Value *NextVal;
if (isa<llvm::PointerType>(InVal->getType())) {
// FIXME: This isn't right for VLAs.
NextVal = llvm::ConstantInt::get(llvm::Type::Int32Ty, AmountVal);
NextVal = Builder.CreateGEP(InVal, NextVal);
} else {
// Add the inc/dec to the real part.
if (isa<llvm::IntegerType>(InVal->getType()))
NextVal = llvm::ConstantInt::get(InVal->getType(), AmountVal);
else
NextVal = llvm::ConstantFP::get(InVal->getType(),
static_cast<double>(AmountVal));
NextVal = Builder.CreateAdd(InVal, NextVal, isInc ? "inc" : "dec");
}
// Store the updated result through the lvalue.
CGF.EmitStoreThroughLValue(RValue::get(NextVal), LV,
E->getSubExpr()->getType());
// If this is a postinc, return the value read from memory, otherwise use the
// updated value.
return isPre ? NextVal : InVal;
}
Value *ScalarExprEmitter::VisitUnaryMinus(const UnaryOperator *E) {
Value *Op = Visit(E->getSubExpr());
return Builder.CreateNeg(Op, "neg");
}
Value *ScalarExprEmitter::VisitUnaryNot(const UnaryOperator *E) {
Value *Op = Visit(E->getSubExpr());
return Builder.CreateNot(Op, "neg");
}
Value *ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *E) {
// Compare operand to zero.
Value *BoolVal = CGF.EvaluateExprAsBool(E->getSubExpr());
// Invert value.
// TODO: Could dynamically modify easy computations here. For example, if
// the operand is an icmp ne, turn into icmp eq.
BoolVal = Builder.CreateNot(BoolVal, "lnot");
// ZExt result to int.
return Builder.CreateZExt(BoolVal, CGF.LLVMIntTy, "lnot.ext");
}
/// EmitSizeAlignOf - Return the size or alignment of the 'TypeToSize' type as
/// an integer (RetType).
Value *ScalarExprEmitter::EmitSizeAlignOf(QualType TypeToSize,
QualType RetType,bool isSizeOf){
/// FIXME: This doesn't handle VLAs yet!
std::pair<uint64_t, unsigned> Info =
CGF.getContext().getTypeInfo(TypeToSize, SourceLocation());
uint64_t Val = isSizeOf ? Info.first : Info.second;
Val /= 8; // Return size in bytes, not bits.
assert(RetType->isIntegerType() && "Result type must be an integer!");
unsigned ResultWidth = static_cast<unsigned>(CGF.getContext().getTypeSize(RetType,SourceLocation()));
return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Val));
}
Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E) {
Expr *Op = E->getSubExpr();
if (Op->getType()->isComplexType())
return CGF.EmitComplexExpr(Op).first;
return Visit(Op);
}
Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E) {
Expr *Op = E->getSubExpr();
if (Op->getType()->isComplexType())
return CGF.EmitComplexExpr(Op).second;
// __imag on a scalar returns zero. Emit it the subexpr to ensure side
// effects are evaluated.
CGF.EmitScalarExpr(Op);
return llvm::Constant::getNullValue(ConvertType(E->getType()));
}
//===----------------------------------------------------------------------===//
// Binary Operators
//===----------------------------------------------------------------------===//
BinOpInfo ScalarExprEmitter::EmitBinOps(const BinaryOperator *E) {
BinOpInfo Result;
Result.LHS = Visit(E->getLHS());
Result.RHS = Visit(E->getRHS());
Result.Ty = E->getType();
Result.E = E;
return Result;
}
Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E,
Value *(ScalarExprEmitter::*Func)(const BinOpInfo &)) {
QualType LHSTy = E->getLHS()->getType(), RHSTy = E->getRHS()->getType();
BinOpInfo OpInfo;
// Load the LHS and RHS operands.
LValue LHSLV = EmitLValue(E->getLHS());
OpInfo.LHS = EmitLoadOfLValue(LHSLV, LHSTy);
// Determine the computation type. If the RHS is complex, then this is one of
// the add/sub/mul/div operators. All of these operators can be computed in
// with just their real component even though the computation domain really is
// complex.
QualType ComputeType = E->getComputationType();
// If the computation type is complex, then the RHS is complex. Emit the RHS.
if (const ComplexType *CT = ComputeType->getAsComplexType()) {
ComputeType = CT->getElementType();
// Emit the RHS, only keeping the real component.
OpInfo.RHS = CGF.EmitComplexExpr(E->getRHS()).first;
RHSTy = RHSTy->getAsComplexType()->getElementType();
} else {
// Otherwise the RHS is a simple scalar value.
OpInfo.RHS = Visit(E->getRHS());
}
// Convert the LHS/RHS values to the computation type.
OpInfo.LHS = EmitScalarConversion(OpInfo.LHS, LHSTy, ComputeType);
// Do not merge types for -= where the LHS is a pointer.
if (E->getOpcode() != BinaryOperator::SubAssign ||
!E->getLHS()->getType()->isPointerType()) {
OpInfo.RHS = EmitScalarConversion(OpInfo.RHS, RHSTy, ComputeType);
}
OpInfo.Ty = ComputeType;
OpInfo.E = E;
// Expand the binary operator.
Value *Result = (this->*Func)(OpInfo);
// Truncate the result back to the LHS type.
Result = EmitScalarConversion(Result, ComputeType, LHSTy);
// Store the result value into the LHS lvalue.
CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV, E->getType());
return Result;
}
Value *ScalarExprEmitter::EmitDiv(const BinOpInfo &Ops) {
if (Ops.LHS->getType()->isFloatingPoint())
return Builder.CreateFDiv(Ops.LHS, Ops.RHS, "div");
else if (Ops.Ty->isUnsignedIntegerType())
return Builder.CreateUDiv(Ops.LHS, Ops.RHS, "div");
else
return Builder.CreateSDiv(Ops.LHS, Ops.RHS, "div");
}
Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) {
// Rem in C can't be a floating point type: C99 6.5.5p2.
if (Ops.Ty->isUnsignedIntegerType())
return Builder.CreateURem(Ops.LHS, Ops.RHS, "rem");
else
return Builder.CreateSRem(Ops.LHS, Ops.RHS, "rem");
}
Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
if (!Ops.Ty->isPointerType())
return Builder.CreateAdd(Ops.LHS, Ops.RHS, "add");
// FIXME: What about a pointer to a VLA?
if (isa<llvm::PointerType>(Ops.LHS->getType())) // pointer + int
return Builder.CreateGEP(Ops.LHS, Ops.RHS, "add.ptr");
// int + pointer
return Builder.CreateGEP(Ops.RHS, Ops.LHS, "add.ptr");
}
Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
if (!isa<llvm::PointerType>(Ops.LHS->getType()))
return Builder.CreateSub(Ops.LHS, Ops.RHS, "sub");
// pointer - int
assert(!isa<llvm::PointerType>(Ops.RHS->getType()) &&
"ptr-ptr shouldn't get here");
// FIXME: The pointer could point to a VLA.
Value *NegatedRHS = Builder.CreateNeg(Ops.RHS, "sub.ptr.neg");
return Builder.CreateGEP(Ops.LHS, NegatedRHS, "sub.ptr");
}
Value *ScalarExprEmitter::VisitBinSub(const BinaryOperator *E) {
// "X - Y" is different from "X -= Y" in one case: when Y is a pointer. In
// the compound assignment case it is invalid, so just handle it here.
if (!E->getRHS()->getType()->isPointerType())
return EmitSub(EmitBinOps(E));
// pointer - pointer
Value *LHS = Visit(E->getLHS());
Value *RHS = Visit(E->getRHS());
const PointerType *LHSPtrType = E->getLHS()->getType()->getAsPointerType();
assert(LHSPtrType == E->getRHS()->getType()->getAsPointerType() &&
"Can't subtract different pointer types");
QualType LHSElementType = LHSPtrType->getPointeeType();
uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType,
SourceLocation()) / 8;
const llvm::Type *ResultType = ConvertType(E->getType());
LHS = Builder.CreatePtrToInt(LHS, ResultType, "sub.ptr.lhs.cast");
RHS = Builder.CreatePtrToInt(RHS, ResultType, "sub.ptr.rhs.cast");
Value *BytesBetween = Builder.CreateSub(LHS, RHS, "sub.ptr.sub");
// HACK: LLVM doesn't have an divide instruction that 'knows' there is no
// remainder. As such, we handle common power-of-two cases here to generate
// better code.
if (llvm::isPowerOf2_64(ElementSize)) {
Value *ShAmt =
llvm::ConstantInt::get(ResultType, llvm::Log2_64(ElementSize));
return Builder.CreateAShr(BytesBetween, ShAmt, "sub.ptr.shr");
}
// Otherwise, do a full sdiv.
Value *BytesPerElt = llvm::ConstantInt::get(ResultType, ElementSize);
return Builder.CreateSDiv(BytesBetween, BytesPerElt, "sub.ptr.div");
}
Value *ScalarExprEmitter::EmitShl(const BinOpInfo &Ops) {
// LLVM requires the LHS and RHS to be the same type: promote or truncate the
// RHS to the same size as the LHS.
Value *RHS = Ops.RHS;
if (Ops.LHS->getType() != RHS->getType())
RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
return Builder.CreateShl(Ops.LHS, RHS, "shl");
}
Value *ScalarExprEmitter::EmitShr(const BinOpInfo &Ops) {
// LLVM requires the LHS and RHS to be the same type: promote or truncate the
// RHS to the same size as the LHS.
Value *RHS = Ops.RHS;
if (Ops.LHS->getType() != RHS->getType())
RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
if (Ops.Ty->isUnsignedIntegerType())
return Builder.CreateLShr(Ops.LHS, RHS, "shr");
return Builder.CreateAShr(Ops.LHS, RHS, "shr");
}
Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
unsigned SICmpOpc, unsigned FCmpOpc) {
Value *Result;
QualType LHSTy = E->getLHS()->getType();
if (!LHSTy->isComplexType()) {
Value *LHS = Visit(E->getLHS());
Value *RHS = Visit(E->getRHS());
if (LHS->getType()->isFloatingPoint()) {
Result = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc,
LHS, RHS, "cmp");
} else if (LHSTy->isUnsignedIntegerType()) {
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
LHS, RHS, "cmp");
} else {
// Signed integers and pointers.
Result = Builder.CreateICmp((llvm::ICmpInst::Predicate)SICmpOpc,
LHS, RHS, "cmp");
}
} else {
// Complex Comparison: can only be an equality comparison.
CodeGenFunction::ComplexPairTy LHS = CGF.EmitComplexExpr(E->getLHS());
CodeGenFunction::ComplexPairTy RHS = CGF.EmitComplexExpr(E->getRHS());
QualType CETy =
cast<ComplexType>(LHSTy.getCanonicalType())->getElementType();
Value *ResultR, *ResultI;
if (CETy->isRealFloatingType()) {
ResultR = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc,
LHS.first, RHS.first, "cmp.r");
ResultI = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc,
LHS.second, RHS.second, "cmp.i");
} else {
// Complex comparisons can only be equality comparisons. As such, signed
// and unsigned opcodes are the same.
ResultR = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
LHS.first, RHS.first, "cmp.r");
ResultI = Builder.CreateICmp((llvm::ICmpInst::Predicate)UICmpOpc,
LHS.second, RHS.second, "cmp.i");
}
if (E->getOpcode() == BinaryOperator::EQ) {
Result = Builder.CreateAnd(ResultR, ResultI, "and.ri");
} else {
assert(E->getOpcode() == BinaryOperator::NE &&
"Complex comparison other than == or != ?");
Result = Builder.CreateOr(ResultR, ResultI, "or.ri");
}
}
// ZExt result to int.
return Builder.CreateZExt(Result, CGF.LLVMIntTy, "cmp.ext");
}
Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
LValue LHS = EmitLValue(E->getLHS());
Value *RHS = Visit(E->getRHS());
// Store the value into the LHS.
// FIXME: Volatility!
CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS, E->getType());
// Return the RHS.
return RHS;
}
Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
Value *LHSCond = CGF.EvaluateExprAsBool(E->getLHS());
llvm::BasicBlock *ContBlock = new llvm::BasicBlock("land_cont");
llvm::BasicBlock *RHSBlock = new llvm::BasicBlock("land_rhs");
llvm::BasicBlock *OrigBlock = Builder.GetInsertBlock();
Builder.CreateCondBr(LHSCond, RHSBlock, ContBlock);
CGF.EmitBlock(RHSBlock);
Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS());
// Reaquire the RHS block, as there may be subblocks inserted.
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
// Create a PHI node. If we just evaluted the LHS condition, the result is
// false. If we evaluated both, the result is the RHS condition.
llvm::PHINode *PN = Builder.CreatePHI(llvm::Type::Int1Ty, "land");
PN->reserveOperandSpace(2);
PN->addIncoming(llvm::ConstantInt::getFalse(), OrigBlock);
PN->addIncoming(RHSCond, RHSBlock);
// ZExt result to int.
return Builder.CreateZExt(PN, CGF.LLVMIntTy, "land.ext");
}
Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
Value *LHSCond = CGF.EvaluateExprAsBool(E->getLHS());
llvm::BasicBlock *ContBlock = new llvm::BasicBlock("lor_cont");
llvm::BasicBlock *RHSBlock = new llvm::BasicBlock("lor_rhs");
llvm::BasicBlock *OrigBlock = Builder.GetInsertBlock();
Builder.CreateCondBr(LHSCond, ContBlock, RHSBlock);
CGF.EmitBlock(RHSBlock);
Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS());
// Reaquire the RHS block, as there may be subblocks inserted.
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
// Create a PHI node. If we just evaluted the LHS condition, the result is
// true. If we evaluated both, the result is the RHS condition.
llvm::PHINode *PN = Builder.CreatePHI(llvm::Type::Int1Ty, "lor");
PN->reserveOperandSpace(2);
PN->addIncoming(llvm::ConstantInt::getTrue(), OrigBlock);
PN->addIncoming(RHSCond, RHSBlock);
// ZExt result to int.
return Builder.CreateZExt(PN, CGF.LLVMIntTy, "lor.ext");
}
Value *ScalarExprEmitter::VisitBinComma(const BinaryOperator *E) {
CGF.EmitStmt(E->getLHS());
return Visit(E->getRHS());
}
//===----------------------------------------------------------------------===//
// Other Operators
//===----------------------------------------------------------------------===//
Value *ScalarExprEmitter::
VisitConditionalOperator(const ConditionalOperator *E) {
llvm::BasicBlock *LHSBlock = new llvm::BasicBlock("cond.?");
llvm::BasicBlock *RHSBlock = new llvm::BasicBlock("cond.:");
llvm::BasicBlock *ContBlock = new llvm::BasicBlock("cond.cont");
Value *Cond = CGF.EvaluateExprAsBool(E->getCond());
Builder.CreateCondBr(Cond, LHSBlock, RHSBlock);
CGF.EmitBlock(LHSBlock);
// Handle the GNU extension for missing LHS.
Value *LHS = E->getLHS() ? Visit(E->getLHS()) : Cond;
Builder.CreateBr(ContBlock);
LHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(RHSBlock);
Value *RHS = Visit(E->getRHS());
Builder.CreateBr(ContBlock);
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBlock(ContBlock);
// Create a PHI node for the real part.
llvm::PHINode *PN = Builder.CreatePHI(LHS->getType(), "cond");
PN->reserveOperandSpace(2);
PN->addIncoming(LHS, LHSBlock);
PN->addIncoming(RHS, RHSBlock);
return PN;
}
Value *ScalarExprEmitter::VisitChooseExpr(ChooseExpr *E) {
llvm::APSInt CondVal(32);
bool IsConst = E->getCond()->isIntegerConstantExpr(CondVal, CGF.getContext());
assert(IsConst && "Condition of choose expr must be i-c-e"); IsConst=IsConst;
// Emit the LHS or RHS as appropriate.
return Visit(CondVal != 0 ? E->getLHS() : E->getRHS());
}
//===----------------------------------------------------------------------===//
// Entry Point into this File
//===----------------------------------------------------------------------===//
/// EmitComplexExpr - Emit the computation of the specified expression of
/// complex type, ignoring the result.
Value *CodeGenFunction::EmitScalarExpr(const Expr *E) {
assert(E && !hasAggregateLLVMType(E->getType()) &&
"Invalid scalar expression to emit");
return ScalarExprEmitter(*this).Visit(const_cast<Expr*>(E));
}
/// EmitScalarConversion - Emit a conversion from the specified type to the
/// specified destination type, both of which are LLVM scalar types.
Value *CodeGenFunction::EmitScalarConversion(Value *Src, QualType SrcTy,
QualType DstTy) {
assert(!hasAggregateLLVMType(SrcTy) && !hasAggregateLLVMType(DstTy) &&
"Invalid scalar expression to emit");
return ScalarExprEmitter(*this).EmitScalarConversion(Src, SrcTy, DstTy);
}
/// EmitComplexToScalarConversion - Emit a conversion from the specified
/// complex type to the specified destination type, where the destination
/// type is an LLVM scalar type.
Value *CodeGenFunction::EmitComplexToScalarConversion(ComplexPairTy Src,
QualType SrcTy,
QualType DstTy) {
assert(SrcTy->isComplexType() && !hasAggregateLLVMType(DstTy) &&
"Invalid complex -> scalar conversion");
return ScalarExprEmitter(*this).EmitComplexToScalarConversion(Src, SrcTy,
DstTy);
}

View File

@@ -1,25 +0,0 @@
//===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Anders Carlsson and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Objective-C code as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/Expr.h"
#include "llvm/Constant.h"
using namespace clang;
using namespace CodeGen;
llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E){
std::string S(E->getString()->getStrData(), E->getString()->getByteLength());
return CGM.GetAddrOfConstantCFString(S);
}

View File

@@ -1,339 +0,0 @@
//===--- CGStmt.cpp - Emit LLVM Code from Statements ----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This contains code to emit Stmt nodes as LLVM code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "clang/AST/AST.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
using namespace clang;
using namespace CodeGen;
//===----------------------------------------------------------------------===//
// Statement Emission
//===----------------------------------------------------------------------===//
void CodeGenFunction::EmitStmt(const Stmt *S) {
assert(S && "Null statement?");
switch (S->getStmtClass()) {
default:
// Must be an expression in a stmt context. Emit the value (to get
// side-effects) and ignore the result.
if (const Expr *E = dyn_cast<Expr>(S)) {
if (!hasAggregateLLVMType(E->getType()))
EmitScalarExpr(E);
else if (E->getType()->isComplexType())
EmitComplexExpr(E);
else
EmitAggExpr(E, 0, false);
} else {
printf("Unimplemented stmt!\n");
S->dump(getContext().SourceMgr);
}
break;
case Stmt::NullStmtClass: break;
case Stmt::CompoundStmtClass: EmitCompoundStmt(cast<CompoundStmt>(*S)); break;
case Stmt::LabelStmtClass: EmitLabelStmt(cast<LabelStmt>(*S)); break;
case Stmt::GotoStmtClass: EmitGotoStmt(cast<GotoStmt>(*S)); break;
case Stmt::IfStmtClass: EmitIfStmt(cast<IfStmt>(*S)); break;
case Stmt::WhileStmtClass: EmitWhileStmt(cast<WhileStmt>(*S)); break;
case Stmt::DoStmtClass: EmitDoStmt(cast<DoStmt>(*S)); break;
case Stmt::ForStmtClass: EmitForStmt(cast<ForStmt>(*S)); break;
case Stmt::ReturnStmtClass: EmitReturnStmt(cast<ReturnStmt>(*S)); break;
case Stmt::DeclStmtClass: EmitDeclStmt(cast<DeclStmt>(*S)); break;
case Stmt::BreakStmtClass: EmitBreakStmt(); break;
case Stmt::ContinueStmtClass: EmitContinueStmt(); break;
}
}
/// EmitCompoundStmt - Emit a compound statement {..} node. If GetLast is true,
/// this captures the expression result of the last sub-statement and returns it
/// (for use by the statement expression extension).
RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
llvm::Value *AggLoc, bool isAggVol) {
// FIXME: handle vla's etc.
if (S.body_empty() || !isa<Expr>(S.body_back())) GetLast = false;
for (CompoundStmt::const_body_iterator I = S.body_begin(),
E = S.body_end()-GetLast; I != E; ++I)
EmitStmt(*I);
if (!GetLast)
return RValue::get(0);
return EmitAnyExpr(cast<Expr>(S.body_back()), AggLoc);
}
void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB) {
// Emit a branch from this block to the next one if this was a real block. If
// this was just a fall-through block after a terminator, don't emit it.
llvm::BasicBlock *LastBB = Builder.GetInsertBlock();
if (LastBB->getTerminator()) {
// If the previous block is already terminated, don't touch it.
} else if (LastBB->empty() && LastBB->getValueName() == 0) {
// If the last block was an empty placeholder, remove it now.
// TODO: cache and reuse these.
Builder.GetInsertBlock()->eraseFromParent();
} else {
// Otherwise, create a fall-through branch.
Builder.CreateBr(BB);
}
CurFn->getBasicBlockList().push_back(BB);
Builder.SetInsertPoint(BB);
}
void CodeGenFunction::EmitLabelStmt(const LabelStmt &S) {
llvm::BasicBlock *NextBB = getBasicBlockForLabel(&S);
EmitBlock(NextBB);
EmitStmt(S.getSubStmt());
}
void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
Builder.CreateBr(getBasicBlockForLabel(S.getLabel()));
// Emit a block after the branch so that dead code after a goto has some place
// to go.
Builder.SetInsertPoint(new llvm::BasicBlock("", CurFn));
}
void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
// C99 6.8.4.1: The first substatement is executed if the expression compares
// unequal to 0. The condition must be a scalar type.
llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
llvm::BasicBlock *ContBlock = new llvm::BasicBlock("ifend");
llvm::BasicBlock *ThenBlock = new llvm::BasicBlock("ifthen");
llvm::BasicBlock *ElseBlock = ContBlock;
if (S.getElse())
ElseBlock = new llvm::BasicBlock("ifelse");
// Insert the conditional branch.
Builder.CreateCondBr(BoolCondVal, ThenBlock, ElseBlock);
// Emit the 'then' code.
EmitBlock(ThenBlock);
EmitStmt(S.getThen());
Builder.CreateBr(ContBlock);
// Emit the 'else' code if present.
if (const Stmt *Else = S.getElse()) {
EmitBlock(ElseBlock);
EmitStmt(Else);
Builder.CreateBr(ContBlock);
}
// Emit the continuation block for code after the if.
EmitBlock(ContBlock);
}
void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
// Emit the header for the loop, insert it, which will create an uncond br to
// it.
llvm::BasicBlock *LoopHeader = new llvm::BasicBlock("whilecond");
EmitBlock(LoopHeader);
// Evaluate the conditional in the while header. C99 6.8.5.1: The evaluation
// of the controlling expression takes place before each execution of the loop
// body.
llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
// TODO: while(1) is common, avoid extra exit blocks, etc. Be sure
// to correctly handle break/continue though.
// Create an exit block for when the condition fails, create a block for the
// body of the loop.
llvm::BasicBlock *ExitBlock = new llvm::BasicBlock("whileexit");
llvm::BasicBlock *LoopBody = new llvm::BasicBlock("whilebody");
// As long as the condition is true, go to the loop body.
Builder.CreateCondBr(BoolCondVal, LoopBody, ExitBlock);
// Store the blocks to use for break and continue.
BreakContinueStack.push_back(BreakContinue(ExitBlock, LoopHeader));
// Emit the loop body.
EmitBlock(LoopBody);
EmitStmt(S.getBody());
BreakContinueStack.pop_back();
// Cycle to the condition.
Builder.CreateBr(LoopHeader);
// Emit the exit block.
EmitBlock(ExitBlock);
}
void CodeGenFunction::EmitDoStmt(const DoStmt &S) {
// TODO: "do {} while (0)" is common in macros, avoid extra blocks. Be sure
// to correctly handle break/continue though.
// Emit the body for the loop, insert it, which will create an uncond br to
// it.
llvm::BasicBlock *LoopBody = new llvm::BasicBlock("dobody");
llvm::BasicBlock *AfterDo = new llvm::BasicBlock("afterdo");
EmitBlock(LoopBody);
llvm::BasicBlock *DoCond = new llvm::BasicBlock("docond");
// Store the blocks to use for break and continue.
BreakContinueStack.push_back(BreakContinue(AfterDo, DoCond));
// Emit the body of the loop into the block.
EmitStmt(S.getBody());
BreakContinueStack.pop_back();
EmitBlock(DoCond);
// C99 6.8.5.2: "The evaluation of the controlling expression takes place
// after each execution of the loop body."
// Evaluate the conditional in the while header.
// C99 6.8.5p2/p4: The first substatement is executed if the expression
// compares unequal to 0. The condition must be a scalar type.
llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
// As long as the condition is true, iterate the loop.
Builder.CreateCondBr(BoolCondVal, LoopBody, AfterDo);
// Emit the exit block.
EmitBlock(AfterDo);
}
void CodeGenFunction::EmitForStmt(const ForStmt &S) {
// FIXME: What do we do if the increment (f.e.) contains a stmt expression,
// which contains a continue/break?
// TODO: We could keep track of whether the loop body contains any
// break/continue statements and not create unnecessary blocks (like
// "afterfor" for a condless loop) if it doesn't.
// Evaluate the first part before the loop.
if (S.getInit())
EmitStmt(S.getInit());
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = new llvm::BasicBlock("forcond");
llvm::BasicBlock *AfterFor = new llvm::BasicBlock("afterfor");
EmitBlock(CondBlock);
// Evaluate the condition if present. If not, treat it as a non-zero-constant
// according to 6.8.5.3p2, aka, true.
if (S.getCond()) {
// C99 6.8.5p2/p4: The first substatement is executed if the expression
// compares unequal to 0. The condition must be a scalar type.
llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
// As long as the condition is true, iterate the loop.
llvm::BasicBlock *ForBody = new llvm::BasicBlock("forbody");
Builder.CreateCondBr(BoolCondVal, ForBody, AfterFor);
EmitBlock(ForBody);
} else {
// Treat it as a non-zero constant. Don't even create a new block for the
// body, just fall into it.
}
// If the for loop doesn't have an increment we can just use the
// condition as the continue block.
llvm::BasicBlock *ContinueBlock;
if (S.getInc())
ContinueBlock = new llvm::BasicBlock("forinc");
else
ContinueBlock = CondBlock;
// Store the blocks to use for break and continue.
BreakContinueStack.push_back(BreakContinue(AfterFor, ContinueBlock));
// If the condition is true, execute the body of the for stmt.
EmitStmt(S.getBody());
BreakContinueStack.pop_back();
if (S.getInc())
EmitBlock(ContinueBlock);
// If there is an increment, emit it next.
if (S.getInc())
EmitStmt(S.getInc());
// Finally, branch back up to the condition for the next iteration.
Builder.CreateBr(CondBlock);
// Emit the fall-through block.
EmitBlock(AfterFor);
}
/// EmitReturnStmt - Note that due to GCC extensions, this can have an operand
/// if the function returns void, or may be missing one if the function returns
/// non-void. Fun stuff :).
void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
// Emit the result value, even if unused, to evalute the side effects.
const Expr *RV = S.getRetValue();
QualType FnRetTy = CurFuncDecl->getType().getCanonicalType();
FnRetTy = cast<FunctionType>(FnRetTy)->getResultType();
if (FnRetTy->isVoidType()) {
// If the function returns void, emit ret void.
Builder.CreateRetVoid();
} else if (RV == 0) {
// Handle "return;" in a function that returns a value.
const llvm::Type *RetTy = CurFn->getFunctionType()->getReturnType();
if (RetTy == llvm::Type::VoidTy)
Builder.CreateRetVoid(); // struct return etc.
else
Builder.CreateRet(llvm::UndefValue::get(RetTy));
} else if (!hasAggregateLLVMType(RV->getType())) {
Builder.CreateRet(EmitScalarExpr(RV));
} else if (RV->getType()->isComplexType()) {
llvm::Value *SRetPtr = CurFn->arg_begin();
EmitComplexExprIntoAddr(RV, SRetPtr, false);
} else {
llvm::Value *SRetPtr = CurFn->arg_begin();
EmitAggExpr(RV, SRetPtr, false);
}
// Emit a block after the branch so that dead code after a return has some
// place to go.
EmitBlock(new llvm::BasicBlock());
}
void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
for (const Decl *Decl = S.getDecl(); Decl; Decl = Decl->getNextDeclarator())
EmitDecl(*Decl);
}
void CodeGenFunction::EmitBreakStmt() {
assert(!BreakContinueStack.empty() && "break stmt not in a loop or switch!");
llvm::BasicBlock *Block = BreakContinueStack.back().BreakBlock;
Builder.CreateBr(Block);
EmitBlock(new llvm::BasicBlock());
}
void CodeGenFunction::EmitContinueStmt() {
assert(!BreakContinueStack.empty() && "continue stmt not in a loop!");
llvm::BasicBlock *Block = BreakContinueStack.back().ContinueBlock;
Builder.CreateBr(Block);
EmitBlock(new llvm::BasicBlock());
}

View File

@@ -1,103 +0,0 @@
//===--- CodeGenFunction.cpp - Emit LLVM Code from ASTs for a Function ----===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This coordinates the per-function state used while generating code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/AST/AST.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Analysis/Verifier.h"
using namespace clang;
using namespace CodeGen;
CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
: CGM(cgm), Target(CGM.getContext().Target) {}
ASTContext &CodeGenFunction::getContext() const {
return CGM.getContext();
}
llvm::BasicBlock *CodeGenFunction::getBasicBlockForLabel(const LabelStmt *S) {
llvm::BasicBlock *&BB = LabelMap[S];
if (BB) return BB;
// Create, but don't insert, the new block.
return BB = new llvm::BasicBlock(S->getName());
}
const llvm::Type *CodeGenFunction::ConvertType(QualType T) {
return CGM.getTypes().ConvertType(T);
}
bool CodeGenFunction::hasAggregateLLVMType(QualType T) {
return !T->isRealType() && !T->isPointerType() && !T->isVoidType() &&
!T->isVectorType() && !T->isFunctionType();
}
void CodeGenFunction::GenerateCode(const FunctionDecl *FD) {
LLVMIntTy = ConvertType(getContext().IntTy);
LLVMPointerWidth = static_cast<unsigned>(
getContext().getTypeSize(getContext().getPointerType(getContext().VoidTy),
SourceLocation()));
CurFn = cast<llvm::Function>(CGM.GetAddrOfGlobalDecl(FD));
CurFuncDecl = FD;
// TODO: Set up linkage and many other things.
assert(CurFn->isDeclaration() && "Function already has body?");
llvm::BasicBlock *EntryBB = new llvm::BasicBlock("entry", CurFn);
Builder.SetInsertPoint(EntryBB);
// Create a marker to make it easy to insert allocas into the entryblock
// later.
llvm::Value *Undef = llvm::UndefValue::get(llvm::Type::Int32Ty);
AllocaInsertPt = Builder.CreateBitCast(Undef,llvm::Type::Int32Ty, "allocapt");
// Emit allocs for param decls. Give the LLVM Argument nodes names.
llvm::Function::arg_iterator AI = CurFn->arg_begin();
// Name the struct return argument.
if (hasAggregateLLVMType(FD->getResultType())) {
AI->setName("agg.result");
++AI;
}
for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i, ++AI) {
assert(AI != CurFn->arg_end() && "Argument mismatch!");
EmitParmDecl(*FD->getParamDecl(i), AI);
}
// Emit the function body.
EmitStmt(FD->getBody());
// Emit a return for code that falls off the end.
// FIXME: if this is C++ main, this should return 0.
if (CurFn->getReturnType() == llvm::Type::VoidTy)
Builder.CreateRetVoid();
else
Builder.CreateRet(llvm::UndefValue::get(CurFn->getReturnType()));
assert(BreakContinueStack.empty() &&
"mismatched push/pop in break/continue stack!");
// Verify that the function is well formed.
assert(!verifyFunction(*CurFn));
}

View File

@@ -1,401 +0,0 @@
//===--- CodeGenFunction.h - Per-Function state for LLVM CodeGen ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the internal per-function state used for llvm translation.
//
//===----------------------------------------------------------------------===//
#ifndef CODEGEN_CODEGENFUNCTION_H
#define CODEGEN_CODEGENFUNCTION_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/LLVMBuilder.h"
#include <vector>
namespace llvm {
class Module;
}
namespace clang {
class ASTContext;
class Decl;
class FunctionDecl;
class TargetInfo;
class QualType;
class FunctionTypeProto;
class Stmt;
class CompoundStmt;
class LabelStmt;
class GotoStmt;
class IfStmt;
class WhileStmt;
class DoStmt;
class ForStmt;
class ReturnStmt;
class DeclStmt;
class Expr;
class DeclRefExpr;
class StringLiteral;
class IntegerLiteral;
class FloatingLiteral;
class CharacterLiteral;
class TypesCompatibleExpr;
class ImplicitCastExpr;
class CastExpr;
class CallExpr;
class UnaryOperator;
class BinaryOperator;
class CompoundAssignOperator;
class ArraySubscriptExpr;
class OCUVectorElementExpr;
class ConditionalOperator;
class ChooseExpr;
class PreDefinedExpr;
class ObjCStringLiteral;
class BlockVarDecl;
class EnumConstantDecl;
class ParmVarDecl;
namespace CodeGen {
class CodeGenModule;
/// RValue - This trivial value class is used to represent the result of an
/// expression that is evaluated. It can be one of three things: either a
/// simple LLVM SSA value, a pair of SSA values for complex numbers, or the
/// address of an aggregate value in memory.
class RValue {
llvm::Value *V1, *V2;
// TODO: Encode this into the low bit of pointer for more efficient
// return-by-value.
enum { Scalar, Complex, Aggregate } Flavor;
// FIXME: Aggregate rvalues need to retain information about whether they are
// volatile or not.
public:
bool isScalar() const { return Flavor == Scalar; }
bool isComplex() const { return Flavor == Complex; }
bool isAggregate() const { return Flavor == Aggregate; }
/// getScalar() - Return the Value* of this scalar value.
llvm::Value *getScalarVal() const {
assert(isScalar() && "Not a scalar!");
return V1;
}
/// getComplexVal - Return the real/imag components of this complex value.
///
std::pair<llvm::Value *, llvm::Value *> getComplexVal() const {
return std::pair<llvm::Value *, llvm::Value *>(V1, V2);
}
/// getAggregateAddr() - Return the Value* of the address of the aggregate.
llvm::Value *getAggregateAddr() const {
assert(isAggregate() && "Not an aggregate!");
return V1;
}
static RValue get(llvm::Value *V) {
RValue ER;
ER.V1 = V;
ER.Flavor = Scalar;
return ER;
}
static RValue getComplex(llvm::Value *V1, llvm::Value *V2) {
RValue ER;
ER.V1 = V1;
ER.V2 = V2;
ER.Flavor = Complex;
return ER;
}
static RValue getComplex(const std::pair<llvm::Value *, llvm::Value *> &C) {
RValue ER;
ER.V1 = C.first;
ER.V2 = C.second;
ER.Flavor = Complex;
return ER;
}
static RValue getAggregate(llvm::Value *V) {
RValue ER;
ER.V1 = V;
ER.Flavor = Aggregate;
return ER;
}
};
/// LValue - This represents an lvalue references. Because C/C++ allow
/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a
/// bitrange.
class LValue {
// FIXME: Volatility. Restrict?
// alignment?
enum {
Simple, // This is a normal l-value, use getAddress().
VectorElt, // This is a vector element l-value (V[i]), use getVector*
BitField, // This is a bitfield l-value, use getBitfield*.
OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp
} LVType;
llvm::Value *V;
union {
llvm::Value *VectorIdx; // Index into a vector subscript: V[i]
unsigned VectorElts; // Encoded OCUVector element subset: V.xyx
};
public:
bool isSimple() const { return LVType == Simple; }
bool isVectorElt() const { return LVType == VectorElt; }
bool isBitfield() const { return LVType == BitField; }
bool isOCUVectorElt() const { return LVType == OCUVectorElt; }
// simple lvalue
llvm::Value *getAddress() const { assert(isSimple()); return V; }
// vector elt lvalue
llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; }
llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; }
// ocu vector elements.
llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; }
unsigned getOCUVectorElts() const {
assert(isOCUVectorElt());
return VectorElts;
}
static LValue MakeAddr(llvm::Value *V) {
LValue R;
R.LVType = Simple;
R.V = V;
return R;
}
static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx) {
LValue R;
R.LVType = VectorElt;
R.V = Vec;
R.VectorIdx = Idx;
return R;
}
static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) {
LValue R;
R.LVType = OCUVectorElt;
R.V = Vec;
R.VectorElts = Elements;
return R;
}
};
/// CodeGenFunction - This class organizes the per-function state that is used
/// while generating LLVM code.
class CodeGenFunction {
public:
CodeGenModule &CGM; // Per-module state.
TargetInfo &Target;
typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
llvm::LLVMBuilder Builder;
const FunctionDecl *CurFuncDecl;
llvm::Function *CurFn;
/// AllocaInsertPoint - This is an instruction in the entry block before which
/// we prefer to insert allocas.
llvm::Instruction *AllocaInsertPt;
const llvm::Type *LLVMIntTy;
unsigned LLVMPointerWidth;
private:
/// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
/// decls.
llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap;
/// LabelMap - This keeps track of the LLVM basic block for each C label.
llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
// BreakContinueStack - This keeps track of where break and continue
// statements should jump to.
struct BreakContinue {
BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb)
: BreakBlock(bb), ContinueBlock(cb) {}
llvm::BasicBlock *BreakBlock;
llvm::BasicBlock *ContinueBlock;
};
llvm::SmallVector<BreakContinue, 8> BreakContinueStack;
public:
CodeGenFunction(CodeGenModule &cgm);
ASTContext &getContext() const;
void GenerateCode(const FunctionDecl *FD);
const llvm::Type *ConvertType(QualType T);
/// hasAggregateLLVMType - Return true if the specified AST type will map into
/// an aggregate LLVM type or is void.
static bool hasAggregateLLVMType(QualType T);
/// getBasicBlockForLabel - Return the LLVM basicblock that the specified
/// label maps to.
llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S);
void EmitBlock(llvm::BasicBlock *BB);
//===--------------------------------------------------------------------===//
// Helpers
//===--------------------------------------------------------------------===//
/// CreateTempAlloca - This creates a alloca and inserts it into the entry
/// block.
llvm::AllocaInst *CreateTempAlloca(const llvm::Type *Ty,
const char *Name = "tmp");
/// EvaluateExprAsBool - Perform the usual unary conversions on the specified
/// expression and compare the result against zero, returning an Int1Ty value.
llvm::Value *EvaluateExprAsBool(const Expr *E);
/// EmitAnyExpr - Emit code to compute the specified expression which can have
/// any type. The result is returned as an RValue struct. If this is an
/// aggregate expression, the aggloc/agglocvolatile arguments indicate where
/// the result should be returned.
RValue EmitAnyExpr(const Expr *E, llvm::Value *AggLoc = 0,
bool isAggLocVolatile = false);
//===--------------------------------------------------------------------===//
// Declaration Emission
//===--------------------------------------------------------------------===//
void EmitDecl(const Decl &D);
void EmitEnumConstantDecl(const EnumConstantDecl &D);
void EmitBlockVarDecl(const BlockVarDecl &D);
void EmitLocalBlockVarDecl(const BlockVarDecl &D);
void EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg);
//===--------------------------------------------------------------------===//
// Statement Emission
//===--------------------------------------------------------------------===//
void EmitStmt(const Stmt *S);
RValue EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
llvm::Value *AggLoc = 0, bool isAggVol = false);
void EmitLabelStmt(const LabelStmt &S);
void EmitGotoStmt(const GotoStmt &S);
void EmitIfStmt(const IfStmt &S);
void EmitWhileStmt(const WhileStmt &S);
void EmitDoStmt(const DoStmt &S);
void EmitForStmt(const ForStmt &S);
void EmitReturnStmt(const ReturnStmt &S);
void EmitDeclStmt(const DeclStmt &S);
void EmitBreakStmt();
void EmitContinueStmt();
//===--------------------------------------------------------------------===//
// LValue Expression Emission
//===--------------------------------------------------------------------===//
/// EmitLValue - Emit code to compute a designator that specifies the location
/// of the expression.
///
/// This can return one of two things: a simple address or a bitfield
/// reference. In either case, the LLVM Value* in the LValue structure is
/// guaranteed to be an LLVM pointer type.
///
/// If this returns a bitfield reference, nothing about the pointee type of
/// the LLVM value is known: For example, it may not be a pointer to an
/// integer.
///
/// If this returns a normal address, and if the lvalue's C type is fixed
/// size, this method guarantees that the returned pointer type will point to
/// an LLVM type of the same size of the lvalue's type. If the lvalue has a
/// variable length type, this is not possible.
///
LValue EmitLValue(const Expr *E);
/// EmitLoadOfLValue - Given an expression that represents a value lvalue,
/// this method emits the address of the lvalue, then loads the result as an
/// rvalue, returning the rvalue.
RValue EmitLoadOfLValue(LValue V, QualType LVType);
RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType);
/// EmitStoreThroughLValue - Store the specified rvalue into the specified
/// lvalue, where both are guaranteed to the have the same type, and that type
/// is 'Ty'.
void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty);
void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty);
LValue EmitDeclRefLValue(const DeclRefExpr *E);
LValue EmitStringLiteralLValue(const StringLiteral *E);
LValue EmitPreDefinedLValue(const PreDefinedExpr *E);
LValue EmitUnaryOpLValue(const UnaryOperator *E);
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E);
//===--------------------------------------------------------------------===//
// Scalar Expression Emission
//===--------------------------------------------------------------------===//
RValue EmitCallExpr(const CallExpr *E);
RValue EmitCallExpr(llvm::Value *Callee, const CallExpr *E);
RValue EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
//===--------------------------------------------------------------------===//
// Expression Emission
//===--------------------------------------------------------------------===//
// Expressions are broken into three classes: scalar, complex, aggregate.
/// EmitScalarExpr - Emit the computation of the specified expression of
/// LLVM scalar type, returning the result.
llvm::Value *EmitScalarExpr(const Expr *E);
/// EmitScalarConversion - Emit a conversion from the specified type to the
/// specified destination type, both of which are LLVM scalar types.
llvm::Value *EmitScalarConversion(llvm::Value *Src, QualType SrcTy,
QualType DstTy);
/// EmitComplexToScalarConversion - Emit a conversion from the specified
/// complex type to the specified destination type, where the destination
/// type is an LLVM scalar type.
llvm::Value *EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy,
QualType DstTy);
/// EmitAggExpr - Emit the computation of the specified expression of
/// aggregate type. The result is computed into DestPtr. Note that if
/// DestPtr is null, the value of the aggregate expression is not needed.
void EmitAggExpr(const Expr *E, llvm::Value *DestPtr, bool VolatileDest);
/// EmitComplexExpr - Emit the computation of the specified expression of
/// complex type, returning the result.
ComplexPairTy EmitComplexExpr(const Expr *E);
/// EmitComplexExprIntoAddr - Emit the computation of the specified expression
/// of complex type, storing into the specified Value*.
void EmitComplexExprIntoAddr(const Expr *E, llvm::Value *DestAddr,
bool DestIsVolatile);
/// LoadComplexFromAddr - Load a complex number from the specified address.
ComplexPairTy LoadComplexFromAddr(llvm::Value *SrcAddr, bool SrcIsVolatile);
};
} // end namespace CodeGen
} // end namespace clang
#endif

View File

@@ -1,209 +0,0 @@
//===--- CodeGenModule.cpp - Emit LLVM Code from ASTs for a Module --------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This coordinates the per-module state used while generating code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenModule.h"
#include "CodeGenFunction.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Intrinsics.h"
using namespace clang;
using namespace CodeGen;
CodeGenModule::CodeGenModule(ASTContext &C, llvm::Module &M)
: Context(C), TheModule(M), Types(C, M), CFConstantStringClassRef(0) {}
llvm::Constant *CodeGenModule::GetAddrOfGlobalDecl(const Decl *D) {
// See if it is already in the map.
llvm::Constant *&Entry = GlobalDeclMap[D];
if (Entry) return Entry;
QualType ASTTy = cast<ValueDecl>(D)->getType();
const llvm::Type *Ty = getTypes().ConvertType(ASTTy);
if (isa<FunctionDecl>(D)) {
const llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty);
// FIXME: param attributes for sext/zext etc.
return Entry = new llvm::Function(FTy, llvm::Function::ExternalLinkage,
D->getName(), &getModule());
}
assert(isa<FileVarDecl>(D) && "Unknown global decl!");
return Entry = new llvm::GlobalVariable(Ty, false,
llvm::GlobalValue::ExternalLinkage,
0, D->getName(), &getModule());
}
void CodeGenModule::EmitFunction(const FunctionDecl *FD) {
// If this is not a prototype, emit the body.
if (FD->getBody())
CodeGenFunction(*this).GenerateCode(FD);
}
void CodeGenModule::EmitGlobalVar(const FileVarDecl *D) {
llvm::GlobalVariable *GV = cast<llvm::GlobalVariable>(GetAddrOfGlobalDecl(D));
// If the storage class is external and there is no initializer, just leave it
// as a declaration.
if (D->getStorageClass() == VarDecl::Extern && D->getInit() == 0)
return;
// Otherwise, convert the initializer, or use zero if appropriate.
llvm::Constant *Init = 0;
if (D->getInit() == 0) {
Init = llvm::Constant::getNullValue(GV->getType()->getElementType());
} else if (D->getType()->isIntegerType()) {
llvm::APSInt Value(static_cast<unsigned>(
getContext().getTypeSize(D->getInit()->getType(), SourceLocation())));
if (D->getInit()->isIntegerConstantExpr(Value, Context))
Init = llvm::ConstantInt::get(Value);
}
assert(Init && "FIXME: Global variable initializers unimp!");
GV->setInitializer(Init);
// Set the llvm linkage type as appropriate.
// FIXME: This isn't right. This should handle common linkage and other
// stuff.
switch (D->getStorageClass()) {
case VarDecl::Auto:
case VarDecl::Register:
assert(0 && "Can't have auto or register globals");
case VarDecl::None:
case VarDecl::Extern:
// todo: common
break;
case VarDecl::Static:
GV->setLinkage(llvm::GlobalVariable::InternalLinkage);
break;
}
}
/// EmitGlobalVarDeclarator - Emit all the global vars attached to the specified
/// declarator chain.
void CodeGenModule::EmitGlobalVarDeclarator(const FileVarDecl *D) {
for (; D; D = cast_or_null<FileVarDecl>(D->getNextDeclarator()))
EmitGlobalVar(D);
}
/// getBuiltinLibFunction
llvm::Function *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) {
if (BuiltinFunctions.size() <= BuiltinID)
BuiltinFunctions.resize(BuiltinID);
// Already available?
llvm::Function *&FunctionSlot = BuiltinFunctions[BuiltinID];
if (FunctionSlot)
return FunctionSlot;
assert(Context.BuiltinInfo.isLibFunction(BuiltinID) && "isn't a lib fn");
// Get the name, skip over the __builtin_ prefix.
const char *Name = Context.BuiltinInfo.GetName(BuiltinID)+10;
// Get the type for the builtin.
QualType Type = Context.BuiltinInfo.GetBuiltinType(BuiltinID, Context);
const llvm::FunctionType *Ty =
cast<llvm::FunctionType>(getTypes().ConvertType(Type));
// FIXME: This has a serious problem with code like this:
// void abs() {}
// ... __builtin_abs(x);
// The two versions of abs will collide. The fix is for the builtin to win,
// and for the existing one to be turned into a constantexpr cast of the
// builtin. In the case where the existing one is a static function, it
// should just be renamed.
if (llvm::Function *Existing = getModule().getFunction(Name)) {
if (Existing->getFunctionType() == Ty && Existing->hasExternalLinkage())
return FunctionSlot = Existing;
assert(Existing == 0 && "FIXME: Name collision");
}
// FIXME: param attributes for sext/zext etc.
return FunctionSlot = new llvm::Function(Ty, llvm::Function::ExternalLinkage,
Name, &getModule());
}
llvm::Function *CodeGenModule::getMemCpyFn() {
if (MemCpyFn) return MemCpyFn;
llvm::Intrinsic::ID IID;
uint64_t Size; unsigned Align;
Context.Target.getPointerInfo(Size, Align, SourceLocation());
switch (Size) {
default: assert(0 && "Unknown ptr width");
case 32: IID = llvm::Intrinsic::memcpy_i32; break;
case 64: IID = llvm::Intrinsic::memcpy_i64; break;
}
return MemCpyFn = llvm::Intrinsic::getDeclaration(&TheModule, IID);
}
llvm::Constant *CodeGenModule::
GetAddrOfConstantCFString(const std::string &str) {
llvm::StringMapEntry<llvm::Constant *> &Entry =
CFConstantStringMap.GetOrCreateValue(&str[0], &str[str.length()]);
if (Entry.getValue())
return Entry.getValue();
std::vector<llvm::Constant*> Fields;
if (!CFConstantStringClassRef) {
const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
Ty = llvm::ArrayType::get(Ty, 0);
CFConstantStringClassRef =
new llvm::GlobalVariable(Ty, false,
llvm::GlobalVariable::ExternalLinkage, 0,
"__CFConstantStringClassReference",
&getModule());
}
// Class pointer.
llvm::Constant *Zero = llvm::Constant::getNullValue(llvm::Type::Int32Ty);
llvm::Constant *Zeros[] = { Zero, Zero };
llvm::Constant *C =
llvm::ConstantExpr::getGetElementPtr(CFConstantStringClassRef, Zeros, 2);
Fields.push_back(C);
// Flags.
const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
Fields.push_back(llvm::ConstantInt::get(Ty, 1992));
// String pointer.
C = llvm::ConstantArray::get(str);
C = new llvm::GlobalVariable(C->getType(), true,
llvm::GlobalValue::InternalLinkage,
C, ".str", &getModule());
C = llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2);
Fields.push_back(C);
// String length.
Ty = getTypes().ConvertType(getContext().LongTy);
Fields.push_back(llvm::ConstantInt::get(Ty, str.length()));
// The struct.
Ty = getTypes().ConvertType(getContext().getCFConstantStringType());
C = llvm::ConstantStruct::get(cast<llvm::StructType>(Ty), Fields);
C = new llvm::GlobalVariable(C->getType(), true,
llvm::GlobalVariable::InternalLinkage,
C, "", &getModule());
Entry.setValue(C);
return C;
}

View File

@@ -1,75 +0,0 @@
//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen --------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the internal per-translation-unit state used for llvm translation.
//
//===----------------------------------------------------------------------===//
#ifndef CODEGEN_CODEGENMODULE_H
#define CODEGEN_CODEGENMODULE_H
#include "CodeGenTypes.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
namespace llvm {
class Module;
class Constant;
class Function;
}
namespace clang {
class ASTContext;
class FunctionDecl;
class Decl;
class FileVarDecl;
namespace CodeGen {
/// CodeGenModule - This class organizes the cross-module state that is used
/// while generating LLVM code.
class CodeGenModule {
ASTContext &Context;
llvm::Module &TheModule;
CodeGenTypes Types;
llvm::Function *MemCpyFn;
llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
llvm::StringMap<llvm::Constant*> CFConstantStringMap;
llvm::Constant *CFConstantStringClassRef;
std::vector<llvm::Function *> BuiltinFunctions;
public:
CodeGenModule(ASTContext &C, llvm::Module &M);
ASTContext &getContext() const { return Context; }
llvm::Module &getModule() const { return TheModule; }
CodeGenTypes &getTypes() { return Types; }
llvm::Constant *GetAddrOfGlobalDecl(const Decl *D);
/// getBuiltinLibFunction - Given a builtin id for a function like
/// "__builtin_fabsf", return a Function* for "fabsf".
///
llvm::Function *getBuiltinLibFunction(unsigned BuiltinID);
llvm::Constant *GetAddrOfConstantCFString(const std::string& str);
llvm::Function *getMemCpyFn();
void EmitFunction(const FunctionDecl *FD);
void EmitGlobalVar(const FileVarDecl *D);
void EmitGlobalVarDeclarator(const FileVarDecl *D);
void PrintStats() {}
};
} // end namespace CodeGen
} // end namespace clang
#endif

View File

@@ -1,207 +0,0 @@
//===--- CodeGenTypes.cpp - Type translation for LLVM CodeGen -------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the code that handles AST -> LLVM type lowering.
//
//===----------------------------------------------------------------------===//
#include "CodeGenTypes.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/AST/AST.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
using namespace clang;
using namespace CodeGen;
CodeGenTypes::CodeGenTypes(ASTContext &Ctx, llvm::Module& M)
: Context(Ctx), Target(Ctx.Target), TheModule(M) {
}
/// ConvertType - Convert the specified type to its LLVM form.
const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
// FIXME: Cache these, move the CodeGenModule, expand, etc.
const clang::Type &Ty = *T.getCanonicalType();
switch (Ty.getTypeClass()) {
case Type::TypeName: // typedef isn't canonical.
case Type::TypeOfExp: // typeof isn't canonical.
case Type::TypeOfTyp: // typeof isn't canonical.
assert(0 && "Non-canonical type, shouldn't happen");
case Type::Builtin: {
switch (cast<BuiltinType>(Ty).getKind()) {
case BuiltinType::Void:
// LLVM void type can only be used as the result of a function call. Just
// map to the same as char.
return llvm::IntegerType::get(8);
case BuiltinType::Bool:
// FIXME: This is very strange. We want scalars to be i1, but in memory
// they can be i1 or i32. Should the codegen handle this issue?
return llvm::Type::Int1Ty;
case BuiltinType::Char_S:
case BuiltinType::Char_U:
case BuiltinType::SChar:
case BuiltinType::UChar:
case BuiltinType::Short:
case BuiltinType::UShort:
case BuiltinType::Int:
case BuiltinType::UInt:
case BuiltinType::Long:
case BuiltinType::ULong:
case BuiltinType::LongLong:
case BuiltinType::ULongLong:
return llvm::IntegerType::get(
static_cast<unsigned>(Context.getTypeSize(T, SourceLocation())));
case BuiltinType::Float: return llvm::Type::FloatTy;
case BuiltinType::Double: return llvm::Type::DoubleTy;
case BuiltinType::LongDouble:
// FIXME: mapping long double onto double.
return llvm::Type::DoubleTy;
}
break;
}
case Type::Complex: {
std::vector<const llvm::Type*> Elts;
Elts.push_back(ConvertType(cast<ComplexType>(Ty).getElementType()));
Elts.push_back(Elts[0]);
return llvm::StructType::get(Elts);
}
case Type::Pointer: {
const PointerType &P = cast<PointerType>(Ty);
return llvm::PointerType::get(ConvertType(P.getPointeeType()));
}
case Type::Reference: {
const ReferenceType &R = cast<ReferenceType>(Ty);
return llvm::PointerType::get(ConvertType(R.getReferenceeType()));
}
case Type::VariableArray: {
const VariableArrayType &A = cast<VariableArrayType>(Ty);
assert(A.getSizeModifier() == ArrayType::Normal &&
A.getIndexTypeQualifier() == 0 &&
"FIXME: We only handle trivial array types so far!");
if (A.getSizeExpr() == 0) {
// int X[] -> [0 x int]
return llvm::ArrayType::get(ConvertType(A.getElementType()), 0);
} else {
assert(0 && "FIXME: VLAs not implemented yet!");
}
}
case Type::ConstantArray: {
const ConstantArrayType &A = cast<ConstantArrayType>(Ty);
const llvm::Type *EltTy = ConvertType(A.getElementType());
return llvm::ArrayType::get(EltTy, A.getSize().getZExtValue());
}
case Type::OCUVector:
case Type::Vector: {
const VectorType &VT = cast<VectorType>(Ty);
return llvm::VectorType::get(ConvertType(VT.getElementType()),
VT.getNumElements());
}
case Type::FunctionNoProto:
case Type::FunctionProto: {
const FunctionType &FP = cast<FunctionType>(Ty);
const llvm::Type *ResultType;
if (FP.getResultType()->isVoidType())
ResultType = llvm::Type::VoidTy; // Result of function uses llvm void.
else
ResultType = ConvertType(FP.getResultType());
// FIXME: Convert argument types.
bool isVarArg;
std::vector<const llvm::Type*> ArgTys;
// Struct return passes the struct byref.
if (!ResultType->isFirstClassType() && ResultType != llvm::Type::VoidTy) {
ArgTys.push_back(llvm::PointerType::get(ResultType));
ResultType = llvm::Type::VoidTy;
}
if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(&FP)) {
DecodeArgumentTypes(*FTP, ArgTys);
isVarArg = FTP->isVariadic();
} else {
isVarArg = true;
}
return llvm::FunctionType::get(ResultType, ArgTys, isVarArg, 0);
}
case Type::Tagged:
const TagType &TT = cast<TagType>(Ty);
const TagDecl *TD = TT.getDecl();
llvm::Type *&ResultType = TagDeclTypes[TD];
if (ResultType)
return ResultType;
if (!TD->isDefinition()) {
ResultType = llvm::OpaqueType::get();
} else if (TD->getKind() == Decl::Enum) {
return ConvertType(cast<EnumDecl>(TD)->getIntegerType());
} else if (TD->getKind() == Decl::Struct) {
const RecordDecl *RD = cast<const RecordDecl>(TD);
std::vector<const llvm::Type*> Fields;
for (unsigned i = 0, e = RD->getNumMembers(); i != e; ++i)
Fields.push_back(ConvertType(RD->getMember(i)->getType()));
ResultType = llvm::StructType::get(Fields);
} else if (TD->getKind() == Decl::Union) {
const RecordDecl *RD = cast<const RecordDecl>(TD);
// Just use the largest element of the union, breaking ties with the
// highest aligned member.
std::vector<const llvm::Type*> Fields;
if (RD->getNumMembers() != 0) {
std::pair<uint64_t, unsigned> MaxElt =
Context.getTypeInfo(RD->getMember(0)->getType(), SourceLocation());
unsigned MaxEltNo = 0;
for (unsigned i = 1, e = RD->getNumMembers(); i != e; ++i) {
std::pair<uint64_t, unsigned> EltInfo =
Context.getTypeInfo(RD->getMember(i)->getType(), SourceLocation());
if (EltInfo.first > MaxElt.first ||
(EltInfo.first == MaxElt.first &&
EltInfo.second > MaxElt.second)) {
MaxElt = EltInfo;
MaxEltNo = i;
}
}
Fields.push_back(ConvertType(RD->getMember(MaxEltNo)->getType()));
}
ResultType = llvm::StructType::get(Fields);
} else {
assert(0 && "FIXME: Implement tag decl kind!");
}
std::string TypeName(TD->getKindName());
TypeName += '.';
TypeName += TD->getName();
TheModule.addTypeName(TypeName, ResultType);
return ResultType;
}
// FIXME: implement.
return llvm::OpaqueType::get();
}
void CodeGenTypes::DecodeArgumentTypes(const FunctionTypeProto &FTP,
std::vector<const llvm::Type*> &ArgTys) {
for (unsigned i = 0, e = FTP.getNumArgs(); i != e; ++i) {
const llvm::Type *Ty = ConvertType(FTP.getArgType(i));
if (Ty->isFirstClassType())
ArgTys.push_back(Ty);
else
ArgTys.push_back(llvm::PointerType::get(Ty));
}
}

View File

@@ -1,55 +0,0 @@
//===--- CodeGenTypes.h - Type translation for LLVM CodeGen -----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the code that handles AST -> LLVM type lowering.
//
//===----------------------------------------------------------------------===//
#ifndef CODEGEN_CODEGENTYPES_H
#define CODEGEN_CODEGENTYPES_H
#include "llvm/ADT/DenseMap.h"
#include <vector>
namespace llvm {
class Module;
class Type;
}
namespace clang {
class ASTContext;
class TagDecl;
class TargetInfo;
class QualType;
class FunctionTypeProto;
namespace CodeGen {
/// CodeGenTypes - This class organizes the cross-module state that is used
/// while lowering AST types to LLVM types.
class CodeGenTypes {
ASTContext &Context;
TargetInfo &Target;
llvm::Module& TheModule;
llvm::DenseMap<const TagDecl*, llvm::Type*> TagDeclTypes;
public:
CodeGenTypes(ASTContext &Ctx, llvm::Module &M);
TargetInfo &getTarget() const { return Target; }
const llvm::Type *ConvertType(QualType T);
void DecodeArgumentTypes(const FunctionTypeProto &FTP,
std::vector<const llvm::Type*> &ArgTys);
};
} // end namespace CodeGen
} // end namespace clang
#endif

View File

@@ -1,23 +0,0 @@
##===- clang/CodeGen/Makefile ------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Chris Lattner and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements the AST -> LLVM code generation library for the
# C-Language front-end.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LIBRARYNAME := clangCodeGen
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
include $(LEVEL)/Makefile.common

View File

@@ -1,45 +0,0 @@
//===--- ModuleBuilder.cpp - Emit LLVM Code from ASTs ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This builds an AST and converts it to LLVM Code.
//
//===----------------------------------------------------------------------===//
#include "clang/CodeGen/ModuleBuilder.h"
#include "CodeGenModule.h"
using namespace clang;
/// Init - Create an ModuleBuilder with the specified ASTContext.
clang::CodeGen::BuilderTy *
clang::CodeGen::Init(ASTContext &Context, llvm::Module &M) {
return new CodeGenModule(Context, M);
}
void clang::CodeGen::Terminate(BuilderTy *B) {
delete static_cast<CodeGenModule*>(B);
}
/// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
///
void clang::CodeGen::CodeGenFunction(BuilderTy *B, FunctionDecl *D) {
static_cast<CodeGenModule*>(B)->EmitFunction(D);
}
/// CodeGenGlobalVar - Emit the specified global variable to LLVM.
void clang::CodeGen::CodeGenGlobalVar(BuilderTy *Builder, FileVarDecl *D) {
static_cast<CodeGenModule*>(Builder)->EmitGlobalVarDeclarator(D);
}
/// PrintStats - Emit statistic information to stderr.
///
void clang::CodeGen::PrintStats(BuilderTy *B) {
static_cast<CodeGenModule*>(B)->PrintStats();
}

View File

@@ -1,282 +0,0 @@
//===--- ASTStreamers.cpp - ASTStreamer Drivers ---------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// ASTStreamer drivers.
//
//===----------------------------------------------------------------------===//
#include "ASTStreamers.h"
#include "clang/AST/AST.h"
#include "clang/AST/CFG.h"
#include "clang/Analysis/LiveVariables.h"
#include "clang/Analysis/LocalCheckers.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/ASTStreamer.h"
using namespace clang;
void clang::BuildASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) {
// collect global stats on Decls/Stmts (until we have a module streamer)
if (Stats) {
Decl::CollectingStats(true);
Stmt::CollectingStats(true);
}
ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(),
PP.getIdentifierTable());
ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
while (ASTStreamer_ReadTopLevelDecl(Streamer))
/* keep reading */;
if (Stats) {
fprintf(stderr, "\nSTATISTICS:\n");
ASTStreamer_PrintStats(Streamer);
Context.PrintStats();
Decl::PrintStats();
Stmt::PrintStats();
}
ASTStreamer_Terminate(Streamer);
}
static void PrintFunctionDeclStart(FunctionDecl *FD) {
bool HasBody = FD->getBody();
fprintf(stderr, "\n");
switch (FD->getStorageClass()) {
default: assert(0 && "Unknown storage class");
case FunctionDecl::None: break;
case FunctionDecl::Extern: fprintf(stderr, "extern "); break;
case FunctionDecl::Static: fprintf(stderr, "static "); break;
}
if (FD->isInline())
fprintf(stderr, "inline ");
std::string Proto = FD->getName();
FunctionType *AFT = cast<FunctionType>(FD->getType());
if (FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(AFT)) {
Proto += "(";
for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
if (i) Proto += ", ";
std::string ParamStr;
if (HasBody) ParamStr = FD->getParamDecl(i)->getName();
FT->getArgType(i).getAsStringInternal(ParamStr);
Proto += ParamStr;
}
if (FT->isVariadic()) {
if (FD->getNumParams()) Proto += ", ";
Proto += "...";
}
Proto += ")";
} else {
assert(isa<FunctionTypeNoProto>(AFT));
Proto += "()";
}
AFT->getResultType().getAsStringInternal(Proto);
fprintf(stderr, "%s", Proto.c_str());
if (!FD->getBody())
fprintf(stderr, ";\n");
// Doesn't print the body.
}
static void PrintTypeDefDecl(TypedefDecl *TD) {
std::string S = TD->getName();
TD->getUnderlyingType().getAsStringInternal(S);
fprintf(stderr, "typedef %s;\n", S.c_str());
}
static void PrintObjcInterfaceDecl(ObjcInterfaceDecl *OID) {
std::string S = OID->getName();
fprintf(stderr, "@interface %s;\n", S.c_str());
// FIXME: implement the rest...
}
void clang::PrintASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) {
ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(),
PP.getIdentifierTable());
ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
PrintFunctionDeclStart(FD);
if (FD->getBody()) {
fprintf(stderr, " ");
FD->getBody()->dumpPretty();
fprintf(stderr, "\n");
}
} else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
PrintTypeDefDecl(TD);
} else if (ObjcInterfaceDecl *OID = dyn_cast<ObjcInterfaceDecl>(D)) {
PrintObjcInterfaceDecl(OID);
} else {
fprintf(stderr, "Read top-level variable decl: '%s'\n", D->getName());
}
}
if (Stats) {
fprintf(stderr, "\nSTATISTICS:\n");
ASTStreamer_PrintStats(Streamer);
Context.PrintStats();
}
ASTStreamer_Terminate(Streamer);
}
void clang::DumpASTs(Preprocessor &PP, unsigned MainFileID, bool Stats) {
ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(),
PP.getIdentifierTable());
ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
PrintFunctionDeclStart(FD);
if (FD->getBody()) {
fprintf(stderr, "\n");
FD->getBody()->dumpAll(PP.getSourceManager());
fprintf(stderr, "\n");
}
} else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
PrintTypeDefDecl(TD);
} else {
fprintf(stderr, "Read top-level variable decl: '%s'\n", D->getName());
}
}
if (Stats) {
fprintf(stderr, "\nSTATISTICS:\n");
ASTStreamer_PrintStats(Streamer);
Context.PrintStats();
}
ASTStreamer_Terminate(Streamer);
}
//===----------------------------------------------------------------------===//
// CFGVisitor & VisitCFGs - Boilerplate interface and logic to visit
// the CFGs for all function definitions.
namespace {
class CFGVisitor {
public:
virtual ~CFGVisitor() {}
virtual void VisitCFG(CFG& C) = 0;
virtual bool printFuncDeclStart() { return true; }
};
} // end anonymous namespace
static void VisitCFGs(CFGVisitor& Visitor, Preprocessor& PP,
unsigned MainFileID, bool Stats) {
bool printFDecl = Visitor.printFuncDeclStart();
ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(),
PP.getIdentifierTable());
ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
if (FD->getBody()) {
if (printFDecl) {
PrintFunctionDeclStart(FD);
fprintf(stderr,"\n");
}
if (CFG* C = CFG::buildCFG(FD->getBody())) {
Visitor.VisitCFG(*C);
delete C;
}
else
fprintf(stderr," Error processing CFG.\n");
}
}
if (Stats) {
fprintf(stderr, "\nSTATISTICS:\n");
ASTStreamer_PrintStats(Streamer);
Context.PrintStats();
}
ASTStreamer_Terminate(Streamer);
}
//===----------------------------------------------------------------------===//
// DumpCFGs - Dump CFGs to stderr or visualize with Graphviz
namespace {
class CFGDumper : public CFGVisitor {
const bool UseGraphviz;
public:
CFGDumper(bool use_graphviz) : UseGraphviz(use_graphviz) {}
virtual void VisitCFG(CFG& C) {
if (UseGraphviz) C.viewCFG();
else C.dump();
}
};
} // end anonymous namespace
void clang::DumpCFGs(Preprocessor &PP, unsigned MainFileID,
bool Stats, bool use_graphviz) {
CFGDumper Visitor(use_graphviz);
VisitCFGs(Visitor,PP,MainFileID,Stats);
}
//===----------------------------------------------------------------------===//
// AnalyzeLiveVariables - perform live variable analysis and dump results
namespace {
class LivenessVisitor : public CFGVisitor {
Preprocessor& PP;
public:
LivenessVisitor(Preprocessor& pp) : PP(pp) {}
virtual void VisitCFG(CFG& C) {
LiveVariables L;
L.runOnCFG(C);
L.dumpBlockLiveness(PP.getSourceManager());
L.dumpVarLiveness(PP.getSourceManager());
}
};
} // end anonymous namespace
void clang::AnalyzeLiveVariables(Preprocessor &PP, unsigned MainFileID) {
LivenessVisitor Visitor(PP);
VisitCFGs(Visitor,PP,MainFileID,false);
}
//===----------------------------------------------------------------------===//
// RunDeadStores - run checker to locate dead stores in a function
namespace {
class DeadStoreVisitor : public CFGVisitor {
Preprocessor& PP;
public:
DeadStoreVisitor(Preprocessor& pp) : PP(pp) {}
virtual void VisitCFG(CFG& C) { CheckDeadStores(C,PP); }
virtual bool printFuncDeclStart() { return false; }
};
} // end anonymous namespace
void clang::RunDeadStoresCheck(Preprocessor &PP,unsigned MainFileID,bool Stats){
DeadStoreVisitor Visitor(PP);
VisitCFGs(Visitor,PP,MainFileID,Stats);
}

View File

@@ -1,36 +0,0 @@
//===--- ASTStreamers.h - ASTStreamer Drivers -------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// AST Streamers.
//
//===----------------------------------------------------------------------===//
#ifndef DRIVER_ASTSTREAMERS_H_
#define DRIVER_ASTSTREAMERS_H_
namespace clang {
class Preprocessor;
class FunctionDecl;
class TypedefDecl;
void BuildASTs(Preprocessor &PP, unsigned MainFileID, bool Stats);
void PrintASTs(Preprocessor &PP, unsigned MainFileID, bool Stats);
void DumpASTs(Preprocessor &PP, unsigned MainFileID, bool Stats);
void DumpCFGs(Preprocessor &PP, unsigned MainFileID,
bool Stats, bool use_graphviz = false);
void AnalyzeLiveVariables(Preprocessor &PP, unsigned MainFileID);
void RunDeadStoresCheck(Preprocessor &PP, unsigned MainFileID, bool Stats);
} // end clang namespace
#endif

View File

@@ -1,237 +0,0 @@
//===--- DiagChecker.cpp - Diagnostic Checking Functions ------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Process the input files and check that the diagnostic messages are expected.
//
//===----------------------------------------------------------------------===//
#include "clang.h"
#include "ASTStreamers.h"
#include "TextDiagnosticBuffer.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Preprocessor.h"
using namespace clang;
typedef TextDiagnosticBuffer::DiagList DiagList;
typedef TextDiagnosticBuffer::const_iterator const_diag_iterator;
// USING THE DIAGNOSTIC CHECKER:
//
// Indicating that a line expects an error or a warning is simple. Put a comment
// on the line that has the diagnostic, use "expected-{error,warning}" to tag
// if it's an expected error or warning, and place the expected text between {{
// and }} markers. The full text doesn't have to be included, only enough to
// ensure that the correct diagnostic was emitted.
//
// Here's an example:
//
// int A = B; // expected-error {{use of undeclared identifier 'B'}}
//
// You can place as many diagnostics on one line as you wish. To make the code
// more readable, you can use slash-newline to separate out the diagnostics.
static const char * const ExpectedErrStr = "expected-error";
static const char * const ExpectedWarnStr = "expected-warning";
/// FindDiagnostics - Go through the comment and see if it indicates expected
/// diagnostics. If so, then put them in a diagnostic list.
///
static void FindDiagnostics(const std::string &Comment,
DiagList &ExpectedDiags,
SourceManager &SourceMgr,
SourceLocation Pos,
const char * const ExpectedStr) {
// Find all expected diagnostics
typedef std::string::size_type size_type;
size_type ColNo = std::string::npos;
for (;;) {
ColNo = Comment.find(ExpectedStr, ColNo);
if (ColNo == std::string::npos) break;
size_type OpenDiag = Comment.find_first_of("{{", ColNo);
if (OpenDiag == std::string::npos) {
fprintf(stderr,
"oops:%d: Cannot find beginning of expected error string\n",
SourceMgr.getLogicalLineNumber(Pos));
break;
}
OpenDiag += 2;
size_type CloseDiag = Comment.find_first_of("}}", OpenDiag);
if (CloseDiag == std::string::npos) {
fprintf(stderr,
"oops:%d: Cannot find end of expected error string\n",
SourceMgr.getLogicalLineNumber(Pos));
break;
}
std::string Msg(Comment.substr(OpenDiag, CloseDiag - OpenDiag));
ExpectedDiags.push_back(std::make_pair(Pos, Msg));
ColNo = CloseDiag + 2;
}
}
/// FindExpectedDiags - Lex the file to finds all of the expected errors and
/// warnings.
static void FindExpectedDiags(Preprocessor &PP, unsigned MainFileID,
DiagList &ExpectedErrors,
DiagList &ExpectedWarnings) {
// Return comments as tokens, this is how we find expected diagnostics.
PP.SetCommentRetentionState(true, true);
// Enter the cave.
PP.EnterSourceFile(MainFileID, 0, true);
// Turn off all warnings from relexing or preprocessing.
PP.getDiagnostics().setWarnOnExtensions(false);
PP.getDiagnostics().setErrorOnExtensions(false);
for (unsigned i = 0; i != diag::NUM_DIAGNOSTICS; ++i)
if (PP.getDiagnostics().isNoteWarningOrExtension((diag::kind)i))
PP.getDiagnostics().setDiagnosticMapping((diag::kind)i, diag::MAP_IGNORE);
Token Tok;
do {
PP.Lex(Tok);
if (Tok.getKind() == tok::comment) {
std::string Comment = PP.getSpelling(Tok);
// Find all expected errors
FindDiagnostics(Comment, ExpectedErrors,PP.getSourceManager(),
Tok.getLocation(), ExpectedErrStr);
// Find all expected warnings
FindDiagnostics(Comment, ExpectedWarnings, PP.getSourceManager(),
Tok.getLocation(), ExpectedWarnStr);
}
} while (Tok.getKind() != tok::eof);
PP.SetCommentRetentionState(false, false);
}
/// PrintProblem - This takes a diagnostic map of the delta between expected and
/// seen diagnostics. If there's anything in it, then something unexpected
/// happened. Print the map out in a nice format and return "true". If the map
/// is empty and we're not going to print things, then return "false".
///
static bool PrintProblem(SourceManager &SourceMgr,
const_diag_iterator diag_begin,
const_diag_iterator diag_end,
const char *Msg) {
if (diag_begin == diag_end) return false;
fprintf(stderr, "%s\n", Msg);
for (const_diag_iterator I = diag_begin, E = diag_end; I != E; ++I)
fprintf(stderr, " Line %d: %s\n",
SourceMgr.getLogicalLineNumber(I->first),
I->second.c_str());
return true;
}
/// CompareDiagLists - Compare two diangnostic lists and return the difference
/// between them.
///
static bool CompareDiagLists(SourceManager &SourceMgr,
const_diag_iterator d1_begin,
const_diag_iterator d1_end,
const_diag_iterator d2_begin,
const_diag_iterator d2_end,
const char *Msg) {
DiagList DiffList;
for (const_diag_iterator I = d1_begin, E = d1_end; I != E; ++I) {
unsigned LineNo1 = SourceMgr.getLogicalLineNumber(I->first);
const std::string &Diag1 = I->second;
bool Found = false;
for (const_diag_iterator II = d2_begin, IE = d2_end; II != IE; ++II) {
unsigned LineNo2 = SourceMgr.getLogicalLineNumber(II->first);
if (LineNo1 != LineNo2) continue;
const std::string &Diag2 = II->second;
if (Diag2.find(Diag1) != std::string::npos ||
Diag1.find(Diag2) != std::string::npos) {
Found = true;
break;
}
}
if (!Found)
DiffList.push_back(std::make_pair(I->first, Diag1));
}
return PrintProblem(SourceMgr, DiffList.begin(), DiffList.end(), Msg);
}
/// CheckResults - This compares the expected results to those that
/// were actually reported. It emits any discrepencies. Return "true" if there
/// were problems. Return "false" otherwise.
///
static bool CheckResults(Preprocessor &PP,
const DiagList &ExpectedErrors,
const DiagList &ExpectedWarnings) {
const TextDiagnosticBuffer &Diags =
static_cast<const TextDiagnosticBuffer&>(PP.getDiagnostics().getClient());
SourceManager &SourceMgr = PP.getSourceManager();
// We want to capture the delta between what was expected and what was
// seen.
//
// Expected \ Seen - set expected but not seen
// Seen \ Expected - set seen but not expected
bool HadProblem = false;
// See if there were errors that were expected but not seen.
HadProblem |= CompareDiagLists(SourceMgr,
ExpectedErrors.begin(), ExpectedErrors.end(),
Diags.err_begin(), Diags.err_end(),
"Errors expected but not seen:");
// See if there were errors that were seen but not expected.
HadProblem |= CompareDiagLists(SourceMgr,
Diags.err_begin(), Diags.err_end(),
ExpectedErrors.begin(), ExpectedErrors.end(),
"Errors seen but not expected:");
// See if there were warnings that were expected but not seen.
HadProblem |= CompareDiagLists(SourceMgr,
ExpectedWarnings.begin(),
ExpectedWarnings.end(),
Diags.warn_begin(), Diags.warn_end(),
"Warnings expected but not seen:");
// See if there were warnings that were seen but not expected.
HadProblem |= CompareDiagLists(SourceMgr,
Diags.warn_begin(), Diags.warn_end(),
ExpectedWarnings.begin(),
ExpectedWarnings.end(),
"Warnings seen but not expected:");
return HadProblem;
}
/// CheckDiagnostics - Implement the -parse-ast-check diagnostic verifier.
bool clang::CheckDiagnostics(Preprocessor &PP, unsigned MainFileID) {
// Parse the specified input file.
BuildASTs(PP, MainFileID, false);
// Gather the set of expected diagnostics.
DiagList ExpectedErrors, ExpectedWarnings;
FindExpectedDiags(PP, MainFileID, ExpectedErrors, ExpectedWarnings);
// Check that the expected diagnostics occurred.
return CheckResults(PP, ExpectedErrors, ExpectedWarnings);
}

View File

@@ -1,71 +0,0 @@
//===--- LLVMCodegen.cpp - Emit LLVM Code from ASTs -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This builds an AST and converts it to LLVM Code.
//
//===----------------------------------------------------------------------===//
#include "clang.h"
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/Sema/ASTStreamer.h"
#include "clang/AST/AST.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "llvm/Module.h"
#include <iostream>
using namespace clang;
//===----------------------------------------------------------------------===//
// LLVM Emission
//===----------------------------------------------------------------------===//
void clang::EmitLLVMFromASTs(Preprocessor &PP, unsigned MainFileID,
bool PrintStats) {
Diagnostic &Diags = PP.getDiagnostics();
// Create the streamer to read the file.
ASTContext Context(PP.getSourceManager(), PP.getTargetInfo(),
PP.getIdentifierTable());
ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
// Create the module to codegen into.
llvm::Module M("foo");
CodeGen::BuilderTy *Builder = CodeGen::Init(Context, M);
while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
// If an error occurred, stop code generation, but continue parsing and
// semantic analysis (to ensure all warnings and errors are emitted).
if (Diags.hasErrorOccurred())
continue;
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
CodeGen::CodeGenFunction(Builder, FD);
} else if (FileVarDecl *FVD = dyn_cast<FileVarDecl>(D)) {
CodeGen::CodeGenGlobalVar(Builder, FVD);
} else {
assert(isa<TypedefDecl>(D) && "Only expected typedefs here");
// don't codegen for now, eventually pass down for debug info.
//std::cerr << "Read top-level typedef decl: '" << D->getName() << "'\n";
}
}
if (PrintStats) {
std::cerr << "\nSTATISTICS:\n";
CodeGen::PrintStats(Builder);
ASTStreamer_PrintStats(Streamer);
Context.PrintStats();
}
CodeGen::Terminate(Builder);
ASTStreamer_Terminate(Streamer);
// Print the generated code.
M.print(std::cout);
}

View File

@@ -1,8 +0,0 @@
LEVEL = ../../..
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
CXXFLAGS = -fno-rtti
TOOLNAME = clang
USEDLIBS = clangCodeGen.a clangAnalysis.a clangSEMA.a clangAST.a clangParse.a clangLex.a clangBasic.a LLVMCore.a LLVMSupport.a LLVMSystem.a
include $(LEVEL)/Makefile.common

View File

@@ -1,24 +0,0 @@
//===--- PPCBuiltins.def - PowerPC Builtin function database ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the PowerPC-specific builtin function database. Users of
// this file must define the BUILTIN macro to make use of this information.
//
//===----------------------------------------------------------------------===//
// FIXME: this needs to be the full list supported by GCC. Right now, I'm just
// adding stuff on demand.
// The format of this database matches clang/AST/Builtins.def.
// This is just a placeholder, the types and attributes are wrong.
BUILTIN(__builtin_altivec_abs_v4sf , "ii" , "nc")
// FIXME: Obviously incomplete.
#undef BUILTIN

View File

@@ -1,55 +0,0 @@
//===--- PrintParserActions.cpp - Implement -parse-print-callbacks mode ---===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This code simply runs the preprocessor on the input file and prints out the
// result. This is the traditional behavior of the -E option.
//
//===----------------------------------------------------------------------===//
#include "clang.h"
#include "clang/Lex/IdentifierTable.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/DeclSpec.h"
#include <iostream>
using namespace clang;
namespace {
class ParserPrintActions : public MinimalAction {
/// ParseDeclarator - This callback is invoked when a declarator is parsed
/// and 'Init' specifies the initializer if any. This is for things like:
/// "int X = 4" or "typedef int foo".
virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D,
DeclTy *LastInGroup) {
std::cout << "ParseDeclarator ";
if (IdentifierInfo *II = D.getIdentifier()) {
std::cout << "'" << II->getName() << "'";
} else {
std::cout << "<anon>";
}
std::cout << "\n";
// Pass up to EmptyActions so that the symbol table is maintained right.
return MinimalAction::ParseDeclarator(S, D, LastInGroup);
}
/// PopScope - This callback is called immediately before the specified scope
/// is popped and deleted.
virtual void PopScope(SourceLocation Loc, Scope *S) {
std::cout << "PopScope\n";
// Pass up to EmptyActions so that the symbol table is maintained right.
MinimalAction::PopScope(Loc, S);
}
};
}
MinimalAction *clang::CreatePrintParserActionsAction() {
return new ParserPrintActions();
}

View File

@@ -1,574 +0,0 @@
//===--- PrintPreprocessedOutput.cpp - Implement the -E mode --------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This code simply runs the preprocessor on the input file and prints out the
// result. This is the traditional behavior of the -E option.
//
//===----------------------------------------------------------------------===//
#include "clang.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/Pragma.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/config.h"
#include <cstdio>
using namespace clang;
//===----------------------------------------------------------------------===//
// Simple buffered I/O
//===----------------------------------------------------------------------===//
//
// Empirically, iostream is over 30% slower than stdio for this workload, and
// stdio itself isn't very well suited. The problem with stdio is use of
// putchar_unlocked. We have many newline characters that need to be emitted,
// but stdio needs to do extra checks to handle line buffering mode. These
// extra checks make putchar_unlocked fall off its inlined code path, hitting
// slow system code. In practice, using 'write' directly makes 'clang -E -P'
// about 10% faster than using the stdio path on darwin.
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#else
#define USE_STDIO 1
#endif
static char *OutBufStart = 0, *OutBufEnd, *OutBufCur;
/// InitOutputBuffer - Initialize our output buffer.
///
static void InitOutputBuffer() {
#ifndef USE_STDIO
OutBufStart = new char[64*1024];
OutBufEnd = OutBufStart+64*1024;
OutBufCur = OutBufStart;
#endif
}
/// FlushBuffer - Write the accumulated bytes to the output stream.
///
static void FlushBuffer() {
#ifndef USE_STDIO
write(STDOUT_FILENO, OutBufStart, OutBufCur-OutBufStart);
OutBufCur = OutBufStart;
#endif
}
/// CleanupOutputBuffer - Finish up output.
///
static void CleanupOutputBuffer() {
#ifndef USE_STDIO
FlushBuffer();
delete [] OutBufStart;
#endif
}
static void OutputChar(char c) {
#if defined(_MSC_VER)
putchar(c);
#elif defined(USE_STDIO)
putchar_unlocked(c);
#else
if (OutBufCur >= OutBufEnd)
FlushBuffer();
*OutBufCur++ = c;
#endif
}
static void OutputString(const char *Ptr, unsigned Size) {
#ifdef USE_STDIO
fwrite(Ptr, Size, 1, stdout);
#else
if (OutBufCur+Size >= OutBufEnd)
FlushBuffer();
switch (Size) {
default:
memcpy(OutBufCur, Ptr, Size);
break;
case 3:
OutBufCur[2] = Ptr[2];
case 2:
OutBufCur[1] = Ptr[1];
case 1:
OutBufCur[0] = Ptr[0];
case 0:
break;
}
OutBufCur += Size;
#endif
}
//===----------------------------------------------------------------------===//
// Preprocessed token printer
//===----------------------------------------------------------------------===//
static llvm::cl::opt<bool>
DisableLineMarkers("P", llvm::cl::desc("Disable linemarker output in -E mode"));
static llvm::cl::opt<bool>
EnableCommentOutput("C", llvm::cl::desc("Enable comment output in -E mode"));
static llvm::cl::opt<bool>
EnableMacroCommentOutput("CC",
llvm::cl::desc("Enable comment output in -E mode, "
"even from macro expansions"));
namespace {
class PrintPPOutputPPCallbacks : public PPCallbacks {
Preprocessor &PP;
unsigned CurLine;
bool EmittedTokensOnThisLine;
DirectoryLookup::DirType FileType;
llvm::SmallString<512> CurFilename;
public:
PrintPPOutputPPCallbacks(Preprocessor &pp) : PP(pp) {
CurLine = 0;
CurFilename += "<uninit>";
EmittedTokensOnThisLine = false;
FileType = DirectoryLookup::NormalHeaderDir;
}
void SetEmittedTokensOnThisLine() { EmittedTokensOnThisLine = true; }
bool hasEmittedTokensOnThisLine() const { return EmittedTokensOnThisLine; }
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
DirectoryLookup::DirType FileType);
virtual void Ident(SourceLocation Loc, const std::string &str);
void HandleFirstTokOnLine(Token &Tok);
void MoveToLine(SourceLocation Loc);
bool AvoidConcat(const Token &PrevTok, const Token &Tok);
};
}
/// UToStr - Do itoa on the specified number, in-place in the specified buffer.
/// endptr points to the end of the buffer.
static char *UToStr(unsigned N, char *EndPtr) {
// Null terminate the buffer.
*--EndPtr = '\0';
if (N == 0) // Zero is a special case.
*--EndPtr = '0';
while (N) {
*--EndPtr = '0' + char(N % 10);
N /= 10;
}
return EndPtr;
}
/// MoveToLine - Move the output to the source line specified by the location
/// object. We can do this by emitting some number of \n's, or be emitting a
/// #line directive.
void PrintPPOutputPPCallbacks::MoveToLine(SourceLocation Loc) {
if (DisableLineMarkers) {
if (EmittedTokensOnThisLine) {
OutputChar('\n');
EmittedTokensOnThisLine = false;
}
return;
}
unsigned LineNo = PP.getSourceManager().getLogicalLineNumber(Loc);
// If this line is "close enough" to the original line, just print newlines,
// otherwise print a #line directive.
if (LineNo-CurLine < 8) {
if (LineNo-CurLine == 1)
OutputChar('\n');
else {
const char *NewLines = "\n\n\n\n\n\n\n\n";
OutputString(NewLines, LineNo-CurLine);
CurLine = LineNo;
}
} else {
if (EmittedTokensOnThisLine) {
OutputChar('\n');
EmittedTokensOnThisLine = false;
}
CurLine = LineNo;
OutputChar('#');
OutputChar(' ');
char NumberBuffer[20];
const char *NumStr = UToStr(LineNo, NumberBuffer+20);
OutputString(NumStr, (NumberBuffer+20)-NumStr-1);
OutputChar(' ');
OutputChar('"');
OutputString(&CurFilename[0], CurFilename.size());
OutputChar('"');
if (FileType == DirectoryLookup::SystemHeaderDir)
OutputString(" 3", 2);
else if (FileType == DirectoryLookup::ExternCSystemHeaderDir)
OutputString(" 3 4", 4);
OutputChar('\n');
}
}
/// FileChanged - Whenever the preprocessor enters or exits a #include file
/// it invokes this handler. Update our conception of the current source
/// position.
void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
FileChangeReason Reason,
DirectoryLookup::DirType FileType) {
if (DisableLineMarkers) return;
// Unless we are exiting a #include, make sure to skip ahead to the line the
// #include directive was at.
SourceManager &SourceMgr = PP.getSourceManager();
if (Reason == PPCallbacks::EnterFile) {
MoveToLine(SourceMgr.getIncludeLoc(Loc));
} else if (Reason == PPCallbacks::SystemHeaderPragma) {
MoveToLine(Loc);
// TODO GCC emits the # directive for this directive on the line AFTER the
// directive and emits a bunch of spaces that aren't needed. Emulate this
// strange behavior.
}
Loc = SourceMgr.getLogicalLoc(Loc);
CurLine = SourceMgr.getLineNumber(Loc);
CurFilename.clear();
CurFilename += SourceMgr.getSourceName(Loc);
Lexer::Stringify(CurFilename);
FileType = FileType;
if (EmittedTokensOnThisLine) {
OutputChar('\n');
EmittedTokensOnThisLine = false;
}
OutputChar('#');
OutputChar(' ');
char NumberBuffer[20];
const char *NumStr = UToStr(CurLine, NumberBuffer+20);
OutputString(NumStr, (NumberBuffer+20)-NumStr-1);
OutputChar(' ');
OutputChar('"');
OutputString(&CurFilename[0], CurFilename.size());
OutputChar('"');
switch (Reason) {
case PPCallbacks::EnterFile:
OutputString(" 1", 2);
break;
case PPCallbacks::ExitFile:
OutputString(" 2", 2);
break;
case PPCallbacks::SystemHeaderPragma: break;
case PPCallbacks::RenameFile: break;
}
if (FileType == DirectoryLookup::SystemHeaderDir)
OutputString(" 3", 2);
else if (FileType == DirectoryLookup::ExternCSystemHeaderDir)
OutputString(" 3 4", 4);
OutputChar('\n');
}
/// HandleIdent - Handle #ident directives when read by the preprocessor.
///
void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, const std::string &S) {
MoveToLine(Loc);
OutputString("#ident ", strlen("#ident "));
OutputString(&S[0], S.size());
EmittedTokensOnThisLine = true;
}
/// HandleFirstTokOnLine - When emitting a preprocessed file in -E mode, this
/// is called for the first token on each new line.
void PrintPPOutputPPCallbacks::HandleFirstTokOnLine(Token &Tok) {
// Figure out what line we went to and insert the appropriate number of
// newline characters.
MoveToLine(Tok.getLocation());
// Print out space characters so that the first token on a line is
// indented for easy reading.
const SourceManager &SourceMgr = PP.getSourceManager();
unsigned ColNo = SourceMgr.getLogicalColumnNumber(Tok.getLocation());
// This hack prevents stuff like:
// #define HASH #
// HASH define foo bar
// From having the # character end up at column 1, which makes it so it
// is not handled as a #define next time through the preprocessor if in
// -fpreprocessed mode.
if (ColNo <= 1 && Tok.getKind() == tok::hash)
OutputChar(' ');
// Otherwise, indent the appropriate number of spaces.
for (; ColNo > 1; --ColNo)
OutputChar(' ');
}
namespace {
struct UnknownPragmaHandler : public PragmaHandler {
const char *Prefix;
PrintPPOutputPPCallbacks *Callbacks;
UnknownPragmaHandler(const char *prefix, PrintPPOutputPPCallbacks *callbacks)
: PragmaHandler(0), Prefix(prefix), Callbacks(callbacks) {}
virtual void HandlePragma(Preprocessor &PP, Token &PragmaTok) {
// Figure out what line we went to and insert the appropriate number of
// newline characters.
Callbacks->MoveToLine(PragmaTok.getLocation());
OutputString(Prefix, strlen(Prefix));
// Read and print all of the pragma tokens.
while (PragmaTok.getKind() != tok::eom) {
if (PragmaTok.hasLeadingSpace())
OutputChar(' ');
std::string TokSpell = PP.getSpelling(PragmaTok);
OutputString(&TokSpell[0], TokSpell.size());
PP.LexUnexpandedToken(PragmaTok);
}
OutputChar('\n');
}
};
} // end anonymous namespace
enum AvoidConcatInfo {
/// By default, a token never needs to avoid concatenation. Most tokens (e.g.
/// ',', ')', etc) don't cause a problem when concatenated.
aci_never_avoid_concat = 0,
/// aci_custom_firstchar - AvoidConcat contains custom code to handle this
/// token's requirements, and it needs to know the first character of the
/// token.
aci_custom_firstchar = 1,
/// aci_custom - AvoidConcat contains custom code to handle this token's
/// requirements, but it doesn't need to know the first character of the
/// token.
aci_custom = 2,
/// aci_avoid_equal - Many tokens cannot be safely followed by an '='
/// character. For example, "<<" turns into "<<=" when followed by an =.
aci_avoid_equal = 4
};
/// This array contains information for each token on what action to take when
/// avoiding concatenation of tokens in the AvoidConcat method.
static char TokenInfo[tok::NUM_TOKENS];
/// InitAvoidConcatTokenInfo - Tokens that must avoid concatenation should be
/// marked by this function.
static void InitAvoidConcatTokenInfo() {
// These tokens have custom code in AvoidConcat.
TokenInfo[tok::identifier ] |= aci_custom;
TokenInfo[tok::numeric_constant] |= aci_custom_firstchar;
TokenInfo[tok::period ] |= aci_custom_firstchar;
TokenInfo[tok::amp ] |= aci_custom_firstchar;
TokenInfo[tok::plus ] |= aci_custom_firstchar;
TokenInfo[tok::minus ] |= aci_custom_firstchar;
TokenInfo[tok::slash ] |= aci_custom_firstchar;
TokenInfo[tok::less ] |= aci_custom_firstchar;
TokenInfo[tok::greater ] |= aci_custom_firstchar;
TokenInfo[tok::pipe ] |= aci_custom_firstchar;
TokenInfo[tok::percent ] |= aci_custom_firstchar;
TokenInfo[tok::colon ] |= aci_custom_firstchar;
TokenInfo[tok::hash ] |= aci_custom_firstchar;
TokenInfo[tok::arrow ] |= aci_custom_firstchar;
// These tokens change behavior if followed by an '='.
TokenInfo[tok::amp ] |= aci_avoid_equal; // &=
TokenInfo[tok::plus ] |= aci_avoid_equal; // +=
TokenInfo[tok::minus ] |= aci_avoid_equal; // -=
TokenInfo[tok::slash ] |= aci_avoid_equal; // /=
TokenInfo[tok::less ] |= aci_avoid_equal; // <=
TokenInfo[tok::greater ] |= aci_avoid_equal; // >=
TokenInfo[tok::pipe ] |= aci_avoid_equal; // |=
TokenInfo[tok::percent ] |= aci_avoid_equal; // %=
TokenInfo[tok::star ] |= aci_avoid_equal; // *=
TokenInfo[tok::exclaim ] |= aci_avoid_equal; // !=
TokenInfo[tok::lessless ] |= aci_avoid_equal; // <<=
TokenInfo[tok::greaterequal] |= aci_avoid_equal; // >>=
TokenInfo[tok::caret ] |= aci_avoid_equal; // ^=
TokenInfo[tok::equal ] |= aci_avoid_equal; // ==
}
/// AvoidConcat - If printing PrevTok immediately followed by Tok would cause
/// the two individual tokens to be lexed as a single token, return true (which
/// causes a space to be printed between them). This allows the output of -E
/// mode to be lexed to the same token stream as lexing the input directly
/// would.
///
/// This code must conservatively return true if it doesn't want to be 100%
/// accurate. This will cause the output to include extra space characters, but
/// the resulting output won't have incorrect concatenations going on. Examples
/// include "..", which we print with a space between, because we don't want to
/// track enough to tell "x.." from "...".
bool PrintPPOutputPPCallbacks::AvoidConcat(const Token &PrevTok,
const Token &Tok) {
char Buffer[256];
tok::TokenKind PrevKind = PrevTok.getKind();
if (PrevTok.getIdentifierInfo()) // Language keyword or named operator.
PrevKind = tok::identifier;
// Look up information on when we should avoid concatenation with prevtok.
unsigned ConcatInfo = TokenInfo[PrevKind];
// If prevtok never causes a problem for anything after it, return quickly.
if (ConcatInfo == 0) return false;
if (ConcatInfo & aci_avoid_equal) {
// If the next token is '=' or '==', avoid concatenation.
if (Tok.getKind() == tok::equal ||
Tok.getKind() == tok::equalequal)
return true;
ConcatInfo &= ~aci_avoid_equal;
}
if (ConcatInfo == 0) return false;
// Basic algorithm: we look at the first character of the second token, and
// determine whether it, if appended to the first token, would form (or would
// contribute) to a larger token if concatenated.
char FirstChar = 0;
if (ConcatInfo & aci_custom) {
// If the token does not need to know the first character, don't get it.
} else if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
// Avoid spelling identifiers, the most common form of token.
FirstChar = II->getName()[0];
} else if (!Tok.needsCleaning()) {
SourceManager &SrcMgr = PP.getSourceManager();
FirstChar =
*SrcMgr.getCharacterData(SrcMgr.getPhysicalLoc(Tok.getLocation()));
} else if (Tok.getLength() < 256) {
const char *TokPtr = Buffer;
PP.getSpelling(Tok, TokPtr);
FirstChar = TokPtr[0];
} else {
FirstChar = PP.getSpelling(Tok)[0];
}
switch (PrevKind) {
default: assert(0 && "InitAvoidConcatTokenInfo built wrong");
case tok::identifier: // id+id or id+number or id+L"foo".
if (Tok.getKind() == tok::numeric_constant || Tok.getIdentifierInfo() ||
Tok.getKind() == tok::wide_string_literal /* ||
Tok.getKind() == tok::wide_char_literal*/)
return true;
if (Tok.getKind() != tok::char_constant)
return false;
// FIXME: need a wide_char_constant!
if (!Tok.needsCleaning()) {
SourceManager &SrcMgr = PP.getSourceManager();
return *SrcMgr.getCharacterData(SrcMgr.getPhysicalLoc(Tok.getLocation()))
== 'L';
} else if (Tok.getLength() < 256) {
const char *TokPtr = Buffer;
PP.getSpelling(Tok, TokPtr);
return TokPtr[0] == 'L';
} else {
return PP.getSpelling(Tok)[0] == 'L';
}
case tok::numeric_constant:
return isalnum(FirstChar) || Tok.getKind() == tok::numeric_constant ||
FirstChar == '+' || FirstChar == '-' || FirstChar == '.';
case tok::period: // ..., .*, .1234
return FirstChar == '.' || FirstChar == '*' || isdigit(FirstChar);
case tok::amp: // &&
return FirstChar == '&';
case tok::plus: // ++
return FirstChar == '+';
case tok::minus: // --, ->, ->*
return FirstChar == '-' || FirstChar == '>';
case tok::slash: //, /*, //
return FirstChar == '*' || FirstChar == '/';
case tok::less: // <<, <<=, <:, <%
return FirstChar == '<' || FirstChar == ':' || FirstChar == '%';
case tok::greater: // >>, >>=
return FirstChar == '>';
case tok::pipe: // ||
return FirstChar == '|';
case tok::percent: // %>, %:
return FirstChar == '>' || FirstChar == ':';
case tok::colon: // ::, :>
return FirstChar == ':' || FirstChar == '>';
case tok::hash: // ##, #@, %:%:
return FirstChar == '#' || FirstChar == '@' || FirstChar == '%';
case tok::arrow: // ->*
return FirstChar == '*';
}
}
/// DoPrintPreprocessedInput - This implements -E mode.
///
void clang::DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
const LangOptions &Options) {
// Inform the preprocessor whether we want it to retain comments or not, due
// to -C or -CC.
PP.SetCommentRetentionState(EnableCommentOutput, EnableMacroCommentOutput);
InitOutputBuffer();
InitAvoidConcatTokenInfo();
Token Tok, PrevTok;
char Buffer[256];
PrintPPOutputPPCallbacks *Callbacks = new PrintPPOutputPPCallbacks(PP);
PP.setPPCallbacks(Callbacks);
PP.AddPragmaHandler(0, new UnknownPragmaHandler("#pragma", Callbacks));
PP.AddPragmaHandler("GCC", new UnknownPragmaHandler("#pragma GCC",Callbacks));
// After we have configured the preprocessor, enter the main file.
// Start parsing the specified input file.
PP.EnterSourceFile(MainFileID, 0, true);
do {
PrevTok = Tok;
PP.Lex(Tok);
// If this token is at the start of a line, emit newlines if needed.
if (Tok.isAtStartOfLine()) {
Callbacks->HandleFirstTokOnLine(Tok);
} else if (Tok.hasLeadingSpace() ||
// If we haven't emitted a token on this line yet, PrevTok isn't
// useful to look at and no concatenation could happen anyway.
(Callbacks->hasEmittedTokensOnThisLine() &&
// Don't print "-" next to "-", it would form "--".
Callbacks->AvoidConcat(PrevTok, Tok))) {
OutputChar(' ');
}
if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
const char *Str = II->getName();
unsigned Len = Tok.needsCleaning() ? strlen(Str) : Tok.getLength();
OutputString(Str, Len);
} else if (Tok.getLength() < 256) {
const char *TokPtr = Buffer;
unsigned Len = PP.getSpelling(Tok, TokPtr);
OutputString(TokPtr, Len);
} else {
std::string S = PP.getSpelling(Tok);
OutputString(&S[0], S.size());
}
Callbacks->SetEmittedTokensOnThisLine();
} while (Tok.getKind() != tok::eof);
OutputChar('\n');
CleanupOutputBuffer();
}

View File

@@ -1,444 +0,0 @@
//===--- Targets.cpp - Implement -arch option and targets -----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the -arch command line option and creates a TargetInfo
// that represents them.
//
//===----------------------------------------------------------------------===//
#include "clang.h"
#include "clang/AST/Builtins.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/Support/CommandLine.h"
using namespace clang;
/// Note: a hard coded list of targets is clearly silly, these should be
/// dynamicly registered and loadable with "-load".
enum SupportedTargets {
target_ppc, target_ppc64,
target_i386, target_x86_64,
target_linux_i386
};
static llvm::cl::list<SupportedTargets>
Archs("arch", llvm::cl::desc("Architectures to compile for"),
llvm::cl::values(clEnumValN(target_ppc, "ppc", "32-bit Darwin PowerPC"),
clEnumValN(target_ppc64, "ppc64", "64-bit Darwin PowerPC"),
clEnumValN(target_i386, "i386", "32-bit Darwin X86"),
clEnumValN(target_x86_64, "x86_64","64-bit Darwin X86"),
clEnumValN(target_linux_i386,"linux", "Linux i386"),
clEnumValEnd));
//===----------------------------------------------------------------------===//
// Common code shared among targets.
//===----------------------------------------------------------------------===//
namespace {
class DarwinTargetInfo : public TargetInfoImpl {
public:
virtual void getTargetDefines(std::vector<std::string> &Defines) const {
Defines.push_back("__APPLE__=1");
Defines.push_back("__MACH__=1");
if (1) {// -fobjc-gc controls this.
Defines.push_back("__weak=");
Defines.push_back("__strong=");
} else {
Defines.push_back("__weak=__attribute__((objc_gc(weak)))");
Defines.push_back("__strong=__attribute__((objc_gc(strong)))");
Defines.push_back("__OBJC_GC__");
}
// darwin_constant_cfstrings controls this.
Defines.push_back("__CONSTANT_CFSTRINGS__=1");
if (0) // darwin_pascal_strings
Defines.push_back("__PASCAL_STRINGS__");
}
};
} // end anonymous namespace.
/// getPowerPCDefines - Return a set of the PowerPC-specific #defines that are
/// not tied to a specific subtarget.
static void getPowerPCDefines(std::vector<std::string> &Defines, bool is64Bit) {
// Target identification.
Defines.push_back("__ppc__");
Defines.push_back("_ARCH_PPC=1");
Defines.push_back("__POWERPC__=1");
if (is64Bit) {
Defines.push_back("_ARCH_PPC64");
Defines.push_back("_LP64");
Defines.push_back("__LP64__");
Defines.push_back("__ppc64__");
} else {
Defines.push_back("__ppc__=1");
}
// Target properties.
Defines.push_back("_BIG_ENDIAN=1");
Defines.push_back("__BIG_ENDIAN__=1");
if (is64Bit) {
Defines.push_back("__INTMAX_MAX__=9223372036854775807L");
Defines.push_back("__INTMAX_TYPE__=long int");
Defines.push_back("__LONG_MAX__=9223372036854775807L");
Defines.push_back("__PTRDIFF_TYPE__=long int");
Defines.push_back("__UINTMAX_TYPE__=long unsigned int");
} else {
Defines.push_back("__INTMAX_MAX__=9223372036854775807LL");
Defines.push_back("__INTMAX_TYPE__=long long int");
Defines.push_back("__LONG_MAX__=2147483647L");
Defines.push_back("__PTRDIFF_TYPE__=int");
Defines.push_back("__UINTMAX_TYPE__=long long unsigned int");
}
Defines.push_back("__INT_MAX__=2147483647");
Defines.push_back("__LONG_LONG_MAX__=9223372036854775807LL");
Defines.push_back("__CHAR_BIT__=8");
Defines.push_back("__SCHAR_MAX__=127");
Defines.push_back("__SHRT_MAX__=32767");
Defines.push_back("__SIZE_TYPE__=long unsigned int");
// Subtarget options.
Defines.push_back("__USER_LABEL_PREFIX__=_");
Defines.push_back("__NATURAL_ALIGNMENT__=1");
Defines.push_back("__REGISTER_PREFIX__=");
Defines.push_back("__WCHAR_MAX__=2147483647");
Defines.push_back("__WCHAR_TYPE__=int");
Defines.push_back("__WINT_TYPE__=int");
// Float macros.
Defines.push_back("__FLT_DENORM_MIN__=1.40129846e-45F");
Defines.push_back("__FLT_DIG__=6");
Defines.push_back("__FLT_EPSILON__=1.19209290e-7F");
Defines.push_back("__FLT_EVAL_METHOD__=0");
Defines.push_back("__FLT_HAS_INFINITY__=1");
Defines.push_back("__FLT_HAS_QUIET_NAN__=1");
Defines.push_back("__FLT_MANT_DIG__=24");
Defines.push_back("__FLT_MAX_10_EXP__=38");
Defines.push_back("__FLT_MAX_EXP__=128");
Defines.push_back("__FLT_MAX__=3.40282347e+38F");
Defines.push_back("__FLT_MIN_10_EXP__=(-37)");
Defines.push_back("__FLT_MIN_EXP__=(-125)");
Defines.push_back("__FLT_MIN__=1.17549435e-38F");
Defines.push_back("__FLT_RADIX__=2");
// double macros.
Defines.push_back("__DBL_DENORM_MIN__=4.9406564584124654e-324");
Defines.push_back("__DBL_DIG__=15");
Defines.push_back("__DBL_EPSILON__=2.2204460492503131e-16");
Defines.push_back("__DBL_HAS_INFINITY__=1");
Defines.push_back("__DBL_HAS_QUIET_NAN__=1");
Defines.push_back("__DBL_MANT_DIG__=53");
Defines.push_back("__DBL_MAX_10_EXP__=308");
Defines.push_back("__DBL_MAX_EXP__=1024");
Defines.push_back("__DBL_MAX__=1.7976931348623157e+308");
Defines.push_back("__DBL_MIN_10_EXP__=(-307)");
Defines.push_back("__DBL_MIN_EXP__=(-1021)");
Defines.push_back("__DBL_MIN__=2.2250738585072014e-308");
Defines.push_back("__DECIMAL_DIG__=33");
// 128-bit long double macros.
Defines.push_back("__LDBL_DENORM_MIN__=4.940656458412465441765687"
"92868221e-324L");
Defines.push_back("__LDBL_DIG__=31");
Defines.push_back("__LDBL_EPSILON__=4.9406564584124654417656879286822"
"1e-324L");
Defines.push_back("__LDBL_HAS_INFINITY__=1");
Defines.push_back("__LDBL_HAS_QUIET_NAN__=1");
Defines.push_back("__LDBL_MANT_DIG__=106");
Defines.push_back("__LDBL_MAX_10_EXP__=308");
Defines.push_back("__LDBL_MAX_EXP__=1024");
Defines.push_back("__LDBL_MAX__=1.7976931348623158079372897140"
"5301e+308L");
Defines.push_back("__LDBL_MIN_10_EXP__=(-291)");
Defines.push_back("__LDBL_MIN_EXP__=(-968)");
Defines.push_back("__LDBL_MIN__=2.004168360008972777996108051350"
"16e-292L");
Defines.push_back("__LONG_DOUBLE_128__=1");
}
/// getX86Defines - Return a set of the X86-specific #defines that are
/// not tied to a specific subtarget.
static void getX86Defines(std::vector<std::string> &Defines, bool is64Bit) {
// Target identification.
if (is64Bit) {
Defines.push_back("_LP64");
Defines.push_back("__LP64__");
Defines.push_back("__amd64__");
Defines.push_back("__amd64");
Defines.push_back("__x86_64");
Defines.push_back("__x86_64__");
} else {
Defines.push_back("__i386__=1");
Defines.push_back("__i386=1");
Defines.push_back("i386=1");
}
// Target properties.
Defines.push_back("__LITTLE_ENDIAN__=1");
if (is64Bit) {
Defines.push_back("__INTMAX_MAX__=9223372036854775807L");
Defines.push_back("__INTMAX_TYPE__=long int");
Defines.push_back("__LONG_MAX__=9223372036854775807L");
Defines.push_back("__PTRDIFF_TYPE__=long int");
Defines.push_back("__UINTMAX_TYPE__=long unsigned int");
} else {
Defines.push_back("__INTMAX_MAX__=9223372036854775807LL");
Defines.push_back("__INTMAX_TYPE__=long long int");
Defines.push_back("__LONG_MAX__=2147483647L");
Defines.push_back("__PTRDIFF_TYPE__=int");
Defines.push_back("__UINTMAX_TYPE__=long long unsigned int");
}
Defines.push_back("__CHAR_BIT__=8");
Defines.push_back("__INT_MAX__=2147483647");
Defines.push_back("__LONG_LONG_MAX__=9223372036854775807LL");
Defines.push_back("__SCHAR_MAX__=127");
Defines.push_back("__SHRT_MAX__=32767");
Defines.push_back("__SIZE_TYPE__=long unsigned int");
// Subtarget options.
Defines.push_back("__nocona=1");
Defines.push_back("__nocona__=1");
Defines.push_back("__tune_nocona__=1");
Defines.push_back("__SSE2_MATH__=1");
Defines.push_back("__SSE2__=1");
Defines.push_back("__SSE_MATH__=1");
Defines.push_back("__SSE__=1");
Defines.push_back("__MMX__=1");
Defines.push_back("__REGISTER_PREFIX__=");
Defines.push_back("__WCHAR_MAX__=2147483647");
Defines.push_back("__WCHAR_TYPE__=int");
Defines.push_back("__WINT_TYPE__=int");
// Float macros.
Defines.push_back("__FLT_DENORM_MIN__=1.40129846e-45F");
Defines.push_back("__FLT_DIG__=6");
Defines.push_back("__FLT_EPSILON__=1.19209290e-7F");
Defines.push_back("__FLT_EVAL_METHOD__=0");
Defines.push_back("__FLT_HAS_INFINITY__=1");
Defines.push_back("__FLT_HAS_QUIET_NAN__=1");
Defines.push_back("__FLT_MANT_DIG__=24");
Defines.push_back("__FLT_MAX_10_EXP__=38");
Defines.push_back("__FLT_MAX_EXP__=128");
Defines.push_back("__FLT_MAX__=3.40282347e+38F");
Defines.push_back("__FLT_MIN_10_EXP__=(-37)");
Defines.push_back("__FLT_MIN_EXP__=(-125)");
Defines.push_back("__FLT_MIN__=1.17549435e-38F");
Defines.push_back("__FLT_RADIX__=2");
// Double macros.
Defines.push_back("__DBL_DENORM_MIN__=4.9406564584124654e-324");
Defines.push_back("__DBL_DIG__=15");
Defines.push_back("__DBL_EPSILON__=2.2204460492503131e-16");
Defines.push_back("__DBL_HAS_INFINITY__=1");
Defines.push_back("__DBL_HAS_QUIET_NAN__=1");
Defines.push_back("__DBL_MANT_DIG__=53");
Defines.push_back("__DBL_MAX_10_EXP__=308");
Defines.push_back("__DBL_MAX_EXP__=1024");
Defines.push_back("__DBL_MAX__=1.7976931348623157e+308");
Defines.push_back("__DBL_MIN_10_EXP__=(-307)");
Defines.push_back("__DBL_MIN_EXP__=(-1021)");
Defines.push_back("__DBL_MIN__=2.2250738585072014e-308");
Defines.push_back("__DECIMAL_DIG__=21");
// 80-bit Long double macros.
Defines.push_back("__LDBL_DENORM_MIN__=3.64519953188247460253e-4951L");
Defines.push_back("__LDBL_DIG__=18");
Defines.push_back("__LDBL_EPSILON__=1.08420217248550443401e-19L");
Defines.push_back("__LDBL_HAS_INFINITY__=1");
Defines.push_back("__LDBL_HAS_QUIET_NAN__=1");
Defines.push_back("__LDBL_MANT_DIG__=64");
Defines.push_back("__LDBL_MAX_10_EXP__=4932");
Defines.push_back("__LDBL_MAX_EXP__=16384");
Defines.push_back("__LDBL_MAX__=1.18973149535723176502e+4932L");
Defines.push_back("__LDBL_MIN_10_EXP__=(-4931)");
Defines.push_back("__LDBL_MIN_EXP__=(-16381)");
Defines.push_back("__LDBL_MIN__=3.36210314311209350626e-4932L");
}
/// PPC builtin info.
namespace PPC {
enum {
LastTIBuiltin = Builtin::FirstTSBuiltin-1,
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
#include "PPCBuiltins.def"
LastTSBuiltin
};
static const Builtin::Info BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS },
#include "PPCBuiltins.def"
};
static void getBuiltins(const Builtin::Info *&Records, unsigned &NumRecords) {
Records = BuiltinInfo;
NumRecords = LastTSBuiltin-Builtin::FirstTSBuiltin;
}
} // End namespace PPC
/// X86 builtin info.
namespace X86 {
enum {
LastTIBuiltin = Builtin::FirstTSBuiltin-1,
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
#include "X86Builtins.def"
LastTSBuiltin
};
static const Builtin::Info BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS },
#include "X86Builtins.def"
};
static void getBuiltins(const Builtin::Info *&Records, unsigned &NumRecords) {
Records = BuiltinInfo;
NumRecords = LastTSBuiltin-Builtin::FirstTSBuiltin;
}
} // End namespace X86
//===----------------------------------------------------------------------===//
// Specific target implementations.
//===----------------------------------------------------------------------===//
namespace {
class DarwinPPCTargetInfo : public DarwinTargetInfo {
public:
virtual void getTargetDefines(std::vector<std::string> &Defines) const {
DarwinTargetInfo::getTargetDefines(Defines);
getPowerPCDefines(Defines, false);
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
PPC::getBuiltins(Records, NumRecords);
}
};
} // end anonymous namespace.
namespace {
class DarwinPPC64TargetInfo : public DarwinTargetInfo {
public:
virtual void getTargetDefines(std::vector<std::string> &Defines) const {
DarwinTargetInfo::getTargetDefines(Defines);
getPowerPCDefines(Defines, true);
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
PPC::getBuiltins(Records, NumRecords);
}
};
} // end anonymous namespace.
namespace {
class DarwinI386TargetInfo : public DarwinTargetInfo {
public:
virtual void getTargetDefines(std::vector<std::string> &Defines) const {
DarwinTargetInfo::getTargetDefines(Defines);
getX86Defines(Defines, false);
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
X86::getBuiltins(Records, NumRecords);
}
};
} // end anonymous namespace.
namespace {
class DarwinX86_64TargetInfo : public DarwinTargetInfo {
public:
virtual void getTargetDefines(std::vector<std::string> &Defines) const {
DarwinTargetInfo::getTargetDefines(Defines);
getX86Defines(Defines, true);
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
X86::getBuiltins(Records, NumRecords);
}
};
} // end anonymous namespace.
namespace {
class LinuxTargetInfo : public DarwinTargetInfo {
public:
LinuxTargetInfo() {
// Note: I have no idea if this is right, just for testing.
WCharWidth = 16;
WCharAlign = 16;
}
virtual void getTargetDefines(std::vector<std::string> &Defines) const {
// TODO: linux-specific stuff.
getX86Defines(Defines, false);
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
X86::getBuiltins(Records, NumRecords);
}
};
} // end anonymous namespace.
//===----------------------------------------------------------------------===//
// Driver code
//===----------------------------------------------------------------------===//
/// CreateTarget - Create the TargetInfoImpl object for the specified target
/// enum value.
static TargetInfoImpl *CreateTarget(SupportedTargets T) {
switch (T) {
default: assert(0 && "Unknown target!");
case target_ppc: return new DarwinPPCTargetInfo();
case target_ppc64: return new DarwinPPC64TargetInfo();
case target_i386: return new DarwinI386TargetInfo();
case target_x86_64: return new DarwinX86_64TargetInfo();
case target_linux_i386: return new LinuxTargetInfo();
}
}
/// CreateTargetInfo - Return the set of target info objects as specified by
/// the -arch command line option.
TargetInfo *clang::CreateTargetInfo(Diagnostic &Diags) {
// If the user didn't specify at least one architecture, auto-sense the
// current host. TODO: This is a hack. :)
if (Archs.empty()) {
#ifndef __APPLE__
// Assume non-apple = i386 for now.
Archs.push_back(target_i386);
#elif (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
defined(__ppc64__)
Archs.push_back(target_ppc64);
#elif defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
Archs.push_back(target_ppc);
#elif defined(__x86_64__)
Archs.push_back(target_x86_64);
#elif defined(__i386__) || defined(i386) || defined(_M_IX86)
Archs.push_back(target_i386);
#else
// Don't know what this is!
return 0;
#endif
}
// Create the primary target and target info.
TargetInfo *TI = new TargetInfo(CreateTarget(Archs[0]), &Diags);
// Add all secondary targets.
for (unsigned i = 1, e = Archs.size(); i != e; ++i)
TI->AddSecondaryTarget(CreateTarget(Archs[i]));
return TI;
}

View File

@@ -1,38 +0,0 @@
//===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is a concrete diagnostic client, which buffers the diagnostic messages.
//
//===----------------------------------------------------------------------===//
#include "TextDiagnosticBuffer.h"
#include "clang/Basic/SourceManager.h"
using namespace clang;
/// HandleDiagnostic - Store the errors & warnings that are reported.
///
void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
SourceLocation Pos,
diag::kind ID,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *,
unsigned) {
switch (Level) {
default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
case Diagnostic::Warning:
Warnings.push_back(std::make_pair(Pos, FormatDiagnostic(Level, ID, Strs,
NumStrs)));
break;
case Diagnostic::Error:
Errors.push_back(std::make_pair(Pos, FormatDiagnostic(Level, ID, Strs,
NumStrs)));
break;
}
}

View File

@@ -1,51 +0,0 @@
//===--- TextDiagnosticBuffer.h - Buffer Text Diagnostics -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is a concrete diagnostic client, which buffers the diagnostic messages.
//
//===----------------------------------------------------------------------===//
#ifndef DRIVER_TEXT_DIAGNOSTIC_BUFFER_H_
#define DRIVER_TEXT_DIAGNOSTIC_BUFFER_H_
#include "TextDiagnostics.h"
#include <vector>
namespace clang {
class Preprocessor;
class SourceManager;
class TextDiagnosticBuffer : public TextDiagnostics {
public:
typedef std::vector<std::pair<SourceLocation, std::string> > DiagList;
typedef DiagList::iterator iterator;
typedef DiagList::const_iterator const_iterator;
private:
DiagList Errors, Warnings;
public:
TextDiagnosticBuffer(SourceManager &SM) : TextDiagnostics(SM) {}
const_iterator err_begin() const { return Errors.begin(); }
const_iterator err_end() const { return Errors.end(); }
const_iterator warn_begin() const { return Warnings.begin(); }
const_iterator warn_end() const { return Warnings.end(); }
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
SourceLocation Pos,
diag::kind ID, const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
unsigned NumRanges);
};
} // end namspace clang
#endif

View File

@@ -1,218 +0,0 @@
//===--- TextDiagnosticPrinter.cpp - Diagnostic Printer -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This diagnostic client prints out their diagnostic messages.
//
//===----------------------------------------------------------------------===//
#include "TextDiagnosticPrinter.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Lexer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include <iostream>
#include <string>
using namespace clang;
static llvm::cl::opt<bool>
NoShowColumn("fno-show-column",
llvm::cl::desc("Do not include column number on diagnostics"));
static llvm::cl::opt<bool>
NoCaretDiagnostics("fno-caret-diagnostics",
llvm::cl::desc("Do not include source line and caret with"
" diagnostics"));
void TextDiagnosticPrinter::
PrintIncludeStack(SourceLocation Pos) {
if (Pos.isInvalid()) return;
Pos = SourceMgr.getLogicalLoc(Pos);
// Print out the other include frames first.
PrintIncludeStack(SourceMgr.getIncludeLoc(Pos));
unsigned LineNo = SourceMgr.getLineNumber(Pos);
std::cerr << "In file included from " << SourceMgr.getSourceName(Pos)
<< ":" << LineNo << ":\n";
}
/// HighlightRange - Given a SourceRange and a line number, highlight (with ~'s)
/// any characters in LineNo that intersect the SourceRange.
void TextDiagnosticPrinter::HighlightRange(const SourceRange &R,
unsigned LineNo,
std::string &CaratLine,
const std::string &SourceLine) {
assert(CaratLine.size() == SourceLine.size() &&
"Expect a correspondence between source and carat line!");
if (!R.isValid()) return;
unsigned StartLineNo = SourceMgr.getLogicalLineNumber(R.Begin());
if (StartLineNo > LineNo) return; // No intersection.
unsigned EndLineNo = SourceMgr.getLogicalLineNumber(R.End());
if (EndLineNo < LineNo) return; // No intersection.
// Compute the column number of the start.
unsigned StartColNo = 0;
if (StartLineNo == LineNo) {
StartColNo = SourceMgr.getLogicalColumnNumber(R.Begin());
if (StartColNo) --StartColNo; // Zero base the col #.
}
// Pick the first non-whitespace column.
while (StartColNo < SourceLine.size() &&
(SourceLine[StartColNo] == ' ' || SourceLine[StartColNo] == '\t'))
++StartColNo;
// Compute the column number of the end.
unsigned EndColNo = CaratLine.size();
if (EndLineNo == LineNo) {
EndColNo = SourceMgr.getLogicalColumnNumber(R.End());
if (EndColNo) {
--EndColNo; // Zero base the col #.
// Add in the length of the token, so that we cover multi-char tokens.
EndColNo += GetTokenLength(R.End());
} else {
EndColNo = CaratLine.size();
}
}
// Pick the last non-whitespace column.
while (EndColNo-1 &&
(SourceLine[EndColNo-1] == ' ' || SourceLine[EndColNo-1] == '\t'))
--EndColNo;
// Fill the range with ~'s.
assert(StartColNo <= EndColNo && "Invalid range!");
for (unsigned i = StartColNo; i != EndColNo; ++i)
CaratLine[i] = '~';
}
/// GetTokenLength - Given the source location of a token, determine its length.
/// This is a fully general function that uses a lexer to relex the token.
unsigned TextDiagnosticPrinter::GetTokenLength(SourceLocation Loc) {
// If this comes from a macro expansion, we really do want the macro name, not
// the token this macro expanded to.
Loc = SourceMgr.getLogicalLoc(Loc);
const char *StrData = SourceMgr.getCharacterData(Loc);
// TODO: this could be special cased for common tokens like identifiers, ')',
// etc to make this faster, if it mattered. This could use
// Lexer::isObviouslySimpleCharacter for example.
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(Loc, *ThePreprocessor, StrData);
Token TheTok;
TheLexer.LexRawToken(TheTok);
return TheTok.getLength();
}
void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
SourceLocation Pos,
diag::kind ID,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
unsigned NumRanges) {
unsigned LineNo = 0, ColNo = 0;
const char *LineStart = 0, *LineEnd = 0;
if (Pos.isValid()) {
SourceLocation LPos = SourceMgr.getLogicalLoc(Pos);
LineNo = SourceMgr.getLineNumber(LPos);
// First, if this diagnostic is not in the main file, print out the
// "included from" lines.
if (LastWarningLoc != SourceMgr.getIncludeLoc(LPos)) {
LastWarningLoc = SourceMgr.getIncludeLoc(LPos);
PrintIncludeStack(LastWarningLoc);
}
// Compute the column number. Rewind from the current position to the start
// of the line.
ColNo = SourceMgr.getColumnNumber(LPos);
const char *TokLogicalPtr = SourceMgr.getCharacterData(LPos);
LineStart = TokLogicalPtr-ColNo+1; // Column # is 1-based
// Compute the line end. Scan forward from the error position to the end of
// the line.
const llvm::MemoryBuffer *Buffer = SourceMgr.getBuffer(LPos.getFileID());
const char *BufEnd = Buffer->getBufferEnd();
LineEnd = TokLogicalPtr;
while (LineEnd != BufEnd &&
*LineEnd != '\n' && *LineEnd != '\r')
++LineEnd;
std::cerr << Buffer->getBufferIdentifier()
<< ":" << LineNo << ":";
if (ColNo && !NoShowColumn)
std::cerr << ColNo << ":";
std::cerr << " ";
}
switch (Level) {
default: assert(0 && "Unknown diagnostic type!");
case Diagnostic::Note: std::cerr << "note: "; break;
case Diagnostic::Warning: std::cerr << "warning: "; break;
case Diagnostic::Error: std::cerr << "error: "; break;
case Diagnostic::Fatal: std::cerr << "fatal error: "; break;
break;
}
std::cerr << FormatDiagnostic(Level, ID, Strs, NumStrs) << "\n";
if (!NoCaretDiagnostics && Pos.isValid()) {
// Get the line of the source file.
std::string SourceLine(LineStart, LineEnd);
// Create a line for the carat that is filled with spaces that is the same
// length as the line of source code.
std::string CaratLine(LineEnd-LineStart, ' ');
// Highlight all of the characters covered by Ranges with ~ characters.
for (unsigned i = 0; i != NumRanges; ++i)
HighlightRange(Ranges[i], LineNo, CaratLine, SourceLine);
// Next, insert the carat itself.
if (ColNo-1 < CaratLine.size())
CaratLine[ColNo-1] = '^';
else
CaratLine.push_back('^');
// Scan the source line, looking for tabs. If we find any, manually expand
// them to 8 characters and update the CaratLine to match.
for (unsigned i = 0; i != SourceLine.size(); ++i) {
if (SourceLine[i] != '\t') continue;
// Replace this tab with at least one space.
SourceLine[i] = ' ';
// Compute the number of spaces we need to insert.
unsigned NumSpaces = ((i+8)&~7) - (i+1);
assert(NumSpaces < 8 && "Invalid computation of space amt");
// Insert spaces into the SourceLine.
SourceLine.insert(i+1, NumSpaces, ' ');
// Insert spaces or ~'s into CaratLine.
CaratLine.insert(i+1, NumSpaces, CaratLine[i] == '~' ? '~' : ' ');
}
// Finally, remove any blank spaces from the end of CaratLine.
while (CaratLine[CaratLine.size()-1] == ' ')
CaratLine.erase(CaratLine.end()-1);
// Emit what we have computed.
std::cerr << SourceLine << "\n";
std::cerr << CaratLine << "\n";
}
}

View File

@@ -1,46 +0,0 @@
//===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is a concrete diagnostic client, which prints the diagnostics to
// standard error.
//
//===----------------------------------------------------------------------===//
#ifndef TEXT_DIAGNOSTIC_PRINTER_H_
#define TEXT_DIAGNOSTIC_PRINTER_H_
#include "TextDiagnostics.h"
#include "clang/Basic/SourceLocation.h"
namespace clang {
class SourceManager;
class TextDiagnosticPrinter : public TextDiagnostics {
SourceLocation LastWarningLoc;
public:
TextDiagnosticPrinter(SourceManager &sourceMgr)
: TextDiagnostics(sourceMgr) {}
void PrintIncludeStack(SourceLocation Pos);
void HighlightRange(const SourceRange &R, unsigned LineNo,
std::string &CaratLine,
const std::string &SourceLine);
unsigned GetTokenLength(SourceLocation Loc);
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
SourceLocation Pos,
diag::kind ID, const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
unsigned NumRanges);
};
} // end namspace clang
#endif

View File

@@ -1,58 +0,0 @@
//===--- TextDiagnostics.cpp - Text Diagnostics Parent Class --------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the parent class for all text diagnostics.
//
//===----------------------------------------------------------------------===//
#include "TextDiagnostics.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/HeaderSearch.h"
using namespace clang;
TextDiagnostics:: ~TextDiagnostics() {}
std::string TextDiagnostics::FormatDiagnostic(Diagnostic::Level Level,
diag::kind ID,
const std::string *Strs,
unsigned NumStrs) {
std::string Msg = Diagnostic::getDescription(ID);
// Replace all instances of %0 in Msg with 'Extra'.
for (unsigned i = 0; i < Msg.size() - 1; ++i) {
if (Msg[i] == '%' && isdigit(Msg[i + 1])) {
unsigned StrNo = Msg[i + 1] - '0';
Msg = std::string(Msg.begin(), Msg.begin() + i) +
(StrNo < NumStrs ? Strs[StrNo] : "<<<INTERNAL ERROR>>>") +
std::string(Msg.begin() + i + 2, Msg.end());
}
}
return Msg;
}
bool TextDiagnostics::IgnoreDiagnostic(Diagnostic::Level Level,
SourceLocation Pos) {
if (Pos.isValid()) {
// If this is a warning or note, and if it a system header, suppress the
// diagnostic.
if (Level == Diagnostic::Warning ||
Level == Diagnostic::Note) {
if (const FileEntry *F = SourceMgr.getFileEntryForLoc(Pos)) {
DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
if (DirInfo == DirectoryLookup::SystemHeaderDir ||
DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
return true;
}
}
}
return false;
}

View File

@@ -1,53 +0,0 @@
//===--- TextDiagnostics.h - Text Diagnostics Checkers ----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the parent class for all text diagnostics.
//
//===----------------------------------------------------------------------===//
#ifndef TEXT_DIAGNOSTICS_H_
#define TEXT_DIAGNOSTICS_H_
#include "clang/Basic/Diagnostic.h"
namespace clang {
class SourceManager;
class HeaderSearch;
class Preprocessor;
class TextDiagnostics : public DiagnosticClient {
HeaderSearch *TheHeaderSearch;
protected:
SourceManager &SourceMgr;
Preprocessor *ThePreprocessor;
std::string FormatDiagnostic(Diagnostic::Level Level,
diag::kind ID,
const std::string *Strs,
unsigned NumStrs);
public:
TextDiagnostics(SourceManager &sourceMgr) : SourceMgr(sourceMgr) {}
virtual ~TextDiagnostics();
void setHeaderSearch(HeaderSearch &HS) { TheHeaderSearch = &HS; }
void setPreprocessor(Preprocessor &P) { ThePreprocessor = &P; }
virtual bool IgnoreDiagnostic(Diagnostic::Level Level,
SourceLocation Pos);
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
SourceLocation Pos,
diag::kind ID, const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
unsigned NumRanges) = 0;
};
} // end namspace clang
#endif

View File

@@ -1,420 +0,0 @@
//===--- X86Builtins.def - X86 Builtin function database --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the X86-specific builtin function database. Users of
// this file must define the BUILTIN macro to make use of this information.
//
//===----------------------------------------------------------------------===//
// FIXME: this needs to be the full list supported by GCC. Right now, I'm just
// adding stuff on demand.
// The format of this database matches clang/AST/Builtins.def.
BUILTIN(__builtin_ia32_emms , "v", "")
// FIXME: These types are incorrect.
// SSE intrinsics.
BUILTIN(__builtin_ia32_comieq, "v", "")
BUILTIN(__builtin_ia32_comilt, "v", "")
BUILTIN(__builtin_ia32_comile, "v", "")
BUILTIN(__builtin_ia32_comigt, "v", "")
BUILTIN(__builtin_ia32_comige, "v", "")
BUILTIN(__builtin_ia32_comineq, "v", "")
BUILTIN(__builtin_ia32_ucomieq, "v", "")
BUILTIN(__builtin_ia32_ucomilt, "v", "")
BUILTIN(__builtin_ia32_ucomile, "v", "")
BUILTIN(__builtin_ia32_ucomigt, "v", "")
BUILTIN(__builtin_ia32_ucomige, "v", "")
BUILTIN(__builtin_ia32_ucomineq, "v", "")
BUILTIN(__builtin_ia32_comisdeq, "v", "")
BUILTIN(__builtin_ia32_comisdlt, "v", "")
BUILTIN(__builtin_ia32_comisdle, "v", "")
BUILTIN(__builtin_ia32_comisdgt, "v", "")
BUILTIN(__builtin_ia32_comisdge, "v", "")
BUILTIN(__builtin_ia32_comisdneq, "v", "")
BUILTIN(__builtin_ia32_ucomisdeq, "v", "")
BUILTIN(__builtin_ia32_ucomisdlt, "v", "")
BUILTIN(__builtin_ia32_ucomisdle, "v", "")
BUILTIN(__builtin_ia32_ucomisdgt, "v", "")
BUILTIN(__builtin_ia32_ucomisdge, "v", "")
BUILTIN(__builtin_ia32_ucomisdneq, "v", "")
BUILTIN(__builtin_ia32_addps, "v", "")
BUILTIN(__builtin_ia32_subps, "v", "")
BUILTIN(__builtin_ia32_mulps, "v", "")
BUILTIN(__builtin_ia32_divps, "v", "")
BUILTIN(__builtin_ia32_addss, "v", "")
BUILTIN(__builtin_ia32_subss, "v", "")
BUILTIN(__builtin_ia32_mulss, "v", "")
BUILTIN(__builtin_ia32_divss, "v", "")
BUILTIN(__builtin_ia32_cmpeqps, "v", "")
BUILTIN(__builtin_ia32_cmpltps, "v", "")
BUILTIN(__builtin_ia32_cmpleps, "v", "")
BUILTIN(__builtin_ia32_cmpgtps, "v", "")
BUILTIN(__builtin_ia32_cmpgeps, "v", "")
BUILTIN(__builtin_ia32_cmpunordps, "v", "")
BUILTIN(__builtin_ia32_cmpneqps, "v", "")
BUILTIN(__builtin_ia32_cmpnltps, "v", "")
BUILTIN(__builtin_ia32_cmpnleps, "v", "")
BUILTIN(__builtin_ia32_cmpngtps, "v", "")
BUILTIN(__builtin_ia32_cmpngeps, "v", "")
BUILTIN(__builtin_ia32_cmpordps, "v", "")
BUILTIN(__builtin_ia32_cmpeqss, "v", "")
BUILTIN(__builtin_ia32_cmpltss, "v", "")
BUILTIN(__builtin_ia32_cmpless, "v", "")
BUILTIN(__builtin_ia32_cmpunordss, "v", "")
BUILTIN(__builtin_ia32_cmpneqss, "v", "")
BUILTIN(__builtin_ia32_cmpnltss, "v", "")
BUILTIN(__builtin_ia32_cmpnless, "v", "")
BUILTIN(__builtin_ia32_cmpngtss, "v", "")
BUILTIN(__builtin_ia32_cmpngess, "v", "")
BUILTIN(__builtin_ia32_cmpordss, "v", "")
BUILTIN(__builtin_ia32_minps, "v", "")
BUILTIN(__builtin_ia32_maxps, "v", "")
BUILTIN(__builtin_ia32_minss, "v", "")
BUILTIN(__builtin_ia32_maxss, "v", "")
BUILTIN(__builtin_ia32_andps, "v", "")
BUILTIN(__builtin_ia32_andnps, "v", "")
BUILTIN(__builtin_ia32_orps, "v", "")
BUILTIN(__builtin_ia32_xorps, "v", "")
BUILTIN(__builtin_ia32_movss, "v", "")
BUILTIN(__builtin_ia32_movhlps, "v", "")
BUILTIN(__builtin_ia32_movlhps, "v", "")
BUILTIN(__builtin_ia32_unpckhps, "v", "")
BUILTIN(__builtin_ia32_unpcklps, "v", "")
BUILTIN(__builtin_ia32_paddb, "v", "")
BUILTIN(__builtin_ia32_paddw, "v", "")
BUILTIN(__builtin_ia32_paddd, "v", "")
BUILTIN(__builtin_ia32_paddq, "v", "")
BUILTIN(__builtin_ia32_psubb, "v", "")
BUILTIN(__builtin_ia32_psubw, "v", "")
BUILTIN(__builtin_ia32_psubd, "v", "")
BUILTIN(__builtin_ia32_psubq, "v", "")
BUILTIN(__builtin_ia32_paddsb, "v", "")
BUILTIN(__builtin_ia32_paddsw, "v", "")
BUILTIN(__builtin_ia32_psubsb, "v", "")
BUILTIN(__builtin_ia32_psubsw, "v", "")
BUILTIN(__builtin_ia32_paddusb, "v", "")
BUILTIN(__builtin_ia32_paddusw, "v", "")
BUILTIN(__builtin_ia32_psubusb, "v", "")
BUILTIN(__builtin_ia32_psubusw, "v", "")
BUILTIN(__builtin_ia32_pmullw, "v", "")
BUILTIN(__builtin_ia32_pmulhw, "v", "")
BUILTIN(__builtin_ia32_pmulhuw, "v", "")
BUILTIN(__builtin_ia32_pand, "v", "")
BUILTIN(__builtin_ia32_pandn, "v", "")
BUILTIN(__builtin_ia32_por, "v", "")
BUILTIN(__builtin_ia32_pxor, "v", "")
BUILTIN(__builtin_ia32_pavgb, "v", "")
BUILTIN(__builtin_ia32_pavgw, "v", "")
BUILTIN(__builtin_ia32_pcmpeqb, "v", "")
BUILTIN(__builtin_ia32_pcmpeqw, "v", "")
BUILTIN(__builtin_ia32_pcmpeqd, "v", "")
BUILTIN(__builtin_ia32_pcmpgtb, "v", "")
BUILTIN(__builtin_ia32_pcmpgtw, "v", "")
BUILTIN(__builtin_ia32_pcmpgtd, "v", "")
BUILTIN(__builtin_ia32_pmaxub, "v", "")
BUILTIN(__builtin_ia32_pmaxsw, "v", "")
BUILTIN(__builtin_ia32_pminub, "v", "")
BUILTIN(__builtin_ia32_pminsw, "v", "")
BUILTIN(__builtin_ia32_punpckhbw, "v", "")
BUILTIN(__builtin_ia32_punpckhwd, "v", "")
BUILTIN(__builtin_ia32_punpckhdq, "v", "")
BUILTIN(__builtin_ia32_punpcklbw, "v", "")
BUILTIN(__builtin_ia32_punpcklwd, "v", "")
BUILTIN(__builtin_ia32_punpckldq, "v", "")
BUILTIN(__builtin_ia32_addpd, "v", "")
BUILTIN(__builtin_ia32_subpd, "v", "")
BUILTIN(__builtin_ia32_mulpd, "v", "")
BUILTIN(__builtin_ia32_divpd, "v", "")
BUILTIN(__builtin_ia32_addsd, "v", "")
BUILTIN(__builtin_ia32_subsd, "v", "")
BUILTIN(__builtin_ia32_mulsd, "v", "")
BUILTIN(__builtin_ia32_divsd, "v", "")
BUILTIN(__builtin_ia32_cmpeqpd, "v", "")
BUILTIN(__builtin_ia32_cmpltpd, "v", "")
BUILTIN(__builtin_ia32_cmplepd, "v", "")
BUILTIN(__builtin_ia32_cmpgtpd, "v", "")
BUILTIN(__builtin_ia32_cmpgepd, "v", "")
BUILTIN(__builtin_ia32_cmpunordpd, "v", "")
BUILTIN(__builtin_ia32_cmpneqpd, "v", "")
BUILTIN(__builtin_ia32_cmpnltpd, "v", "")
BUILTIN(__builtin_ia32_cmpnlepd, "v", "")
BUILTIN(__builtin_ia32_cmpngtpd, "v", "")
BUILTIN(__builtin_ia32_cmpngepd, "v", "")
BUILTIN(__builtin_ia32_cmpordpd, "v", "")
BUILTIN(__builtin_ia32_cmpeqsd, "v", "")
BUILTIN(__builtin_ia32_cmpltsd, "v", "")
BUILTIN(__builtin_ia32_cmplesd, "v", "")
BUILTIN(__builtin_ia32_cmpunordsd, "v", "")
BUILTIN(__builtin_ia32_cmpneqsd, "v", "")
BUILTIN(__builtin_ia32_cmpnltsd, "v", "")
BUILTIN(__builtin_ia32_cmpnlesd, "v", "")
BUILTIN(__builtin_ia32_cmpordsd, "v", "")
BUILTIN(__builtin_ia32_minpd, "v", "")
BUILTIN(__builtin_ia32_maxpd, "v", "")
BUILTIN(__builtin_ia32_minsd, "v", "")
BUILTIN(__builtin_ia32_maxsd, "v", "")
BUILTIN(__builtin_ia32_andpd, "v", "")
BUILTIN(__builtin_ia32_andnpd, "v", "")
BUILTIN(__builtin_ia32_orpd, "v", "")
BUILTIN(__builtin_ia32_xorpd, "v", "")
BUILTIN(__builtin_ia32_movsd, "v", "")
BUILTIN(__builtin_ia32_unpckhpd, "v", "")
BUILTIN(__builtin_ia32_unpcklpd, "v", "")
BUILTIN(__builtin_ia32_paddb128, "v", "")
BUILTIN(__builtin_ia32_paddw128, "v", "")
BUILTIN(__builtin_ia32_paddd128, "v", "")
BUILTIN(__builtin_ia32_paddq128, "v", "")
BUILTIN(__builtin_ia32_psubb128, "v", "")
BUILTIN(__builtin_ia32_psubw128, "v", "")
BUILTIN(__builtin_ia32_psubd128, "v", "")
BUILTIN(__builtin_ia32_psubq128, "v", "")
BUILTIN(__builtin_ia32_paddsb128, "v", "")
BUILTIN(__builtin_ia32_paddsw128, "v", "")
BUILTIN(__builtin_ia32_psubsb128, "v", "")
BUILTIN(__builtin_ia32_psubsw128, "v", "")
BUILTIN(__builtin_ia32_paddusb128, "v", "")
BUILTIN(__builtin_ia32_paddusw128, "v", "")
BUILTIN(__builtin_ia32_psubusb128, "v", "")
BUILTIN(__builtin_ia32_psubusw128, "v", "")
BUILTIN(__builtin_ia32_pmullw128, "v", "")
BUILTIN(__builtin_ia32_pmulhw128, "v", "")
BUILTIN(__builtin_ia32_pand128, "v", "")
BUILTIN(__builtin_ia32_pandn128, "v", "")
BUILTIN(__builtin_ia32_por128, "v", "")
BUILTIN(__builtin_ia32_pxor128, "v", "")
BUILTIN(__builtin_ia32_pavgb128, "v", "")
BUILTIN(__builtin_ia32_pavgw128, "v", "")
BUILTIN(__builtin_ia32_pcmpeqb128, "v", "")
BUILTIN(__builtin_ia32_pcmpeqw128, "v", "")
BUILTIN(__builtin_ia32_pcmpeqd128, "v", "")
BUILTIN(__builtin_ia32_pcmpgtb128, "v", "")
BUILTIN(__builtin_ia32_pcmpgtw128, "v", "")
BUILTIN(__builtin_ia32_pcmpgtd128, "v", "")
BUILTIN(__builtin_ia32_pmaxub128, "v", "")
BUILTIN(__builtin_ia32_pmaxsw128, "v", "")
BUILTIN(__builtin_ia32_pminub128, "v", "")
BUILTIN(__builtin_ia32_pminsw128, "v", "")
BUILTIN(__builtin_ia32_punpckhbw128, "v", "")
BUILTIN(__builtin_ia32_punpckhwd128, "v", "")
BUILTIN(__builtin_ia32_punpckhdq128, "v", "")
BUILTIN(__builtin_ia32_punpckhqdq128, "v", "")
BUILTIN(__builtin_ia32_punpcklbw128, "v", "")
BUILTIN(__builtin_ia32_punpcklwd128, "v", "")
BUILTIN(__builtin_ia32_punpckldq128, "v", "")
BUILTIN(__builtin_ia32_punpcklqdq128, "v", "")
BUILTIN(__builtin_ia32_packsswb128, "v", "")
BUILTIN(__builtin_ia32_packssdw128, "v", "")
BUILTIN(__builtin_ia32_packuswb128, "v", "")
BUILTIN(__builtin_ia32_pmulhuw128, "v", "")
BUILTIN(__builtin_ia32_addsubps, "v", "")
BUILTIN(__builtin_ia32_addsubpd, "v", "")
BUILTIN(__builtin_ia32_haddps, "v", "")
BUILTIN(__builtin_ia32_haddpd, "v", "")
BUILTIN(__builtin_ia32_hsubps, "v", "")
BUILTIN(__builtin_ia32_hsubpd, "v", "")
BUILTIN(__builtin_ia32_phaddw128, "v", "")
BUILTIN(__builtin_ia32_phaddw, "v", "")
BUILTIN(__builtin_ia32_phaddd128, "v", "")
BUILTIN(__builtin_ia32_phaddd, "v", "")
BUILTIN(__builtin_ia32_phaddsw128, "v", "")
BUILTIN(__builtin_ia32_phaddsw, "v", "")
BUILTIN(__builtin_ia32_phsubw128, "v", "")
BUILTIN(__builtin_ia32_phsubw, "v", "")
BUILTIN(__builtin_ia32_phsubd128, "v", "")
BUILTIN(__builtin_ia32_phsubd, "v", "")
BUILTIN(__builtin_ia32_phsubsw128, "v", "")
BUILTIN(__builtin_ia32_phsubsw, "v", "")
BUILTIN(__builtin_ia32_pmaddubsw128, "v", "")
BUILTIN(__builtin_ia32_pmaddubsw, "v", "")
BUILTIN(__builtin_ia32_pmulhrsw128, "v", "")
BUILTIN(__builtin_ia32_pmulhrsw, "v", "")
BUILTIN(__builtin_ia32_pshufb128, "v", "")
BUILTIN(__builtin_ia32_pshufb, "v", "")
BUILTIN(__builtin_ia32_psignb128, "v", "")
BUILTIN(__builtin_ia32_psignb, "v", "")
BUILTIN(__builtin_ia32_psignw128, "v", "")
BUILTIN(__builtin_ia32_psignw, "v", "")
BUILTIN(__builtin_ia32_psignd128, "v", "")
BUILTIN(__builtin_ia32_psignd, "v", "")
BUILTIN(__builtin_ia32_pabsb128, "v", "")
BUILTIN(__builtin_ia32_pabsb, "v", "")
BUILTIN(__builtin_ia32_pabsw128, "v", "")
BUILTIN(__builtin_ia32_pabsw, "v", "")
BUILTIN(__builtin_ia32_pabsd128, "v", "")
BUILTIN(__builtin_ia32_pabsd, "v", "")
BUILTIN(__builtin_ia32_psllw, "v", "")
BUILTIN(__builtin_ia32_pslld, "v", "")
BUILTIN(__builtin_ia32_psllq, "v", "")
BUILTIN(__builtin_ia32_psrlw, "v", "")
BUILTIN(__builtin_ia32_psrld, "v", "")
BUILTIN(__builtin_ia32_psrlq, "v", "")
BUILTIN(__builtin_ia32_psraw, "v", "")
BUILTIN(__builtin_ia32_psrad, "v", "")
BUILTIN(__builtin_ia32_pshufw, "v", "")
BUILTIN(__builtin_ia32_pmaddwd, "v", "")
BUILTIN(__builtin_ia32_packsswb, "v", "")
BUILTIN(__builtin_ia32_packssdw, "v", "")
BUILTIN(__builtin_ia32_packuswb, "v", "")
BUILTIN(__builtin_ia32_ldmxcsr, "v", "")
BUILTIN(__builtin_ia32_stmxcsr, "v", "")
BUILTIN(__builtin_ia32_cvtpi2ps, "v", "")
BUILTIN(__builtin_ia32_cvtps2pi, "v", "")
BUILTIN(__builtin_ia32_cvtsi2ss, "v", "")
BUILTIN(__builtin_ia32_cvtsi642ss, "v", "")
BUILTIN(__builtin_ia32_cvtss2si, "v", "")
BUILTIN(__builtin_ia32_cvtss2si64, "v", "")
BUILTIN(__builtin_ia32_cvttps2pi, "v", "")
BUILTIN(__builtin_ia32_cvttss2si, "v", "")
BUILTIN(__builtin_ia32_cvttss2si64, "v", "")
BUILTIN(__builtin_ia32_maskmovq, "v", "")
BUILTIN(__builtin_ia32_loadups, "v", "")
BUILTIN(__builtin_ia32_storeups, "v", "")
BUILTIN(__builtin_ia32_loadhps, "v", "")
BUILTIN(__builtin_ia32_loadlps, "v", "")
BUILTIN(__builtin_ia32_storehps, "v", "")
BUILTIN(__builtin_ia32_storelps, "v", "")
BUILTIN(__builtin_ia32_movmskps, "v", "")
BUILTIN(__builtin_ia32_pmovmskb, "v", "")
BUILTIN(__builtin_ia32_movntps, "v", "")
BUILTIN(__builtin_ia32_movntq, "v", "")
BUILTIN(__builtin_ia32_sfence, "v", "")
BUILTIN(__builtin_ia32_psadbw, "v", "")
BUILTIN(__builtin_ia32_rcpps, "v", "")
BUILTIN(__builtin_ia32_rcpss, "v", "")
BUILTIN(__builtin_ia32_rsqrtps, "v", "")
BUILTIN(__builtin_ia32_rsqrtss, "v", "")
BUILTIN(__builtin_ia32_sqrtps, "v", "")
BUILTIN(__builtin_ia32_sqrtss, "v", "")
BUILTIN(__builtin_ia32_shufps, "v", "")
BUILTIN(__builtin_ia32_femms, "v", "")
BUILTIN(__builtin_ia32_pavgusb, "v", "")
BUILTIN(__builtin_ia32_pf2id, "v", "")
BUILTIN(__builtin_ia32_pfacc, "v", "")
BUILTIN(__builtin_ia32_pfadd, "v", "")
BUILTIN(__builtin_ia32_pfcmpeq, "v", "")
BUILTIN(__builtin_ia32_pfcmpge, "v", "")
BUILTIN(__builtin_ia32_pfcmpgt, "v", "")
BUILTIN(__builtin_ia32_pfmax, "v", "")
BUILTIN(__builtin_ia32_pfmin, "v", "")
BUILTIN(__builtin_ia32_pfmul, "v", "")
BUILTIN(__builtin_ia32_pfrcp, "v", "")
BUILTIN(__builtin_ia32_pfrcpit1, "v", "")
BUILTIN(__builtin_ia32_pfrcpit2, "v", "")
BUILTIN(__builtin_ia32_pfrsqrt, "v", "")
BUILTIN(__builtin_ia32_pfrsqit1, "v", "")
BUILTIN(__builtin_ia32_pfsub, "v", "")
BUILTIN(__builtin_ia32_pfsubr, "v", "")
BUILTIN(__builtin_ia32_pi2fd, "v", "")
BUILTIN(__builtin_ia32_pmulhrw, "v", "")
BUILTIN(__builtin_ia32_pf2iw, "v", "")
BUILTIN(__builtin_ia32_pfnacc, "v", "")
BUILTIN(__builtin_ia32_pfpnacc, "v", "")
BUILTIN(__builtin_ia32_pi2fw, "v", "")
BUILTIN(__builtin_ia32_pswapdsf, "v", "")
BUILTIN(__builtin_ia32_pswapdsi, "v", "")
BUILTIN(__builtin_ia32_maskmovdqu, "v", "")
BUILTIN(__builtin_ia32_loadupd, "v", "")
BUILTIN(__builtin_ia32_storeupd, "v", "")
BUILTIN(__builtin_ia32_loadhpd, "v", "")
BUILTIN(__builtin_ia32_loadlpd, "v", "")
BUILTIN(__builtin_ia32_movmskpd, "v", "")
BUILTIN(__builtin_ia32_pmovmskb128, "v", "")
BUILTIN(__builtin_ia32_movnti, "v", "")
BUILTIN(__builtin_ia32_movntpd, "v", "")
BUILTIN(__builtin_ia32_movntdq, "v", "")
BUILTIN(__builtin_ia32_pshufd, "v", "")
BUILTIN(__builtin_ia32_pshuflw, "v", "")
BUILTIN(__builtin_ia32_pshufhw, "v", "")
BUILTIN(__builtin_ia32_psadbw128, "v", "")
BUILTIN(__builtin_ia32_sqrtpd, "v", "")
BUILTIN(__builtin_ia32_sqrtsd, "v", "")
BUILTIN(__builtin_ia32_shufpd, "v", "")
BUILTIN(__builtin_ia32_cvtdq2pd, "v", "")
BUILTIN(__builtin_ia32_cvtdq2ps, "v", "")
BUILTIN(__builtin_ia32_cvtpd2dq, "v", "")
BUILTIN(__builtin_ia32_cvtpd2pi, "v", "")
BUILTIN(__builtin_ia32_cvtpd2ps, "v", "")
BUILTIN(__builtin_ia32_cvttpd2dq, "v", "")
BUILTIN(__builtin_ia32_cvttpd2pi, "v", "")
BUILTIN(__builtin_ia32_cvtpi2pd, "v", "")
BUILTIN(__builtin_ia32_cvtsd2si, "v", "")
BUILTIN(__builtin_ia32_cvttsd2si, "v", "")
BUILTIN(__builtin_ia32_cvtsd2si64, "v", "")
BUILTIN(__builtin_ia32_cvttsd2si64, "v", "")
BUILTIN(__builtin_ia32_cvtps2dq, "v", "")
BUILTIN(__builtin_ia32_cvtps2pd, "v", "")
BUILTIN(__builtin_ia32_cvttps2dq, "v", "")
BUILTIN(__builtin_ia32_cvtsi2sd, "v", "")
BUILTIN(__builtin_ia32_cvtsi642sd, "v", "")
BUILTIN(__builtin_ia32_cvtsd2ss, "v", "")
BUILTIN(__builtin_ia32_cvtss2sd, "v", "")
BUILTIN(__builtin_ia32_clflush, "v", "")
BUILTIN(__builtin_ia32_lfence, "v", "")
BUILTIN(__builtin_ia32_mfence, "v", "")
BUILTIN(__builtin_ia32_loaddqu, "v", "")
BUILTIN(__builtin_ia32_storedqu, "v", "")
BUILTIN(__builtin_ia32_psllwi, "v", "")
BUILTIN(__builtin_ia32_pslldi, "v", "")
BUILTIN(__builtin_ia32_psllqi, "v", "")
BUILTIN(__builtin_ia32_psrawi, "v", "")
BUILTIN(__builtin_ia32_psradi, "v", "")
BUILTIN(__builtin_ia32_psrlwi, "v", "")
BUILTIN(__builtin_ia32_psrldi, "v", "")
BUILTIN(__builtin_ia32_psrlqi, "v", "")
BUILTIN(__builtin_ia32_pmuludq, "v", "")
BUILTIN(__builtin_ia32_pmuludq128, "v", "")
BUILTIN(__builtin_ia32_psllw128, "v", "")
BUILTIN(__builtin_ia32_pslld128, "v", "")
BUILTIN(__builtin_ia32_psllq128, "v", "")
BUILTIN(__builtin_ia32_psrlw128, "v", "")
BUILTIN(__builtin_ia32_psrld128, "v", "")
BUILTIN(__builtin_ia32_psrlq128, "v", "")
BUILTIN(__builtin_ia32_psraw128, "v", "")
BUILTIN(__builtin_ia32_psrad128, "v", "")
BUILTIN(__builtin_ia32_pslldqi128, "v", "")
BUILTIN(__builtin_ia32_psllwi128, "v", "")
BUILTIN(__builtin_ia32_pslldi128, "v", "")
BUILTIN(__builtin_ia32_psllqi128, "v", "")
BUILTIN(__builtin_ia32_psrldqi128, "v", "")
BUILTIN(__builtin_ia32_psrlwi128, "v", "")
BUILTIN(__builtin_ia32_psrldi128, "v", "")
BUILTIN(__builtin_ia32_psrlqi128, "v", "")
BUILTIN(__builtin_ia32_psrawi128, "v", "")
BUILTIN(__builtin_ia32_psradi128, "v", "")
BUILTIN(__builtin_ia32_pmaddwd128, "v", "")
BUILTIN(__builtin_ia32_monitor, "v", "")
BUILTIN(__builtin_ia32_mwait, "v", "")
BUILTIN(__builtin_ia32_movshdup, "v", "")
BUILTIN(__builtin_ia32_movsldup, "v", "")
BUILTIN(__builtin_ia32_lddqu, "v", "")
BUILTIN(__builtin_ia32_palignr128, "v", "")
BUILTIN(__builtin_ia32_palignr, "v", "")
BUILTIN(__builtin_ia32_vec_init_v2si, "v", "")
BUILTIN(__builtin_ia32_vec_init_v4hi, "v", "")
BUILTIN(__builtin_ia32_vec_init_v8qi, "v", "")
BUILTIN(__builtin_ia32_vec_ext_v2df, "v", "")
BUILTIN(__builtin_ia32_vec_ext_v2di, "v", "")
BUILTIN(__builtin_ia32_vec_ext_v4sf, "v", "")
BUILTIN(__builtin_ia32_vec_ext_v4si, "v", "")
BUILTIN(__builtin_ia32_vec_ext_v8hi, "v", "")
BUILTIN(__builtin_ia32_vec_ext_v4hi, "v", "")
BUILTIN(__builtin_ia32_vec_ext_v2si, "v", "")
BUILTIN(__builtin_ia32_vec_set_v8hi, "v", "")
BUILTIN(__builtin_ia32_vec_set_v4hi, "v", "")
// Apple local SSE builtins? These are probably not needed eventually, but are
// in the apple-gcc xmmintrin.h file (rdar://4099020).
BUILTIN(__builtin_ia32_movqv4si, "v", "")
BUILTIN(__builtin_ia32_loadlv4si, "v", "")
BUILTIN(__builtin_ia32_storelv4si, "v", "")
#undef BUILTIN

View File

@@ -1,978 +0,0 @@
//===--- clang.cpp - C-Language Front-end ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This utility may be invoked in the following manner:
// clang --help - Output help info.
// clang [options] - Read from stdin.
// clang [options] file - Read from "file".
// clang [options] file1 file2 - Read these files.
//
//===----------------------------------------------------------------------===//
//
// TODO: Options to support:
//
// -ffatal-errors
// -ftabstop=width
//
//===----------------------------------------------------------------------===//
#include "clang.h"
#include "ASTStreamers.h"
#include "TextDiagnosticBuffer.h"
#include "TextDiagnosticPrinter.h"
#include "clang/Parse/Parser.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Signals.h"
#include <memory>
using namespace clang;
//===----------------------------------------------------------------------===//
// Global options.
//===----------------------------------------------------------------------===//
static llvm::cl::opt<bool>
Verbose("v", llvm::cl::desc("Enable verbose output"));
static llvm::cl::opt<bool>
Stats("stats", llvm::cl::desc("Print performance metrics and statistics"));
enum ProgActions {
EmitLLVM, // Emit a .ll file.
ParseASTPrint, // Parse ASTs and print them.
ParseASTDump, // Parse ASTs and dump them.
ParseASTCheck, // Parse ASTs and check diagnostics.
ParseAST, // Parse ASTs.
ParseCFGDump, // Parse ASTS. Build CFGs. Print CFGs.
ParseCFGView, // Parse ASTS. Build CFGs. View CFGs.
AnalysisLiveVariables, // Print results of live-variable analysis.
WarnDeadStores, // Run DeadStores checker on parsed ASTs.
ParsePrintCallbacks, // Parse and print each callback.
ParseSyntaxOnly, // Parse and perform semantic analysis.
ParseNoop, // Parse with noop callbacks.
RunPreprocessorOnly, // Just lex, no output.
PrintPreprocessedInput, // -E mode.
DumpTokens // Token dump mode.
};
static llvm::cl::opt<ProgActions>
ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore,
llvm::cl::init(ParseSyntaxOnly),
llvm::cl::values(
clEnumValN(RunPreprocessorOnly, "Eonly",
"Just run preprocessor, no output (for timings)"),
clEnumValN(PrintPreprocessedInput, "E",
"Run preprocessor, emit preprocessed file"),
clEnumValN(DumpTokens, "dumptokens",
"Run preprocessor, dump internal rep of tokens"),
clEnumValN(ParseNoop, "parse-noop",
"Run parser with noop callbacks (for timings)"),
clEnumValN(ParseSyntaxOnly, "fsyntax-only",
"Run parser and perform semantic analysis"),
clEnumValN(ParsePrintCallbacks, "parse-print-callbacks",
"Run parser and print each callback invoked"),
clEnumValN(ParseAST, "parse-ast",
"Run parser and build ASTs"),
clEnumValN(ParseASTPrint, "parse-ast-print",
"Run parser, build ASTs, then print ASTs"),
clEnumValN(ParseASTDump, "parse-ast-dump",
"Run parser, build ASTs, then dump them"),
clEnumValN(ParseASTCheck, "parse-ast-check",
"Run parser, build ASTs, then check diagnostics"),
clEnumValN(ParseCFGDump, "dump-cfg",
"Run parser, then build and print CFGs."),
clEnumValN(ParseCFGView, "view-cfg",
"Run parser, then build and view CFGs with Graphviz."),
clEnumValN(AnalysisLiveVariables, "dump-live-variables",
"Print results of live variable analysis."),
clEnumValN(WarnDeadStores, "check-dead-stores",
"Flag warnings of stores to dead variables."),
clEnumValN(EmitLLVM, "emit-llvm",
"Build ASTs then convert to LLVM, emit .ll file"),
clEnumValEnd));
//===----------------------------------------------------------------------===//
// Language Options
//===----------------------------------------------------------------------===//
enum LangKind {
langkind_unspecified,
langkind_c,
langkind_c_cpp,
langkind_cxx,
langkind_cxx_cpp,
langkind_objc,
langkind_objc_cpp,
langkind_objcxx,
langkind_objcxx_cpp
};
/* TODO: GCC also accepts:
c-header c++-header objective-c-header objective-c++-header
assembler assembler-with-cpp
ada, f77*, ratfor (!), f95, java, treelang
*/
static llvm::cl::opt<LangKind>
BaseLang("x", llvm::cl::desc("Base language to compile"),
llvm::cl::init(langkind_unspecified),
llvm::cl::values(clEnumValN(langkind_c, "c", "C"),
clEnumValN(langkind_cxx, "c++", "C++"),
clEnumValN(langkind_objc, "objective-c", "Objective C"),
clEnumValN(langkind_objcxx,"objective-c++","Objective C++"),
clEnumValN(langkind_c_cpp, "c-cpp-output",
"Preprocessed C"),
clEnumValN(langkind_cxx_cpp, "c++-cpp-output",
"Preprocessed C++"),
clEnumValN(langkind_objc_cpp, "objective-c-cpp-output",
"Preprocessed Objective C"),
clEnumValN(langkind_objcxx_cpp,"objective-c++-cpp-output",
"Preprocessed Objective C++"),
clEnumValEnd));
static llvm::cl::opt<bool>
LangObjC("ObjC", llvm::cl::desc("Set base language to Objective-C"),
llvm::cl::Hidden);
static llvm::cl::opt<bool>
LangObjCXX("ObjC++", llvm::cl::desc("Set base language to Objective-C++"),
llvm::cl::Hidden);
/// InitializeBaseLanguage - Handle the -x foo options or infer a base language
/// from the input filename.
static void InitializeBaseLanguage(LangOptions &Options,
const std::string &Filename) {
if (BaseLang == langkind_unspecified) {
std::string::size_type DotPos = Filename.rfind('.');
if (LangObjC) {
BaseLang = langkind_objc;
} else if (LangObjCXX) {
BaseLang = langkind_objcxx;
} else if (DotPos == std::string::npos) {
BaseLang = langkind_c; // Default to C if no extension.
} else {
std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
// C header: .h
// C++ header: .hh or .H;
// assembler no preprocessing: .s
// assembler: .S
if (Ext == "c")
BaseLang = langkind_c;
else if (Ext == "i")
BaseLang = langkind_c_cpp;
else if (Ext == "ii")
BaseLang = langkind_cxx_cpp;
else if (Ext == "m")
BaseLang = langkind_objc;
else if (Ext == "mi")
BaseLang = langkind_objc_cpp;
else if (Ext == "mm" || Ext == "M")
BaseLang = langkind_objcxx;
else if (Ext == "mii")
BaseLang = langkind_objcxx_cpp;
else if (Ext == "C" || Ext == "cc" || Ext == "cpp" || Ext == "CPP" ||
Ext == "c++" || Ext == "cp" || Ext == "cxx")
BaseLang = langkind_cxx;
else
BaseLang = langkind_c;
}
}
// FIXME: implement -fpreprocessed mode.
bool NoPreprocess = false;
switch (BaseLang) {
default: assert(0 && "Unknown language kind!");
case langkind_c_cpp:
NoPreprocess = true;
// FALLTHROUGH
case langkind_c:
break;
case langkind_cxx_cpp:
NoPreprocess = true;
// FALLTHROUGH
case langkind_cxx:
Options.CPlusPlus = 1;
break;
case langkind_objc_cpp:
NoPreprocess = true;
// FALLTHROUGH
case langkind_objc:
Options.ObjC1 = Options.ObjC2 = 1;
break;
case langkind_objcxx_cpp:
NoPreprocess = true;
// FALLTHROUGH
case langkind_objcxx:
Options.ObjC1 = Options.ObjC2 = 1;
Options.CPlusPlus = 1;
break;
}
}
/// LangStds - Language standards we support.
enum LangStds {
lang_unspecified,
lang_c89, lang_c94, lang_c99,
lang_gnu89, lang_gnu99,
lang_cxx98, lang_gnucxx98,
lang_cxx0x, lang_gnucxx0x
};
static llvm::cl::opt<LangStds>
LangStd("std", llvm::cl::desc("Language standard to compile for"),
llvm::cl::init(lang_unspecified),
llvm::cl::values(clEnumValN(lang_c89, "c89", "ISO C 1990"),
clEnumValN(lang_c89, "c90", "ISO C 1990"),
clEnumValN(lang_c89, "iso9899:1990", "ISO C 1990"),
clEnumValN(lang_c94, "iso9899:199409",
"ISO C 1990 with amendment 1"),
clEnumValN(lang_c99, "c99", "ISO C 1999"),
// clEnumValN(lang_c99, "c9x", "ISO C 1999"),
clEnumValN(lang_c99, "iso9899:1999", "ISO C 1999"),
// clEnumValN(lang_c99, "iso9899:199x", "ISO C 1999"),
clEnumValN(lang_gnu89, "gnu89",
"ISO C 1990 with GNU extensions (default for C)"),
clEnumValN(lang_gnu99, "gnu99",
"ISO C 1999 with GNU extensions"),
clEnumValN(lang_gnu99, "gnu9x",
"ISO C 1999 with GNU extensions"),
clEnumValN(lang_cxx98, "c++98",
"ISO C++ 1998 with amendments"),
clEnumValN(lang_gnucxx98, "gnu++98",
"ISO C++ 1998 with amendments and GNU "
"extensions (default for C++)"),
clEnumValN(lang_cxx0x, "c++0x",
"Upcoming ISO C++ 200x with amendments"),
clEnumValN(lang_gnucxx0x, "gnu++0x",
"Upcoming ISO C++ 200x with amendments and GNU "
"extensions (default for C++)"),
clEnumValEnd));
static llvm::cl::opt<bool>
NoOperatorNames("fno-operator-names",
llvm::cl::desc("Do not treat C++ operator name keywords as "
"synonyms for operators"));
// FIXME: add:
// -ansi
// -trigraphs
// -fdollars-in-identifiers
static void InitializeLanguageStandard(LangOptions &Options) {
if (LangStd == lang_unspecified) {
// Based on the base language, pick one.
switch (BaseLang) {
default: assert(0 && "Unknown base language");
case langkind_c:
case langkind_c_cpp:
case langkind_objc:
case langkind_objc_cpp:
LangStd = lang_gnu99;
break;
case langkind_cxx:
case langkind_cxx_cpp:
case langkind_objcxx:
case langkind_objcxx_cpp:
LangStd = lang_gnucxx98;
break;
}
}
switch (LangStd) {
default: assert(0 && "Unknown language standard!");
// Fall through from newer standards to older ones. This isn't really right.
// FIXME: Enable specifically the right features based on the language stds.
case lang_gnucxx0x:
case lang_cxx0x:
Options.CPlusPlus0x = 1;
// FALL THROUGH
case lang_gnucxx98:
case lang_cxx98:
Options.CPlusPlus = 1;
Options.CXXOperatorNames = !NoOperatorNames;
// FALL THROUGH.
case lang_gnu99:
case lang_c99:
Options.Digraphs = 1;
Options.C99 = 1;
Options.HexFloats = 1;
// FALL THROUGH.
case lang_gnu89:
Options.BCPLComment = 1; // Only for C99/C++.
// FALL THROUGH.
case lang_c94:
case lang_c89:
break;
}
Options.Trigraphs = 1; // -trigraphs or -ansi
Options.DollarIdents = 1; // FIXME: Really a target property.
}
//===----------------------------------------------------------------------===//
// Our DiagnosticClient implementation
//===----------------------------------------------------------------------===//
// FIXME: Werror should take a list of things, -Werror=foo,bar
static llvm::cl::opt<bool>
WarningsAsErrors("Werror", llvm::cl::desc("Treat all warnings as errors"));
static llvm::cl::opt<bool>
WarnOnExtensions("pedantic", llvm::cl::init(false),
llvm::cl::desc("Issue a warning on uses of GCC extensions"));
static llvm::cl::opt<bool>
ErrorOnExtensions("pedantic-errors",
llvm::cl::desc("Issue an error on uses of GCC extensions"));
static llvm::cl::opt<bool>
WarnUnusedMacros("Wunused_macros",
llvm::cl::desc("Warn for unused macros in the main translation unit"));
/// InitializeDiagnostics - Initialize the diagnostic object, based on the
/// current command line option settings.
static void InitializeDiagnostics(Diagnostic &Diags) {
Diags.setWarningsAsErrors(WarningsAsErrors);
Diags.setWarnOnExtensions(WarnOnExtensions);
Diags.setErrorOnExtensions(ErrorOnExtensions);
// Silence the "macro is not used" warning unless requested.
if (!WarnUnusedMacros)
Diags.setDiagnosticMapping(diag::pp_macro_not_used, diag::MAP_IGNORE);
}
//===----------------------------------------------------------------------===//
// Preprocessor Initialization
//===----------------------------------------------------------------------===//
// FIXME: Preprocessor builtins to support.
// -A... - Play with #assertions
// -undef - Undefine all predefined macros
static llvm::cl::list<std::string>
D_macros("D", llvm::cl::value_desc("macro"), llvm::cl::Prefix,
llvm::cl::desc("Predefine the specified macro"));
static llvm::cl::list<std::string>
U_macros("U", llvm::cl::value_desc("macro"), llvm::cl::Prefix,
llvm::cl::desc("Undefine the specified macro"));
// Append a #define line to Buf for Macro. Macro should be of the form XXX,
// in which case we emit "#define XXX 1" or "XXX=Y z W" in which case we emit
// "#define XXX Y z W". To get a #define with no value, use "XXX=".
static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro,
const char *Command = "#define ") {
Buf.insert(Buf.end(), Command, Command+strlen(Command));
if (const char *Equal = strchr(Macro, '=')) {
// Turn the = into ' '.
Buf.insert(Buf.end(), Macro, Equal);
Buf.push_back(' ');
Buf.insert(Buf.end(), Equal+1, Equal+strlen(Equal));
} else {
// Push "macroname 1".
Buf.insert(Buf.end(), Macro, Macro+strlen(Macro));
Buf.push_back(' ');
Buf.push_back('1');
}
Buf.push_back('\n');
}
static void InitializePredefinedMacros(Preprocessor &PP,
std::vector<char> &Buf) {
// FIXME: Implement magic like cpp_init_builtins for things like __STDC__
// and __DATE__ etc.
#if 0
/* __STDC__ has the value 1 under normal circumstances.
However, if (a) we are in a system header, (b) the option
stdc_0_in_system_headers is true (set by target config), and
(c) we are not in strictly conforming mode, then it has the
value 0. (b) and (c) are already checked in cpp_init_builtins. */
//case BT_STDC:
if (cpp_in_system_header (pfile))
number = 0;
else
number = 1;
break;
#endif
// These should all be defined in the preprocessor according to the
// current language configuration.
DefineBuiltinMacro(Buf, "__STDC__=1");
//DefineBuiltinMacro(Buf, "__ASSEMBLER__=1");
if (PP.getLangOptions().C99 && !PP.getLangOptions().CPlusPlus)
DefineBuiltinMacro(Buf, "__STDC_VERSION__=199901L");
else if (0) // STDC94 ?
DefineBuiltinMacro(Buf, "__STDC_VERSION__=199409L");
DefineBuiltinMacro(Buf, "__STDC_HOSTED__=1");
if (PP.getLangOptions().ObjC1)
DefineBuiltinMacro(Buf, "__OBJC__=1");
if (PP.getLangOptions().ObjC2)
DefineBuiltinMacro(Buf, "__OBJC2__=1");
// Get the target #defines.
PP.getTargetInfo().getTargetDefines(Buf);
// Compiler set macros.
DefineBuiltinMacro(Buf, "__APPLE_CC__=5250");
DefineBuiltinMacro(Buf, "__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=1030");
DefineBuiltinMacro(Buf, "__GNUC_MINOR__=0");
DefineBuiltinMacro(Buf, "__GNUC_PATCHLEVEL__=1");
DefineBuiltinMacro(Buf, "__GNUC__=4");
DefineBuiltinMacro(Buf, "__GXX_ABI_VERSION=1002");
DefineBuiltinMacro(Buf, "__VERSION__=\"4.0.1 (Apple Computer, Inc. "
"build 5250)\"");
// Build configuration options.
DefineBuiltinMacro(Buf, "__DYNAMIC__=1");
DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0");
DefineBuiltinMacro(Buf, "__NO_INLINE__=1");
DefineBuiltinMacro(Buf, "__PIC__=1");
if (PP.getLangOptions().CPlusPlus) {
DefineBuiltinMacro(Buf, "__DEPRECATED=1");
DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
DefineBuiltinMacro(Buf, "__GNUG__=4");
DefineBuiltinMacro(Buf, "__GXX_WEAK__=1");
DefineBuiltinMacro(Buf, "__cplusplus=1");
DefineBuiltinMacro(Buf, "__private_extern__=extern");
}
// FIXME: Should emit a #line directive here.
// Add macros from the command line.
// FIXME: Should traverse the #define/#undef lists in parallel.
for (unsigned i = 0, e = D_macros.size(); i != e; ++i)
DefineBuiltinMacro(Buf, D_macros[i].c_str());
for (unsigned i = 0, e = U_macros.size(); i != e; ++i)
DefineBuiltinMacro(Buf, U_macros[i].c_str(), "#undef ");
}
//===----------------------------------------------------------------------===//
// Preprocessor include path information.
//===----------------------------------------------------------------------===//
// This tool exports a large number of command line options to control how the
// preprocessor searches for header files. At root, however, the Preprocessor
// object takes a very simple interface: a list of directories to search for
//
// FIXME: -nostdinc,-nostdinc++
// FIXME: -imultilib
//
// FIXME: -include,-imacros
static llvm::cl::opt<bool>
nostdinc("nostdinc", llvm::cl::desc("Disable standard #include directories"));
// Various command line options. These four add directories to each chain.
static llvm::cl::list<std::string>
F_dirs("F", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
llvm::cl::desc("Add directory to framework include search path"));
static llvm::cl::list<std::string>
I_dirs("I", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
llvm::cl::desc("Add directory to include search path"));
static llvm::cl::list<std::string>
idirafter_dirs("idirafter", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
llvm::cl::desc("Add directory to AFTER include search path"));
static llvm::cl::list<std::string>
iquote_dirs("iquote", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
llvm::cl::desc("Add directory to QUOTE include search path"));
static llvm::cl::list<std::string>
isystem_dirs("isystem", llvm::cl::value_desc("directory"), llvm::cl::Prefix,
llvm::cl::desc("Add directory to SYSTEM include search path"));
// These handle -iprefix/-iwithprefix/-iwithprefixbefore.
static llvm::cl::list<std::string>
iprefix_vals("iprefix", llvm::cl::value_desc("prefix"), llvm::cl::Prefix,
llvm::cl::desc("Set the -iwithprefix/-iwithprefixbefore prefix"));
static llvm::cl::list<std::string>
iwithprefix_vals("iwithprefix", llvm::cl::value_desc("dir"), llvm::cl::Prefix,
llvm::cl::desc("Set directory to SYSTEM include search path with prefix"));
static llvm::cl::list<std::string>
iwithprefixbefore_vals("iwithprefixbefore", llvm::cl::value_desc("dir"),
llvm::cl::Prefix,
llvm::cl::desc("Set directory to include search path with prefix"));
static llvm::cl::opt<std::string>
isysroot("isysroot", llvm::cl::value_desc("dir"), llvm::cl::init("/"),
llvm::cl::desc("Set the system root directory (usually /)"));
// Finally, implement the code that groks the options above.
enum IncludeDirGroup {
Quoted = 0,
Angled,
System,
After
};
static std::vector<DirectoryLookup> IncludeGroup[4];
/// AddPath - Add the specified path to the specified group list.
///
static void AddPath(const std::string &Path, IncludeDirGroup Group,
bool isCXXAware, bool isUserSupplied,
bool isFramework, FileManager &FM) {
const DirectoryEntry *DE;
if (Group == System)
DE = FM.getDirectory(isysroot + "/" + Path);
else
DE = FM.getDirectory(Path);
if (DE == 0) {
if (Verbose)
fprintf(stderr, "ignoring nonexistent directory \"%s\"\n",
Path.c_str());
return;
}
DirectoryLookup::DirType Type;
if (Group == Quoted || Group == Angled)
Type = DirectoryLookup::NormalHeaderDir;
else if (isCXXAware)
Type = DirectoryLookup::SystemHeaderDir;
else
Type = DirectoryLookup::ExternCSystemHeaderDir;
IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied,
isFramework));
}
/// RemoveDuplicates - If there are duplicate directory entries in the specified
/// search list, remove the later (dead) ones.
static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList) {
std::set<const DirectoryEntry *> SeenDirs;
for (unsigned i = 0; i != SearchList.size(); ++i) {
// If this isn't the first time we've seen this dir, remove it.
if (!SeenDirs.insert(SearchList[i].getDir()).second) {
if (Verbose)
fprintf(stderr, "ignoring duplicate directory \"%s\"\n",
SearchList[i].getDir()->getName());
SearchList.erase(SearchList.begin()+i);
--i;
}
}
}
/// InitializeIncludePaths - Process the -I options and set them in the
/// HeaderSearch object.
static void InitializeIncludePaths(HeaderSearch &Headers, FileManager &FM,
Diagnostic &Diags, const LangOptions &Lang) {
// Handle -F... options.
for (unsigned i = 0, e = F_dirs.size(); i != e; ++i)
AddPath(F_dirs[i], Angled, false, true, true, FM);
// Handle -I... options.
for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) {
if (I_dirs[i] == "-") {
// -I- is a deprecated GCC feature.
Diags.Report(SourceLocation(), diag::err_pp_I_dash_not_supported);
} else {
AddPath(I_dirs[i], Angled, false, true, false, FM);
}
}
// Handle -idirafter... options.
for (unsigned i = 0, e = idirafter_dirs.size(); i != e; ++i)
AddPath(idirafter_dirs[i], After, false, true, false, FM);
// Handle -iquote... options.
for (unsigned i = 0, e = iquote_dirs.size(); i != e; ++i)
AddPath(iquote_dirs[i], Quoted, false, true, false, FM);
// Handle -isystem... options.
for (unsigned i = 0, e = isystem_dirs.size(); i != e; ++i)
AddPath(isystem_dirs[i], System, false, true, false, FM);
// Walk the -iprefix/-iwithprefix/-iwithprefixbefore argument lists in
// parallel, processing the values in order of occurance to get the right
// prefixes.
{
std::string Prefix = ""; // FIXME: this isn't the correct default prefix.
unsigned iprefix_idx = 0;
unsigned iwithprefix_idx = 0;
unsigned iwithprefixbefore_idx = 0;
bool iprefix_done = iprefix_vals.empty();
bool iwithprefix_done = iwithprefix_vals.empty();
bool iwithprefixbefore_done = iwithprefixbefore_vals.empty();
while (!iprefix_done || !iwithprefix_done || !iwithprefixbefore_done) {
if (!iprefix_done &&
(iwithprefix_done ||
iprefix_vals.getPosition(iprefix_idx) <
iwithprefix_vals.getPosition(iwithprefix_idx)) &&
(iwithprefixbefore_done ||
iprefix_vals.getPosition(iprefix_idx) <
iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) {
Prefix = iprefix_vals[iprefix_idx];
++iprefix_idx;
iprefix_done = iprefix_idx == iprefix_vals.size();
} else if (!iwithprefix_done &&
(iwithprefixbefore_done ||
iwithprefix_vals.getPosition(iwithprefix_idx) <
iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) {
AddPath(Prefix+iwithprefix_vals[iwithprefix_idx],
System, false, false, false, FM);
++iwithprefix_idx;
iwithprefix_done = iwithprefix_idx == iwithprefix_vals.size();
} else {
AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx],
Angled, false, false, false, FM);
++iwithprefixbefore_idx;
iwithprefixbefore_done =
iwithprefixbefore_idx == iwithprefixbefore_vals.size();
}
}
}
// FIXME: Add contents of the CPATH, C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
// OBJC_INCLUDE_PATH, OBJCPLUS_INCLUDE_PATH environment variables.
// FIXME: temporary hack: hard-coded paths.
// FIXME: get these from the target?
if (!nostdinc) {
if (Lang.CPlusPlus) {
AddPath("/usr/include/c++/4.0.0", System, true, false, false, FM);
AddPath("/usr/include/c++/4.0.0/i686-apple-darwin8", System, true, false,
false, FM);
AddPath("/usr/include/c++/4.0.0/backward", System, true, false, false,FM);
}
AddPath("/usr/local/include", System, false, false, false, FM);
// leopard
AddPath("/usr/lib/gcc/i686-apple-darwin9/4.0.1/include", System,
false, false, false, FM);
AddPath("/usr/lib/gcc/powerpc-apple-darwin9/4.0.1/include",
System, false, false, false, FM);
AddPath("/usr/lib/gcc/powerpc-apple-darwin9/"
"4.0.1/../../../../powerpc-apple-darwin0/include",
System, false, false, false, FM);
// tiger
AddPath("/usr/lib/gcc/i686-apple-darwin8/4.0.1/include", System,
false, false, false, FM);
AddPath("/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include",
System, false, false, false, FM);
AddPath("/usr/lib/gcc/powerpc-apple-darwin8/"
"4.0.1/../../../../powerpc-apple-darwin8/include",
System, false, false, false, FM);
AddPath("/usr/include", System, false, false, false, FM);
AddPath("/System/Library/Frameworks", System, true, false, true, FM);
AddPath("/Library/Frameworks", System, true, false, true, FM);
}
// Now that we have collected all of the include paths, merge them all
// together and tell the preprocessor about them.
// Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList.
std::vector<DirectoryLookup> SearchList;
SearchList = IncludeGroup[Angled];
SearchList.insert(SearchList.end(), IncludeGroup[System].begin(),
IncludeGroup[System].end());
SearchList.insert(SearchList.end(), IncludeGroup[After].begin(),
IncludeGroup[After].end());
RemoveDuplicates(SearchList);
RemoveDuplicates(IncludeGroup[Quoted]);
// Prepend QUOTED list on the search list.
SearchList.insert(SearchList.begin(), IncludeGroup[Quoted].begin(),
IncludeGroup[Quoted].end());
bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
Headers.SetSearchPaths(SearchList, IncludeGroup[Quoted].size(),
DontSearchCurDir);
// If verbose, print the list of directories that will be searched.
if (Verbose) {
fprintf(stderr, "#include \"...\" search starts here:\n");
unsigned QuotedIdx = IncludeGroup[Quoted].size();
for (unsigned i = 0, e = SearchList.size(); i != e; ++i) {
if (i == QuotedIdx)
fprintf(stderr, "#include <...> search starts here:\n");
fprintf(stderr, " %s\n", SearchList[i].getDir()->getName());
}
}
}
// Read any files specified by -imacros or -include.
static void ReadPrologFiles(Preprocessor &PP, std::vector<char> &Buf) {
// FIXME: IMPLEMENT
}
//===----------------------------------------------------------------------===//
// Basic Parser driver
//===----------------------------------------------------------------------===//
static void ParseFile(Preprocessor &PP, MinimalAction *PA, unsigned MainFileID){
Parser P(PP, *PA);
PP.EnterSourceFile(MainFileID, 0, true);
// Parsing the specified input file.
P.ParseTranslationUnit();
delete PA;
}
//===----------------------------------------------------------------------===//
// Main driver
//===----------------------------------------------------------------------===//
/// InitializePreprocessor - Initialize the preprocessor getting it and the
/// environment ready to process a single file. This returns the file ID for the
/// input file. If a failure happens, it returns 0.
///
static unsigned InitializePreprocessor(Preprocessor &PP,
const std::string &InFile,
SourceManager &SourceMgr,
HeaderSearch &HeaderInfo,
const LangOptions &LangInfo,
std::vector<char> &PrologMacros) {
FileManager &FileMgr = HeaderInfo.getFileMgr();
// Install things like __POWERPC__, __GNUC__, etc into the macro table.
InitializePredefinedMacros(PP, PrologMacros);
// Read any files specified by -imacros or -include.
ReadPrologFiles(PP, PrologMacros);
// Figure out where to get and map in the main file.
unsigned MainFileID = 0;
if (InFile != "-") {
const FileEntry *File = FileMgr.getFile(InFile);
if (File) MainFileID = SourceMgr.createFileID(File, SourceLocation());
if (MainFileID == 0) {
fprintf(stderr, "Error reading '%s'!\n",InFile.c_str());
return 0;
}
} else {
llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN();
if (SB) MainFileID = SourceMgr.createFileIDForMemBuffer(SB);
if (MainFileID == 0) {
fprintf(stderr, "Error reading standard input! Empty?\n");
return 0;
}
}
// Now that we have emitted the predefined macros, #includes, etc into
// PrologMacros, preprocess it to populate the initial preprocessor state.
// Memory buffer must end with a null byte!
PrologMacros.push_back(0);
llvm::MemoryBuffer *SB =
llvm::MemoryBuffer::getMemBuffer(&PrologMacros.front(),&PrologMacros.back(),
"<predefines>");
assert(SB && "Cannot fail to create predefined source buffer");
unsigned FileID = SourceMgr.createFileIDForMemBuffer(SB);
assert(FileID && "Could not create FileID for predefines?");
// Start parsing the predefines.
PP.EnterSourceFile(FileID, 0);
// Lex the file, which will read all the macros.
Token Tok;
PP.Lex(Tok);
assert(Tok.getKind() == tok::eof && "Didn't read entire file!");
// Once we've read this, we're done.
return MainFileID;
}
/// ProcessInputFile - Process a single input file with the specified state.
///
static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
const std::string &InFile,
SourceManager &SourceMgr,
TextDiagnostics &OurDiagnosticClient,
HeaderSearch &HeaderInfo,
const LangOptions &LangInfo) {
bool ClearSourceMgr = false;
switch (ProgAction) {
default:
fprintf(stderr, "Unexpected program action!\n");
return;
case DumpTokens: { // Token dump mode.
Token Tok;
// Start parsing the specified input file.
PP.EnterSourceFile(MainFileID, 0, true);
do {
PP.Lex(Tok);
PP.DumpToken(Tok, true);
fprintf(stderr, "\n");
} while (Tok.getKind() != tok::eof);
ClearSourceMgr = true;
break;
}
case RunPreprocessorOnly: { // Just lex as fast as we can, no output.
Token Tok;
// Start parsing the specified input file.
PP.EnterSourceFile(MainFileID, 0, true);
do {
PP.Lex(Tok);
} while (Tok.getKind() != tok::eof);
ClearSourceMgr = true;
break;
}
case PrintPreprocessedInput: // -E mode.
DoPrintPreprocessedInput(MainFileID, PP, LangInfo);
ClearSourceMgr = true;
break;
case ParseNoop: // -parse-noop
ParseFile(PP, new MinimalAction(), MainFileID);
ClearSourceMgr = true;
break;
case ParsePrintCallbacks:
ParseFile(PP, CreatePrintParserActionsAction(), MainFileID);
ClearSourceMgr = true;
break;
case ParseSyntaxOnly: // -fsyntax-only
case ParseAST:
BuildASTs(PP, MainFileID, Stats);
break;
case ParseASTPrint:
PrintASTs(PP, MainFileID, Stats);
break;
case ParseASTDump:
DumpASTs(PP, MainFileID, Stats);
break;
case ParseCFGDump:
DumpCFGs(PP, MainFileID, Stats);
break;
case ParseCFGView:
DumpCFGs(PP, MainFileID, Stats, true);
break;
case AnalysisLiveVariables:
AnalyzeLiveVariables(PP, MainFileID);
break;
case WarnDeadStores:
RunDeadStoresCheck(PP, MainFileID, Stats);
break;
case EmitLLVM:
EmitLLVMFromASTs(PP, MainFileID, Stats);
break;
case ParseASTCheck:
exit(CheckDiagnostics(PP, MainFileID));
break;
}
if (Stats) {
fprintf(stderr, "\nSTATISTICS FOR '%s':\n", InFile.c_str());
PP.PrintStats();
PP.getIdentifierTable().PrintStats();
HeaderInfo.PrintStats();
if (ClearSourceMgr)
SourceMgr.PrintStats();
fprintf(stderr, "\n");
}
// For a multi-file compilation, some things are ok with nuking the source
// manager tables, other require stable fileid/macroid's across multiple
// files.
if (ClearSourceMgr) {
SourceMgr.clearIDTables();
}
}
static llvm::cl::list<std::string>
InputFilenames(llvm::cl::Positional, llvm::cl::desc("<input files>"));
int main(int argc, char **argv) {
llvm::cl::ParseCommandLineOptions(argc, argv, " llvm cfe\n");
llvm::sys::PrintStackTraceOnErrorSignal();
// If no input was specified, read from stdin.
if (InputFilenames.empty())
InputFilenames.push_back("-");
/// Create a SourceManager object. This tracks and owns all the file buffers
/// allocated to the program.
SourceManager SourceMgr;
// Create a file manager object to provide access to and cache the filesystem.
FileManager FileMgr;
// Initialize language options, inferring file types from input filenames.
// FIXME: This infers info from the first file, we should clump by language
// to handle 'x.c y.c a.cpp b.cpp'.
LangOptions LangInfo;
InitializeBaseLanguage(LangInfo, InputFilenames[0]);
InitializeLanguageStandard(LangInfo);
std::auto_ptr<TextDiagnostics> DiagClient;
if (ProgAction != ParseASTCheck) {
// Print diagnostics to stderr by default.
DiagClient.reset(new TextDiagnosticPrinter(SourceMgr));
} else {
// When checking diagnostics, just buffer them up.
DiagClient.reset(new TextDiagnosticBuffer(SourceMgr));
if (InputFilenames.size() != 1) {
fprintf(stderr,
"parse-ast-check only works on single input files for now.\n");
return 1;
}
}
// Configure our handling of diagnostics.
Diagnostic Diags(*DiagClient);
InitializeDiagnostics(Diags);
// Get information about the targets being compiled for. Note that this
// pointer and the TargetInfoImpl objects are never deleted by this toy
// driver.
TargetInfo *Target = CreateTargetInfo(Diags);
if (Target == 0) {
fprintf(stderr,
"Sorry, don't know what target this is, please use -arch.\n");
exit(1);
}
// Process the -I options and set them in the HeaderInfo.
HeaderSearch HeaderInfo(FileMgr);
DiagClient->setHeaderSearch(HeaderInfo);
InitializeIncludePaths(HeaderInfo, FileMgr, Diags, LangInfo);
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
// Set up the preprocessor with these options.
Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo);
DiagClient->setPreprocessor(PP);
const std::string &InFile = InputFilenames[i];
std::vector<char> PrologMacros;
unsigned MainFileID = InitializePreprocessor(PP, InFile, SourceMgr,
HeaderInfo, LangInfo,
PrologMacros);
if (!MainFileID) continue;
ProcessInputFile(PP, MainFileID, InFile, SourceMgr,
*DiagClient, HeaderInfo, LangInfo);
HeaderInfo.ClearFileInfo();
}
unsigned NumDiagnostics = Diags.getNumDiagnostics();
if (NumDiagnostics)
fprintf(stderr, "%d diagnostic%s generated.\n", NumDiagnostics,
(NumDiagnostics == 1 ? "" : "s"));
if (Stats) {
// Printed from high-to-low level.
SourceMgr.PrintStats();
FileMgr.PrintStats();
fprintf(stderr, "\n");
}
return Diags.getNumErrors() != 0;
}

View File

@@ -1,45 +0,0 @@
//===--- clang.h - C-Language Front-end -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the header file that pulls together the top-level driver.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_CLANG_H
#define LLVM_CLANG_CLANG_H
namespace clang {
class Preprocessor;
struct LangOptions;
class MinimalAction;
class TargetInfo;
class Diagnostic;
/// DoPrintPreprocessedInput - Implement -E mode.
void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
const LangOptions &Options);
/// CreatePrintParserActionsAction - Return the actions implementation that
/// implements the -parse-print-callbacks option.
MinimalAction *CreatePrintParserActionsAction();
/// CreateTargetInfo - Return the set of target info objects as specified by
/// the -arch command line option.
TargetInfo *CreateTargetInfo(Diagnostic &Diags);
/// EmitLLVMFromASTs - Implement -emit-llvm, which generates llvm IR from C.
void EmitLLVMFromASTs(Preprocessor &PP, unsigned MainFileID,
bool PrintStats);
/// CheckDiagnostics - Implement the -parse-ast-check diagnostic verifier.
bool CheckDiagnostics(Preprocessor &PP, unsigned MainFileID);
} // end namespace clang
#endif

View File

@@ -1,2 +0,0 @@
#import <Cocoa/Cocoa.h>

View File

@@ -1,4 +0,0 @@
#include <Carbon/Carbon.h>
//#import<vecLib/vecLib.h>

View File

@@ -1,5 +0,0 @@
// clang -I/usr/include/c++/4.0.0 -I/usr/include/c++/4.0.0/powerpc-apple-darwin8 -I/usr/include/c++/4.0.0/backward INPUTS/iostream.cc -Eonly
#include <iostream>
#include <stdint.h>

View File

@@ -1,17 +0,0 @@
// This pounds on macro expansion for performance reasons. This is currently
// heavily constrained by darwin's malloc.
// Function-like macros.
#define A0(A, B) A B
#define A1(A, B) A0(A,B) A0(A,B) A0(A,B) A0(A,B) A0(A,B) A0(A,B)
#define A2(A, B) A1(A,B) A1(A,B) A1(A,B) A1(A,B) A1(A,B) A1(A,B)
#define A3(A, B) A2(A,B) A2(A,B) A2(A,B) A2(A,B) A2(A,B) A2(A,B)
#define A4(A, B) A3(A,B) A3(A,B) A3(A,B) A3(A,B) A3(A,B) A3(A,B)
#define A5(A, B) A4(A,B) A4(A,B) A4(A,B) A4(A,B) A4(A,B) A4(A,B)
#define A6(A, B) A5(A,B) A5(A,B) A5(A,B) A5(A,B) A5(A,B) A5(A,B)
#define A7(A, B) A6(A,B) A6(A,B) A6(A,B) A6(A,B) A6(A,B) A6(A,B)
#define A8(A, B) A7(A,B) A7(A,B) A7(A,B) A7(A,B) A7(A,B) A7(A,B)
A8(a, b)

View File

@@ -1,16 +0,0 @@
// This pounds on macro expansion for performance reasons. This is currently
// heavily constrained by darwin's malloc.
// Object-like expansions
#define A0 a b
#define A1 A0 A0 A0 A0 A0 A0
#define A2 A1 A1 A1 A1 A1 A1
#define A3 A2 A2 A2 A2 A2 A2
#define A4 A3 A3 A3 A3 A3 A3
#define A5 A4 A4 A4 A4 A4 A4
#define A6 A5 A5 A5 A5 A5 A5
#define A7 A6 A6 A6 A6 A6 A6
#define A8 A7 A7 A7 A7 A7 A7
A8

View File

@@ -1,47 +0,0 @@
#define __extension__
#define __stpcpy(dest, src) (__extension__ (__builtin_constant_p (src) ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 ? __stpcpy_small (dest, __stpcpy_args (src), strlen (src) + 1) : ((char *) __mempcpy (dest, src, strlen (src) + 1) - 1)) : __stpcpy (dest, src)))
#define stpcpy(dest, src) __stpcpy (dest, src)
#define __stpcpy_args(src) __extension__ __STRING2_SMALL_GET16 (src, 0), __extension__ __STRING2_SMALL_GET16 (src, 4), __extension__ __STRING2_SMALL_GET32 (src, 0), __extension__ __STRING2_SMALL_GET32 (src, 4)
#define __mempcpy(dest, src, n) (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) && __string2_1bptr_p (src) && n <= 8 ? __mempcpy_small (dest, __mempcpy_args (src), n) : __mempcpy (dest, src, n)))
#define mempcpy(dest, src, n) __mempcpy (dest, src, n)
#define __mempcpy_args(src) ((char *) (src))[0], ((char *) (src))[2], ((char *) (src))[4], ((char *) (src))[6], __extension__ __STRING2_SMALL_GET16 (src, 0), __extension__ __STRING2_SMALL_GET16 (src, 4), __extension__ __STRING2_SMALL_GET32 (src, 0), __extension__ __STRING2_SMALL_GET32 (src, 4)
#define __STRING2_SMALL_GET16(src, idx) (((__const unsigned char *) (__const char *) (src))[idx + 1] << 8 | ((__const unsigned char *) (__const char *) (src))[idx])
#define __STRING2_SMALL_GET32(src, idx) (((((__const unsigned char *) (__const char *) (src))[idx + 3] << 8 | ((__const unsigned char *) (__const char *) (src))[idx + 2]) << 8 | ((__const unsigned char *) (__const char *) (src))[idx + 1]) << 8 | ((__const unsigned char *) (__const char *) (src))[idx])
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)
stpcpy (stpcpy (stpcpy (stpcpy (a, b), c), d), e)

View File

@@ -1,63 +0,0 @@
==============================================================================
LLVM Release License
==============================================================================
University of Illinois/NCSA
Open Source License
Copyright (c) 2007 University of Illinois at Urbana-Champaign.
All rights reserved.
Developed by:
LLVM Team
University of Illinois at Urbana-Champaign
http://llvm.org
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
* Neither the names of the LLVM Team, University of Illinois at
Urbana-Champaign, nor the names of its contributors may be used to
endorse or promote products derived from this Software without specific
prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
==============================================================================
The LLVM software contains code written by third parties. Such software will
have its own individual LICENSE.TXT file in the directory in which it appears.
This file will describe the copyrights, license, and restrictions which apply
to that code.
The disclaimer of warranty in the University of Illinois Open Source License
applies to all code in the LLVM Distribution, and nothing in any of the
other licenses gives permission to use the names of the LLVM Team or the
University of Illinois to endorse or promote products derived from this
Software.
The following pieces of software have additional or alternate copyrights,
licenses, and/or restrictions:
Program Directory
------- ---------
<none yet>

View File

@@ -1,343 +0,0 @@
//===--- HeaderSearch.cpp - Resolve Header File Locations ---===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the DirectoryLookup and HeaderSearch interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/FileManager.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/IdentifierTable.h"
#include "llvm/System/Path.h"
#include "llvm/ADT/SmallString.h"
using namespace clang;
HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM), FrameworkMap(64) {
SystemDirIdx = 0;
NoCurDirSearch = false;
NumIncluded = 0;
NumMultiIncludeFileOptzn = 0;
NumFrameworkLookups = NumSubFrameworkLookups = 0;
}
void HeaderSearch::PrintStats() {
fprintf(stderr, "\n*** HeaderSearch Stats:\n");
fprintf(stderr, "%d files tracked.\n", (int)FileInfo.size());
unsigned NumOnceOnlyFiles = 0, MaxNumIncludes = 0, NumSingleIncludedFiles = 0;
for (unsigned i = 0, e = FileInfo.size(); i != e; ++i) {
NumOnceOnlyFiles += FileInfo[i].isImport;
if (MaxNumIncludes < FileInfo[i].NumIncludes)
MaxNumIncludes = FileInfo[i].NumIncludes;
NumSingleIncludedFiles += FileInfo[i].NumIncludes == 1;
}
fprintf(stderr, " %d #import/#pragma once files.\n", NumOnceOnlyFiles);
fprintf(stderr, " %d included exactly once.\n", NumSingleIncludedFiles);
fprintf(stderr, " %d max times a file is included.\n", MaxNumIncludes);
fprintf(stderr, " %d #include/#include_next/#import.\n", NumIncluded);
fprintf(stderr, " %d #includes skipped due to"
" the multi-include optimization.\n", NumMultiIncludeFileOptzn);
fprintf(stderr, "%d framework lookups.\n", NumFrameworkLookups);
fprintf(stderr, "%d subframework lookups.\n", NumSubFrameworkLookups);
}
//===----------------------------------------------------------------------===//
// Header File Location.
//===----------------------------------------------------------------------===//
const FileEntry *HeaderSearch::DoFrameworkLookup(const DirectoryEntry *Dir,
const char *FilenameStart,
const char *FilenameEnd) {
// Framework names must have a '/' in the filename.
const char *SlashPos = std::find(FilenameStart, FilenameEnd, '/');
if (SlashPos == FilenameEnd) return 0;
llvm::StringMapEntry<const DirectoryEntry *> &CacheLookup =
FrameworkMap.GetOrCreateValue(FilenameStart, SlashPos);
// If it is some other directory, fail.
if (CacheLookup.getValue() && CacheLookup.getValue() != Dir)
return 0;
// FrameworkName = "/System/Library/Frameworks/"
llvm::SmallString<1024> FrameworkName;
FrameworkName += Dir->getName();
if (FrameworkName.empty() || FrameworkName.back() != '/')
FrameworkName.push_back('/');
// FrameworkName = "/System/Library/Frameworks/Cocoa"
FrameworkName.append(FilenameStart, SlashPos);
// FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
FrameworkName += ".framework/";
if (CacheLookup.getValue() == 0) {
++NumFrameworkLookups;
// If the framework dir doesn't exist, we fail.
if (!llvm::sys::Path(std::string(FrameworkName.begin(),
FrameworkName.end())).exists())
return 0;
// Otherwise, if it does, remember that this is the right direntry for this
// framework.
CacheLookup.setValue(Dir);
}
// Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
unsigned OrigSize = FrameworkName.size();
FrameworkName += "Headers/";
FrameworkName.append(SlashPos+1, FilenameEnd);
if (const FileEntry *FE = FileMgr.getFile(FrameworkName.begin(),
FrameworkName.end())) {
return FE;
}
// Check "/System/Library/Frameworks/Cocoa.framework/PrivateHeaders/file.h"
const char *Private = "Private";
FrameworkName.insert(FrameworkName.begin()+OrigSize, Private,
Private+strlen(Private));
return FileMgr.getFile(FrameworkName.begin(), FrameworkName.end());
}
/// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
/// return null on failure. isAngled indicates whether the file reference is
/// for system #include's or not (i.e. using <> instead of ""). CurFileEnt, if
/// non-null, indicates where the #including file is, in case a relative search
/// is needed.
const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart,
const char *FilenameEnd,
bool isAngled,
const DirectoryLookup *FromDir,
const DirectoryLookup *&CurDir,
const FileEntry *CurFileEnt) {
// If 'Filename' is absolute, check to see if it exists and no searching.
// FIXME: Portability. This should be a sys::Path interface, this doesn't
// handle things like C:\foo.txt right, nor win32 \\network\device\blah.
if (FilenameStart[0] == '/') {
CurDir = 0;
// If this was an #include_next "/absolute/file", fail.
if (FromDir) return 0;
// Otherwise, just return the file.
return FileMgr.getFile(FilenameStart, FilenameEnd);
}
llvm::SmallString<1024> TmpDir;
// Step #0, unless disabled, check to see if the file is in the #includer's
// directory. This search is not done for <> headers.
if (CurFileEnt && !isAngled && !NoCurDirSearch) {
// Concatenate the requested file onto the directory.
// FIXME: Portability. Filename concatenation should be in sys::Path.
TmpDir += CurFileEnt->getDir()->getName();
TmpDir.push_back('/');
TmpDir.append(FilenameStart, FilenameEnd);
if (const FileEntry *FE = FileMgr.getFile(TmpDir.begin(), TmpDir.end())) {
// Leave CurDir unset.
// This file is a system header or C++ unfriendly if the old file is.
getFileInfo(FE).DirInfo = getFileInfo(CurFileEnt).DirInfo;
return FE;
}
TmpDir.clear();
}
CurDir = 0;
// If this is a system #include, ignore the user #include locs.
unsigned i = isAngled ? SystemDirIdx : 0;
// If this is a #include_next request, start searching after the directory the
// file was found in.
if (FromDir)
i = FromDir-&SearchDirs[0];
// Cache all of the lookups performed by this method. Many headers are
// multiply included, and the "pragma once" optimization prevents them from
// being relex/pp'd, but they would still have to search through a
// (potentially huge) series of SearchDirs to find it.
std::pair<unsigned, unsigned> &CacheLookup =
LookupFileCache.GetOrCreateValue(FilenameStart, FilenameEnd).getValue();
// If the entry has been previously looked up, the first value will be
// non-zero. If the value is equal to i (the start point of our search), then
// this is a matching hit.
if (CacheLookup.first == i+1) {
// Skip querying potentially lots of directories for this lookup.
i = CacheLookup.second;
} else {
// Otherwise, this is the first query, or the previous query didn't match
// our search start. We will fill in our found location below, so prime the
// start point value.
CacheLookup.first = i+1;
}
// Check each directory in sequence to see if it contains this file.
for (; i != SearchDirs.size(); ++i) {
const FileEntry *FE = 0;
if (!SearchDirs[i].isFramework()) {
// FIXME: Portability. Adding file to dir should be in sys::Path.
// Concatenate the requested file onto the directory.
TmpDir.clear();
TmpDir += SearchDirs[i].getDir()->getName();
TmpDir.push_back('/');
TmpDir.append(FilenameStart, FilenameEnd);
FE = FileMgr.getFile(TmpDir.begin(), TmpDir.end());
} else {
FE = DoFrameworkLookup(SearchDirs[i].getDir(), FilenameStart,FilenameEnd);
}
if (FE) {
CurDir = &SearchDirs[i];
// This file is a system header or C++ unfriendly if the dir is.
getFileInfo(FE).DirInfo = CurDir->getDirCharacteristic();
// Remember this location for the next lookup we do.
CacheLookup.second = i;
return FE;
}
}
// Otherwise, didn't find it. Remember we didn't find this.
CacheLookup.second = SearchDirs.size();
return 0;
}
/// LookupSubframeworkHeader - Look up a subframework for the specified
/// #include file. For example, if #include'ing <HIToolbox/HIToolbox.h> from
/// within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox
/// is a subframework within Carbon.framework. If so, return the FileEntry
/// for the designated file, otherwise return null.
const FileEntry *HeaderSearch::
LookupSubframeworkHeader(const char *FilenameStart,
const char *FilenameEnd,
const FileEntry *ContextFileEnt) {
// Framework names must have a '/' in the filename. Find it.
const char *SlashPos = std::find(FilenameStart, FilenameEnd, '/');
if (SlashPos == FilenameEnd) return 0;
// Look up the base framework name of the ContextFileEnt.
const char *ContextName = ContextFileEnt->getName();
// If the context info wasn't a framework, couldn't be a subframework.
const char *FrameworkPos = strstr(ContextName, ".framework/");
if (FrameworkPos == 0)
return 0;
llvm::SmallString<1024> FrameworkName(ContextName,
FrameworkPos+strlen(".framework/"));
// Append Frameworks/HIToolbox.framework/
FrameworkName += "Frameworks/";
FrameworkName.append(FilenameStart, SlashPos);
FrameworkName += ".framework/";
llvm::StringMapEntry<const DirectoryEntry *> &CacheLookup =
FrameworkMap.GetOrCreateValue(FilenameStart, SlashPos);
// Some other location?
if (CacheLookup.getValue() &&
CacheLookup.getKeyLength() == FrameworkName.size() &&
memcmp(CacheLookup.getKeyData(), &FrameworkName[0],
CacheLookup.getKeyLength()) != 0)
return 0;
// Cache subframework.
if (CacheLookup.getValue() == 0) {
++NumSubFrameworkLookups;
// If the framework dir doesn't exist, we fail.
const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.begin(),
FrameworkName.end());
if (Dir == 0) return 0;
// Otherwise, if it does, remember that this is the right direntry for this
// framework.
CacheLookup.setValue(Dir);
}
const FileEntry *FE = 0;
// Check ".../Frameworks/HIToolbox.framework/Headers/HIToolbox.h"
llvm::SmallString<1024> HeadersFilename(FrameworkName);
HeadersFilename += "Headers/";
HeadersFilename.append(SlashPos+1, FilenameEnd);
if (!(FE = FileMgr.getFile(HeadersFilename.begin(),
HeadersFilename.end()))) {
// Check ".../Frameworks/HIToolbox.framework/PrivateHeaders/HIToolbox.h"
HeadersFilename = FrameworkName;
HeadersFilename += "PrivateHeaders/";
HeadersFilename.append(SlashPos+1, FilenameEnd);
if (!(FE = FileMgr.getFile(HeadersFilename.begin(), HeadersFilename.end())))
return 0;
}
// This file is a system header or C++ unfriendly if the old file is.
getFileInfo(FE).DirInfo = getFileInfo(ContextFileEnt).DirInfo;
return FE;
}
//===----------------------------------------------------------------------===//
// File Info Management.
//===----------------------------------------------------------------------===//
/// getFileInfo - Return the PerFileInfo structure for the specified
/// FileEntry.
HeaderSearch::PerFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
if (FE->getUID() >= FileInfo.size())
FileInfo.resize(FE->getUID()+1);
return FileInfo[FE->getUID()];
}
/// ShouldEnterIncludeFile - Mark the specified file as a target of of a
/// #include, #include_next, or #import directive. Return false if #including
/// the file will have no effect or true if we should include it.
bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){
++NumIncluded; // Count # of attempted #includes.
// Get information about this file.
PerFileInfo &FileInfo = getFileInfo(File);
// If this is a #import directive, check that we have not already imported
// this header.
if (isImport) {
// If this has already been imported, don't import it again.
FileInfo.isImport = true;
// Has this already been #import'ed or #include'd?
if (FileInfo.NumIncludes) return false;
} else {
// Otherwise, if this is a #include of a file that was previously #import'd
// or if this is the second #include of a #pragma once file, ignore it.
if (FileInfo.isImport)
return false;
}
// Next, check to see if the file is wrapped with #ifndef guards. If so, and
// if the macro that guards it is defined, we know the #include has no effect.
if (FileInfo.ControllingMacro && FileInfo.ControllingMacro->getMacroInfo()) {
++NumMultiIncludeFileOptzn;
return false;
}
// Increment the number of times this file has been included.
++FileInfo.NumIncludes;
return true;
}

View File

@@ -1,211 +0,0 @@
//===--- IdentifierTable.cpp - Hash table for identifier lookup -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the IdentifierInfo, IdentifierVisitor, and
// IdentifierTable interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/IdentifierTable.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Basic/LangOptions.h"
using namespace clang;
//===----------------------------------------------------------------------===//
// Token Implementation
//===----------------------------------------------------------------------===//
/// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.
bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const {
return getKind() == tok::identifier &&
getIdentifierInfo()->getObjCKeywordID() == objcKey;
}
/// getObjCKeywordID - Return the ObjC keyword kind.
tok::ObjCKeywordKind Token::getObjCKeywordID() const {
IdentifierInfo *specId = getIdentifierInfo();
return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword;
}
//===----------------------------------------------------------------------===//
// IdentifierInfo Implementation
//===----------------------------------------------------------------------===//
IdentifierInfo::IdentifierInfo() {
Macro = 0;
TokenID = tok::identifier;
PPID = tok::pp_not_keyword;
ObjCID = tok::objc_not_keyword;
BuiltinID = 0;
IsExtension = false;
IsPoisoned = false;
IsOtherTargetMacro = false;
IsCPPOperatorKeyword = false;
IsNonPortableBuiltin = false;
FETokenInfo = 0;
}
IdentifierInfo::~IdentifierInfo() {
delete Macro;
}
//===----------------------------------------------------------------------===//
// IdentifierTable Implementation
//===----------------------------------------------------------------------===//
IdentifierTable::IdentifierTable(const LangOptions &LangOpts)
// Start with space for 8K identifiers.
: HashTable(8192) {
// Populate the identifier table with info about keywords for the current
// language.
AddKeywords(LangOpts);
}
//===----------------------------------------------------------------------===//
// Language Keyword Implementation
//===----------------------------------------------------------------------===//
/// AddKeyword - This method is used to associate a token ID with specific
/// identifiers because they are language keywords. This causes the lexer to
/// automatically map matching identifiers to specialized token codes.
///
/// The C90/C99/CPP/CPP0x flags are set to 0 if the token should be
/// enabled in the specified langauge, set to 1 if it is an extension
/// in the specified language, and set to 2 if disabled in the
/// specified language.
static void AddKeyword(const char *Keyword, unsigned KWLen,
tok::TokenKind TokenCode,
int C90, int C99, int CXX, int CXX0x,
const LangOptions &LangOpts, IdentifierTable &Table) {
int Flags = LangOpts.CPlusPlus ? (LangOpts.CPlusPlus0x? CXX0x : CXX)
: (LangOpts.C99 ? C99 : C90);
// Don't add this keyword if disabled in this language or if an extension
// and extensions are disabled.
if (Flags + LangOpts.NoExtensions >= 2) return;
IdentifierInfo &Info = Table.get(Keyword, Keyword+KWLen);
Info.setTokenID(TokenCode);
Info.setIsExtensionToken(Flags == 1);
}
static void AddAlias(const char *Keyword, unsigned KWLen,
const char *AliaseeKeyword, unsigned AliaseeKWLen,
const LangOptions &LangOpts, IdentifierTable &Table) {
IdentifierInfo &AliasInfo = Table.get(Keyword, Keyword+KWLen);
IdentifierInfo &AliaseeInfo = Table.get(AliaseeKeyword,
AliaseeKeyword+AliaseeKWLen);
AliasInfo.setTokenID(AliaseeInfo.getTokenID());
AliasInfo.setIsExtensionToken(AliaseeInfo.isExtensionToken());
}
/// AddPPKeyword - Register a preprocessor keyword like "define" "undef" or
/// "elif".
static void AddPPKeyword(tok::PPKeywordKind PPID,
const char *Name, unsigned NameLen,
IdentifierTable &Table) {
Table.get(Name, Name+NameLen).setPPKeywordID(PPID);
}
/// AddCXXOperatorKeyword - Register a C++ operator keyword alternative
/// representations.
static void AddCXXOperatorKeyword(const char *Keyword, unsigned KWLen,
tok::TokenKind TokenCode,
IdentifierTable &Table) {
IdentifierInfo &Info = Table.get(Keyword, Keyword + KWLen);
Info.setTokenID(TokenCode);
Info.setIsCPlusplusOperatorKeyword();
}
/// AddObjCKeyword - Register an Objective-C @keyword like "class" "selector" or
/// "property".
static void AddObjCKeyword(tok::ObjCKeywordKind ObjCID,
const char *Name, unsigned NameLen,
IdentifierTable &Table) {
Table.get(Name, Name+NameLen).setObjCKeywordID(ObjCID);
}
/// AddKeywords - Add all keywords to the symbol table.
///
void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
enum {
C90Shift = 0,
EXTC90 = 1 << C90Shift,
NOTC90 = 2 << C90Shift,
C99Shift = 2,
EXTC99 = 1 << C99Shift,
NOTC99 = 2 << C99Shift,
CPPShift = 4,
EXTCPP = 1 << CPPShift,
NOTCPP = 2 << CPPShift,
CPP0xShift = 6,
EXTCPP0x = 1 << CPP0xShift,
NOTCPP0x = 2 << CPP0xShift,
Mask = 3
};
// Add keywords and tokens for the current language.
#define KEYWORD(NAME, FLAGS) \
AddKeyword(#NAME, strlen(#NAME), tok::kw_ ## NAME, \
((FLAGS) >> C90Shift) & Mask, \
((FLAGS) >> C99Shift) & Mask, \
((FLAGS) >> CPPShift) & Mask, \
((FLAGS) >> CPP0xShift) & Mask, LangOpts, *this);
#define ALIAS(NAME, TOK) \
AddAlias(NAME, strlen(NAME), #TOK, strlen(#TOK), LangOpts, *this);
#define PPKEYWORD(NAME) \
AddPPKeyword(tok::pp_##NAME, #NAME, strlen(#NAME), *this);
#define CXX_KEYWORD_OPERATOR(NAME, ALIAS) \
if (LangOpts.CXXOperatorNames) \
AddCXXOperatorKeyword(#NAME, strlen(#NAME), tok::ALIAS, *this);
#define OBJC1_AT_KEYWORD(NAME) \
if (LangOpts.ObjC1) \
AddObjCKeyword(tok::objc_##NAME, #NAME, strlen(#NAME), *this);
#define OBJC2_AT_KEYWORD(NAME) \
if (LangOpts.ObjC2) \
AddObjCKeyword(tok::objc_##NAME, #NAME, strlen(#NAME), *this);
#include "clang/Basic/TokenKinds.def"
}
//===----------------------------------------------------------------------===//
// Stats Implementation
//===----------------------------------------------------------------------===//
/// PrintStats - Print statistics about how well the identifier table is doing
/// at hashing identifiers.
void IdentifierTable::PrintStats() const {
unsigned NumBuckets = HashTable.getNumBuckets();
unsigned NumIdentifiers = HashTable.getNumItems();
unsigned NumEmptyBuckets = NumBuckets-NumIdentifiers;
unsigned AverageIdentifierSize = 0;
unsigned MaxIdentifierLength = 0;
// TODO: Figure out maximum times an identifier had to probe for -stats.
for (llvm::StringMap<IdentifierInfo, llvm::BumpPtrAllocator>::const_iterator
I = HashTable.begin(), E = HashTable.end(); I != E; ++I) {
unsigned IdLen = I->getKeyLength();
AverageIdentifierSize += IdLen;
if (MaxIdentifierLength < IdLen)
MaxIdentifierLength = IdLen;
}
fprintf(stderr, "\n*** Identifier Table Stats:\n");
fprintf(stderr, "# Identifiers: %d\n", NumIdentifiers);
fprintf(stderr, "# Empty Buckets: %d\n", NumEmptyBuckets);
fprintf(stderr, "Hash density (#identifiers per bucket): %f\n",
NumIdentifiers/(double)NumBuckets);
fprintf(stderr, "Ave identifier length: %f\n",
(AverageIdentifierSize/(double)NumIdentifiers));
fprintf(stderr, "Max identifier length: %d\n", MaxIdentifierLength);
// Compute statistics about the memory allocated for identifiers.
HashTable.getAllocator().PrintStats();
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,661 +0,0 @@
//===--- LiteralSupport.cpp - Code to parse and process literals ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Steve Naroff and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the NumericLiteralParser, CharLiteralParser, and
// StringLiteralParser interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/LiteralSupport.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/StringExtras.h"
using namespace clang;
/// HexDigitValue - Return the value of the specified hex digit, or -1 if it's
/// not valid.
static int HexDigitValue(char C) {
if (C >= '0' && C <= '9') return C-'0';
if (C >= 'a' && C <= 'f') return C-'a'+10;
if (C >= 'A' && C <= 'F') return C-'A'+10;
return -1;
}
/// ProcessCharEscape - Parse a standard C escape sequence, which can occur in
/// either a character or a string literal.
static unsigned ProcessCharEscape(const char *&ThisTokBuf,
const char *ThisTokEnd, bool &HadError,
SourceLocation Loc, bool IsWide,
Preprocessor &PP) {
// Skip the '\' char.
++ThisTokBuf;
// We know that this character can't be off the end of the buffer, because
// that would have been \", which would not have been the end of string.
unsigned ResultChar = *ThisTokBuf++;
switch (ResultChar) {
// These map to themselves.
case '\\': case '\'': case '"': case '?': break;
// These have fixed mappings.
case 'a':
// TODO: K&R: the meaning of '\\a' is different in traditional C
ResultChar = 7;
break;
case 'b':
ResultChar = 8;
break;
case 'e':
PP.Diag(Loc, diag::ext_nonstandard_escape, "e");
ResultChar = 27;
break;
case 'f':
ResultChar = 12;
break;
case 'n':
ResultChar = 10;
break;
case 'r':
ResultChar = 13;
break;
case 't':
ResultChar = 9;
break;
case 'v':
ResultChar = 11;
break;
//case 'u': case 'U': // FIXME: UCNs.
case 'x': { // Hex escape.
ResultChar = 0;
if (ThisTokBuf == ThisTokEnd || !isxdigit(*ThisTokBuf)) {
PP.Diag(Loc, diag::err_hex_escape_no_digits);
HadError = 1;
break;
}
// Hex escapes are a maximal series of hex digits.
bool Overflow = false;
for (; ThisTokBuf != ThisTokEnd; ++ThisTokBuf) {
int CharVal = HexDigitValue(ThisTokBuf[0]);
if (CharVal == -1) break;
Overflow |= (ResultChar & 0xF0000000) ? true : false; // About to shift out a digit?
ResultChar <<= 4;
ResultChar |= CharVal;
}
// See if any bits will be truncated when evaluated as a character.
unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc)
: PP.getTargetInfo().getCharWidth(Loc);
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
Overflow = true;
ResultChar &= ~0U >> (32-CharWidth);
}
// Check for overflow.
if (Overflow) // Too many digits to fit in
PP.Diag(Loc, diag::warn_hex_escape_too_large);
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7': {
// Octal escapes.
--ThisTokBuf;
ResultChar = 0;
// Octal escapes are a series of octal digits with maximum length 3.
// "\0123" is a two digit sequence equal to "\012" "3".
unsigned NumDigits = 0;
do {
ResultChar <<= 3;
ResultChar |= *ThisTokBuf++ - '0';
++NumDigits;
} while (ThisTokBuf != ThisTokEnd && NumDigits < 3 &&
ThisTokBuf[0] >= '0' && ThisTokBuf[0] <= '7');
// Check for overflow. Reject '\777', but not L'\777'.
unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc)
: PP.getTargetInfo().getCharWidth(Loc);
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
PP.Diag(Loc, diag::warn_octal_escape_too_large);
ResultChar &= ~0U >> (32-CharWidth);
}
break;
}
// Otherwise, these are not valid escapes.
case '(': case '{': case '[': case '%':
// GCC accepts these as extensions. We warn about them as such though.
if (!PP.getLangOptions().NoExtensions) {
PP.Diag(Loc, diag::ext_nonstandard_escape,
std::string()+(char)ResultChar);
break;
}
// FALL THROUGH.
default:
if (isgraph(ThisTokBuf[0])) {
PP.Diag(Loc, diag::ext_unknown_escape, std::string()+(char)ResultChar);
} else {
PP.Diag(Loc, diag::ext_unknown_escape, "x"+llvm::utohexstr(ResultChar));
}
break;
}
return ResultChar;
}
/// integer-constant: [C99 6.4.4.1]
/// decimal-constant integer-suffix
/// octal-constant integer-suffix
/// hexadecimal-constant integer-suffix
/// decimal-constant:
/// nonzero-digit
/// decimal-constant digit
/// octal-constant:
/// 0
/// octal-constant octal-digit
/// hexadecimal-constant:
/// hexadecimal-prefix hexadecimal-digit
/// hexadecimal-constant hexadecimal-digit
/// hexadecimal-prefix: one of
/// 0x 0X
/// integer-suffix:
/// unsigned-suffix [long-suffix]
/// unsigned-suffix [long-long-suffix]
/// long-suffix [unsigned-suffix]
/// long-long-suffix [unsigned-sufix]
/// nonzero-digit:
/// 1 2 3 4 5 6 7 8 9
/// octal-digit:
/// 0 1 2 3 4 5 6 7
/// hexadecimal-digit:
/// 0 1 2 3 4 5 6 7 8 9
/// a b c d e f
/// A B C D E F
/// unsigned-suffix: one of
/// u U
/// long-suffix: one of
/// l L
/// long-long-suffix: one of
/// ll LL
///
/// floating-constant: [C99 6.4.4.2]
/// TODO: add rules...
///
NumericLiteralParser::
NumericLiteralParser(const char *begin, const char *end,
SourceLocation TokLoc, Preprocessor &pp)
: PP(pp), ThisTokBegin(begin), ThisTokEnd(end) {
s = DigitsBegin = begin;
saw_exponent = false;
saw_period = false;
isLong = false;
isUnsigned = false;
isLongLong = false;
isFloat = false;
isImaginary = false;
hadError = false;
if (*s == '0') { // parse radix
s++;
if ((*s == 'x' || *s == 'X') && (isxdigit(s[1]) || s[1] == '.')) {
s++;
radix = 16;
DigitsBegin = s;
s = SkipHexDigits(s);
if (s == ThisTokEnd) {
// Done.
} else if (*s == '.') {
s++;
saw_period = true;
s = SkipHexDigits(s);
}
// A binary exponent can appear with or with a '.'. If dotted, the
// binary exponent is required.
if (*s == 'p' || *s == 'P') {
s++;
saw_exponent = true;
if (*s == '+' || *s == '-') s++; // sign
const char *first_non_digit = SkipDigits(s);
if (first_non_digit == s) {
Diag(TokLoc, diag::err_exponent_has_no_digits);
return;
} else {
s = first_non_digit;
}
} else if (saw_period) {
Diag(TokLoc, diag::err_hexconstant_requires_exponent);
return;
}
} else if (*s == 'b' || *s == 'B') {
// 0b101010 is a GCC extension.
++s;
radix = 2;
DigitsBegin = s;
s = SkipBinaryDigits(s);
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s)) {
Diag(TokLoc, diag::err_invalid_binary_digit, std::string(s, s+1));
return;
}
PP.Diag(TokLoc, diag::ext_binary_literal);
} else {
// For now, the radix is set to 8. If we discover that we have a
// floating point constant, the radix will change to 10. Octal floating
// point constants are not permitted (only decimal and hexadecimal).
radix = 8;
DigitsBegin = s;
s = SkipOctalDigits(s);
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s)) {
TokLoc = PP.AdvanceToTokenCharacter(TokLoc, s-begin);
Diag(TokLoc, diag::err_invalid_octal_digit, std::string(s, s+1));
return;
} else if (*s == '.') {
s++;
radix = 10;
saw_period = true;
s = SkipDigits(s);
}
if (*s == 'e' || *s == 'E') { // exponent
s++;
radix = 10;
saw_exponent = true;
if (*s == '+' || *s == '-') s++; // sign
const char *first_non_digit = SkipDigits(s);
if (first_non_digit == s) {
Diag(TokLoc, diag::err_exponent_has_no_digits);
return;
} else {
s = first_non_digit;
}
}
}
} else { // the first digit is non-zero
radix = 10;
s = SkipDigits(s);
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s)) {
Diag(TokLoc, diag::err_invalid_decimal_digit, std::string(s, s+1));
return;
} else if (*s == '.') {
s++;
saw_period = true;
s = SkipDigits(s);
}
if (*s == 'e' || *s == 'E') { // exponent
s++;
saw_exponent = true;
if (*s == '+' || *s == '-') s++; // sign
const char *first_non_digit = SkipDigits(s);
if (first_non_digit == s) {
Diag(TokLoc, diag::err_exponent_has_no_digits);
return;
} else {
s = first_non_digit;
}
}
}
SuffixBegin = s;
// Parse the suffix. At this point we can classify whether we have an FP or
// integer constant.
bool isFPConstant = isFloatingLiteral();
// Loop over all of the characters of the suffix. If we see something bad,
// we break out of the loop.
for (; s != ThisTokEnd; ++s) {
switch (*s) {
case 'f': // FP Suffix for "float"
case 'F':
if (!isFPConstant) break; // Error for integer constant.
if (isFloat || isLong) break; // FF, LF invalid.
isFloat = true;
continue; // Success.
case 'u':
case 'U':
if (isFPConstant) break; // Error for floating constant.
if (isUnsigned) break; // Cannot be repeated.
isUnsigned = true;
continue; // Success.
case 'l':
case 'L':
if (isLong || isLongLong) break; // Cannot be repeated.
if (isFloat) break; // LF invalid.
// Check for long long. The L's need to be adjacent and the same case.
if (s+1 != ThisTokEnd && s[1] == s[0]) {
if (isFPConstant) break; // long long invalid for floats.
isLongLong = true;
++s; // Eat both of them.
} else {
isLong = true;
}
continue; // Success.
case 'i':
case 'I':
case 'j':
case 'J':
if (isImaginary) break; // Cannot be repeated.
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin),
diag::ext_imaginary_constant);
isImaginary = true;
continue; // Success.
}
// If we reached here, there was an error.
break;
}
// Report an error if there are any.
if (s != ThisTokEnd) {
TokLoc = PP.AdvanceToTokenCharacter(TokLoc, s-begin);
Diag(TokLoc, isFPConstant ? diag::err_invalid_suffix_float_constant :
diag::err_invalid_suffix_integer_constant,
std::string(SuffixBegin, ThisTokEnd));
return;
}
}
/// GetIntegerValue - Convert this numeric literal value to an APInt that
/// matches Val's input width. If there is an overflow, set Val to the low bits
/// of the result and return true. Otherwise, return false.
bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) {
Val = 0;
s = DigitsBegin;
llvm::APInt RadixVal(Val.getBitWidth(), radix);
llvm::APInt CharVal(Val.getBitWidth(), 0);
llvm::APInt OldVal = Val;
bool OverflowOccurred = false;
while (s < SuffixBegin) {
unsigned C = HexDigitValue(*s++);
// If this letter is out of bound for this radix, reject it.
assert(C < radix && "NumericLiteralParser ctor should have rejected this");
CharVal = C;
// Add the digit to the value in the appropriate radix. If adding in digits
// made the value smaller, then this overflowed.
OldVal = Val;
// Multiply by radix, did overflow occur on the multiply?
Val *= RadixVal;
OverflowOccurred |= Val.udiv(RadixVal) != OldVal;
OldVal = Val;
// Add value, did overflow occur on the value?
Val += CharVal;
OverflowOccurred |= Val.ult(OldVal);
OverflowOccurred |= Val.ult(CharVal);
}
return OverflowOccurred;
}
// GetFloatValue - Poor man's floatvalue (FIXME).
float NumericLiteralParser::GetFloatValue() {
char floatChars[256];
strncpy(floatChars, ThisTokBegin, ThisTokEnd-ThisTokBegin);
floatChars[ThisTokEnd-ThisTokBegin] = '\0';
return (float)strtod(floatChars, 0);
}
void NumericLiteralParser::Diag(SourceLocation Loc, unsigned DiagID,
const std::string &M) {
PP.Diag(Loc, DiagID, M);
hadError = true;
}
CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
SourceLocation Loc, Preprocessor &PP) {
// At this point we know that the character matches the regex "L?'.*'".
HadError = false;
Value = 0;
// Determine if this is a wide character.
IsWide = begin[0] == 'L';
if (IsWide) ++begin;
// Skip over the entry quote.
assert(begin[0] == '\'' && "Invalid token lexed");
++begin;
// FIXME: This assumes that 'int' is 32-bits in overflow calculation, and the
// size of "value".
assert(PP.getTargetInfo().getIntWidth(Loc) == 32 &&
"Assumes sizeof(int) == 4 for now");
// FIXME: This assumes that wchar_t is 32-bits for now.
assert(PP.getTargetInfo().getWCharWidth(Loc) == 32 &&
"Assumes sizeof(wchar_t) == 4 for now");
// FIXME: This extensively assumes that 'char' is 8-bits.
assert(PP.getTargetInfo().getCharWidth(Loc) == 8 &&
"Assumes char is 8 bits");
bool isFirstChar = true;
bool isMultiChar = false;
while (begin[0] != '\'') {
unsigned ResultChar;
if (begin[0] != '\\') // If this is a normal character, consume it.
ResultChar = *begin++;
else // Otherwise, this is an escape character.
ResultChar = ProcessCharEscape(begin, end, HadError, Loc, IsWide, PP);
// If this is a multi-character constant (e.g. 'abc'), handle it. These are
// implementation defined (C99 6.4.4.4p10).
if (!isFirstChar) {
// If this is the second character being processed, do special handling.
if (!isMultiChar) {
isMultiChar = true;
// Warn about discarding the top bits for multi-char wide-character
// constants (L'abcd').
if (IsWide)
PP.Diag(Loc, diag::warn_extraneous_wide_char_constant);
}
if (IsWide) {
// Emulate GCC's (unintentional?) behavior: L'ab' -> L'b'.
Value = 0;
} else {
// Narrow character literals act as though their value is concatenated
// in this implementation.
if (((Value << 8) >> 8) != Value)
PP.Diag(Loc, diag::warn_char_constant_too_large);
Value <<= 8;
}
}
Value += ResultChar;
isFirstChar = false;
}
// If this is a single narrow character, sign extend it (e.g. '\xFF' is "-1")
// if 'char' is signed for this target (C99 6.4.4.4p10). Note that multiple
// character constants are not sign extended in the this implementation:
// '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC.
if (!IsWide && !isMultiChar && (Value & 128) &&
PP.getTargetInfo().isCharSigned(Loc))
Value = (signed char)Value;
}
/// string-literal: [C99 6.4.5]
/// " [s-char-sequence] "
/// L" [s-char-sequence] "
/// s-char-sequence:
/// s-char
/// s-char-sequence s-char
/// s-char:
/// any source character except the double quote ",
/// backslash \, or newline character
/// escape-character
/// universal-character-name
/// escape-character: [C99 6.4.4.4]
/// \ escape-code
/// universal-character-name
/// escape-code:
/// character-escape-code
/// octal-escape-code
/// hex-escape-code
/// character-escape-code: one of
/// n t b r f v a
/// \ ' " ?
/// octal-escape-code:
/// octal-digit
/// octal-digit octal-digit
/// octal-digit octal-digit octal-digit
/// hex-escape-code:
/// x hex-digit
/// hex-escape-code hex-digit
/// universal-character-name:
/// \u hex-quad
/// \U hex-quad hex-quad
/// hex-quad:
/// hex-digit hex-digit hex-digit hex-digit
///
StringLiteralParser::
StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
Preprocessor &pp, TargetInfo &t)
: PP(pp), Target(t) {
// Scan all of the string portions, remember the max individual token length,
// computing a bound on the concatenated string length, and see whether any
// piece is a wide-string. If any of the string portions is a wide-string
// literal, the result is a wide-string literal [C99 6.4.5p4].
MaxTokenLength = StringToks[0].getLength();
SizeBound = StringToks[0].getLength()-2; // -2 for "".
AnyWide = StringToks[0].getKind() == tok::wide_string_literal;
hadError = false;
// Implement Translation Phase #6: concatenation of string literals
/// (C99 5.1.1.2p1). The common case is only one string fragment.
for (unsigned i = 1; i != NumStringToks; ++i) {
// The string could be shorter than this if it needs cleaning, but this is a
// reasonable bound, which is all we need.
SizeBound += StringToks[i].getLength()-2; // -2 for "".
// Remember maximum string piece length.
if (StringToks[i].getLength() > MaxTokenLength)
MaxTokenLength = StringToks[i].getLength();
// Remember if we see any wide strings.
AnyWide |= StringToks[i].getKind() == tok::wide_string_literal;
}
// Include space for the null terminator.
++SizeBound;
// TODO: K&R warning: "traditional C rejects string constant concatenation"
// Get the width in bytes of wchar_t. If no wchar_t strings are used, do not
// query the target. As such, wchar_tByteWidth is only valid if AnyWide=true.
wchar_tByteWidth = ~0U;
if (AnyWide) {
wchar_tByteWidth = Target.getWCharWidth(StringToks[0].getLocation());
assert((wchar_tByteWidth & 7) == 0 && "Assumes wchar_t is byte multiple!");
wchar_tByteWidth /= 8;
}
// The output buffer size needs to be large enough to hold wide characters.
// This is a worst-case assumption which basically corresponds to L"" "long".
if (AnyWide)
SizeBound *= wchar_tByteWidth;
// Size the temporary buffer to hold the result string data.
ResultBuf.resize(SizeBound);
// Likewise, but for each string piece.
llvm::SmallString<512> TokenBuf;
TokenBuf.resize(MaxTokenLength);
// Loop over all the strings, getting their spelling, and expanding them to
// wide strings as appropriate.
ResultPtr = &ResultBuf[0]; // Next byte to fill in.
for (unsigned i = 0, e = NumStringToks; i != e; ++i) {
const char *ThisTokBuf = &TokenBuf[0];
// Get the spelling of the token, which eliminates trigraphs, etc. We know
// that ThisTokBuf points to a buffer that is big enough for the whole token
// and 'spelled' tokens can only shrink.
unsigned ThisTokLen = PP.getSpelling(StringToks[i], ThisTokBuf);
const char *ThisTokEnd = ThisTokBuf+ThisTokLen-1; // Skip end quote.
// TODO: Input character set mapping support.
// Skip L marker for wide strings.
bool ThisIsWide = false;
if (ThisTokBuf[0] == 'L') {
++ThisTokBuf;
ThisIsWide = true;
}
assert(ThisTokBuf[0] == '"' && "Expected quote, lexer broken?");
++ThisTokBuf;
while (ThisTokBuf != ThisTokEnd) {
// Is this a span of non-escape characters?
if (ThisTokBuf[0] != '\\') {
const char *InStart = ThisTokBuf;
do {
++ThisTokBuf;
} while (ThisTokBuf != ThisTokEnd && ThisTokBuf[0] != '\\');
// Copy the character span over.
unsigned Len = ThisTokBuf-InStart;
if (!AnyWide) {
memcpy(ResultPtr, InStart, Len);
ResultPtr += Len;
} else {
// Note: our internal rep of wide char tokens is always little-endian.
for (; Len; --Len, ++InStart) {
*ResultPtr++ = InStart[0];
// Add zeros at the end.
for (unsigned i = 1, e = wchar_tByteWidth; i != e; ++i)
*ResultPtr++ = 0;
}
}
continue;
}
// Otherwise, this is an escape character. Process it.
unsigned ResultChar = ProcessCharEscape(ThisTokBuf, ThisTokEnd, hadError,
StringToks[i].getLocation(),
ThisIsWide, PP);
// Note: our internal rep of wide char tokens is always little-endian.
*ResultPtr++ = ResultChar & 0xFF;
if (AnyWide) {
for (unsigned i = 1, e = wchar_tByteWidth; i != e; ++i)
*ResultPtr++ = ResultChar >> i*8;
}
}
}
// Add zero terminator.
*ResultPtr = 0;
if (AnyWide) {
for (unsigned i = 1, e = wchar_tByteWidth; i != e; ++i)
*ResultPtr++ = 0;
}
}

View File

@@ -1,647 +0,0 @@
//===--- MacroExpander.cpp - Lex from a macro expansion -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the MacroExpander interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/MacroExpander.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;
//===----------------------------------------------------------------------===//
// MacroArgs Implementation
//===----------------------------------------------------------------------===//
/// MacroArgs ctor function - This destroys the vector passed in.
MacroArgs *MacroArgs::create(const MacroInfo *MI,
const Token *UnexpArgTokens,
unsigned NumToks, bool VarargsElided) {
assert(MI->isFunctionLike() &&
"Can't have args for an object-like macro!");
// Allocate memory for the MacroArgs object with the lexer tokens at the end.
MacroArgs *Result = (MacroArgs*)malloc(sizeof(MacroArgs) +
NumToks*sizeof(Token));
// Construct the macroargs object.
new (Result) MacroArgs(NumToks, VarargsElided);
// Copy the actual unexpanded tokens to immediately after the result ptr.
if (NumToks)
memcpy(const_cast<Token*>(Result->getUnexpArgument(0)),
UnexpArgTokens, NumToks*sizeof(Token));
return Result;
}
/// destroy - Destroy and deallocate the memory for this object.
///
void MacroArgs::destroy() {
// Run the dtor to deallocate the vectors.
this->~MacroArgs();
// Release the memory for the object.
free(this);
}
/// getArgLength - Given a pointer to an expanded or unexpanded argument,
/// return the number of tokens, not counting the EOF, that make up the
/// argument.
unsigned MacroArgs::getArgLength(const Token *ArgPtr) {
unsigned NumArgTokens = 0;
for (; ArgPtr->getKind() != tok::eof; ++ArgPtr)
++NumArgTokens;
return NumArgTokens;
}
/// getUnexpArgument - Return the unexpanded tokens for the specified formal.
///
const Token *MacroArgs::getUnexpArgument(unsigned Arg) const {
// The unexpanded argument tokens start immediately after the MacroArgs object
// in memory.
const Token *Start = (const Token *)(this+1);
const Token *Result = Start;
// Scan to find Arg.
for (; Arg; ++Result) {
assert(Result < Start+NumUnexpArgTokens && "Invalid arg #");
if (Result->getKind() == tok::eof)
--Arg;
}
return Result;
}
/// ArgNeedsPreexpansion - If we can prove that the argument won't be affected
/// by pre-expansion, return false. Otherwise, conservatively return true.
bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok) const {
// If there are no identifiers in the argument list, or if the identifiers are
// known to not be macros, pre-expansion won't modify it.
for (; ArgTok->getKind() != tok::eof; ++ArgTok)
if (IdentifierInfo *II = ArgTok->getIdentifierInfo()) {
if (II->getMacroInfo() && II->getMacroInfo()->isEnabled())
// Return true even though the macro could be a function-like macro
// without a following '(' token.
return true;
}
return false;
}
/// getPreExpArgument - Return the pre-expanded form of the specified
/// argument.
const std::vector<Token> &
MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) {
assert(Arg < NumUnexpArgTokens && "Invalid argument number!");
// If we have already computed this, return it.
if (PreExpArgTokens.empty())
PreExpArgTokens.resize(NumUnexpArgTokens);
std::vector<Token> &Result = PreExpArgTokens[Arg];
if (!Result.empty()) return Result;
const Token *AT = getUnexpArgument(Arg);
unsigned NumToks = getArgLength(AT)+1; // Include the EOF.
// Otherwise, we have to pre-expand this argument, populating Result. To do
// this, we set up a fake MacroExpander to lex from the unexpanded argument
// list. With this installed, we lex expanded tokens until we hit the EOF
// token at the end of the unexp list.
PP.EnterTokenStream(AT, NumToks);
// Lex all of the macro-expanded tokens into Result.
do {
Result.push_back(Token());
PP.Lex(Result.back());
} while (Result.back().getKind() != tok::eof);
// Pop the token stream off the top of the stack. We know that the internal
// pointer inside of it is to the "end" of the token stream, but the stack
// will not otherwise be popped until the next token is lexed. The problem is
// that the token may be lexed sometime after the vector of tokens itself is
// destroyed, which would be badness.
PP.RemoveTopOfLexerStack();
return Result;
}
/// StringifyArgument - Implement C99 6.10.3.2p2, converting a sequence of
/// tokens into the literal string token that should be produced by the C #
/// preprocessor operator.
///
static Token StringifyArgument(const Token *ArgToks,
Preprocessor &PP, bool Charify = false) {
Token Tok;
Tok.startToken();
Tok.setKind(tok::string_literal);
const Token *ArgTokStart = ArgToks;
// Stringify all the tokens.
std::string Result = "\"";
// FIXME: Optimize this loop to not use std::strings.
bool isFirst = true;
for (; ArgToks->getKind() != tok::eof; ++ArgToks) {
const Token &Tok = *ArgToks;
if (!isFirst && (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()))
Result += ' ';
isFirst = false;
// If this is a string or character constant, escape the token as specified
// by 6.10.3.2p2.
if (Tok.getKind() == tok::string_literal || // "foo"
Tok.getKind() == tok::wide_string_literal || // L"foo"
Tok.getKind() == tok::char_constant) { // 'x' and L'x'.
Result += Lexer::Stringify(PP.getSpelling(Tok));
} else {
// Otherwise, just append the token.
Result += PP.getSpelling(Tok);
}
}
// If the last character of the string is a \, and if it isn't escaped, this
// is an invalid string literal, diagnose it as specified in C99.
if (Result[Result.size()-1] == '\\') {
// Count the number of consequtive \ characters. If even, then they are
// just escaped backslashes, otherwise it's an error.
unsigned FirstNonSlash = Result.size()-2;
// Guaranteed to find the starting " if nothing else.
while (Result[FirstNonSlash] == '\\')
--FirstNonSlash;
if ((Result.size()-1-FirstNonSlash) & 1) {
// Diagnose errors for things like: #define F(X) #X / F(\)
PP.Diag(ArgToks[-1], diag::pp_invalid_string_literal);
Result.erase(Result.end()-1); // remove one of the \'s.
}
}
Result += '"';
// If this is the charify operation and the result is not a legal character
// constant, diagnose it.
if (Charify) {
// First step, turn double quotes into single quotes:
Result[0] = '\'';
Result[Result.size()-1] = '\'';
// Check for bogus character.
bool isBad = false;
if (Result.size() == 3) {
isBad = Result[1] == '\''; // ''' is not legal. '\' already fixed above.
} else {
isBad = (Result.size() != 4 || Result[1] != '\\'); // Not '\x'
}
if (isBad) {
PP.Diag(ArgTokStart[0], diag::err_invalid_character_to_charify);
Result = "' '"; // Use something arbitrary, but legal.
}
}
Tok.setLength(Result.size());
Tok.setLocation(PP.CreateString(&Result[0], Result.size()));
return Tok;
}
/// getStringifiedArgument - Compute, cache, and return the specified argument
/// that has been 'stringified' as required by the # operator.
const Token &MacroArgs::getStringifiedArgument(unsigned ArgNo,
Preprocessor &PP) {
assert(ArgNo < NumUnexpArgTokens && "Invalid argument number!");
if (StringifiedArgs.empty()) {
StringifiedArgs.resize(getNumArguments());
memset(&StringifiedArgs[0], 0,
sizeof(StringifiedArgs[0])*getNumArguments());
}
if (StringifiedArgs[ArgNo].getKind() != tok::string_literal)
StringifiedArgs[ArgNo] = StringifyArgument(getUnexpArgument(ArgNo), PP);
return StringifiedArgs[ArgNo];
}
//===----------------------------------------------------------------------===//
// MacroExpander Implementation
//===----------------------------------------------------------------------===//
/// Create a macro expander for the specified macro with the specified actual
/// arguments. Note that this ctor takes ownership of the ActualArgs pointer.
void MacroExpander::Init(Token &Tok, MacroArgs *Actuals) {
// If the client is reusing a macro expander, make sure to free any memory
// associated with it.
destroy();
Macro = Tok.getIdentifierInfo()->getMacroInfo();
ActualArgs = Actuals;
CurToken = 0;
InstantiateLoc = Tok.getLocation();
AtStartOfLine = Tok.isAtStartOfLine();
HasLeadingSpace = Tok.hasLeadingSpace();
MacroTokens = &*Macro->tokens_begin();
OwnsMacroTokens = false;
NumMacroTokens = Macro->tokens_end()-Macro->tokens_begin();
// If this is a function-like macro, expand the arguments and change
// MacroTokens to point to the expanded tokens.
if (Macro->isFunctionLike() && Macro->getNumArgs())
ExpandFunctionArguments();
// Mark the macro as currently disabled, so that it is not recursively
// expanded. The macro must be disabled only after argument pre-expansion of
// function-like macro arguments occurs.
Macro->DisableMacro();
}
/// Create a macro expander for the specified token stream. This does not
/// take ownership of the specified token vector.
void MacroExpander::Init(const Token *TokArray, unsigned NumToks) {
// If the client is reusing a macro expander, make sure to free any memory
// associated with it.
destroy();
Macro = 0;
ActualArgs = 0;
MacroTokens = TokArray;
OwnsMacroTokens = false;
NumMacroTokens = NumToks;
CurToken = 0;
InstantiateLoc = SourceLocation();
AtStartOfLine = false;
HasLeadingSpace = false;
// Set HasLeadingSpace/AtStartOfLine so that the first token will be
// returned unmodified.
if (NumToks != 0) {
AtStartOfLine = TokArray[0].isAtStartOfLine();
HasLeadingSpace = TokArray[0].hasLeadingSpace();
}
}
void MacroExpander::destroy() {
// If this was a function-like macro that actually uses its arguments, delete
// the expanded tokens.
if (OwnsMacroTokens) {
delete [] MacroTokens;
MacroTokens = 0;
}
// MacroExpander owns its formal arguments.
if (ActualArgs) ActualArgs->destroy();
}
/// Expand the arguments of a function-like macro so that we can quickly
/// return preexpanded tokens from MacroTokens.
void MacroExpander::ExpandFunctionArguments() {
llvm::SmallVector<Token, 128> ResultToks;
// Loop through the MacroTokens tokens, expanding them into ResultToks. Keep
// track of whether we change anything. If not, no need to keep them. If so,
// we install the newly expanded sequence as MacroTokens.
bool MadeChange = false;
// NextTokGetsSpace - When this is true, the next token appended to the
// output list will get a leading space, regardless of whether it had one to
// begin with or not. This is used for placemarker support.
bool NextTokGetsSpace = false;
for (unsigned i = 0, e = NumMacroTokens; i != e; ++i) {
// If we found the stringify operator, get the argument stringified. The
// preprocessor already verified that the following token is a macro name
// when the #define was parsed.
const Token &CurTok = MacroTokens[i];
if (CurTok.getKind() == tok::hash || CurTok.getKind() == tok::hashat) {
int ArgNo = Macro->getArgumentNum(MacroTokens[i+1].getIdentifierInfo());
assert(ArgNo != -1 && "Token following # is not an argument?");
Token Res;
if (CurTok.getKind() == tok::hash) // Stringify
Res = ActualArgs->getStringifiedArgument(ArgNo, PP);
else {
// 'charify': don't bother caching these.
Res = StringifyArgument(ActualArgs->getUnexpArgument(ArgNo), PP, true);
}
// The stringified/charified string leading space flag gets set to match
// the #/#@ operator.
if (CurTok.hasLeadingSpace() || NextTokGetsSpace)
Res.setFlag(Token::LeadingSpace);
ResultToks.push_back(Res);
MadeChange = true;
++i; // Skip arg name.
NextTokGetsSpace = false;
continue;
}
// Otherwise, if this is not an argument token, just add the token to the
// output buffer.
IdentifierInfo *II = CurTok.getIdentifierInfo();
int ArgNo = II ? Macro->getArgumentNum(II) : -1;
if (ArgNo == -1) {
// This isn't an argument, just add it.
ResultToks.push_back(CurTok);
if (NextTokGetsSpace) {
ResultToks.back().setFlag(Token::LeadingSpace);
NextTokGetsSpace = false;
}
continue;
}
// An argument is expanded somehow, the result is different than the
// input.
MadeChange = true;
// Otherwise, this is a use of the argument. Find out if there is a paste
// (##) operator before or after the argument.
bool PasteBefore =
!ResultToks.empty() && ResultToks.back().getKind() == tok::hashhash;
bool PasteAfter = i+1 != e && MacroTokens[i+1].getKind() == tok::hashhash;
// If it is not the LHS/RHS of a ## operator, we must pre-expand the
// argument and substitute the expanded tokens into the result. This is
// C99 6.10.3.1p1.
if (!PasteBefore && !PasteAfter) {
const Token *ResultArgToks;
// Only preexpand the argument if it could possibly need it. This
// avoids some work in common cases.
const Token *ArgTok = ActualArgs->getUnexpArgument(ArgNo);
if (ActualArgs->ArgNeedsPreexpansion(ArgTok))
ResultArgToks = &ActualArgs->getPreExpArgument(ArgNo, PP)[0];
else
ResultArgToks = ArgTok; // Use non-preexpanded tokens.
// If the arg token expanded into anything, append it.
if (ResultArgToks->getKind() != tok::eof) {
unsigned FirstResult = ResultToks.size();
unsigned NumToks = MacroArgs::getArgLength(ResultArgToks);
ResultToks.append(ResultArgToks, ResultArgToks+NumToks);
// If any tokens were substituted from the argument, the whitespace
// before the first token should match the whitespace of the arg
// identifier.
ResultToks[FirstResult].setFlagValue(Token::LeadingSpace,
CurTok.hasLeadingSpace() ||
NextTokGetsSpace);
NextTokGetsSpace = false;
} else {
// If this is an empty argument, and if there was whitespace before the
// formal token, make sure the next token gets whitespace before it.
NextTokGetsSpace = CurTok.hasLeadingSpace();
}
continue;
}
// Okay, we have a token that is either the LHS or RHS of a paste (##)
// argument. It gets substituted as its non-pre-expanded tokens.
const Token *ArgToks = ActualArgs->getUnexpArgument(ArgNo);
unsigned NumToks = MacroArgs::getArgLength(ArgToks);
if (NumToks) { // Not an empty argument?
ResultToks.append(ArgToks, ArgToks+NumToks);
// If the next token was supposed to get leading whitespace, ensure it has
// it now.
if (NextTokGetsSpace) {
ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace);
NextTokGetsSpace = false;
}
continue;
}
// If an empty argument is on the LHS or RHS of a paste, the standard (C99
// 6.10.3.3p2,3) calls for a bunch of placemarker stuff to occur. We
// implement this by eating ## operators when a LHS or RHS expands to
// empty.
NextTokGetsSpace |= CurTok.hasLeadingSpace();
if (PasteAfter) {
// Discard the argument token and skip (don't copy to the expansion
// buffer) the paste operator after it.
NextTokGetsSpace |= MacroTokens[i+1].hasLeadingSpace();
++i;
continue;
}
// If this is on the RHS of a paste operator, we've already copied the
// paste operator to the ResultToks list. Remove it.
assert(PasteBefore && ResultToks.back().getKind() == tok::hashhash);
NextTokGetsSpace |= ResultToks.back().hasLeadingSpace();
ResultToks.pop_back();
// If this is the __VA_ARGS__ token, and if the argument wasn't provided,
// and if the macro had at least one real argument, and if the token before
// the ## was a comma, remove the comma.
if ((unsigned)ArgNo == Macro->getNumArgs()-1 && // is __VA_ARGS__
ActualArgs->isVarargsElidedUse() && // Argument elided.
!ResultToks.empty() && ResultToks.back().getKind() == tok::comma) {
// Never add a space, even if the comma, ##, or arg had a space.
NextTokGetsSpace = false;
ResultToks.pop_back();
}
continue;
}
// If anything changed, install this as the new MacroTokens list.
if (MadeChange) {
// This is deleted in the dtor.
NumMacroTokens = ResultToks.size();
Token *Res = new Token[ResultToks.size()];
if (NumMacroTokens)
memcpy(Res, &ResultToks[0], NumMacroTokens*sizeof(Token));
MacroTokens = Res;
OwnsMacroTokens = true;
}
}
/// Lex - Lex and return a token from this macro stream.
///
void MacroExpander::Lex(Token &Tok) {
// Lexing off the end of the macro, pop this macro off the expansion stack.
if (isAtEnd()) {
// If this is a macro (not a token stream), mark the macro enabled now
// that it is no longer being expanded.
if (Macro) Macro->EnableMacro();
// Pop this context off the preprocessors lexer stack and get the next
// token. This will delete "this" so remember the PP instance var.
Preprocessor &PPCache = PP;
if (PP.HandleEndOfMacro(Tok))
return;
// HandleEndOfMacro may not return a token. If it doesn't, lex whatever is
// next.
return PPCache.Lex(Tok);
}
// If this is the first token of the expanded result, we inherit spacing
// properties later.
bool isFirstToken = CurToken == 0;
// Get the next token to return.
Tok = MacroTokens[CurToken++];
// If this token is followed by a token paste (##) operator, paste the tokens!
if (!isAtEnd() && MacroTokens[CurToken].getKind() == tok::hashhash)
PasteTokens(Tok);
// The token's current location indicate where the token was lexed from. We
// need this information to compute the spelling of the token, but any
// diagnostics for the expanded token should appear as if they came from
// InstantiationLoc. Pull this information together into a new SourceLocation
// that captures all of this.
if (InstantiateLoc.isValid()) { // Don't do this for token streams.
SourceManager &SrcMgr = PP.getSourceManager();
Tok.setLocation(SrcMgr.getInstantiationLoc(Tok.getLocation(),
InstantiateLoc));
}
// If this is the first token, set the lexical properties of the token to
// match the lexical properties of the macro identifier.
if (isFirstToken) {
Tok.setFlagValue(Token::StartOfLine , AtStartOfLine);
Tok.setFlagValue(Token::LeadingSpace, HasLeadingSpace);
}
// Handle recursive expansion!
if (Tok.getIdentifierInfo())
return PP.HandleIdentifier(Tok);
// Otherwise, return a normal token.
}
/// PasteTokens - Tok is the LHS of a ## operator, and CurToken is the ##
/// operator. Read the ## and RHS, and paste the LHS/RHS together. If there
/// are is another ## after it, chomp it iteratively. Return the result as Tok.
void MacroExpander::PasteTokens(Token &Tok) {
llvm::SmallVector<char, 128> Buffer;
do {
// Consume the ## operator.
SourceLocation PasteOpLoc = MacroTokens[CurToken].getLocation();
++CurToken;
assert(!isAtEnd() && "No token on the RHS of a paste operator!");
// Get the RHS token.
const Token &RHS = MacroTokens[CurToken];
bool isInvalid = false;
// Allocate space for the result token. This is guaranteed to be enough for
// the two tokens and a null terminator.
Buffer.resize(Tok.getLength() + RHS.getLength() + 1);
// Get the spelling of the LHS token in Buffer.
const char *BufPtr = &Buffer[0];
unsigned LHSLen = PP.getSpelling(Tok, BufPtr);
if (BufPtr != &Buffer[0]) // Really, we want the chars in Buffer!
memcpy(&Buffer[0], BufPtr, LHSLen);
BufPtr = &Buffer[LHSLen];
unsigned RHSLen = PP.getSpelling(RHS, BufPtr);
if (BufPtr != &Buffer[LHSLen]) // Really, we want the chars in Buffer!
memcpy(&Buffer[LHSLen], BufPtr, RHSLen);
// Add null terminator.
Buffer[LHSLen+RHSLen] = '\0';
// Trim excess space.
Buffer.resize(LHSLen+RHSLen+1);
// Plop the pasted result (including the trailing newline and null) into a
// scratch buffer where we can lex it.
SourceLocation ResultTokLoc = PP.CreateString(&Buffer[0], Buffer.size());
// Lex the resultant pasted token into Result.
Token Result;
// Avoid testing /*, as the lexer would think it is the start of a comment
// and emit an error that it is unterminated.
if (Tok.getKind() == tok::slash && RHS.getKind() == tok::star) {
isInvalid = true;
} else if (Tok.getKind() == tok::identifier &&
RHS.getKind() == tok::identifier) {
// Common paste case: identifier+identifier = identifier. Avoid creating
// a lexer and other overhead.
PP.IncrementPasteCounter(true);
Result.startToken();
Result.setKind(tok::identifier);
Result.setLocation(ResultTokLoc);
Result.setLength(LHSLen+RHSLen);
} else {
PP.IncrementPasteCounter(false);
// Make a lexer to lex this string from.
SourceManager &SourceMgr = PP.getSourceManager();
const char *ResultStrData = SourceMgr.getCharacterData(ResultTokLoc);
// Make a lexer object so that we lex and expand the paste result.
Lexer *TL = new Lexer(ResultTokLoc, PP, ResultStrData,
ResultStrData+LHSLen+RHSLen /*don't include null*/);
// Lex a token in raw mode. This way it won't look up identifiers
// automatically, lexing off the end will return an eof token, and
// warnings are disabled. This returns true if the result token is the
// entire buffer.
bool IsComplete = TL->LexRawToken(Result);
// If we got an EOF token, we didn't form even ONE token. For example, we
// did "/ ## /" to get "//".
IsComplete &= Result.getKind() != tok::eof;
isInvalid = !IsComplete;
// We're now done with the temporary lexer.
delete TL;
}
// If pasting the two tokens didn't form a full new token, this is an error.
// This occurs with "x ## +" and other stuff. Return with Tok unmodified
// and with RHS as the next token to lex.
if (isInvalid) {
// If not in assembler language mode.
PP.Diag(PasteOpLoc, diag::err_pp_bad_paste,
std::string(Buffer.begin(), Buffer.end()-1));
return;
}
// Turn ## into 'other' to avoid # ## # from looking like a paste operator.
if (Result.getKind() == tok::hashhash)
Result.setKind(tok::unknown);
// FIXME: Turn __VARRGS__ into "not a token"?
// Transfer properties of the LHS over the the Result.
Result.setFlagValue(Token::StartOfLine , Tok.isAtStartOfLine());
Result.setFlagValue(Token::LeadingSpace, Tok.hasLeadingSpace());
// Finally, replace LHS with the result, consume the RHS, and iterate.
++CurToken;
Tok = Result;
} while (!isAtEnd() && MacroTokens[CurToken].getKind() == tok::hashhash);
// Now that we got the result token, it will be subject to expansion. Since
// token pasting re-lexes the result token in raw mode, identifier information
// isn't looked up. As such, if the result is an identifier, look up id info.
if (Tok.getKind() == tok::identifier) {
// Look up the identifier info for the token. We disabled identifier lookup
// by saying we're skipping contents, so we need to do this manually.
Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok));
}
}
/// isNextTokenLParen - If the next token lexed will pop this macro off the
/// expansion stack, return 2. If the next unexpanded token is a '(', return
/// 1, otherwise return 0.
unsigned MacroExpander::isNextTokenLParen() const {
// Out of tokens?
if (isAtEnd())
return 2;
return MacroTokens[CurToken].getKind() == tok::l_paren;
}

View File

@@ -1,73 +0,0 @@
//===--- MacroInfo.cpp - Information about #defined identifiers -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the MacroInfo interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
using namespace clang;
MacroInfo::MacroInfo(SourceLocation DefLoc) : Location(DefLoc) {
IsFunctionLike = false;
IsC99Varargs = false;
IsGNUVarargs = false;
IsBuiltinMacro = false;
IsTargetSpecific = false;
IsDisabled = false;
IsUsed = true;
ArgumentList = 0;
NumArguments = 0;
}
/// isIdenticalTo - Return true if the specified macro definition is equal to
/// this macro in spelling, arguments, and whitespace. This is used to emit
/// duplicate definition warnings. This implements the rules in C99 6.10.3.
///
/// Note that this intentionally does not check isTargetSpecific for matching.
///
bool MacroInfo::isIdenticalTo(const MacroInfo &Other, Preprocessor &PP) const {
// Check # tokens in replacement, number of args, and various flags all match.
if (ReplacementTokens.size() != Other.ReplacementTokens.size() ||
getNumArgs() != Other.getNumArgs() ||
isFunctionLike() != Other.isFunctionLike() ||
isC99Varargs() != Other.isC99Varargs() ||
isGNUVarargs() != Other.isGNUVarargs())
return false;
// Check arguments.
for (arg_iterator I = arg_begin(), OI = Other.arg_begin(), E = arg_end();
I != E; ++I, ++OI)
if (*I != *OI) return false;
// Check all the tokens.
for (unsigned i = 0, e = ReplacementTokens.size(); i != e; ++i) {
const Token &A = ReplacementTokens[i];
const Token &B = Other.ReplacementTokens[i];
if (A.getKind() != B.getKind() ||
A.isAtStartOfLine() != B.isAtStartOfLine() ||
A.hasLeadingSpace() != B.hasLeadingSpace())
return false;
// If this is an identifier, it is easy.
if (A.getIdentifierInfo() || B.getIdentifierInfo()) {
if (A.getIdentifierInfo() != B.getIdentifierInfo())
return false;
continue;
}
// Otherwise, check the spelling.
if (PP.getSpelling(A) != PP.getSpelling(B))
return false;
}
return true;
}

View File

@@ -1,28 +0,0 @@
##===- clang/Lex/Makefile ----------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Chris Lattner and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements the Lexer library for the C-Language front-end.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
include $(LEVEL)/Makefile.config
LIBRARYNAME := clangLex
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
ifeq ($(ARCH),PowerPC)
CXXFLAGS += -maltivec
endif
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
include $(LEVEL)/Makefile.common

View File

@@ -1,659 +0,0 @@
//===--- PPExpressions.cpp - Preprocessor Expression Evaluation -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Preprocessor::EvaluateDirectiveExpression method,
// which parses and evaluates integer constant expressions for #if directives.
//
//===----------------------------------------------------------------------===//
//
// FIXME: implement testing for #assert's.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallString.h"
using namespace clang;
static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec,
Token &PeekTok, bool ValueLive,
Preprocessor &PP);
/// DefinedTracker - This struct is used while parsing expressions to keep track
/// of whether !defined(X) has been seen.
///
/// With this simple scheme, we handle the basic forms:
/// !defined(X) and !defined X
/// but we also trivially handle (silly) stuff like:
/// !!!defined(X) and +!defined(X) and !+!+!defined(X) and !(defined(X)).
struct DefinedTracker {
/// Each time a Value is evaluated, it returns information about whether the
/// parsed value is of the form defined(X), !defined(X) or is something else.
enum TrackerState {
DefinedMacro, // defined(X)
NotDefinedMacro, // !defined(X)
Unknown // Something else.
} State;
/// TheMacro - When the state is DefinedMacro or NotDefinedMacro, this
/// indicates the macro that was checked.
IdentifierInfo *TheMacro;
};
/// EvaluateValue - Evaluate the token PeekTok (and any others needed) and
/// return the computed value in Result. Return true if there was an error
/// parsing. This function also returns information about the form of the
/// expression in DT. See above for information on what DT means.
///
/// If ValueLive is false, then this value is being evaluated in a context where
/// the result is not used. As such, avoid diagnostics that relate to
/// evaluation.
static bool EvaluateValue(llvm::APSInt &Result, Token &PeekTok,
DefinedTracker &DT, bool ValueLive,
Preprocessor &PP) {
Result = 0;
DT.State = DefinedTracker::Unknown;
// If this token's spelling is a pp-identifier, check to see if it is
// 'defined' or if it is a macro. Note that we check here because many
// keywords are pp-identifiers, so we can't check the kind.
if (IdentifierInfo *II = PeekTok.getIdentifierInfo()) {
// If this identifier isn't 'defined' and it wasn't macro expanded, it turns
// into a simple 0, unless it is the C++ keyword "true", in which case it
// turns into "1".
if (II->getPPKeywordID() != tok::pp_defined) {
Result = II->getTokenID() == tok::kw_true;
Result.setIsUnsigned(false); // "0" is signed intmax_t 0.
PP.LexNonComment(PeekTok);
return false;
}
// Handle "defined X" and "defined(X)".
// Get the next token, don't expand it.
PP.LexUnexpandedToken(PeekTok);
// Two options, it can either be a pp-identifier or a (.
bool InParens = false;
if (PeekTok.getKind() == tok::l_paren) {
// Found a paren, remember we saw it and skip it.
InParens = true;
PP.LexUnexpandedToken(PeekTok);
}
// If we don't have a pp-identifier now, this is an error.
if ((II = PeekTok.getIdentifierInfo()) == 0) {
PP.Diag(PeekTok, diag::err_pp_defined_requires_identifier);
return true;
}
// Otherwise, we got an identifier, is it defined to something?
Result = II->getMacroInfo() != 0;
Result.setIsUnsigned(false); // Result is signed intmax_t.
// If there is a macro, mark it used.
if (Result != 0 && ValueLive) {
II->getMacroInfo()->setIsUsed(true);
// If this is the first use of a target-specific macro, warn about it.
if (II->getMacroInfo()->isTargetSpecific()) {
// Don't warn on second use.
II->getMacroInfo()->setIsTargetSpecific(false);
PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(),
diag::port_target_macro_use);
}
} else if (ValueLive) {
// Use of a target-specific macro for some other target? If so, warn.
if (II->isOtherTargetMacro()) {
II->setIsOtherTargetMacro(false); // Don't warn on second use.
PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(),
diag::port_target_macro_use);
}
}
// Consume identifier.
PP.LexNonComment(PeekTok);
// If we are in parens, ensure we have a trailing ).
if (InParens) {
if (PeekTok.getKind() != tok::r_paren) {
PP.Diag(PeekTok, diag::err_pp_missing_rparen);
return true;
}
// Consume the ).
PP.LexNonComment(PeekTok);
}
// Success, remember that we saw defined(X).
DT.State = DefinedTracker::DefinedMacro;
DT.TheMacro = II;
return false;
}
switch (PeekTok.getKind()) {
default: // Non-value token.
PP.Diag(PeekTok, diag::err_pp_expr_bad_token);
return true;
case tok::eom:
case tok::r_paren:
// If there is no expression, report and exit.
PP.Diag(PeekTok, diag::err_pp_expected_value_in_expr);
return true;
case tok::numeric_constant: {
llvm::SmallString<64> IntegerBuffer;
IntegerBuffer.resize(PeekTok.getLength());
const char *ThisTokBegin = &IntegerBuffer[0];
unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin);
NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
PeekTok.getLocation(), PP);
if (Literal.hadError)
return true; // a diagnostic was already reported.
if (Literal.isFloatingLiteral() || Literal.isImaginary) {
PP.Diag(PeekTok, diag::err_pp_illegal_floating_literal);
return true;
}
assert(Literal.isIntegerLiteral() && "Unknown ppnumber");
// long long is a C99 feature.
if (!PP.getLangOptions().C99 && !PP.getLangOptions().CPlusPlus0x
&& Literal.isLongLong)
PP.Diag(PeekTok, diag::ext_longlong);
// Parse the integer literal into Result.
if (Literal.GetIntegerValue(Result)) {
// Overflow parsing integer literal.
if (ValueLive) PP.Diag(PeekTok, diag::warn_integer_too_large);
Result.setIsUnsigned(true);
} else {
// Set the signedness of the result to match whether there was a U suffix
// or not.
Result.setIsUnsigned(Literal.isUnsigned);
// Detect overflow based on whether the value is signed. If signed
// and if the value is too large, emit a warning "integer constant is so
// large that it is unsigned" e.g. on 12345678901234567890 where intmax_t
// is 64-bits.
if (!Literal.isUnsigned && Result.isNegative()) {
if (ValueLive)PP.Diag(PeekTok, diag::warn_integer_too_large_for_signed);
Result.setIsUnsigned(true);
}
}
// Consume the token.
PP.LexNonComment(PeekTok);
return false;
}
case tok::char_constant: { // 'x'
llvm::SmallString<32> CharBuffer;
CharBuffer.resize(PeekTok.getLength());
const char *ThisTokBegin = &CharBuffer[0];
unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin);
CharLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
PeekTok.getLocation(), PP);
if (Literal.hadError())
return true; // A diagnostic was already emitted.
// Character literals are always int or wchar_t, expand to intmax_t.
TargetInfo &TI = PP.getTargetInfo();
unsigned NumBits;
if (Literal.isWide())
NumBits = TI.getWCharWidth(PeekTok.getLocation());
else
NumBits = TI.getCharWidth(PeekTok.getLocation());
// Set the width.
llvm::APSInt Val(NumBits);
// Set the value.
Val = Literal.getValue();
// Set the signedness.
Val.setIsUnsigned(!TI.isCharSigned(PeekTok.getLocation()));
if (Result.getBitWidth() > Val.getBitWidth()) {
if (Val.isSigned())
Result = Val.sext(Result.getBitWidth());
else
Result = Val.zext(Result.getBitWidth());
Result.setIsUnsigned(Val.isUnsigned());
} else {
assert(Result.getBitWidth() == Val.getBitWidth() &&
"intmax_t smaller than char/wchar_t?");
Result = Val;
}
// Consume the token.
PP.LexNonComment(PeekTok);
return false;
}
case tok::l_paren:
PP.LexNonComment(PeekTok); // Eat the (.
// Parse the value and if there are any binary operators involved, parse
// them.
if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
// If this is a silly value like (X), which doesn't need parens, check for
// !(defined X).
if (PeekTok.getKind() == tok::r_paren) {
// Just use DT unmodified as our result.
} else {
if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive, PP))
return true;
if (PeekTok.getKind() != tok::r_paren) {
PP.Diag(PeekTok, diag::err_pp_expected_rparen);
return true;
}
DT.State = DefinedTracker::Unknown;
}
PP.LexNonComment(PeekTok); // Eat the ).
return false;
case tok::plus:
// Unary plus doesn't modify the value.
PP.LexNonComment(PeekTok);
return EvaluateValue(Result, PeekTok, DT, ValueLive, PP);
case tok::minus: {
SourceLocation Loc = PeekTok.getLocation();
PP.LexNonComment(PeekTok);
if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
// C99 6.5.3.3p3: The sign of the result matches the sign of the operand.
Result = -Result;
bool Overflow = false;
if (Result.isUnsigned())
Overflow = !Result.isPositive();
else if (Result.isMinSignedValue())
Overflow = true; // -MININT is the only thing that overflows.
// If this operator is live and overflowed, report the issue.
if (Overflow && ValueLive)
PP.Diag(Loc, diag::warn_pp_expr_overflow);
DT.State = DefinedTracker::Unknown;
return false;
}
case tok::tilde:
PP.LexNonComment(PeekTok);
if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
// C99 6.5.3.3p4: The sign of the result matches the sign of the operand.
Result = ~Result;
DT.State = DefinedTracker::Unknown;
return false;
case tok::exclaim:
PP.LexNonComment(PeekTok);
if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
Result = !Result;
// C99 6.5.3.3p5: The sign of the result is 'int', aka it is signed.
Result.setIsUnsigned(false);
if (DT.State == DefinedTracker::DefinedMacro)
DT.State = DefinedTracker::NotDefinedMacro;
else if (DT.State == DefinedTracker::NotDefinedMacro)
DT.State = DefinedTracker::DefinedMacro;
return false;
// FIXME: Handle #assert
}
}
/// getPrecedence - Return the precedence of the specified binary operator
/// token. This returns:
/// ~0 - Invalid token.
/// 14 - *,/,%
/// 13 - -,+
/// 12 - <<,>>
/// 11 - >=, <=, >, <
/// 10 - ==, !=
/// 9 - &
/// 8 - ^
/// 7 - |
/// 6 - &&
/// 5 - ||
/// 4 - ?
/// 3 - :
/// 0 - eom, )
static unsigned getPrecedence(tok::TokenKind Kind) {
switch (Kind) {
default: return ~0U;
case tok::percent:
case tok::slash:
case tok::star: return 14;
case tok::plus:
case tok::minus: return 13;
case tok::lessless:
case tok::greatergreater: return 12;
case tok::lessequal:
case tok::less:
case tok::greaterequal:
case tok::greater: return 11;
case tok::exclaimequal:
case tok::equalequal: return 10;
case tok::amp: return 9;
case tok::caret: return 8;
case tok::pipe: return 7;
case tok::ampamp: return 6;
case tok::pipepipe: return 5;
case tok::question: return 4;
case tok::colon: return 3;
case tok::comma: return 2;
case tok::r_paren: return 0; // Lowest priority, end of expr.
case tok::eom: return 0; // Lowest priority, end of macro.
}
}
/// EvaluateDirectiveSubExpr - Evaluate the subexpression whose first token is
/// PeekTok, and whose precedence is PeekPrec.
///
/// If ValueLive is false, then this value is being evaluated in a context where
/// the result is not used. As such, avoid diagnostics that relate to
/// evaluation.
static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec,
Token &PeekTok, bool ValueLive,
Preprocessor &PP) {
unsigned PeekPrec = getPrecedence(PeekTok.getKind());
// If this token isn't valid, report the error.
if (PeekPrec == ~0U) {
PP.Diag(PeekTok, diag::err_pp_expr_bad_token);
return true;
}
while (1) {
// If this token has a lower precedence than we are allowed to parse, return
// it so that higher levels of the recursion can parse it.
if (PeekPrec < MinPrec)
return false;
tok::TokenKind Operator = PeekTok.getKind();
// If this is a short-circuiting operator, see if the RHS of the operator is
// dead. Note that this cannot just clobber ValueLive. Consider
// "0 && 1 ? 4 : 1 / 0", which is parsed as "(0 && 1) ? 4 : (1 / 0)". In
// this example, the RHS of the && being dead does not make the rest of the
// expr dead.
bool RHSIsLive;
if (Operator == tok::ampamp && LHS == 0)
RHSIsLive = false; // RHS of "0 && x" is dead.
else if (Operator == tok::pipepipe && LHS != 0)
RHSIsLive = false; // RHS of "1 || x" is dead.
else if (Operator == tok::question && LHS == 0)
RHSIsLive = false; // RHS (x) of "0 ? x : y" is dead.
else
RHSIsLive = ValueLive;
// Consume the operator, saving the operator token for error reporting.
Token OpToken = PeekTok;
PP.LexNonComment(PeekTok);
llvm::APSInt RHS(LHS.getBitWidth());
// Parse the RHS of the operator.
DefinedTracker DT;
if (EvaluateValue(RHS, PeekTok, DT, RHSIsLive, PP)) return true;
// Remember the precedence of this operator and get the precedence of the
// operator immediately to the right of the RHS.
unsigned ThisPrec = PeekPrec;
PeekPrec = getPrecedence(PeekTok.getKind());
// If this token isn't valid, report the error.
if (PeekPrec == ~0U) {
PP.Diag(PeekTok, diag::err_pp_expr_bad_token);
return true;
}
bool isRightAssoc = Operator == tok::question;
// Get the precedence of the operator to the right of the RHS. If it binds
// more tightly with RHS than we do, evaluate it completely first.
if (ThisPrec < PeekPrec ||
(ThisPrec == PeekPrec && isRightAssoc)) {
if (EvaluateDirectiveSubExpr(RHS, ThisPrec+1, PeekTok, RHSIsLive, PP))
return true;
PeekPrec = getPrecedence(PeekTok.getKind());
}
assert(PeekPrec <= ThisPrec && "Recursion didn't work!");
// Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
// either operand is unsigned. Don't do this for x and y in "x ? y : z".
llvm::APSInt Res(LHS.getBitWidth());
if (Operator != tok::question) {
Res.setIsUnsigned(LHS.isUnsigned()|RHS.isUnsigned());
// If this just promoted something from signed to unsigned, and if the
// value was negative, warn about it.
if (ValueLive && Res.isUnsigned()) {
if (!LHS.isUnsigned() && LHS.isNegative())
PP.Diag(OpToken, diag::warn_pp_convert_lhs_to_positive,
LHS.toStringSigned() + " to " + LHS.toStringUnsigned());
if (!RHS.isUnsigned() && RHS.isNegative())
PP.Diag(OpToken, diag::warn_pp_convert_rhs_to_positive,
RHS.toStringSigned() + " to " + RHS.toStringUnsigned());
}
LHS.setIsUnsigned(Res.isUnsigned());
RHS.setIsUnsigned(Res.isUnsigned());
}
// FIXME: All of these should detect and report overflow??
bool Overflow = false;
switch (Operator) {
default: assert(0 && "Unknown operator token!");
case tok::percent:
if (RHS == 0) {
if (ValueLive) PP.Diag(OpToken, diag::err_pp_remainder_by_zero);
return true;
}
Res = LHS % RHS;
break;
case tok::slash:
if (RHS == 0) {
if (ValueLive) PP.Diag(OpToken, diag::err_pp_division_by_zero);
return true;
}
Res = LHS / RHS;
if (LHS.isSigned())
Overflow = LHS.isMinSignedValue() && RHS.isAllOnesValue(); // MININT/-1
break;
case tok::star:
Res = LHS * RHS;
if (LHS != 0 && RHS != 0)
Overflow = Res/RHS != LHS || Res/LHS != RHS;
break;
case tok::lessless: {
// Determine whether overflow is about to happen.
unsigned ShAmt = static_cast<unsigned>(RHS.getLimitedValue());
if (ShAmt >= LHS.getBitWidth())
Overflow = true, ShAmt = LHS.getBitWidth()-1;
else if (LHS.isUnsigned())
Overflow = ShAmt > LHS.countLeadingZeros();
else if (LHS.isPositive())
Overflow = ShAmt >= LHS.countLeadingZeros(); // Don't allow sign change.
else
Overflow = ShAmt >= LHS.countLeadingOnes();
Res = LHS << ShAmt;
break;
}
case tok::greatergreater: {
// Determine whether overflow is about to happen.
unsigned ShAmt = static_cast<unsigned>(RHS.getLimitedValue());
if (ShAmt >= LHS.getBitWidth())
Overflow = true, ShAmt = LHS.getBitWidth()-1;
Res = LHS >> ShAmt;
break;
}
case tok::plus:
Res = LHS + RHS;
if (LHS.isUnsigned())
Overflow = Res.ult(LHS);
else if (LHS.isPositive() == RHS.isPositive() &&
Res.isPositive() != LHS.isPositive())
Overflow = true; // Overflow for signed addition.
break;
case tok::minus:
Res = LHS - RHS;
if (LHS.isUnsigned())
Overflow = Res.ugt(LHS);
else if (LHS.isPositive() != RHS.isPositive() &&
Res.isPositive() != LHS.isPositive())
Overflow = true; // Overflow for signed subtraction.
break;
case tok::lessequal:
Res = LHS <= RHS;
Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
break;
case tok::less:
Res = LHS < RHS;
Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
break;
case tok::greaterequal:
Res = LHS >= RHS;
Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
break;
case tok::greater:
Res = LHS > RHS;
Res.setIsUnsigned(false); // C99 6.5.8p6, result is always int (signed)
break;
case tok::exclaimequal:
Res = LHS != RHS;
Res.setIsUnsigned(false); // C99 6.5.9p3, result is always int (signed)
break;
case tok::equalequal:
Res = LHS == RHS;
Res.setIsUnsigned(false); // C99 6.5.9p3, result is always int (signed)
break;
case tok::amp:
Res = LHS & RHS;
break;
case tok::caret:
Res = LHS ^ RHS;
break;
case tok::pipe:
Res = LHS | RHS;
break;
case tok::ampamp:
Res = (LHS != 0 && RHS != 0);
Res.setIsUnsigned(false); // C99 6.5.13p3, result is always int (signed)
break;
case tok::pipepipe:
Res = (LHS != 0 || RHS != 0);
Res.setIsUnsigned(false); // C99 6.5.14p3, result is always int (signed)
break;
case tok::comma:
PP.Diag(OpToken, diag::ext_pp_comma_expr);
Res = RHS; // LHS = LHS,RHS -> RHS.
break;
case tok::question: {
// Parse the : part of the expression.
if (PeekTok.getKind() != tok::colon) {
PP.Diag(OpToken, diag::err_pp_question_without_colon);
return true;
}
// Consume the :.
PP.LexNonComment(PeekTok);
// Evaluate the value after the :.
bool AfterColonLive = ValueLive && LHS == 0;
llvm::APSInt AfterColonVal(LHS.getBitWidth());
DefinedTracker DT;
if (EvaluateValue(AfterColonVal, PeekTok, DT, AfterColonLive, PP))
return true;
// Parse anything after the : RHS that has a higher precedence than ?.
if (EvaluateDirectiveSubExpr(AfterColonVal, ThisPrec+1,
PeekTok, AfterColonLive, PP))
return true;
// Now that we have the condition, the LHS and the RHS of the :, evaluate.
Res = LHS != 0 ? RHS : AfterColonVal;
// Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
// either operand is unsigned.
Res.setIsUnsigned(RHS.isUnsigned() | AfterColonVal.isUnsigned());
// Figure out the precedence of the token after the : part.
PeekPrec = getPrecedence(PeekTok.getKind());
break;
}
case tok::colon:
// Don't allow :'s to float around without being part of ?: exprs.
PP.Diag(OpToken, diag::err_pp_colon_without_question);
return true;
}
// If this operator is live and overflowed, report the issue.
if (Overflow && ValueLive)
PP.Diag(OpToken, diag::warn_pp_expr_overflow);
// Put the result back into 'LHS' for our next iteration.
LHS = Res;
}
return false;
}
/// EvaluateDirectiveExpression - Evaluate an integer constant expression that
/// may occur after a #if or #elif directive. If the expression is equivalent
/// to "!defined(X)" return X in IfNDefMacro.
bool Preprocessor::
EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {
// Peek ahead one token.
Token Tok;
Lex(Tok);
// C99 6.10.1p3 - All expressions are evaluated as intmax_t or uintmax_t.
unsigned BitWidth = getTargetInfo().getIntMaxTWidth(Tok.getLocation());
llvm::APSInt ResVal(BitWidth);
DefinedTracker DT;
if (EvaluateValue(ResVal, Tok, DT, true, *this)) {
// Parse error, skip the rest of the macro line.
if (Tok.getKind() != tok::eom)
DiscardUntilEndOfDirective();
return false;
}
// If we are at the end of the expression after just parsing a value, there
// must be no (unparenthesized) binary operators involved, so we can exit
// directly.
if (Tok.getKind() == tok::eom) {
// If the expression we parsed was of the form !defined(macro), return the
// macro in IfNDefMacro.
if (DT.State == DefinedTracker::NotDefinedMacro)
IfNDefMacro = DT.TheMacro;
return ResVal != 0;
}
// Otherwise, we must have a binary operator (e.g. "#if 1 < 2"), so parse the
// operator and the stuff after it.
if (EvaluateDirectiveSubExpr(ResVal, 1, Tok, true, *this)) {
// Parse error, skip the rest of the macro line.
if (Tok.getKind() != tok::eom)
DiscardUntilEndOfDirective();
return false;
}
// If we aren't at the tok::eom token, something bad happened, like an extra
// ')' token.
if (Tok.getKind() != tok::eom) {
Diag(Tok, diag::err_pp_expected_eol);
DiscardUntilEndOfDirective();
}
return ResVal != 0;
}

View File

@@ -1,367 +0,0 @@
//===--- Pragma.cpp - Pragma registration and handling --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the PragmaHandler/PragmaTable interfaces and implements
// pragma related methods of the Preprocessor class.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/Pragma.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;
// Out-of-line destructor to provide a home for the class.
PragmaHandler::~PragmaHandler() {
}
//===----------------------------------------------------------------------===//
// PragmaNamespace Implementation.
//===----------------------------------------------------------------------===//
PragmaNamespace::~PragmaNamespace() {
for (unsigned i = 0, e = Handlers.size(); i != e; ++i)
delete Handlers[i];
}
/// FindHandler - Check to see if there is already a handler for the
/// specified name. If not, return the handler for the null identifier if it
/// exists, otherwise return null. If IgnoreNull is true (the default) then
/// the null handler isn't returned on failure to match.
PragmaHandler *PragmaNamespace::FindHandler(const IdentifierInfo *Name,
bool IgnoreNull) const {
PragmaHandler *NullHandler = 0;
for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
if (Handlers[i]->getName() == Name)
return Handlers[i];
if (Handlers[i]->getName() == 0)
NullHandler = Handlers[i];
}
return IgnoreNull ? 0 : NullHandler;
}
void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) {
// Read the 'namespace' that the directive is in, e.g. STDC. Do not macro
// expand it, the user can have a STDC #define, that should not affect this.
PP.LexUnexpandedToken(Tok);
// Get the handler for this token. If there is no handler, ignore the pragma.
PragmaHandler *Handler = FindHandler(Tok.getIdentifierInfo(), false);
if (Handler == 0) return;
// Otherwise, pass it down.
Handler->HandlePragma(PP, Tok);
}
//===----------------------------------------------------------------------===//
// Preprocessor Pragma Directive Handling.
//===----------------------------------------------------------------------===//
/// HandlePragmaDirective - The "#pragma" directive has been parsed. Lex the
/// rest of the pragma, passing it to the registered pragma handlers.
void Preprocessor::HandlePragmaDirective() {
++NumPragma;
// Invoke the first level of pragma handlers which reads the namespace id.
Token Tok;
PragmaHandlers->HandlePragma(*this, Tok);
// If the pragma handler didn't read the rest of the line, consume it now.
if (CurLexer->ParsingPreprocessorDirective)
DiscardUntilEndOfDirective();
}
/// Handle_Pragma - Read a _Pragma directive, slice it up, process it, then
/// return the first token after the directive. The _Pragma token has just
/// been read into 'Tok'.
void Preprocessor::Handle_Pragma(Token &Tok) {
// Remember the pragma token location.
SourceLocation PragmaLoc = Tok.getLocation();
// Read the '('.
Lex(Tok);
if (Tok.getKind() != tok::l_paren)
return Diag(PragmaLoc, diag::err__Pragma_malformed);
// Read the '"..."'.
Lex(Tok);
if (Tok.getKind() != tok::string_literal &&
Tok.getKind() != tok::wide_string_literal)
return Diag(PragmaLoc, diag::err__Pragma_malformed);
// Remember the string.
std::string StrVal = getSpelling(Tok);
SourceLocation StrLoc = Tok.getLocation();
// Read the ')'.
Lex(Tok);
if (Tok.getKind() != tok::r_paren)
return Diag(PragmaLoc, diag::err__Pragma_malformed);
// The _Pragma is lexically sound. Destringize according to C99 6.10.9.1.
if (StrVal[0] == 'L') // Remove L prefix.
StrVal.erase(StrVal.begin());
assert(StrVal[0] == '"' && StrVal[StrVal.size()-1] == '"' &&
"Invalid string token!");
// Remove the front quote, replacing it with a space, so that the pragma
// contents appear to have a space before them.
StrVal[0] = ' ';
// Replace the terminating quote with a \n\0.
StrVal[StrVal.size()-1] = '\n';
StrVal += '\0';
// Remove escaped quotes and escapes.
for (unsigned i = 0, e = StrVal.size(); i != e-1; ++i) {
if (StrVal[i] == '\\' &&
(StrVal[i+1] == '\\' || StrVal[i+1] == '"')) {
// \\ -> '\' and \" -> '"'.
StrVal.erase(StrVal.begin()+i);
--e;
}
}
// Plop the string (including the newline and trailing null) into a buffer
// where we can lex it.
SourceLocation TokLoc = CreateString(&StrVal[0], StrVal.size(), StrLoc);
const char *StrData = SourceMgr.getCharacterData(TokLoc);
// Make and enter a lexer object so that we lex and expand the tokens just
// like any others.
Lexer *TL = new Lexer(TokLoc, *this,
StrData, StrData+StrVal.size()-1 /* no null */);
// Ensure that the lexer thinks it is inside a directive, so that end \n will
// return an EOM token.
TL->ParsingPreprocessorDirective = true;
// This lexer really is for _Pragma.
TL->Is_PragmaLexer = true;
EnterSourceFileWithLexer(TL, 0);
// With everything set up, lex this as a #pragma directive.
HandlePragmaDirective();
// Finally, return whatever came after the pragma directive.
return Lex(Tok);
}
/// HandlePragmaOnce - Handle #pragma once. OnceTok is the 'once'.
///
void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
if (isInPrimaryFile()) {
Diag(OnceTok, diag::pp_pragma_once_in_main_file);
return;
}
// Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
SourceLocation FileLoc = getCurrentFileLexer()->getFileLoc();
// Mark the file as a once-only file now.
HeaderInfo.MarkFileIncludeOnce(SourceMgr.getFileEntryForLoc(FileLoc));
}
/// HandlePragmaPoison - Handle #pragma GCC poison. PoisonTok is the 'poison'.
///
void Preprocessor::HandlePragmaPoison(Token &PoisonTok) {
Token Tok;
while (1) {
// Read the next token to poison. While doing this, pretend that we are
// skipping while reading the identifier to poison.
// This avoids errors on code like:
// #pragma GCC poison X
// #pragma GCC poison X
if (CurLexer) CurLexer->LexingRawMode = true;
LexUnexpandedToken(Tok);
if (CurLexer) CurLexer->LexingRawMode = false;
// If we reached the end of line, we're done.
if (Tok.getKind() == tok::eom) return;
// Can only poison identifiers.
if (Tok.getKind() != tok::identifier) {
Diag(Tok, diag::err_pp_invalid_poison);
return;
}
// Look up the identifier info for the token. We disabled identifier lookup
// by saying we're skipping contents, so we need to do this manually.
IdentifierInfo *II = LookUpIdentifierInfo(Tok);
// Already poisoned.
if (II->isPoisoned()) continue;
// If this is a macro identifier, emit a warning.
if (II->getMacroInfo())
Diag(Tok, diag::pp_poisoning_existing_macro);
// Finally, poison it!
II->setIsPoisoned();
}
}
/// HandlePragmaSystemHeader - Implement #pragma GCC system_header. We know
/// that the whole directive has been parsed.
void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) {
if (isInPrimaryFile()) {
Diag(SysHeaderTok, diag::pp_pragma_sysheader_in_main_file);
return;
}
// Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
Lexer *TheLexer = getCurrentFileLexer();
// Mark the file as a system header.
const FileEntry *File = SourceMgr.getFileEntryForLoc(TheLexer->getFileLoc());
HeaderInfo.MarkFileSystemHeader(File);
// Notify the client, if desired, that we are in a new source file.
if (Callbacks)
Callbacks->FileChanged(TheLexer->getSourceLocation(TheLexer->BufferPtr),
PPCallbacks::SystemHeaderPragma,
DirectoryLookup::SystemHeaderDir);
}
/// HandlePragmaDependency - Handle #pragma GCC dependency "foo" blah.
///
void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
Token FilenameTok;
CurLexer->LexIncludeFilename(FilenameTok);
// If the token kind is EOM, the error has already been diagnosed.
if (FilenameTok.getKind() == tok::eom)
return;
// Reserve a buffer to get the spelling.
llvm::SmallVector<char, 128> FilenameBuffer;
FilenameBuffer.resize(FilenameTok.getLength());
const char *FilenameStart = &FilenameBuffer[0];
unsigned Len = getSpelling(FilenameTok, FilenameStart);
const char *FilenameEnd = FilenameStart+Len;
bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(),
FilenameStart, FilenameEnd);
// If GetIncludeFilenameSpelling set the start ptr to null, there was an
// error.
if (FilenameStart == 0)
return;
// Search include directories for this file.
const DirectoryLookup *CurDir;
const FileEntry *File = LookupFile(FilenameStart, FilenameEnd,
isAngled, 0, CurDir);
if (File == 0)
return Diag(FilenameTok, diag::err_pp_file_not_found,
std::string(FilenameStart, FilenameEnd));
SourceLocation FileLoc = getCurrentFileLexer()->getFileLoc();
const FileEntry *CurFile = SourceMgr.getFileEntryForLoc(FileLoc);
// If this file is older than the file it depends on, emit a diagnostic.
if (CurFile && CurFile->getModificationTime() < File->getModificationTime()) {
// Lex tokens at the end of the message and include them in the message.
std::string Message;
Lex(DependencyTok);
while (DependencyTok.getKind() != tok::eom) {
Message += getSpelling(DependencyTok) + " ";
Lex(DependencyTok);
}
Message.erase(Message.end()-1);
Diag(FilenameTok, diag::pp_out_of_date_dependency, Message);
}
}
/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
/// If 'Namespace' is non-null, then it is a token required to exist on the
/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
void Preprocessor::AddPragmaHandler(const char *Namespace,
PragmaHandler *Handler) {
PragmaNamespace *InsertNS = PragmaHandlers;
// If this is specified to be in a namespace, step down into it.
if (Namespace) {
IdentifierInfo *NSID = getIdentifierInfo(Namespace);
// If there is already a pragma handler with the name of this namespace,
// we either have an error (directive with the same name as a namespace) or
// we already have the namespace to insert into.
if (PragmaHandler *Existing = PragmaHandlers->FindHandler(NSID)) {
InsertNS = Existing->getIfNamespace();
assert(InsertNS != 0 && "Cannot have a pragma namespace and pragma"
" handler with the same name!");
} else {
// Otherwise, this namespace doesn't exist yet, create and insert the
// handler for it.
InsertNS = new PragmaNamespace(NSID);
PragmaHandlers->AddPragma(InsertNS);
}
}
// Check to make sure we don't already have a pragma for this identifier.
assert(!InsertNS->FindHandler(Handler->getName()) &&
"Pragma handler already exists for this identifier!");
InsertNS->AddPragma(Handler);
}
namespace {
struct PragmaOnceHandler : public PragmaHandler {
PragmaOnceHandler(const IdentifierInfo *OnceID) : PragmaHandler(OnceID) {}
virtual void HandlePragma(Preprocessor &PP, Token &OnceTok) {
PP.CheckEndOfDirective("#pragma once");
PP.HandlePragmaOnce(OnceTok);
}
};
struct PragmaPoisonHandler : public PragmaHandler {
PragmaPoisonHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
virtual void HandlePragma(Preprocessor &PP, Token &PoisonTok) {
PP.HandlePragmaPoison(PoisonTok);
}
};
struct PragmaSystemHeaderHandler : public PragmaHandler {
PragmaSystemHeaderHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
virtual void HandlePragma(Preprocessor &PP, Token &SHToken) {
PP.HandlePragmaSystemHeader(SHToken);
PP.CheckEndOfDirective("#pragma");
}
};
struct PragmaDependencyHandler : public PragmaHandler {
PragmaDependencyHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
virtual void HandlePragma(Preprocessor &PP, Token &DepToken) {
PP.HandlePragmaDependency(DepToken);
}
};
} // end anonymous namespace
/// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
/// #pragma GCC poison/system_header/dependency and #pragma once.
void Preprocessor::RegisterBuiltinPragmas() {
AddPragmaHandler(0, new PragmaOnceHandler(getIdentifierInfo("once")));
AddPragmaHandler("GCC", new PragmaPoisonHandler(getIdentifierInfo("poison")));
AddPragmaHandler("GCC", new PragmaSystemHeaderHandler(
getIdentifierInfo("system_header")));
AddPragmaHandler("GCC", new PragmaDependencyHandler(
getIdentifierInfo("dependency")));
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,71 +0,0 @@
//===--- ScratchBuffer.cpp - Scratch space for forming tokens -------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ScratchBuffer interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/ScratchBuffer.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/MemoryBuffer.h"
using namespace clang;
// ScratchBufSize - The size of each chunk of scratch memory. Slightly less
//than a page, almost certainly enough for anything. :)
static const unsigned ScratchBufSize = 4060;
ScratchBuffer::ScratchBuffer(SourceManager &SM) : SourceMgr(SM), CurBuffer(0) {
// Set BytesUsed so that the first call to getToken will require an alloc.
BytesUsed = ScratchBufSize;
FileID = 0;
}
/// getToken - Splat the specified text into a temporary MemoryBuffer and
/// return a SourceLocation that refers to the token. This is just like the
/// method below, but returns a location that indicates the physloc of the
/// token.
SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len) {
if (BytesUsed+Len > ScratchBufSize)
AllocScratchBuffer(Len);
// Copy the token data into the buffer.
memcpy(CurBuffer+BytesUsed, Buf, Len);
// Remember that we used these bytes.
BytesUsed += Len;
assert(BytesUsed-Len < (1 << SourceLocation::FilePosBits) &&
"Out of range file position!");
return SourceLocation::getFileLoc(FileID, BytesUsed-Len);
}
/// getToken - Splat the specified text into a temporary MemoryBuffer and
/// return a SourceLocation that refers to the token. The SourceLoc value
/// gives a virtual location that the token will appear to be from.
SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len,
SourceLocation SourceLoc) {
// Map the physloc to the specified sourceloc.
return SourceMgr.getInstantiationLoc(getToken(Buf, Len), SourceLoc);
}
void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) {
// Only pay attention to the requested length if it is larger than our default
// page size. If it is, we allocate an entire chunk for it. This is to
// support gigantic tokens, which almost certainly won't happen. :)
if (RequestLen < ScratchBufSize)
RequestLen = ScratchBufSize;
llvm::MemoryBuffer *Buf =
llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>");
FileID = SourceMgr.createFileIDForMemBuffer(Buf);
CurBuffer = const_cast<char*>(Buf->getBufferStart());
BytesUsed = 0;
}

View File

@@ -1,11 +0,0 @@
LEVEL = ../..
DIRS := Basic Lex Parse AST Sema CodeGen Analysis Driver
include $(LEVEL)/Makefile.common
test::
cd test; $(MAKE)
clean::
@rm -rf build
@rm -rf `find test -name Output`

View File

@@ -1,5 +0,0 @@
# This file provides information for llvm-top
DepModule: llvm
ConfigCmd:
ConfigTest:
BuildCmd:

View File

@@ -1,219 +0,0 @@
//===---------------------------------------------------------------------===//
// Random Notes
//===---------------------------------------------------------------------===//
C90/C99/C++ Comparisons:
http://david.tribble.com/text/cdiffs.htm
//===---------------------------------------------------------------------===//
Extensions:
* "#define_target X Y"
This preprocessor directive works exactly the same was as #define, but it
notes that 'X' is a target-specific preprocessor directive. When used, a
diagnostic is emitted indicating that the translation unit is non-portable.
If a target-define is #undef'd before use, no diagnostic is emitted. If 'X'
were previously a normal #define macro, the macro is tainted. If 'X' is
subsequently #defined as a non-target-specific define, the taint bit is
cleared.
* "#define_other_target X"
The preprocessor directive takes a single identifier argument. It notes
that this identifier is a target-specific #define for some target other than
the current one. Use of this identifier will result in a diagnostic.
If 'X' is later #undef'd or #define'd, the taint bit is cleared. If 'X' is
already defined, X is marked as a target-specific define.
//===---------------------------------------------------------------------===//
To time GCC preprocessing speed without output, use:
"time gcc -MM file"
This is similar to -Eonly.
//===---------------------------------------------------------------------===//
C++ Template Instantiation benchmark:
http://users.rcn.com/abrahams/instantiation_speed/index.html
//===---------------------------------------------------------------------===//
TODO: File Manager Speedup:
We currently do a lot of stat'ing for files that don't exist, particularly
when lots of -I paths exist (e.g. see the <iostream> example, check for
failures in stat in FileManager::getFile). It would be far better to make
the following changes:
1. FileEntry contains a sys::Path instead of a std::string for Name.
2. sys::Path contains timestamp and size, lazily computed. Eliminate from
FileEntry.
3. File UIDs are created on request, not when files are opened.
These changes make it possible to efficiently have FileEntry objects for
files that exist on the file system, but have not been used yet.
Once this is done:
1. DirectoryEntry gets a boolean value "has read entries". When false, not
all entries in the directory are in the file mgr, when true, they are.
2. Instead of stat'ing the file in FileManager::getFile, check to see if
the dir has been read. If so, fail immediately, if not, read the dir,
then retry.
3. Reading the dir uses the getdirentries syscall, creating an FileEntry
for all files found.
//===---------------------------------------------------------------------===//
TODO: Fast #Import:
* Get frameworks that don't use #import to do so, e.g.
DirectoryService, AudioToolbox, CoreFoundation, etc. Why not using #import?
Because they work in C mode? C has #import.
* Have the lexer return a token for #import instead of handling it itself.
- Create a new preprocessor object with no external state (no -D/U options
from the command line, etc). Alternatively, keep track of exactly which
external state is used by a #import: declare it somehow.
* When having reading a #import file, keep track of whether we have (and/or
which) seen any "configuration" macros. Various cases:
- Uses of target args (__POWERPC__, __i386): Header has to be parsed
multiple times, per-target. What about #ifndef checks? How do we know?
- "Configuration" preprocessor macros not defined: POWERPC, etc. What about
things like __STDC__ etc? What is and what isn't allowed.
* Special handling for "umbrella" headers, which just contain #import stmts:
- Cocoa.h/AppKit.h - Contain pointers to digests instead of entire digests
themselves? Foundation.h isn't pure umbrella!
* Frameworks digests:
- Can put "digest" of a framework-worth of headers into the framework
itself. To open AppKit, just mmap
/System/Library/Frameworks/AppKit.framework/"digest", which provides a
symbol table in a well defined format. Lazily unstream stuff that is
needed. Contains declarations, macros, and debug information.
- System frameworks ship with digests. How do we handle configuration
information? How do we handle stuff like:
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2
which guards a bunch of decls? Should there be a couple of default
configs, then have the UI fall back to building/caching its own?
- GUI automatically builds digests when UI is idle, both of system
frameworks if they aren't not available in the right config, and of app
frameworks.
- GUI builds dependence graph of frameworks/digests based on #imports. If a
digest is out date, dependent digests are automatically invalidated.
* New constraints on #import for objc-v3:
- #imported file must not define non-inline function bodies.
- Alternatively, they can, and these bodies get compiled/linked *once*
per app into a dylib. What about building user dylibs?
- Restrictions on ObjC grammar: can't #import the body of a for stmt or fn.
- Compiler must detect and reject these cases.
- #defines defined within a #import have two behaviors:
- By default, they escape the header. These macros *cannot* be #undef'd
by other code: this is enforced by the front-end.
- Optionally, user can specify what macros escape (whitelist) or can use
#undef.
//===---------------------------------------------------------------------===//
TODO: New language feature: Configuration queries:
- Instead of #ifdef __POWERPC__, use "if (strcmp(`cpu`, __POWERPC__))", or
some other, better, syntax.
- Use it to increase the number of "architecture-clean" #import'd files,
allowing a single index to be used for all fat slices.
//===---------------------------------------------------------------------===//
The 'portability' model in clang is sufficient to catch translation units (or
their parts) that are not portable, but it doesn't help if the system headers
are non-portable and not fixed. An alternative model that would be easy to use
is a 'tainting' scheme. Consider:
int32_t
OSHostByteOrder(void) {
#if defined(__LITTLE_ENDIAN__)
return OSLittleEndian;
#elif defined(__BIG_ENDIAN__)
return OSBigEndian;
#else
return OSUnknownByteOrder;
#endif
}
It would be trivial to mark 'OSHostByteOrder' as being non-portable (tainted)
instead of marking the entire translation unit. Then, if OSHostByteOrder is
never called/used by the current translation unit, the t-u wouldn't be marked
non-portable. However, there is no good way to handle stuff like:
extern int X, Y;
#ifndef __POWERPC__
#define X Y
#endif
int bar() { return X; }
When compiling for powerpc, the #define is skipped, so it doesn't know that bar
uses a #define that is set on some other target. In practice, limited cases
could be handled by scanning the skipped region of a #if, but the fully general
case cannot be implemented efficiently. In this case, for example, the #define
in the protected region could be turned into either a #define_target or
#define_other_target as appropriate. The harder case is code like this (from
OSByteOrder.h):
#if (defined(__ppc__) || defined(__ppc64__))
#include <libkern/ppc/OSByteOrder.h>
#elif (defined(__i386__) || defined(__x86_64__))
#include <libkern/i386/OSByteOrder.h>
#else
#include <libkern/machine/OSByteOrder.h>
#endif
The realistic way to fix this is by having an initial #ifdef __llvm__ that
defines its contents in terms of the llvm bswap intrinsics. Other things should
be handled on a case-by-case basis.
We probably have to do something smarter like this in the future. The C++ header
<limits> contains a lot of code like this:
static const int digits10 = __LDBL_DIG__;
static const int min_exponent = __LDBL_MIN_EXP__;
static const int min_exponent10 = __LDBL_MIN_10_EXP__;
static const float_denorm_style has_denorm
= bool(__LDBL_DENORM_MIN__) ? denorm_present : denorm_absent;
... since this isn't being used in an #ifdef, it should be easy enough to taint
the decl for these ivars.
/usr/include/sys/cdefs.h contains stuff like this:
#if defined(__ppc__)
# if defined(__LDBL_MANT_DIG__) && defined(__DBL_MANT_DIG__) && \
__LDBL_MANT_DIG__ > __DBL_MANT_DIG__
# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 < 1040
# define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBLStub")
# else
# define __DARWIN_LDBL_COMPAT(x) __asm("_" __STRING(x) "$LDBL128")
# endif
# define __DARWIN_LDBL_COMPAT2(x) __asm("_" __STRING(x) "$LDBL128")
# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0
# else
# define __DARWIN_LDBL_COMPAT(x) /* nothing */
# define __DARWIN_LDBL_COMPAT2(x) /* nothing */
# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 1
# endif
#elif defined(__i386__) || defined(__ppc64__) || defined(__x86_64__)
# define __DARWIN_LDBL_COMPAT(x) /* nothing */
# define __DARWIN_LDBL_COMPAT2(x) /* nothing */
# define __DARWIN_LONG_DOUBLE_IS_DOUBLE 0
#else
# error Unknown architecture
#endif
An ideal way to solve this issue is to mark __DARWIN_LDBL_COMPAT /
__DARWIN_LDBL_COMPAT2 / __DARWIN_LONG_DOUBLE_IS_DOUBLE as being non-portable
because they depend on non-portable macros. In practice though, this may end
up being a serious problem: every use of printf will mark the translation unit
non-portable if targetting ppc32 and something else.
//===---------------------------------------------------------------------===//

View File

@@ -1,27 +0,0 @@
//===--- AttributeList.cpp --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Steve Naroff and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the AttributeList class implementation
//
//===----------------------------------------------------------------------===//
#include "clang/Parse/AttributeList.h"
#include "clang/Lex/IdentifierTable.h"
using namespace clang;
AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
IdentifierInfo *pName, SourceLocation pLoc,
Action::ExprTy **elist, unsigned numargs,
AttributeList *n)
: AttrName(aName), AttrLoc(aLoc), ParmName(pName), ParmLoc(pLoc),
NumArgs(numargs), Next(n) {
Args = new Action::ExprTy*[numargs];
for (unsigned i = 0; i != numargs; ++i)
Args[i] = elist[i];
}

View File

@@ -1,286 +0,0 @@
//===--- SemaDeclSpec.cpp - Declaration Specifier Semantic Analysis -------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements semantic analysis for declaration specifiers.
//
//===----------------------------------------------------------------------===//
#include "clang/Parse/DeclSpec.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
using namespace clang;
/// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
///
unsigned DeclSpec::getParsedSpecifiers() const {
unsigned Res = 0;
if (StorageClassSpec != SCS_unspecified ||
SCS_thread_specified)
Res |= PQ_StorageClassSpecifier;
if (TypeQualifiers != TQ_unspecified)
Res |= PQ_TypeQualifier;
if (hasTypeSpecifier())
Res |= PQ_TypeSpecifier;
if (FS_inline_specified)
Res |= PQ_FunctionSpecifier;
return Res;
}
const char *DeclSpec::getSpecifierName(DeclSpec::SCS S) {
switch (S) {
default: assert(0 && "Unknown typespec!");
case DeclSpec::SCS_unspecified: return "unspecified";
case DeclSpec::SCS_typedef: return "typedef";
case DeclSpec::SCS_extern: return "extern";
case DeclSpec::SCS_static: return "static";
case DeclSpec::SCS_auto: return "auto";
case DeclSpec::SCS_register: return "register";
}
}
static bool BadSpecifier(DeclSpec::SCS S, const char *&PrevSpec) {
PrevSpec = DeclSpec::getSpecifierName(S);
return true;
}
static bool BadSpecifier(DeclSpec::TSW W, const char *&PrevSpec) {
switch (W) {
case DeclSpec::TSW_unspecified: PrevSpec = "unspecified"; break;
case DeclSpec::TSW_short: PrevSpec = "short"; break;
case DeclSpec::TSW_long: PrevSpec = "long"; break;
case DeclSpec::TSW_longlong: PrevSpec = "long long"; break;
}
return true;
}
static bool BadSpecifier(DeclSpec::TSC C, const char *&PrevSpec) {
switch (C) {
case DeclSpec::TSC_unspecified: PrevSpec = "unspecified"; break;
case DeclSpec::TSC_imaginary: PrevSpec = "imaginary"; break;
case DeclSpec::TSC_complex: PrevSpec = "complex"; break;
}
return true;
}
static bool BadSpecifier(DeclSpec::TSS S, const char *&PrevSpec) {
switch (S) {
case DeclSpec::TSS_unspecified: PrevSpec = "unspecified"; break;
case DeclSpec::TSS_signed: PrevSpec = "signed"; break;
case DeclSpec::TSS_unsigned: PrevSpec = "unsigned"; break;
}
return true;
}
const char *DeclSpec::getSpecifierName(DeclSpec::TST T) {
switch (T) {
default: assert(0 && "Unknown typespec!");
case DeclSpec::TST_unspecified: return "unspecified";
case DeclSpec::TST_void: return "void";
case DeclSpec::TST_char: return "char";
case DeclSpec::TST_int: return "int";
case DeclSpec::TST_float: return "float";
case DeclSpec::TST_double: return "double";
case DeclSpec::TST_bool: return "_Bool";
case DeclSpec::TST_decimal32: return "_Decimal32";
case DeclSpec::TST_decimal64: return "_Decimal64";
case DeclSpec::TST_decimal128: return "_Decimal128";
case DeclSpec::TST_enum: return "enum";
case DeclSpec::TST_union: return "union";
case DeclSpec::TST_struct: return "struct";
case DeclSpec::TST_typedef: return "typedef";
case DeclSpec::TST_typeofType:
case DeclSpec::TST_typeofExpr: return "typeof";
}
}
static bool BadSpecifier(DeclSpec::TST T, const char *&PrevSpec) {
PrevSpec = DeclSpec::getSpecifierName(T);
return true;
}
static bool BadSpecifier(DeclSpec::TQ T, const char *&PrevSpec) {
switch (T) {
case DeclSpec::TQ_unspecified: PrevSpec = "unspecified"; break;
case DeclSpec::TQ_const: PrevSpec = "const"; break;
case DeclSpec::TQ_restrict: PrevSpec = "restrict"; break;
case DeclSpec::TQ_volatile: PrevSpec = "volatile"; break;
}
return true;
}
bool DeclSpec::SetStorageClassSpec(SCS S, SourceLocation Loc,
const char *&PrevSpec) {
if (StorageClassSpec != SCS_unspecified)
return BadSpecifier(StorageClassSpec, PrevSpec);
StorageClassSpec = S;
StorageClassSpecLoc = Loc;
return false;
}
bool DeclSpec::SetStorageClassSpecThread(SourceLocation Loc,
const char *&PrevSpec) {
if (SCS_thread_specified) {
PrevSpec = "__thread";
return true;
}
SCS_thread_specified = true;
SCS_threadLoc = Loc;
return false;
}
/// These methods set the specified attribute of the DeclSpec, but return true
/// and ignore the request if invalid (e.g. "extern" then "auto" is
/// specified).
bool DeclSpec::SetTypeSpecWidth(TSW W, SourceLocation Loc,
const char *&PrevSpec) {
if (TypeSpecWidth != TSW_unspecified &&
// Allow turning long -> long long.
(W != TSW_longlong || TypeSpecWidth != TSW_long))
return BadSpecifier(TypeSpecWidth, PrevSpec);
TypeSpecWidth = W;
TSWLoc = Loc;
return false;
}
bool DeclSpec::SetTypeSpecComplex(TSC C, SourceLocation Loc,
const char *&PrevSpec) {
if (TypeSpecComplex != TSC_unspecified)
return BadSpecifier(TypeSpecComplex, PrevSpec);
TypeSpecComplex = C;
TSCLoc = Loc;
return false;
}
bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
const char *&PrevSpec) {
if (TypeSpecSign != TSS_unspecified)
return BadSpecifier(TypeSpecSign, PrevSpec);
TypeSpecSign = S;
TSSLoc = Loc;
return false;
}
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
const char *&PrevSpec, void *Rep) {
if (TypeSpecType != TST_unspecified)
return BadSpecifier(TypeSpecType, PrevSpec);
TypeSpecType = T;
TypeRep = Rep;
TSTLoc = Loc;
return false;
}
bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
const LangOptions &Lang) {
// Duplicates turn into warnings pre-C99.
if ((TypeQualifiers & T) && !Lang.C99)
return BadSpecifier(T, PrevSpec);
TypeQualifiers |= T;
switch (T) {
default: assert(0 && "Unknown type qualifier!");
case TQ_const: TQ_constLoc = Loc; break;
case TQ_restrict: TQ_restrictLoc = Loc; break;
case TQ_volatile: TQ_volatileLoc = Loc; break;
}
return false;
}
bool DeclSpec::SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec){
// 'inline inline' is ok.
FS_inline_specified = true;
FS_inlineLoc = Loc;
return false;
}
/// Finish - This does final analysis of the declspec, rejecting things like
/// "_Imaginary" (lacking an FP type). This returns a diagnostic to issue or
/// diag::NUM_DIAGNOSTICS if there is no error. After calling this method,
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
void DeclSpec::Finish(Diagnostic &D, const LangOptions &Lang) {
// Check the type specifier components first.
// signed/unsigned are only valid with int/char.
if (TypeSpecSign != TSS_unspecified) {
if (TypeSpecType == TST_unspecified)
TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
else if (TypeSpecType != TST_int && TypeSpecType != TST_char) {
Diag(D, TSSLoc, diag::err_invalid_sign_spec,
getSpecifierName(TypeSpecType));
// signed double -> double.
TypeSpecSign = TSS_unspecified;
}
}
// Validate the width of the type.
switch (TypeSpecWidth) {
case TSW_unspecified: break;
case TSW_short: // short int
case TSW_longlong: // long long int
if (TypeSpecType == TST_unspecified)
TypeSpecType = TST_int; // short -> short int, long long -> long long int.
else if (TypeSpecType != TST_int) {
Diag(D, TSWLoc,
TypeSpecWidth == TSW_short ? diag::err_invalid_short_spec
: diag::err_invalid_longlong_spec,
getSpecifierName(TypeSpecType));
TypeSpecType = TST_int;
}
break;
case TSW_long: // long double, long int
if (TypeSpecType == TST_unspecified)
TypeSpecType = TST_int; // long -> long int.
else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
Diag(D, TSWLoc, diag::err_invalid_long_spec,
getSpecifierName(TypeSpecType));
TypeSpecType = TST_int;
}
break;
}
// TODO: if the implementation does not implement _Complex or _Imaginary,
// disallow their use. Need information about the backend.
if (TypeSpecComplex != TSC_unspecified) {
if (TypeSpecType == TST_unspecified) {
Diag(D, TSCLoc, diag::ext_plain_complex);
TypeSpecType = TST_double; // _Complex -> _Complex double.
} else if (TypeSpecType == TST_int || TypeSpecType == TST_char) {
// Note that this intentionally doesn't include _Complex _Bool.
Diag(D, TSTLoc, diag::ext_integer_complex);
} else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
Diag(D, TSCLoc, diag::err_invalid_complex_spec,
getSpecifierName(TypeSpecType));
TypeSpecComplex = TSC_unspecified;
}
}
// Verify __thread.
if (SCS_thread_specified) {
if (StorageClassSpec == SCS_unspecified) {
StorageClassSpec = SCS_extern; // '__thread int' -> 'extern __thread int'
} else if (StorageClassSpec != SCS_extern &&
StorageClassSpec != SCS_static) {
Diag(D, getStorageClassSpecLoc(), diag::err_invalid_thread_spec,
getSpecifierName(StorageClassSpec));
SCS_thread_specified = false;
}
}
// Okay, now we can infer the real type.
// TODO: return "auto function" and other bad things based on the real type.
// 'data definition has no type or storage class'?
}

View File

@@ -1,22 +0,0 @@
##===- clang/Parse/Makefile --------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Chris Lattner and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements the Parser library for the C-Language front-end.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LIBRARYNAME := clangParse
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
include $(LEVEL)/Makefile.common

View File

@@ -1,116 +0,0 @@
//===--- MinimalAction.cpp - Implement the MinimalAction class ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the MinimalAction interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
using namespace clang;
/// TypeNameInfo - A link exists here for each scope that an identifier is
/// defined.
struct TypeNameInfo {
TypeNameInfo *Prev;
bool isTypeName;
TypeNameInfo(bool istypename, TypeNameInfo *prev) {
isTypeName = istypename;
Prev = prev;
}
};
/// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to
/// determine whether the name is a type name (objc class name or typedef) or
/// not in this scope.
Action::DeclTy *
MinimalAction::isTypeName(const IdentifierInfo &II, Scope *S) const {
if (TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>())
if (TI->isTypeName)
return TI;
return 0;
}
/// ParseDeclarator - If this is a typedef declarator, we modify the
/// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
/// popped.
Action::DeclTy *
MinimalAction::ParseDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup) {
IdentifierInfo *II = D.getIdentifier();
// If there is no identifier associated with this declarator, bail out.
if (II == 0) return 0;
TypeNameInfo *weCurrentlyHaveTypeInfo = II->getFETokenInfo<TypeNameInfo>();
bool isTypeName =
D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef;
// this check avoids creating TypeNameInfo objects for the common case.
// It does need to handle the uncommon case of shadowing a typedef name with a
// non-typedef name. e.g. { typedef int a; a xx; { int a; } }
if (weCurrentlyHaveTypeInfo || isTypeName) {
TypeNameInfo *TI = new TypeNameInfo(isTypeName, weCurrentlyHaveTypeInfo);
II->setFETokenInfo(TI);
// Remember that this needs to be removed when the scope is popped.
S->AddDecl(II);
}
return 0;
}
Action::DeclTy *
MinimalAction::ObjcStartClassInterface(SourceLocation AtInterafceLoc,
IdentifierInfo *ClassName, SourceLocation ClassLoc,
IdentifierInfo *SuperName, SourceLocation SuperLoc,
IdentifierInfo **ProtocolNames, unsigned NumProtocols,
AttributeList *AttrList) {
TypeNameInfo *TI =
new TypeNameInfo(1, ClassName->getFETokenInfo<TypeNameInfo>());
ClassName->setFETokenInfo(TI);
return 0;
}
/// ObjcClassDeclaration -
/// Scope will always be top level file scope.
Action::DeclTy *
MinimalAction::ObjcClassDeclaration(Scope *S, SourceLocation AtClassLoc,
IdentifierInfo **IdentList, unsigned NumElts) {
for (unsigned i = 0; i != NumElts; ++i) {
TypeNameInfo *TI =
new TypeNameInfo(1, IdentList[i]->getFETokenInfo<TypeNameInfo>());
IdentList[i]->setFETokenInfo(TI);
// Remember that this needs to be removed when the scope is popped.
S->AddDecl(IdentList[i]);
}
return 0;
}
/// PopScope - When a scope is popped, if any typedefs are now out-of-scope,
/// they are removed from the IdentifierInfo::FETokenInfo field.
void MinimalAction::PopScope(SourceLocation Loc, Scope *S) {
for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
I != E; ++I) {
IdentifierInfo &II = *static_cast<IdentifierInfo*>(*I);
TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>();
assert(TI && "This decl didn't get pushed??");
if (TI) {
TypeNameInfo *Next = TI->Prev;
delete TI;
II.setFETokenInfo(Next);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,82 +0,0 @@
//===--- ParseDeclCXX.cpp - C++ Declaration Parsing -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the C++ Declaration portions of the Parser interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Parse/Scope.h"
#include "clang/Basic/Diagnostic.h"
using namespace clang;
/// ParseNamespace - We know that the current token is a namespace keyword. This
/// may either be a top level namespace or a block-level namespace alias.
///
/// namespace-definition: [C++ 7.3: basic.namespace]
/// named-namespace-definition
/// unnamed-namespace-definition
///
/// unnamed-namespace-definition:
/// 'namespace' attributes[opt] '{' namespace-body '}'
///
/// named-namespace-definition:
/// original-namespace-definition
/// extension-namespace-definition
///
/// original-namespace-definition:
/// 'namespace' identifier attributes[opt] '{' namespace-body '}'
///
/// extension-namespace-definition:
/// 'namespace' original-namespace-name '{' namespace-body '}'
///
/// namespace-alias-definition: [C++ 7.3.2: namespace.alias]
/// 'namespace' identifier '=' qualified-namespace-specifier ';'
///
Parser::DeclTy *Parser::ParseNamespace(unsigned Context) {
assert(Tok.getKind() == tok::kw_namespace && "Not a namespace!");
SourceLocation NamespaceLoc = ConsumeToken(); // eat the 'namespace'.
SourceLocation IdentLoc;
IdentifierInfo *Ident = 0;
if (Tok.getKind() == tok::identifier) {
Ident = Tok.getIdentifierInfo();
IdentLoc = ConsumeToken(); // eat the identifier.
}
// Read label attributes, if present.
DeclTy *AttrList = 0;
if (Tok.getKind() == tok::kw___attribute)
// FIXME: save these somewhere.
AttrList = ParseAttributes();
if (Tok.getKind() == tok::equal) {
// FIXME: Verify no attributes were present.
// FIXME: parse this.
} else if (Tok.getKind() == tok::l_brace) {
SourceLocation LBrace = ConsumeBrace();
// FIXME: push a scope, push a namespace decl.
while (Tok.getKind() != tok::r_brace && Tok.getKind() != tok::eof) {
// FIXME capture the decls.
ParseExternalDeclaration();
}
SourceLocation RBrace = MatchRHSPunctuation(tok::r_brace, LBrace);
// FIXME: act on this.
} else {
unsigned D = Ident ? diag::err_expected_lbrace :
diag::err_expected_ident_lbrace;
Diag(Tok.getLocation(), D);
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,78 +0,0 @@
//===--- ParseExprCXX.cpp - C++ Expression Parsing ------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Expression parsing implementation for C++.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/Diagnostic.h"
#include "clang/Parse/Parser.h"
using namespace clang;
/// ParseCXXCasts - This handles the various ways to cast expressions to another
/// type.
///
/// postfix-expression: [C++ 5.2p1]
/// 'dynamic_cast' '<' type-name '>' '(' expression ')'
/// 'static_cast' '<' type-name '>' '(' expression ')'
/// 'reinterpret_cast' '<' type-name '>' '(' expression ')'
/// 'const_cast' '<' type-name '>' '(' expression ')'
///
Parser::ExprResult Parser::ParseCXXCasts() {
tok::TokenKind Kind = Tok.getKind();
const char *CastName = 0; // For error messages
switch (Kind) {
default: assert(0 && "Unknown C++ cast!"); abort();
case tok::kw_const_cast: CastName = "const_cast"; break;
case tok::kw_dynamic_cast: CastName = "dynamic_cast"; break;
case tok::kw_reinterpret_cast: CastName = "reinterpret_cast"; break;
case tok::kw_static_cast: CastName = "static_cast"; break;
}
SourceLocation OpLoc = ConsumeToken();
SourceLocation LAngleBracketLoc = Tok.getLocation();
if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
return ExprResult(true);
TypeTy *CastTy = ParseTypeName();
SourceLocation RAngleBracketLoc = Tok.getLocation();
if (ExpectAndConsume(tok::greater, diag::err_expected_greater)) {
Diag(LAngleBracketLoc, diag::err_matching, "<");
return ExprResult(true);
}
SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, CastName);
return ExprResult(true);
}
ExprResult Result = ParseSimpleParenExpression(RParenLoc);
if (!Result.isInvalid)
Result = Actions.ParseCXXCasts(OpLoc, Kind,
LAngleBracketLoc, CastTy, RAngleBracketLoc,
LParenLoc, Result.Val, RParenLoc);
return Result;
}
/// ParseCXXBoolLiteral - This handles the C++ Boolean literals.
///
/// boolean-literal: [C++ 2.13.5]
/// 'true'
/// 'false'
Parser::ExprResult Parser::ParseCXXBoolLiteral() {
tok::TokenKind Kind = Tok.getKind();
return Actions.ParseCXXBoolLiteral(ConsumeToken(), Kind);
}

View File

@@ -1,199 +0,0 @@
//===--- ParseInit.cpp - Initializer Parsing ------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements initializer parsing as specified by C99 6.7.8.
//
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/SmallString.h"
using namespace clang;
/// MayBeDesignationStart - Return true if this token might be the start of a
/// designator.
static bool MayBeDesignationStart(tok::TokenKind K) {
switch (K) {
default: return false;
case tok::period: // designator: '.' identifier
case tok::l_square: // designator: array-designator
case tok::identifier: // designation: identifier ':'
return true;
}
}
/// ParseInitializerWithPotentialDesignator - Parse the 'initializer' production
/// checking to see if the token stream starts with a designator.
///
/// designation:
/// designator-list '='
/// [GNU] array-designator
/// [GNU] identifier ':'
///
/// designator-list:
/// designator
/// designator-list designator
///
/// designator:
/// array-designator
/// '.' identifier
///
/// array-designator:
/// '[' constant-expression ']'
/// [GNU] '[' constant-expression '...' constant-expression ']'
///
/// NOTE: [OBC] allows '[ objc-receiver objc-message-args ]' as an
/// initializer. We need to consider this case when parsing array designators.
///
Parser::ExprResult Parser::ParseInitializerWithPotentialDesignator() {
// Parse each designator in the designator list until we find an initializer.
while (1) {
switch (Tok.getKind()) {
case tok::equal:
// We read some number (at least one due to the grammar we implemented)
// of designators and found an '=' sign. The following tokens must be
// the initializer.
ConsumeToken();
return ParseInitializer();
default: {
// We read some number (at least one due to the grammar we implemented)
// of designators and found something that isn't an = or an initializer.
// If we have exactly one array designator [TODO CHECK], this is the GNU
// 'designation: array-designator' extension. Otherwise, it is a parse
// error.
SourceLocation Loc = Tok.getLocation();
ExprResult Init = ParseInitializer();
if (Init.isInvalid) return Init;
Diag(Tok, diag::ext_gnu_missing_equal_designator);
return Init;
}
case tok::period:
// designator: '.' identifier
ConsumeToken();
if (ExpectAndConsume(tok::identifier, diag::err_expected_ident))
return ExprResult(true);
break;
case tok::l_square: {
// array-designator: '[' constant-expression ']'
// array-designator: '[' constant-expression '...' constant-expression ']'
SourceLocation StartLoc = ConsumeBracket();
ExprResult Idx = ParseConstantExpression();
if (Idx.isInvalid) {
SkipUntil(tok::r_square);
return Idx;
}
// Handle the gnu array range extension.
if (Tok.getKind() == tok::ellipsis) {
Diag(Tok, diag::ext_gnu_array_range);
ConsumeToken();
ExprResult RHS = ParseConstantExpression();
if (RHS.isInvalid) {
SkipUntil(tok::r_square);
return RHS;
}
}
MatchRHSPunctuation(tok::r_square, StartLoc);
break;
}
case tok::identifier: {
// Due to the GNU "designation: identifier ':'" extension, we don't know
// whether something starting with an identifier is an
// assignment-expression or if it is an old-style structure field
// designator.
// TODO: Check that this is the first designator.
Token Ident = Tok;
ConsumeToken();
// If this is the gross GNU extension, handle it now.
if (Tok.getKind() == tok::colon) {
Diag(Ident, diag::ext_gnu_old_style_field_designator);
ConsumeToken();
return ParseInitializer();
}
// Otherwise, we just consumed the first token of an expression. Parse
// the rest of it now.
return ParseAssignmentExprWithLeadingIdentifier(Ident);
}
}
}
}
/// ParseInitializer
/// initializer: [C99 6.7.8]
/// assignment-expression
/// '{' initializer-list '}'
/// '{' initializer-list ',' '}'
/// [GNU] '{' '}'
///
/// initializer-list:
/// designation[opt] initializer
/// initializer-list ',' designation[opt] initializer
///
Parser::ExprResult Parser::ParseInitializer() {
if (Tok.getKind() != tok::l_brace)
return ParseAssignmentExpression();
SourceLocation LBraceLoc = ConsumeBrace();
// We support empty initializers, but tell the user that they aren't using
// C99-clean code.
if (Tok.getKind() == tok::r_brace) {
Diag(LBraceLoc, diag::ext_gnu_empty_initializer);
// Match the '}'.
return Actions.ParseInitList(LBraceLoc, 0, 0, ConsumeBrace());
}
llvm::SmallVector<ExprTy*, 8> InitExprs;
bool InitExprsOk = true;
while (1) {
// Parse: designation[opt] initializer
// If we know that this cannot be a designation, just parse the nested
// initializer directly.
ExprResult SubElt;
if (!MayBeDesignationStart(Tok.getKind()))
SubElt = ParseInitializer();
else
SubElt = ParseInitializerWithPotentialDesignator();
// If we couldn't parse the subelement, bail out.
if (SubElt.isInvalid) {
InitExprsOk = false;
SkipUntil(tok::r_brace);
break;
} else
InitExprs.push_back(SubElt.Val);
// If we don't have a comma continued list, we're done.
if (Tok.getKind() != tok::comma) break;
// FIXME: save comma locations.
ConsumeToken();
// Handle trailing comma.
if (Tok.getKind() == tok::r_brace) break;
}
if (InitExprsOk && Tok.getKind() == tok::r_brace)
return Actions.ParseInitList(LBraceLoc, &InitExprs[0], InitExprs.size(),
ConsumeBrace());
// Match the '}'.
MatchRHSPunctuation(tok::r_brace, LBraceLoc);
return ExprResult(true); // an error occurred.
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,978 +0,0 @@
//===--- ParseStmt.cpp - Statement and Block Parser -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Statement and Block portions of the Parser
// interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
using namespace clang;
//===----------------------------------------------------------------------===//
// C99 6.8: Statements and Blocks.
//===----------------------------------------------------------------------===//
/// ParseStatementOrDeclaration - Read 'statement' or 'declaration'.
/// StatementOrDeclaration:
/// statement
/// declaration
///
/// statement:
/// labeled-statement
/// compound-statement
/// expression-statement
/// selection-statement
/// iteration-statement
/// jump-statement
/// [OBC] objc-throw-statement [TODO]
/// [OBC] objc-try-catch-statement [TODO]
/// [OBC] objc-synchronized-statement [TODO]
/// [GNU] asm-statement
/// [OMP] openmp-construct [TODO]
///
/// labeled-statement:
/// identifier ':' statement
/// 'case' constant-expression ':' statement
/// 'default' ':' statement
///
/// selection-statement:
/// if-statement
/// switch-statement
///
/// iteration-statement:
/// while-statement
/// do-statement
/// for-statement
///
/// expression-statement:
/// expression[opt] ';'
///
/// jump-statement:
/// 'goto' identifier ';'
/// 'continue' ';'
/// 'break' ';'
/// 'return' expression[opt] ';'
/// [GNU] 'goto' '*' expression ';'
///
/// [OBC] objc-throw-statement: [TODO]
/// [OBC] '@' 'throw' expression ';' [TODO]
/// [OBC] '@' 'throw' ';' [TODO]
///
Parser::StmtResult Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
const char *SemiError = 0;
Parser::StmtResult Res;
// Cases in this switch statement should fall through if the parser expects
// the token to end in a semicolon (in which case SemiError should be set),
// or they directly 'return;' if not.
switch (Tok.getKind()) {
case tok::identifier: // C99 6.8.1: labeled-statement
// identifier ':' statement
// declaration (if !OnlyStatement)
// expression[opt] ';'
return ParseIdentifierStatement(OnlyStatement);
default:
if (!OnlyStatement && isDeclarationSpecifier()) {
return Actions.ParseDeclStmt(ParseDeclaration(Declarator::BlockContext));
} else if (Tok.getKind() == tok::r_brace) {
Diag(Tok, diag::err_expected_statement);
return true;
} else {
// expression[opt] ';'
ExprResult Res = ParseExpression();
if (Res.isInvalid) {
// If the expression is invalid, skip ahead to the next semicolon. Not
// doing this opens us up to the possibility of infinite loops if
// ParseExpression does not consume any tokens.
SkipUntil(tok::semi);
return true;
}
// Otherwise, eat the semicolon.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
return Actions.ParseExprStmt(Res.Val);
}
case tok::kw_case: // C99 6.8.1: labeled-statement
return ParseCaseStatement();
case tok::kw_default: // C99 6.8.1: labeled-statement
return ParseDefaultStatement();
case tok::l_brace: // C99 6.8.2: compound-statement
return ParseCompoundStatement();
case tok::semi: // C99 6.8.3p3: expression[opt] ';'
return Actions.ParseNullStmt(ConsumeToken());
case tok::kw_if: // C99 6.8.4.1: if-statement
return ParseIfStatement();
case tok::kw_switch: // C99 6.8.4.2: switch-statement
return ParseSwitchStatement();
case tok::kw_while: // C99 6.8.5.1: while-statement
return ParseWhileStatement();
case tok::kw_do: // C99 6.8.5.2: do-statement
Res = ParseDoStatement();
SemiError = "do/while loop";
break;
case tok::kw_for: // C99 6.8.5.3: for-statement
return ParseForStatement();
case tok::kw_goto: // C99 6.8.6.1: goto-statement
Res = ParseGotoStatement();
SemiError = "goto statement";
break;
case tok::kw_continue: // C99 6.8.6.2: continue-statement
Res = ParseContinueStatement();
SemiError = "continue statement";
break;
case tok::kw_break: // C99 6.8.6.3: break-statement
Res = ParseBreakStatement();
SemiError = "break statement";
break;
case tok::kw_return: // C99 6.8.6.4: return-statement
Res = ParseReturnStatement();
SemiError = "return statement";
break;
case tok::kw_asm:
Res = ParseAsmStatement();
SemiError = "asm statement";
break;
}
// If we reached this code, the statement must end in a semicolon.
if (Tok.getKind() == tok::semi) {
ConsumeToken();
} else {
Diag(Tok, diag::err_expected_semi_after, SemiError);
SkipUntil(tok::semi);
}
return Res;
}
/// ParseIdentifierStatement - Because we don't have two-token lookahead, we
/// have a bit of a quandry here. Reading the identifier is necessary to see if
/// there is a ':' after it. If there is, this is a label, regardless of what
/// else the identifier can mean. If not, this is either part of a declaration
/// (if the identifier is a type-name) or part of an expression.
///
/// labeled-statement:
/// identifier ':' statement
/// [GNU] identifier ':' attributes[opt] statement
/// declaration (if !OnlyStatement)
/// expression[opt] ';'
///
Parser::StmtResult Parser::ParseIdentifierStatement(bool OnlyStatement) {
assert(Tok.getKind() == tok::identifier && Tok.getIdentifierInfo() &&
"Not an identifier!");
Token IdentTok = Tok; // Save the whole token.
ConsumeToken(); // eat the identifier.
// identifier ':' statement
if (Tok.getKind() == tok::colon) {
SourceLocation ColonLoc = ConsumeToken();
// Read label attributes, if present.
DeclTy *AttrList = 0;
if (Tok.getKind() == tok::kw___attribute)
// TODO: save these somewhere.
AttrList = ParseAttributes();
StmtResult SubStmt = ParseStatement();
// Broken substmt shouldn't prevent the label from being added to the AST.
if (SubStmt.isInvalid)
SubStmt = Actions.ParseNullStmt(ColonLoc);
return Actions.ParseLabelStmt(IdentTok.getLocation(),
IdentTok.getIdentifierInfo(),
ColonLoc, SubStmt.Val);
}
// Check to see if this is a declaration.
void *TypeRep;
if (!OnlyStatement &&
(TypeRep = Actions.isTypeName(*IdentTok.getIdentifierInfo(), CurScope))) {
// Handle this. Warn/disable if in middle of block and !C99.
DeclSpec DS;
// Add the typedef name to the start of the decl-specs.
const char *PrevSpec = 0;
int isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typedef,
IdentTok.getLocation(), PrevSpec,
TypeRep);
assert(!isInvalid && "First declspec can't be invalid!");
// ParseDeclarationSpecifiers will continue from there.
ParseDeclarationSpecifiers(DS);
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
if (Tok.getKind() == tok::semi) {
// TODO: emit error on 'int;' or 'const enum foo;'.
// if (!DS.isMissingDeclaratorOk()) Diag(...);
ConsumeToken();
// FIXME: Return this as a type decl.
return 0;
}
// Parse all the declarators.
Declarator DeclaratorInfo(DS, Declarator::BlockContext);
ParseDeclarator(DeclaratorInfo);
DeclTy *Decl = ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
return Decl ? Actions.ParseDeclStmt(Decl) : 0;
}
// Otherwise, this is an expression. Seed it with II and parse it.
ExprResult Res = ParseExpressionWithLeadingIdentifier(IdentTok);
if (Res.isInvalid) {
SkipUntil(tok::semi);
return true;
} else if (Tok.getKind() != tok::semi) {
Diag(Tok, diag::err_expected_semi_after, "expression");
SkipUntil(tok::semi);
return true;
} else {
ConsumeToken();
// Convert expr to a stmt.
return Actions.ParseExprStmt(Res.Val);
}
}
/// ParseCaseStatement
/// labeled-statement:
/// 'case' constant-expression ':' statement
/// [GNU] 'case' constant-expression '...' constant-expression ':' statement
///
/// Note that this does not parse the 'statement' at the end.
///
Parser::StmtResult Parser::ParseCaseStatement() {
assert(Tok.getKind() == tok::kw_case && "Not a case stmt!");
SourceLocation CaseLoc = ConsumeToken(); // eat the 'case'.
ExprResult LHS = ParseConstantExpression();
if (LHS.isInvalid) {
SkipUntil(tok::colon);
return true;
}
// GNU case range extension.
SourceLocation DotDotDotLoc;
ExprTy *RHSVal = 0;
if (Tok.getKind() == tok::ellipsis) {
Diag(Tok, diag::ext_gnu_case_range);
DotDotDotLoc = ConsumeToken();
ExprResult RHS = ParseConstantExpression();
if (RHS.isInvalid) {
SkipUntil(tok::colon);
return true;
}
RHSVal = RHS.Val;
}
if (Tok.getKind() != tok::colon) {
Diag(Tok, diag::err_expected_colon_after, "'case'");
SkipUntil(tok::colon);
return true;
}
SourceLocation ColonLoc = ConsumeToken();
// Diagnose the common error "switch (X) { case 4: }", which is not valid.
if (Tok.getKind() == tok::r_brace) {
Diag(Tok, diag::err_label_end_of_compound_statement);
return true;
}
StmtResult SubStmt = ParseStatement();
// Broken substmt shouldn't prevent the case from being added to the AST.
if (SubStmt.isInvalid)
SubStmt = Actions.ParseNullStmt(ColonLoc);
return Actions.ParseCaseStmt(CaseLoc, LHS.Val, DotDotDotLoc, RHSVal, ColonLoc,
SubStmt.Val);
}
/// ParseDefaultStatement
/// labeled-statement:
/// 'default' ':' statement
/// Note that this does not parse the 'statement' at the end.
///
Parser::StmtResult Parser::ParseDefaultStatement() {
assert(Tok.getKind() == tok::kw_default && "Not a default stmt!");
SourceLocation DefaultLoc = ConsumeToken(); // eat the 'default'.
if (Tok.getKind() != tok::colon) {
Diag(Tok, diag::err_expected_colon_after, "'default'");
SkipUntil(tok::colon);
return true;
}
SourceLocation ColonLoc = ConsumeToken();
// Diagnose the common error "switch (X) {... default: }", which is not valid.
if (Tok.getKind() == tok::r_brace) {
Diag(Tok, diag::err_label_end_of_compound_statement);
return true;
}
StmtResult SubStmt = ParseStatement();
if (SubStmt.isInvalid)
return true;
return Actions.ParseDefaultStmt(DefaultLoc, ColonLoc, SubStmt.Val, CurScope);
}
/// ParseCompoundStatement - Parse a "{}" block.
///
/// compound-statement: [C99 6.8.2]
/// { block-item-list[opt] }
/// [GNU] { label-declarations block-item-list } [TODO]
///
/// block-item-list:
/// block-item
/// block-item-list block-item
///
/// block-item:
/// declaration
/// [GNU] '__extension__' declaration
/// statement
/// [OMP] openmp-directive [TODO]
///
/// [GNU] label-declarations:
/// [GNU] label-declaration
/// [GNU] label-declarations label-declaration
///
/// [GNU] label-declaration:
/// [GNU] '__label__' identifier-list ';'
///
/// [OMP] openmp-directive: [TODO]
/// [OMP] barrier-directive
/// [OMP] flush-directive
///
Parser::StmtResult Parser::ParseCompoundStatement(bool isStmtExpr) {
assert(Tok.getKind() == tok::l_brace && "Not a compount stmt!");
// Enter a scope to hold everything within the compound stmt. Compound
// statements can always hold declarations.
EnterScope(Scope::DeclScope);
// Parse the statements in the body.
StmtResult Body = ParseCompoundStatementBody(isStmtExpr);
ExitScope();
return Body;
}
/// ParseCompoundStatementBody - Parse a sequence of statements and invoke the
/// ParseCompoundStmt action. This expects the '{' to be the current token, and
/// consume the '}' at the end of the block. It does not manipulate the scope
/// stack.
Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
SourceLocation LBraceLoc = ConsumeBrace(); // eat the '{'.
// TODO: "__label__ X, Y, Z;" is the GNU "Local Label" extension. These are
// only allowed at the start of a compound stmt regardless of the language.
llvm::SmallVector<StmtTy*, 32> Stmts;
while (Tok.getKind() != tok::r_brace && Tok.getKind() != tok::eof) {
StmtResult R;
if (Tok.getKind() != tok::kw___extension__) {
R = ParseStatementOrDeclaration(false);
} else {
// __extension__ can start declarations and it can also be a unary
// operator for expressions. Consume multiple __extension__ markers here
// until we can determine which is which.
SourceLocation ExtLoc = ConsumeToken();
while (Tok.getKind() == tok::kw___extension__)
ConsumeToken();
// If this is the start of a declaration, parse it as such.
if (isDeclarationSpecifier()) {
// FIXME: Save the __extension__ on the decl as a node somehow.
// FIXME: disable extwarns.
R = Actions.ParseDeclStmt(ParseDeclaration(Declarator::BlockContext));
} else {
// Otherwise this was a unary __extension__ marker. Parse the
// subexpression and add the __extension__ unary op.
// FIXME: disable extwarns.
ExprResult Res = ParseCastExpression(false);
if (Res.isInvalid) {
SkipUntil(tok::semi);
continue;
}
// Add the __extension__ node to the AST.
Res = Actions.ParseUnaryOp(ExtLoc, tok::kw___extension__, Res.Val);
if (Res.isInvalid)
continue;
// Eat the semicolon at the end of stmt and convert the expr into a stmt.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
R = Actions.ParseExprStmt(Res.Val);
}
}
if (!R.isInvalid && R.Val)
Stmts.push_back(R.Val);
}
// We broke out of the while loop because we found a '}' or EOF.
if (Tok.getKind() != tok::r_brace) {
Diag(Tok, diag::err_expected_rbrace);
return 0;
}
SourceLocation RBraceLoc = ConsumeBrace();
return Actions.ParseCompoundStmt(LBraceLoc, RBraceLoc,
&Stmts[0], Stmts.size(), isStmtExpr);
}
/// ParseIfStatement
/// if-statement: [C99 6.8.4.1]
/// 'if' '(' expression ')' statement
/// 'if' '(' expression ')' statement 'else' statement
///
Parser::StmtResult Parser::ParseIfStatement() {
assert(Tok.getKind() == tok::kw_if && "Not an if stmt!");
SourceLocation IfLoc = ConsumeToken(); // eat the 'if'.
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, "if");
SkipUntil(tok::semi);
return true;
}
// C99 6.8.4p3 - In C99, the if statement is a block. This is not
// the case for C90.
if (getLang().C99)
EnterScope(Scope::DeclScope);
// Parse the condition.
ExprResult CondExp = ParseSimpleParenExpression();
if (CondExp.isInvalid) {
SkipUntil(tok::semi);
if (getLang().C99)
ExitScope();
return true;
}
// C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace;
if (NeedsInnerScope) EnterScope(Scope::DeclScope);
// Read the if condition.
StmtResult CondStmt = ParseStatement();
// Broken substmt shouldn't prevent the label from being added to the AST.
if (CondStmt.isInvalid)
CondStmt = Actions.ParseNullStmt(Tok.getLocation());
// Pop the 'if' scope if needed.
if (NeedsInnerScope) ExitScope();
// If it has an else, parse it.
SourceLocation ElseLoc;
StmtResult ElseStmt(false);
if (Tok.getKind() == tok::kw_else) {
ElseLoc = ConsumeToken();
// C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do
// this if the body isn't a compound statement to avoid push/pop in common
// cases.
NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace;
if (NeedsInnerScope) EnterScope(Scope::DeclScope);
ElseStmt = ParseStatement();
// Pop the 'else' scope if needed.
if (NeedsInnerScope) ExitScope();
if (ElseStmt.isInvalid)
ElseStmt = Actions.ParseNullStmt(ElseLoc);
}
if (getLang().C99)
ExitScope();
return Actions.ParseIfStmt(IfLoc, CondExp.Val, CondStmt.Val,
ElseLoc, ElseStmt.Val);
}
/// ParseSwitchStatement
/// switch-statement:
/// 'switch' '(' expression ')' statement
Parser::StmtResult Parser::ParseSwitchStatement() {
assert(Tok.getKind() == tok::kw_switch && "Not a switch stmt!");
SourceLocation SwitchLoc = ConsumeToken(); // eat the 'switch'.
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, "switch");
SkipUntil(tok::semi);
return true;
}
// C99 6.8.4p3 - In C99, the switch statement is a block. This is
// not the case for C90. Start the switch scope.
if (getLang().C99)
EnterScope(Scope::BreakScope|Scope::DeclScope);
else
EnterScope(Scope::BreakScope);
// Parse the condition.
ExprResult Cond = ParseSimpleParenExpression();
if (Cond.isInvalid) {
ExitScope();
return true;
}
StmtResult Switch = Actions.StartSwitchStmt(Cond.Val);
// C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace;
if (NeedsInnerScope) EnterScope(Scope::DeclScope);
// Read the body statement.
StmtResult Body = ParseStatement();
// Pop the body scope if needed.
if (NeedsInnerScope) ExitScope();
if (Body.isInvalid) {
Body = Actions.ParseNullStmt(Tok.getLocation());
// FIXME: Remove the case statement list from the Switch statement.
}
ExitScope();
return Actions.FinishSwitchStmt(SwitchLoc, Switch.Val, Body.Val);
}
/// ParseWhileStatement
/// while-statement: [C99 6.8.5.1]
/// 'while' '(' expression ')' statement
Parser::StmtResult Parser::ParseWhileStatement() {
assert(Tok.getKind() == tok::kw_while && "Not a while stmt!");
SourceLocation WhileLoc = Tok.getLocation();
ConsumeToken(); // eat the 'while'.
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, "while");
SkipUntil(tok::semi);
return true;
}
// C99 6.8.5p5 - In C99, the while statement is a block. This is not
// the case for C90. Start the loop scope.
if (getLang().C99)
EnterScope(Scope::BreakScope | Scope::ContinueScope | Scope::DeclScope);
else
EnterScope(Scope::BreakScope | Scope::ContinueScope);
// Parse the condition.
ExprResult Cond = ParseSimpleParenExpression();
// C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace;
if (NeedsInnerScope) EnterScope(Scope::DeclScope);
// Read the body statement.
StmtResult Body = ParseStatement();
// Pop the body scope if needed.
if (NeedsInnerScope) ExitScope();
ExitScope();
if (Cond.isInvalid || Body.isInvalid) return true;
return Actions.ParseWhileStmt(WhileLoc, Cond.Val, Body.Val);
}
/// ParseDoStatement
/// do-statement: [C99 6.8.5.2]
/// 'do' statement 'while' '(' expression ')' ';'
/// Note: this lets the caller parse the end ';'.
Parser::StmtResult Parser::ParseDoStatement() {
assert(Tok.getKind() == tok::kw_do && "Not a do stmt!");
SourceLocation DoLoc = ConsumeToken(); // eat the 'do'.
// C99 6.8.5p5 - In C99, the do statement is a block. This is not
// the case for C90. Start the loop scope.
if (getLang().C99)
EnterScope(Scope::BreakScope | Scope::ContinueScope | Scope::DeclScope);
else
EnterScope(Scope::BreakScope | Scope::ContinueScope);
// C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace;
if (NeedsInnerScope) EnterScope(Scope::DeclScope);
// Read the body statement.
StmtResult Body = ParseStatement();
// Pop the body scope if needed.
if (NeedsInnerScope) ExitScope();
if (Tok.getKind() != tok::kw_while) {
ExitScope();
Diag(Tok, diag::err_expected_while);
Diag(DoLoc, diag::err_matching, "do");
SkipUntil(tok::semi);
return true;
}
SourceLocation WhileLoc = ConsumeToken();
if (Tok.getKind() != tok::l_paren) {
ExitScope();
Diag(Tok, diag::err_expected_lparen_after, "do/while");
SkipUntil(tok::semi);
return true;
}
// Parse the condition.
ExprResult Cond = ParseSimpleParenExpression();
ExitScope();
if (Cond.isInvalid || Body.isInvalid) return true;
return Actions.ParseDoStmt(DoLoc, Body.Val, WhileLoc, Cond.Val);
}
/// ParseForStatement
/// for-statement: [C99 6.8.5.3]
/// 'for' '(' expr[opt] ';' expr[opt] ';' expr[opt] ')' statement
/// 'for' '(' declaration expr[opt] ';' expr[opt] ')' statement
Parser::StmtResult Parser::ParseForStatement() {
assert(Tok.getKind() == tok::kw_for && "Not a for stmt!");
SourceLocation ForLoc = ConsumeToken(); // eat the 'for'.
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, "for");
SkipUntil(tok::semi);
return true;
}
// C99 6.8.5p5 - In C99, the for statement is a block. This is not
// the case for C90. Start the loop scope.
if (getLang().C99)
EnterScope(Scope::BreakScope | Scope::ContinueScope | Scope::DeclScope);
else
EnterScope(Scope::BreakScope | Scope::ContinueScope);
SourceLocation LParenLoc = ConsumeParen();
ExprResult Value;
StmtTy *FirstPart = 0;
ExprTy *SecondPart = 0;
StmtTy *ThirdPart = 0;
// Parse the first part of the for specifier.
if (Tok.getKind() == tok::semi) { // for (;
// no first part, eat the ';'.
ConsumeToken();
} else if (isDeclarationSpecifier()) { // for (int X = 4;
// Parse declaration, which eats the ';'.
if (!getLang().C99) // Use of C99-style for loops in C90 mode?
Diag(Tok, diag::ext_c99_variable_decl_in_for_loop);
DeclTy *aBlockVarDecl = ParseDeclaration(Declarator::ForContext);
StmtResult stmtResult = Actions.ParseDeclStmt(aBlockVarDecl);
FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val;
} else {
Value = ParseExpression();
// Turn the expression into a stmt.
if (!Value.isInvalid) {
StmtResult R = Actions.ParseExprStmt(Value.Val);
if (!R.isInvalid)
FirstPart = R.Val;
}
if (Tok.getKind() == tok::semi) {
ConsumeToken();
} else {
if (!Value.isInvalid) Diag(Tok, diag::err_expected_semi_for);
SkipUntil(tok::semi);
}
}
// Parse the second part of the for specifier.
if (Tok.getKind() == tok::semi) { // for (...;;
// no second part.
Value = ExprResult();
} else {
Value = ParseExpression();
if (!Value.isInvalid)
SecondPart = Value.Val;
}
if (Tok.getKind() == tok::semi) {
ConsumeToken();
} else {
if (!Value.isInvalid) Diag(Tok, diag::err_expected_semi_for);
SkipUntil(tok::semi);
}
// Parse the third part of the for specifier.
if (Tok.getKind() == tok::r_paren) { // for (...;...;)
// no third part.
Value = ExprResult();
} else {
Value = ParseExpression();
if (!Value.isInvalid) {
// Turn the expression into a stmt.
StmtResult R = Actions.ParseExprStmt(Value.Val);
if (!R.isInvalid)
ThirdPart = R.Val;
}
}
// Match the ')'.
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
// C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace;
if (NeedsInnerScope) EnterScope(Scope::DeclScope);
// Read the body statement.
StmtResult Body = ParseStatement();
// Pop the body scope if needed.
if (NeedsInnerScope) ExitScope();
// Leave the for-scope.
ExitScope();
if (Body.isInvalid)
return Body;
return Actions.ParseForStmt(ForLoc, LParenLoc, FirstPart, SecondPart,
ThirdPart, RParenLoc, Body.Val);
}
/// ParseGotoStatement
/// jump-statement:
/// 'goto' identifier ';'
/// [GNU] 'goto' '*' expression ';'
///
/// Note: this lets the caller parse the end ';'.
///
Parser::StmtResult Parser::ParseGotoStatement() {
assert(Tok.getKind() == tok::kw_goto && "Not a goto stmt!");
SourceLocation GotoLoc = ConsumeToken(); // eat the 'goto'.
StmtResult Res;
if (Tok.getKind() == tok::identifier) {
Res = Actions.ParseGotoStmt(GotoLoc, Tok.getLocation(),
Tok.getIdentifierInfo());
ConsumeToken();
} else if (Tok.getKind() == tok::star && !getLang().NoExtensions) {
// GNU indirect goto extension.
Diag(Tok, diag::ext_gnu_indirect_goto);
SourceLocation StarLoc = ConsumeToken();
ExprResult R = ParseExpression();
if (R.isInvalid) { // Skip to the semicolon, but don't consume it.
SkipUntil(tok::semi, false, true);
return true;
}
Res = Actions.ParseIndirectGotoStmt(GotoLoc, StarLoc, R.Val);
} else {
Diag(Tok, diag::err_expected_ident);
return true;
}
return Res;
}
/// ParseContinueStatement
/// jump-statement:
/// 'continue' ';'
///
/// Note: this lets the caller parse the end ';'.
///
Parser::StmtResult Parser::ParseContinueStatement() {
SourceLocation ContinueLoc = ConsumeToken(); // eat the 'continue'.
return Actions.ParseContinueStmt(ContinueLoc, CurScope);
}
/// ParseBreakStatement
/// jump-statement:
/// 'break' ';'
///
/// Note: this lets the caller parse the end ';'.
///
Parser::StmtResult Parser::ParseBreakStatement() {
SourceLocation BreakLoc = ConsumeToken(); // eat the 'break'.
return Actions.ParseBreakStmt(BreakLoc, CurScope);
}
/// ParseReturnStatement
/// jump-statement:
/// 'return' expression[opt] ';'
Parser::StmtResult Parser::ParseReturnStatement() {
assert(Tok.getKind() == tok::kw_return && "Not a return stmt!");
SourceLocation ReturnLoc = ConsumeToken(); // eat the 'return'.
ExprResult R(0);
if (Tok.getKind() != tok::semi) {
R = ParseExpression();
if (R.isInvalid) { // Skip to the semicolon, but don't consume it.
SkipUntil(tok::semi, false, true);
return true;
}
}
return Actions.ParseReturnStmt(ReturnLoc, R.Val);
}
/// ParseAsmStatement - Parse a GNU extended asm statement.
/// [GNU] asm-statement:
/// 'asm' type-qualifier[opt] '(' asm-argument ')' ';'
///
/// [GNU] asm-argument:
/// asm-string-literal
/// asm-string-literal ':' asm-operands[opt]
/// asm-string-literal ':' asm-operands[opt] ':' asm-operands[opt]
/// asm-string-literal ':' asm-operands[opt] ':' asm-operands[opt]
/// ':' asm-clobbers
///
/// [GNU] asm-clobbers:
/// asm-string-literal
/// asm-clobbers ',' asm-string-literal
///
Parser::StmtResult Parser::ParseAsmStatement() {
assert(Tok.getKind() == tok::kw_asm && "Not an asm stmt");
ConsumeToken();
DeclSpec DS;
SourceLocation Loc = Tok.getLocation();
ParseTypeQualifierListOpt(DS);
// GNU asms accept, but warn, about type-qualifiers other than volatile.
if (DS.getTypeQualifiers() & DeclSpec::TQ_const)
Diag(Loc, diag::w_asm_qualifier_ignored, "const");
if (DS.getTypeQualifiers() & DeclSpec::TQ_restrict)
Diag(Loc, diag::w_asm_qualifier_ignored, "restrict");
// Remember if this was a volatile asm.
//bool isVolatile = DS.TypeQualifiers & DeclSpec::TQ_volatile;
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, "asm");
SkipUntil(tok::r_paren);
return true;
}
Loc = ConsumeParen();
ParseAsmStringLiteral();
// Parse Outputs, if present.
ParseAsmOperandsOpt();
// Parse Inputs, if present.
ParseAsmOperandsOpt();
// Parse the clobbers, if present.
if (Tok.getKind() == tok::colon) {
ConsumeToken();
if (isTokenStringLiteral()) {
// Parse the asm-string list for clobbers.
while (1) {
ParseAsmStringLiteral();
if (Tok.getKind() != tok::comma) break;
ConsumeToken();
}
}
}
MatchRHSPunctuation(tok::r_paren, Loc);
// FIXME: Implement action for asm parsing.
return false;
}
/// ParseAsmOperands - Parse the asm-operands production as used by
/// asm-statement. We also parse a leading ':' token. If the leading colon is
/// not present, we do not parse anything.
///
/// [GNU] asm-operands:
/// asm-operand
/// asm-operands ',' asm-operand
///
/// [GNU] asm-operand:
/// asm-string-literal '(' expression ')'
/// '[' identifier ']' asm-string-literal '(' expression ')'
///
void Parser::ParseAsmOperandsOpt() {
// Only do anything if this operand is present.
if (Tok.getKind() != tok::colon) return;
ConsumeToken();
// 'asm-operands' isn't present?
if (!isTokenStringLiteral() && Tok.getKind() != tok::l_square)
return;
while (1) {
// Read the [id] if present.
if (Tok.getKind() == tok::l_square) {
SourceLocation Loc = ConsumeBracket();
if (Tok.getKind() != tok::identifier) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::r_paren);
return;
}
MatchRHSPunctuation(tok::r_square, Loc);
}
ParseAsmStringLiteral();
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, "asm operand");
SkipUntil(tok::r_paren);
return;
}
// Read the parenthesized expression.
ExprResult Res = ParseSimpleParenExpression();
if (Res.isInvalid) {
SkipUntil(tok::r_paren);
return;
}
// Eat the comma and continue parsing if it exists.
if (Tok.getKind() != tok::comma) return;
ConsumeToken();
}
}

View File

@@ -1,647 +0,0 @@
//===--- Parser.cpp - C Language Family Parser ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Parser interfaces.
//
//===----------------------------------------------------------------------===//
#include "clang/Parse/Parser.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
using namespace clang;
Parser::Parser(Preprocessor &pp, Action &actions)
: PP(pp), Actions(actions), Diags(PP.getDiagnostics()) {
Tok.setKind(tok::eof);
CurScope = 0;
NumCachedScopes = 0;
ParenCount = BracketCount = BraceCount = 0;
ObjcImpDecl = 0;
}
/// Out-of-line virtual destructor to provide home for Action class.
Action::~Action() {}
void Parser::Diag(SourceLocation Loc, unsigned DiagID,
const std::string &Msg) {
Diags.Report(Loc, DiagID, &Msg, 1);
}
/// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'),
/// this helper function matches and consumes the specified RHS token if
/// present. If not present, it emits the specified diagnostic indicating
/// that the parser failed to match the RHS of the token at LHSLoc. LHSName
/// should be the name of the unmatched LHS token.
SourceLocation Parser::MatchRHSPunctuation(tok::TokenKind RHSTok,
SourceLocation LHSLoc) {
if (Tok.getKind() == RHSTok)
return ConsumeAnyToken();
SourceLocation R = Tok.getLocation();
const char *LHSName = "unknown";
diag::kind DID = diag::err_parse_error;
switch (RHSTok) {
default: break;
case tok::r_paren : LHSName = "("; DID = diag::err_expected_rparen; break;
case tok::r_brace : LHSName = "{"; DID = diag::err_expected_rbrace; break;
case tok::r_square: LHSName = "["; DID = diag::err_expected_rsquare; break;
case tok::greater: LHSName = "<"; DID = diag::err_expected_greater; break;
}
Diag(Tok, DID);
Diag(LHSLoc, diag::err_matching, LHSName);
SkipUntil(RHSTok);
return R;
}
/// ExpectAndConsume - The parser expects that 'ExpectedTok' is next in the
/// input. If so, it is consumed and false is returned.
///
/// If the input is malformed, this emits the specified diagnostic. Next, if
/// SkipToTok is specified, it calls SkipUntil(SkipToTok). Finally, true is
/// returned.
bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID,
const char *Msg, tok::TokenKind SkipToTok) {
if (Tok.getKind() == ExpectedTok) {
ConsumeAnyToken();
return false;
}
Diag(Tok, DiagID, Msg);
if (SkipToTok != tok::unknown)
SkipUntil(SkipToTok);
return true;
}
//===----------------------------------------------------------------------===//
// Error recovery.
//===----------------------------------------------------------------------===//
/// SkipUntil - Read tokens until we get to the specified token, then consume
/// it (unless DontConsume is true). Because we cannot guarantee that the
/// token will ever occur, this skips to the next token, or to some likely
/// good stopping point. If StopAtSemi is true, skipping will stop at a ';'
/// character.
///
/// If SkipUntil finds the specified token, it returns true, otherwise it
/// returns false.
bool Parser::SkipUntil(const tok::TokenKind *Toks, unsigned NumToks,
bool StopAtSemi, bool DontConsume) {
// We always want this function to skip at least one token if the first token
// isn't T and if not at EOF.
bool isFirstTokenSkipped = true;
while (1) {
// If we found one of the tokens, stop and return true.
for (unsigned i = 0; i != NumToks; ++i) {
if (Tok.getKind() == Toks[i]) {
if (DontConsume) {
// Noop, don't consume the token.
} else {
ConsumeAnyToken();
}
return true;
}
}
switch (Tok.getKind()) {
case tok::eof:
// Ran out of tokens.
return false;
case tok::l_paren:
// Recursively skip properly-nested parens.
ConsumeParen();
SkipUntil(tok::r_paren, false);
break;
case tok::l_square:
// Recursively skip properly-nested square brackets.
ConsumeBracket();
SkipUntil(tok::r_square, false);
break;
case tok::l_brace:
// Recursively skip properly-nested braces.
ConsumeBrace();
SkipUntil(tok::r_brace, false);
break;
// Okay, we found a ']' or '}' or ')', which we think should be balanced.
// Since the user wasn't looking for this token (if they were, it would
// already be handled), this isn't balanced. If there is a LHS token at a
// higher level, we will assume that this matches the unbalanced token
// and return it. Otherwise, this is a spurious RHS token, which we skip.
case tok::r_paren:
if (ParenCount && !isFirstTokenSkipped)
return false; // Matches something.
ConsumeParen();
break;
case tok::r_square:
if (BracketCount && !isFirstTokenSkipped)
return false; // Matches something.
ConsumeBracket();
break;
case tok::r_brace:
if (BraceCount && !isFirstTokenSkipped)
return false; // Matches something.
ConsumeBrace();
break;
case tok::string_literal:
case tok::wide_string_literal:
ConsumeStringToken();
break;
case tok::semi:
if (StopAtSemi)
return false;
// FALL THROUGH.
default:
// Skip this token.
ConsumeToken();
break;
}
isFirstTokenSkipped = false;
}
}
//===----------------------------------------------------------------------===//
// Scope manipulation
//===----------------------------------------------------------------------===//
/// EnterScope - Start a new scope.
void Parser::EnterScope(unsigned ScopeFlags) {
if (NumCachedScopes) {
Scope *N = ScopeCache[--NumCachedScopes];
N->Init(CurScope, ScopeFlags);
CurScope = N;
} else {
CurScope = new Scope(CurScope, ScopeFlags);
}
}
/// ExitScope - Pop a scope off the scope stack.
void Parser::ExitScope() {
assert(CurScope && "Scope imbalance!");
// Inform the actions module that this scope is going away.
Actions.PopScope(Tok.getLocation(), CurScope);
Scope *OldScope = CurScope;
CurScope = OldScope->getParent();
if (NumCachedScopes == ScopeCacheSize)
delete OldScope;
else
ScopeCache[NumCachedScopes++] = OldScope;
}
//===----------------------------------------------------------------------===//
// C99 6.9: External Definitions.
//===----------------------------------------------------------------------===//
Parser::~Parser() {
// If we still have scopes active, delete the scope tree.
delete CurScope;
// Free the scope cache.
for (unsigned i = 0, e = NumCachedScopes; i != e; ++i)
delete ScopeCache[i];
}
/// Initialize - Warm up the parser.
///
void Parser::Initialize() {
// Prime the lexer look-ahead.
ConsumeToken();
// Create the translation unit scope. Install it as the current scope.
assert(CurScope == 0 && "A scope is already active?");
EnterScope(Scope::DeclScope);
// Install builtin types.
// TODO: Move this someplace more useful.
{
const char *Dummy;
//__builtin_va_list
DeclSpec DS;
bool Error = DS.SetStorageClassSpec(DeclSpec::SCS_typedef, SourceLocation(),
Dummy);
// TODO: add a 'TST_builtin' type?
Error |= DS.SetTypeSpecType(DeclSpec::TST_int, SourceLocation(), Dummy);
assert(!Error && "Error setting up __builtin_va_list!");
Declarator D(DS, Declarator::FileContext);
D.SetIdentifier(PP.getIdentifierInfo("__builtin_va_list"),SourceLocation());
Actions.ParseDeclarator(CurScope, D, 0);
}
if (Tok.getKind() == tok::eof &&
!getLang().CPlusPlus) // Empty source file is an extension in C
Diag(Tok, diag::ext_empty_source_file);
// Initialization for Objective-C context sensitive keywords recognition.
// Referenced in Parser::isObjCTypeQualifier.
if (getLang().ObjC1) {
ObjcTypeQuals[objc_in] = &PP.getIdentifierTable().get("in");
ObjcTypeQuals[objc_out] = &PP.getIdentifierTable().get("out");
ObjcTypeQuals[objc_inout] = &PP.getIdentifierTable().get("inout");
ObjcTypeQuals[objc_oneway] = &PP.getIdentifierTable().get("oneway");
ObjcTypeQuals[objc_bycopy] = &PP.getIdentifierTable().get("bycopy");
ObjcTypeQuals[objc_byref] = &PP.getIdentifierTable().get("byref");
}
if (getLang().ObjC2) {
ObjcPropertyAttrs[objc_readonly] = &PP.getIdentifierTable().get("readonly");
ObjcPropertyAttrs[objc_getter] = &PP.getIdentifierTable().get("getter");
ObjcPropertyAttrs[objc_setter] = &PP.getIdentifierTable().get("setter");
ObjcPropertyAttrs[objc_assign] = &PP.getIdentifierTable().get("assign");
ObjcPropertyAttrs[objc_readwrite] =
&PP.getIdentifierTable().get("readwrite");
ObjcPropertyAttrs[objc_retain] = &PP.getIdentifierTable().get("retain");
ObjcPropertyAttrs[objc_copy] = &PP.getIdentifierTable().get("copy");
ObjcPropertyAttrs[objc_nonatomic] =
&PP.getIdentifierTable().get("nonatomic");
}
}
/// ParseTopLevelDecl - Parse one top-level declaration, return whatever the
/// action tells us to. This returns true if the EOF was encountered.
bool Parser::ParseTopLevelDecl(DeclTy*& Result) {
Result = 0;
if (Tok.getKind() == tok::eof) return true;
Result = ParseExternalDeclaration();
return false;
}
/// Finalize - Shut down the parser.
///
void Parser::Finalize() {
ExitScope();
assert(CurScope == 0 && "Scope imbalance!");
}
/// ParseTranslationUnit:
/// translation-unit: [C99 6.9]
/// external-declaration
/// translation-unit external-declaration
void Parser::ParseTranslationUnit() {
Initialize();
DeclTy *Res;
while (!ParseTopLevelDecl(Res))
/*parse them all*/;
Finalize();
}
/// ParseExternalDeclaration:
/// external-declaration: [C99 6.9]
/// function-definition
/// declaration
/// [EXT] ';'
/// [GNU] asm-definition
/// [GNU] __extension__ external-declaration
/// [OBJC] objc-class-definition
/// [OBJC] objc-class-declaration
/// [OBJC] objc-alias-declaration
/// [OBJC] objc-protocol-definition
/// [OBJC] objc-method-definition
/// [OBJC] @end
///
/// [GNU] asm-definition:
/// simple-asm-expr ';'
///
Parser::DeclTy *Parser::ParseExternalDeclaration() {
switch (Tok.getKind()) {
case tok::semi:
Diag(Tok, diag::ext_top_level_semi);
ConsumeToken();
// TODO: Invoke action for top-level semicolon.
return 0;
case tok::kw___extension__: {
ConsumeToken();
// FIXME: Disable extension warnings.
DeclTy *RV = ParseExternalDeclaration();
// FIXME: Restore extension warnings.
return RV;
}
case tok::kw_asm:
ParseSimpleAsm();
ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
"top-level asm block");
// TODO: Invoke action for top-level asm.
return 0;
case tok::at:
// @ is not a legal token unless objc is enabled, no need to check.
return ParseObjCAtDirectives();
case tok::minus:
if (getLang().ObjC1) {
ParseObjCInstanceMethodDefinition();
} else {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
}
return 0;
case tok::plus:
if (getLang().ObjC1) {
ParseObjCClassMethodDefinition();
} else {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
}
return 0;
case tok::kw_namespace:
case tok::kw_typedef:
// A function definition cannot start with a these keywords.
return ParseDeclaration(Declarator::FileContext);
default:
// We can't tell whether this is a function-definition or declaration yet.
return ParseDeclarationOrFunctionDefinition();
}
}
/// ParseDeclarationOrFunctionDefinition - Parse either a function-definition or
/// a declaration. We can't tell which we have until we read up to the
/// compound-statement in function-definition.
///
/// function-definition: [C99 6.9.1]
/// declaration-specifiers[opt] declarator declaration-list[opt]
/// compound-statement
/// declaration: [C99 6.7]
/// declaration-specifiers init-declarator-list[opt] ';'
/// [!C99] init-declarator-list ';' [TODO: warn in c99 mode]
/// [OMP] threadprivate-directive [TODO]
///
Parser::DeclTy *Parser::ParseDeclarationOrFunctionDefinition() {
// Parse the common declaration-specifiers piece.
DeclSpec DS;
ParseDeclarationSpecifiers(DS);
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
if (Tok.getKind() == tok::semi) {
ConsumeToken();
return Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
}
// ObjC2 allows prefix attributes on class interfaces.
if (getLang().ObjC2 && Tok.getKind() == tok::at) {
SourceLocation AtLoc = ConsumeToken(); // the "@"
if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_interface)
return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes());
}
// Parse the first declarator.
Declarator DeclaratorInfo(DS, Declarator::FileContext);
ParseDeclarator(DeclaratorInfo);
// Error parsing the declarator?
if (DeclaratorInfo.getIdentifier() == 0) {
// If so, skip until the semi-colon or a }.
SkipUntil(tok::r_brace, true);
if (Tok.getKind() == tok::semi)
ConsumeToken();
return 0;
}
// If the declarator is the start of a function definition, handle it.
if (Tok.getKind() == tok::equal || // int X()= -> not a function def
Tok.getKind() == tok::comma || // int X(), -> not a function def
Tok.getKind() == tok::semi || // int X(); -> not a function def
Tok.getKind() == tok::kw_asm || // int X() __asm__ -> not a fn def
Tok.getKind() == tok::kw___attribute) {// int X() __attr__ -> not a fn def
// FALL THROUGH.
} else if (DeclaratorInfo.isFunctionDeclarator() &&
(Tok.getKind() == tok::l_brace || // int X() {}
isDeclarationSpecifier())) { // int X(f) int f; {}
return ParseFunctionDefinition(DeclaratorInfo);
} else {
if (DeclaratorInfo.isFunctionDeclarator())
Diag(Tok, diag::err_expected_fn_body);
else
Diag(Tok, diag::err_expected_after_declarator);
SkipUntil(tok::semi);
return 0;
}
// Parse the init-declarator-list for a normal declaration.
return ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
}
/// ParseFunctionDefinition - We parsed and verified that the specified
/// Declarator is well formed. If this is a K&R-style function, read the
/// parameters declaration-list, then start the compound-statement.
///
/// declaration-specifiers[opt] declarator declaration-list[opt]
/// compound-statement [TODO]
///
Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
const DeclaratorChunk &FnTypeInfo = D.getTypeObject(0);
assert(FnTypeInfo.Kind == DeclaratorChunk::Function &&
"This isn't a function declarator!");
const DeclaratorChunk::FunctionTypeInfo &FTI = FnTypeInfo.Fun;
// If this declaration was formed with a K&R-style identifier list for the
// arguments, parse declarations for all of the args next.
// int foo(a,b) int a; float b; {}
if (!FTI.hasPrototype && FTI.NumArgs != 0)
ParseKNRParamDeclarations(D);
// Enter a scope for the function body.
EnterScope(Scope::FnScope|Scope::DeclScope);
// Tell the actions module that we have entered a function definition with the
// specified Declarator for the function.
DeclTy *Res = Actions.ParseStartOfFunctionDef(CurScope, D);
// We should have an opening brace now.
if (Tok.getKind() != tok::l_brace) {
Diag(Tok, diag::err_expected_fn_body);
// Skip over garbage, until we get to '{'. Don't eat the '{'.
SkipUntil(tok::l_brace, true, true);
// If we didn't find the '{', bail out.
if (Tok.getKind() != tok::l_brace) {
ExitScope();
return 0;
}
}
// Do not enter a scope for the brace, as the arguments are in the same scope
// (the function body) as the body itself. Instead, just read the statement
// list and put it into a CompoundStmt for safe keeping.
StmtResult FnBody = ParseCompoundStatementBody();
if (FnBody.isInvalid) {
ExitScope();
return 0;
}
// Leave the function body scope.
ExitScope();
// TODO: Pass argument information.
return Actions.ParseFunctionDefBody(Res, FnBody.Val);
}
/// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides
/// types for a function with a K&R-style identifier list for arguments.
void Parser::ParseKNRParamDeclarations(Declarator &D) {
// We know that the top-level of this declarator is a function.
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
// Read all the argument declarations.
while (isDeclarationSpecifier()) {
SourceLocation DSStart = Tok.getLocation();
// Parse the common declaration-specifiers piece.
DeclSpec DS;
ParseDeclarationSpecifiers(DS);
// C99 6.9.1p6: 'each declaration in the declaration list shall have at
// least one declarator'.
// NOTE: GCC just makes this an ext-warn. It's not clear what it does with
// the declarations though. It's trivial to ignore them, really hard to do
// anything else with them.
if (Tok.getKind() == tok::semi) {
Diag(DSStart, diag::err_declaration_does_not_declare_param);
ConsumeToken();
continue;
}
// C99 6.9.1p6: Declarations shall contain no storage-class specifiers other
// than register.
if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified &&
DS.getStorageClassSpec() != DeclSpec::SCS_register) {
Diag(DS.getStorageClassSpecLoc(),
diag::err_invalid_storage_class_in_func_decl);
DS.ClearStorageClassSpecs();
}
if (DS.isThreadSpecified()) {
Diag(DS.getThreadSpecLoc(),
diag::err_invalid_storage_class_in_func_decl);
DS.ClearStorageClassSpecs();
}
// Parse the first declarator attached to this declspec.
Declarator ParmDeclarator(DS, Declarator::KNRTypeListContext);
ParseDeclarator(ParmDeclarator);
// Handle the full declarator list.
while (1) {
DeclTy *AttrList;
// If attributes are present, parse them.
if (Tok.getKind() == tok::kw___attribute)
// FIXME: attach attributes too.
AttrList = ParseAttributes();
// Ask the actions module to compute the type for this declarator.
Action::TypeResult TR =
Actions.ParseParamDeclaratorType(CurScope, ParmDeclarator);
if (!TR.isInvalid &&
// A missing identifier has already been diagnosed.
ParmDeclarator.getIdentifier()) {
// Scan the argument list looking for the correct param to apply this
// type.
for (unsigned i = 0; ; ++i) {
// C99 6.9.1p6: those declarators shall declare only identifiers from
// the identifier list.
if (i == FTI.NumArgs) {
Diag(ParmDeclarator.getIdentifierLoc(), diag::err_no_matching_param,
ParmDeclarator.getIdentifier()->getName());
break;
}
if (FTI.ArgInfo[i].Ident == ParmDeclarator.getIdentifier()) {
// Reject redefinitions of parameters.
if (FTI.ArgInfo[i].TypeInfo) {
Diag(ParmDeclarator.getIdentifierLoc(),
diag::err_param_redefinition,
ParmDeclarator.getIdentifier()->getName());
} else {
FTI.ArgInfo[i].TypeInfo = TR.Val;
}
break;
}
}
}
// If we don't have a comma, it is either the end of the list (a ';') or
// an error, bail out.
if (Tok.getKind() != tok::comma)
break;
// Consume the comma.
ConsumeToken();
// Parse the next declarator.
ParmDeclarator.clear();
ParseDeclarator(ParmDeclarator);
}
if (Tok.getKind() == tok::semi) {
ConsumeToken();
} else {
Diag(Tok, diag::err_parse_error);
// Skip to end of block or statement
SkipUntil(tok::semi, true);
if (Tok.getKind() == tok::semi)
ConsumeToken();
}
}
// The actions module must verify that all arguments were declared.
}
/// ParseAsmStringLiteral - This is just a normal string-literal, but is not
/// allowed to be a wide string, and is not subject to character translation.
///
/// [GNU] asm-string-literal:
/// string-literal
///
void Parser::ParseAsmStringLiteral() {
if (!isTokenStringLiteral()) {
Diag(Tok, diag::err_expected_string_literal);
return;
}
ExprResult Res = ParseStringLiteralExpression();
if (Res.isInvalid) return;
// TODO: Diagnose: wide string literal in 'asm'
}
/// ParseSimpleAsm
///
/// [GNU] simple-asm-expr:
/// 'asm' '(' asm-string-literal ')'
///
void Parser::ParseSimpleAsm() {
assert(Tok.getKind() == tok::kw_asm && "Not an asm!");
ConsumeToken();
if (Tok.getKind() != tok::l_paren) {
Diag(Tok, diag::err_expected_lparen_after, "asm");
return;
}
SourceLocation Loc = ConsumeParen();
ParseAsmStringLiteral();
MatchRHSPunctuation(tok::r_paren, Loc);
}

View File

@@ -1,180 +0,0 @@
//===----------------------------------------------------------------------===//
// C Language Family Front-end
//===----------------------------------------------------------------------===//
Chris Lattner
I. Introduction:
clang: noun
1. A loud, resonant, metallic sound.
2. The strident call of a crane or goose.
3. C-language family front-end toolkit.
The world needs better compiler tools, tools which are built as libraries. This
design point allows reuse of the tools in new and novel ways. However, building
the tools as libraries isn't enough: they must have clean APIs, be as
decoupled from each other as possible, and be easy to modify/extend. This
requires clean layering, decent design, and avoiding tying the libraries to a
specific use. Oh yeah, did I mention that we want the resultant libraries to
be as fast as possible? :)
This front-end is built as a component of the LLVM toolkit that can be used
with the LLVM backend or independently of it. In this spirit, the API has been
carefully designed as the following components:
libsupport - Basic support library, reused from LLVM.
libsystem - System abstraction library, reused from LLVM.
libbasic - Diagnostics, SourceLocations, SourceBuffer abstraction,
file system caching for input source files. This depends on
libsupport and libsystem.
libast - Provides classes to represent the C AST, the C type system,
builtin functions, and various helpers for analyzing and
manipulating the AST (visitors, pretty printers, etc). This
library depends on libbasic.
liblex - C/C++/ObjC lexing and preprocessing, identifier hash table,
pragma handling, tokens, and macros. This depends on libbasic.
libparse - C (for now) parsing and local semantic analysis. This library
invokes coarse-grained 'Actions' provided by the client to do
stuff (e.g. libsema builds ASTs). This depends on liblex.
libsema - Provides a set of parser actions to build a standardized AST
for programs. AST's are 'streamed' out a top-level declaration
at a time, allowing clients to use decl-at-a-time processing,
build up entire translation units, or even build 'whole
program' ASTs depending on how they use the APIs. This depends
on libast and libparse.
libcodegen - Lower the AST to LLVM IR for optimization & codegen. Depends
on libast.
clang - An example driver, client of the libraries at various levels.
This depends on all these libraries, and on LLVM VMCore.
This front-end has been intentionally built as a DAG of libraries, making it
easy to reuse individual parts or replace pieces if desired. For example, to
build a preprocessor, you take the Basic and Lexer libraries. If you want an
indexer, you take those plus the Parser library and provide some actions for
indexing. If you want a refactoring, static analysis, or source-to-source
compiler tool, it makes sense to take those plus the AST building and semantic
analyzer library. Finally, if you want to use this with the LLVM backend,
you'd take these components plus the AST to LLVM lowering code.
In the future I hope this toolkit will grow to include new and interesting
components, including a C++ front-end, ObjC support, and a whole lot of other
things.
Finally, it should be pointed out that the goal here is to build something that
is high-quality and industrial-strength: all the obnoxious features of the C
family must be correctly supported (trigraphs, preprocessor arcana, K&R-style
prototypes, GCC/MS extensions, etc). It cannot be used if it is not 'real'.
II. Usage of clang driver:
* Basic Command-Line Options:
- Help: clang --help
- Standard GCC options accepted: -E, -I*, -i*, -pedantic, -std=c90, etc.
- To make diagnostics more gcc-like: -fno-caret-diagnostics -fno-show-column
- Enable metric printing: -stats
* -fsyntax-only is currently the default mode.
* -E mode works the same way as GCC.
* -Eonly mode does all preprocessing, but does not print the output,
useful for timing the preprocessor.
* -fsyntax-only is currently partially implemented, lacking some
semantic analysis (some errors and warnings are not produced).
* -parse-noop parses code without building an AST. This is useful
for timing the cost of the parser without including AST building
time.
* -parse-ast builds ASTs, but doesn't print them. This is most
useful for timing AST building vs -parse-noop.
* -parse-ast-print pretty prints most expression and statements nodes.
* -parse-ast-check checks that diagnostic messages that are expected
are reported and that those which are reported are expected.
* -dump-cfg builds ASTs and then CFGs. CFGs are then pretty-printed.
* -view-cfg builds ASTs and then CFGs. CFGs are then visualized by
invoking Graphviz.
For more information on getting Graphviz to work with clang/LLVM,
see: http://llvm.org/docs/ProgrammersManual.html#ViewGraph
III. Current advantages over GCC:
* Column numbers are fully tracked (no 256 col limit, no GCC-style pruning).
* All diagnostics have column numbers, includes 'caret diagnostics', and they
highlight regions of interesting code (e.g. the LHS and RHS of a binop).
* Full diagnostic customization by client (can format diagnostics however they
like, e.g. in an IDE or refactoring tool) through DiagnosticClient interface.
* Built as a framework, can be reused by multiple tools.
* All languages supported linked into same library (no cc1,cc1obj, ...).
* mmap's code in read-only, does not dirty the pages like GCC (mem footprint).
* LLVM License, can be linked into non-GPL projects.
* Full diagnostic control, per diagnostic. Diagnostics are identified by ID.
* Significantly faster than GCC at semantic analysis, parsing, preprocessing
and lexing.
* Defers exposing platform-specific stuff to as late as possible, tracks use of
platform-specific features (e.g. #ifdef PPC) to allow 'portable bytecodes'.
* The lexer doesn't rely on the "lexer hack": it has no notion of scope and
does not categorize identifiers as types or variables -- this is up to the
parser to decide.
Potential Future Features:
* Fine grained diag control within the source (#pragma enable/disable warning).
* Better token tracking within macros? (Token came from this line, which is
a macro argument instantiated here, recursively instantiated here).
* Fast #import with a module system.
* Dependency tracking: change to header file doesn't recompile every function
that texually depends on it: recompile only those functions that need it.
This is aka 'incremental parsing'.
IV. Missing Functionality / Improvements
clang driver:
* Include search paths are hard-coded into the driver. Doh.
File Manager:
* Reduce syscalls for reduced compile time, see NOTES.txt.
Lexer:
* Source character mapping. GCC supports ASCII and UTF-8.
See GCC options: -ftarget-charset and -ftarget-wide-charset.
* Universal character support. Experimental in GCC, enabled with
-fextended-identifiers.
* -fpreprocessed mode.
Preprocessor:
* Know about apple header maps.
* #assert/#unassert
* #line / #file directives (currently accepted and ignored).
* MSExtension: "L#param" stringizes to a wide string literal.
* Charize extension: "#define F(o) #@o F(a)" -> 'a'.
* Consider merging the parser's expression parser into the preprocessor to
eliminate duplicate code.
* Add support for -M*
Traditional Preprocessor:
* Currently, we have none. :)
Parser:
* C90/K&R modes are only partially implemented.
* __extension__ is currently just skipped and ignored.
* "initializers", GCC inline asm.
Semantic Analysis:
* Perhaps 75% done.
LLVM Code Gen:
* Still very early.

View File

@@ -1,111 +0,0 @@
//===--- ASTStreamer.cpp - Provide streaming interface to ASTs ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ASTStreamer interface.
//
//===----------------------------------------------------------------------===//
#include "clang/Sema/ASTStreamer.h"
#include "clang/AST/ASTContext.h"
#include "Sema.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/Parser.h"
using namespace clang;
namespace {
class ASTStreamer {
Parser P;
std::vector<Decl*> LastInGroupList;
public:
ASTStreamer(Preprocessor &pp, ASTContext &ctxt, unsigned MainFileID)
: P(pp, *new Sema(pp, ctxt, LastInGroupList)) {
pp.EnterSourceFile(MainFileID, 0, true);
// Initialize the parser.
P.Initialize();
}
/// ReadTopLevelDecl - Parse and return the next top-level declaration.
Decl *ReadTopLevelDecl();
void PrintStats() const;
~ASTStreamer() {
P.Finalize();
delete &P.getActions();
}
};
}
/// ReadTopLevelDecl - Parse and return the next top-level declaration.
///
Decl *ASTStreamer::ReadTopLevelDecl() {
Parser::DeclTy *Result;
/// If the previous time through we read something like 'int X, Y', return
/// the next declarator.
if (!LastInGroupList.empty()) {
Result = LastInGroupList.back();
LastInGroupList.pop_back();
return static_cast<Decl*>(Result);
}
do {
if (P.ParseTopLevelDecl(Result))
return 0; // End of file.
// If we got a null return and something *was* parsed, try again. This
// is due to a top-level semicolon, an action override, or a parse error
// skipping something.
} while (Result == 0);
// If we parsed a declspec with multiple declarators, reverse the list and
// return the first one.
if (!LastInGroupList.empty()) {
LastInGroupList.push_back((Decl*)Result);
std::reverse(LastInGroupList.begin(), LastInGroupList.end());
Result = LastInGroupList.back();
LastInGroupList.pop_back();
}
return static_cast<Decl*>(Result);
}
void ASTStreamer::PrintStats() const {
}
//===----------------------------------------------------------------------===//
// Public interface to the file
//===----------------------------------------------------------------------===//
/// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
/// and FileID.
ASTStreamerTy *clang::ASTStreamer_Init(Preprocessor &pp, ASTContext &ctxt,
unsigned MainFileID) {
return new ASTStreamer(pp, ctxt, MainFileID);
}
/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration.
/// This returns null at end of file.
Decl *clang::ASTStreamer_ReadTopLevelDecl(ASTStreamerTy *Streamer) {
return static_cast<ASTStreamer*>(Streamer)->ReadTopLevelDecl();
}
/// ASTStreamer_PrintStats - Emit statistic information to stderr.
///
void clang::ASTStreamer_PrintStats(ASTStreamerTy *Streamer) {
return static_cast<ASTStreamer*>(Streamer)->PrintStats();
}
/// ASTStreamer_Terminate - Gracefully shut down the streamer.
///
void clang::ASTStreamer_Terminate(ASTStreamerTy *Streamer) {
delete static_cast<ASTStreamer*>(Streamer);
}

View File

@@ -1,23 +0,0 @@
##===- clang/Sema/Makefile ---------------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file was developed by Chris Lattner and is distributed under
# the University of Illinois Open Source License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements the semantic analyzer and AST builder library for the
# C-Language front-end.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
LIBRARYNAME := clangSEMA
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../include
include $(LEVEL)/Makefile.common

View File

@@ -1,111 +0,0 @@
//===--- Sema.cpp - AST Builder and Semantic Analysis Implementation ------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the actions class which performs semantic analysis and
// builds an AST out of a parse stream.
//
//===----------------------------------------------------------------------===//
#include "Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Diagnostic.h"
using namespace clang;
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
: PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {
// Get IdentifierInfo objects for known functions for which we
// do extra checking.
IdentifierTable& IT = PP.getIdentifierTable();
KnownFunctionIDs[ id_printf ] = &IT.get("printf");
KnownFunctionIDs[ id_fprintf ] = &IT.get("fprintf");
KnownFunctionIDs[ id_sprintf ] = &IT.get("sprintf");
KnownFunctionIDs[ id_snprintf ] = &IT.get("snprintf");
KnownFunctionIDs[ id_asprintf ] = &IT.get("asprintf");
KnownFunctionIDs[ id_vsnprintf ] = &IT.get("vsnprintf");
KnownFunctionIDs[ id_vasprintf ] = &IT.get("vasprintf");
KnownFunctionIDs[ id_vfprintf ] = &IT.get("vfprintf");
KnownFunctionIDs[ id_vsprintf ] = &IT.get("vsprintf");
KnownFunctionIDs[ id_vprintf ] = &IT.get("vprintf");
}
void Sema::DeleteExpr(ExprTy *E) {
delete static_cast<Expr*>(E);
}
void Sema::DeleteStmt(StmtTy *S) {
delete static_cast<Stmt*>(S);
}
//===----------------------------------------------------------------------===//
// Helper functions.
//===----------------------------------------------------------------------===//
bool Sema::Diag(SourceLocation Loc, unsigned DiagID) {
PP.getDiagnostics().Report(Loc, DiagID);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) {
PP.getDiagnostics().Report(Loc, DiagID, &Msg, 1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
const std::string &Msg2) {
std::string MsgArr[] = { Msg1, Msg2 };
PP.getDiagnostics().Report(Loc, DiagID, MsgArr, 2);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, SourceRange Range) {
PP.getDiagnostics().Report(Loc, DiagID, 0, 0, &Range, 1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
SourceRange Range) {
PP.getDiagnostics().Report(Loc, DiagID, &Msg, 1, &Range, 1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
const std::string &Msg2, SourceRange Range) {
std::string MsgArr[] = { Msg1, Msg2 };
PP.getDiagnostics().Report(Loc, DiagID, MsgArr, 2, &Range, 1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID,
SourceRange R1, SourceRange R2) {
SourceRange RangeArr[] = { R1, R2 };
PP.getDiagnostics().Report(Loc, DiagID, 0, 0, RangeArr, 2);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
SourceRange R1, SourceRange R2) {
SourceRange RangeArr[] = { R1, R2 };
PP.getDiagnostics().Report(Loc, DiagID, &Msg, 1, RangeArr, 2);
return true;
}
bool Sema::Diag(SourceLocation Range, unsigned DiagID, const std::string &Msg1,
const std::string &Msg2, SourceRange R1, SourceRange R2) {
std::string MsgArr[] = { Msg1, Msg2 };
SourceRange RangeArr[] = { R1, R2 };
PP.getDiagnostics().Report(Range, DiagID, MsgArr, 2, RangeArr, 2);
return true;
}
const LangOptions &Sema::getLangOptions() const {
return PP.getLangOptions();
}

View File

@@ -1,512 +0,0 @@
//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the Sema class, which performs semantic analysis and
// builds ASTs.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_SEMA_H
#define LLVM_CLANG_AST_SEMA_H
#include "clang/Parse/Action.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include <vector>
#include <string>
namespace llvm {
class APSInt;
}
namespace clang {
class ASTContext;
class Preprocessor;
class Decl;
class Expr;
class InitListExpr;
class VarDecl;
class ParmVarDecl;
class TypedefDecl;
class FunctionDecl;
class QualType;
struct LangOptions;
struct DeclaratorChunk;
class Token;
class IntegerLiteral;
class ArrayType;
class LabelStmt;
class SwitchStmt;
class OCUVectorType;
class TypedefDecl;
/// Sema - This implements semantic analysis and AST building for C.
class Sema : public Action {
Preprocessor &PP;
ASTContext &Context;
/// CurFunctionDecl - If inside of a function body, this contains a pointer to
/// the function decl for the function being parsed.
FunctionDecl *CurFunctionDecl;
/// LastInGroupList - This vector is populated when there are multiple
/// declarators in a single decl group (e.g. "int A, B, C"). In this case,
/// all but the last decl will be entered into this. This is used by the
/// ASTStreamer.
std::vector<Decl*> &LastInGroupList;
/// LabelMap - This is a mapping from label identifiers to the LabelStmt for
/// it (which acts like the label decl in some ways). Forward referenced
/// labels have a LabelStmt created for them with a null location & SubStmt.
llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
/// OCUVectorDecls - This is a list all the OCU vector types. This allows
/// us to associate a raw vector type with one of the OCU type names.
/// This is only necessary for issuing pretty diagnostics.
llvm::SmallVector<TypedefDecl*, 24> OCUVectorDecls;
// Enum values used by KnownFunctionIDs (see below).
enum {
id_printf,
id_fprintf,
id_sprintf,
id_snprintf,
id_asprintf,
id_vsnprintf,
id_vasprintf,
id_vfprintf,
id_vsprintf,
id_vprintf,
id_num_known_functions
};
/// KnownFunctionIDs - This is a list of IdentifierInfo objects to a set
/// of known functions used by the semantic analysis to do various
/// kinds of checking (e.g. checking format string errors in printf calls).
/// This list is populated upon the creation of a Sema object.
IdentifierInfo* KnownFunctionIDs[ id_num_known_functions ];
public:
Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup);
const LangOptions &getLangOptions() const;
/// The primitive diagnostic helpers - always returns true, which simplifies
/// error handling (i.e. less code).
bool Diag(SourceLocation Loc, unsigned DiagID);
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg);
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
const std::string &Msg2);
/// More expressive diagnostic helpers for expressions (say that 6 times:-)
bool Diag(SourceLocation Loc, unsigned DiagID, SourceRange R1);
bool Diag(SourceLocation Loc, unsigned DiagID,
SourceRange R1, SourceRange R2);
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
SourceRange R1);
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
SourceRange R1, SourceRange R2);
bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
const std::string &Msg2, SourceRange R1);
bool Diag(SourceLocation Loc, unsigned DiagID,
const std::string &Msg1, const std::string &Msg2,
SourceRange R1, SourceRange R2);
virtual void DeleteExpr(ExprTy *E);
virtual void DeleteStmt(StmtTy *S);
//===--------------------------------------------------------------------===//
// Type Analysis / Processing: SemaType.cpp.
//
QualType GetTypeForDeclarator(Declarator &D, Scope *S);
virtual TypeResult ParseTypeName(Scope *S, Declarator &D);
virtual TypeResult ParseParamDeclaratorType(Scope *S, Declarator &D);
private:
//===--------------------------------------------------------------------===//
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
//
virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const;
virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
void AddInitializerToDecl(DeclTy *dcl, ExprTy *init);
virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group);
virtual DeclTy *ParseStartOfFunctionDef(Scope *S, Declarator &D);
virtual DeclTy *ParseFunctionDefBody(DeclTy *Decl, StmtTy *Body);
virtual void PopScope(SourceLocation Loc, Scope *S);
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
/// no declarator (e.g. "struct foo;") is parsed.
virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
virtual DeclTy *ParseTag(Scope *S, unsigned TagType, TagKind TK,
SourceLocation KWLoc, IdentifierInfo *Name,
SourceLocation NameLoc, AttributeList *Attr);
virtual DeclTy *ParseField(Scope *S, DeclTy *TagDecl,SourceLocation DeclStart,
Declarator &D, ExprTy *BitfieldWidth);
virtual void ParseRecordBody(SourceLocation RecLoc, DeclTy *TagDecl,
DeclTy **Fields, unsigned NumFields);
virtual DeclTy *ParseEnumConstant(Scope *S, DeclTy *EnumDecl,
DeclTy *LastEnumConstant,
SourceLocation IdLoc, IdentifierInfo *Id,
SourceLocation EqualLoc, ExprTy *Val);
virtual void ParseEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl,
DeclTy **Elements, unsigned NumElements);
private:
/// Subroutines of ParseDeclarator()...
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, Decl *LastDeclarator);
TypedefDecl *MergeTypeDefDecl(TypedefDecl *New, Decl *Old);
FunctionDecl *MergeFunctionDecl(FunctionDecl *New, Decl *Old);
VarDecl *MergeVarDecl(VarDecl *New, Decl *Old);
/// AddTopLevelDecl - called after the decl has been fully processed.
/// Allows for bookkeeping and post-processing of each declaration.
void AddTopLevelDecl(Decl *current, Decl *last);
/// More parsing and symbol table subroutines...
ParmVarDecl *ParseParamDeclarator(DeclaratorChunk &FI, unsigned ArgNo,
Scope *FnBodyScope);
Decl *LookupScopedDecl(IdentifierInfo *II, unsigned NSI, SourceLocation IdLoc,
Scope *S);
Decl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S);
Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
Scope *S);
// Decl attributes - this routine is the top level dispatcher.
void HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix,
AttributeList *declarator_postfix);
void HandleDeclAttribute(Decl *New, AttributeList *rawAttr);
// HandleVectorTypeAttribute - this attribute is only applicable to
// integral and float scalars, although arrays, pointers, and function
// return values are allowed in conjunction with this construct. Aggregates
// with this attribute are invalid, even if they are of the same size as a
// corresponding scalar.
// The raw attribute should contain precisely 1 argument, the vector size
// for the variable, measured in bytes. If curType and rawAttr are well
// formed, this routine will return a new vector type.
QualType HandleVectorTypeAttribute(QualType curType, AttributeList *rawAttr);
void HandleOCUVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr);
//===--------------------------------------------------------------------===//
// Statement Parsing Callbacks: SemaStmt.cpp.
public:
virtual StmtResult ParseExprStmt(ExprTy *Expr);
virtual StmtResult ParseNullStmt(SourceLocation SemiLoc);
virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R,
StmtTy **Elts, unsigned NumElts,
bool isStmtExpr);
virtual StmtResult ParseDeclStmt(DeclTy *Decl);
virtual StmtResult ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
SourceLocation DotDotDotLoc, ExprTy *RHSVal,
SourceLocation ColonLoc, StmtTy *SubStmt);
virtual StmtResult ParseDefaultStmt(SourceLocation DefaultLoc,
SourceLocation ColonLoc, StmtTy *SubStmt,
Scope *CurScope);
virtual StmtResult ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
SourceLocation ColonLoc, StmtTy *SubStmt);
virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
StmtTy *ThenVal, SourceLocation ElseLoc,
StmtTy *ElseVal);
virtual StmtResult StartSwitchStmt(ExprTy *Cond);
virtual StmtResult FinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch,
ExprTy *Body);
virtual StmtResult ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond,
StmtTy *Body);
virtual StmtResult ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
SourceLocation WhileLoc, ExprTy *Cond);
virtual StmtResult ParseForStmt(SourceLocation ForLoc,
SourceLocation LParenLoc,
StmtTy *First, ExprTy *Second, ExprTy *Third,
SourceLocation RParenLoc, StmtTy *Body);
virtual StmtResult ParseGotoStmt(SourceLocation GotoLoc,
SourceLocation LabelLoc,
IdentifierInfo *LabelII);
virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc,
SourceLocation StarLoc,
ExprTy *DestExp);
virtual StmtResult ParseContinueStmt(SourceLocation ContinueLoc,
Scope *CurScope);
virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc, Scope *CurScope);
virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp);
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks: SemaExpr.cpp.
// Primary Expressions.
virtual ExprResult ParseIdentifierExpr(Scope *S, SourceLocation Loc,
IdentifierInfo &II,
bool HasTrailingLParen);
virtual ExprResult ParsePreDefinedExpr(SourceLocation Loc,
tok::TokenKind Kind);
virtual ExprResult ParseNumericConstant(const Token &);
virtual ExprResult ParseCharacterConstant(const Token &);
virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R,
ExprTy *Val);
/// ParseStringLiteral - The specified tokens were lexed as pasted string
/// fragments (e.g. "foo" "bar" L"baz").
virtual ExprResult ParseStringLiteral(const Token *Toks, unsigned NumToks);
// Binary/Unary Operators. 'Tok' is the token for the operator.
virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
ExprTy *Input);
virtual ExprResult
ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
SourceLocation LParenLoc, TypeTy *Ty,
SourceLocation RParenLoc);
virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
tok::TokenKind Kind, ExprTy *Input);
virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
ExprTy *Idx, SourceLocation RLoc);
virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
tok::TokenKind OpKind,
SourceLocation MemberLoc,
IdentifierInfo &Member);
/// ParseCallExpr - Handle a call to Fn with the specified array of arguments.
/// This provides the location of the left/right parens and a list of comma
/// locations.
virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
ExprTy **Args, unsigned NumArgs,
SourceLocation *CommaLocs,
SourceLocation RParenLoc);
virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
SourceLocation RParenLoc, ExprTy *Op);
virtual ExprResult ParseCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
SourceLocation RParenLoc, ExprTy *Op);
virtual ExprResult ParseInitList(SourceLocation LParenLoc,
ExprTy **InitList, unsigned NumInit,
SourceLocation RParenLoc);
virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
ExprTy *LHS,ExprTy *RHS);
/// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
/// in the case of a the GNU conditional expr extension.
virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc,
SourceLocation ColonLoc,
ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
/// ParseAddrLabel - Parse the GNU address of label extension: "&&foo".
virtual ExprResult ParseAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
IdentifierInfo *LabelII);
virtual ExprResult ParseStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt,
SourceLocation RPLoc); // "({..})"
/// __builtin_offsetof(type, a.b[123][456].c)
virtual ExprResult ParseBuiltinOffsetOf(SourceLocation BuiltinLoc,
SourceLocation TypeLoc, TypeTy *Arg1,
OffsetOfComponent *CompPtr,
unsigned NumComponents,
SourceLocation RParenLoc);
// __builtin_types_compatible_p(type1, type2)
virtual ExprResult ParseTypesCompatibleExpr(SourceLocation BuiltinLoc,
TypeTy *arg1, TypeTy *arg2,
SourceLocation RPLoc);
// __builtin_choose_expr(constExpr, expr1, expr2)
virtual ExprResult ParseChooseExpr(SourceLocation BuiltinLoc,
ExprTy *cond, ExprTy *expr1, ExprTy *expr2,
SourceLocation RPLoc);
/// ParseCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's.
virtual ExprResult ParseCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind,
SourceLocation LAngleBracketLoc, TypeTy *Ty,
SourceLocation RAngleBracketLoc,
SourceLocation LParenLoc, ExprTy *E,
SourceLocation RParenLoc);
/// ParseCXXBoolLiteral - Parse {true,false} literals.
virtual ExprResult ParseCXXBoolLiteral(SourceLocation OpLoc,
tok::TokenKind Kind);
// ParseObjCStringLiteral - Parse Objective-C string literals.
virtual ExprResult ParseObjCStringLiteral(ExprTy *string);
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation LParenLoc,
TypeTy *Ty,
SourceLocation RParenLoc);
// Objective-C declarations.
virtual DeclTy *ObjcStartClassInterface(SourceLocation AtInterafceLoc,
IdentifierInfo *ClassName, SourceLocation ClassLoc,
IdentifierInfo *SuperName, SourceLocation SuperLoc,
IdentifierInfo **ProtocolNames, unsigned NumProtocols,
AttributeList *AttrList);
virtual DeclTy *ObjcClassDeclaration(Scope *S, SourceLocation AtClassLoc,
IdentifierInfo **IdentList,
unsigned NumElts);
virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl,
DeclTy **allMethods, unsigned allNum);
virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType,
ObjcKeywordInfo *Keywords, unsigned NumKeywords,
AttributeList *AttrList);
virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType,
IdentifierInfo *SelectorName, AttributeList *AttrList);
virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy *Ivar,
tok::ObjCKeywordKind visibility);
private:
// UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
// functions and arrays to their respective pointers (C99 6.3.2.1).
void UsualUnaryConversions(Expr *&expr);
// DefaultFunctionArrayConversion - converts functions and arrays
// to their respective pointers (C99 6.3.2.1).
void DefaultFunctionArrayConversion(Expr *&expr);
// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
// do not have a prototype. Integer promotions are performed on each
// argument, and arguments that have type float are promoted to double.
void DefaultArgumentPromotion(Expr *&expr);
// UsualArithmeticConversions - performs the UsualUnaryConversions on it's
// operands and then handles various conversions that are common to binary
// operators (C99 6.3.1.8). If both operands aren't arithmetic, this
// routine returns the first non-arithmetic type found. The client is
// responsible for emitting appropriate error diagnostics.
QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
bool isCompAssign = false);
enum AssignmentCheckResult {
Compatible,
Incompatible,
PointerFromInt,
IntFromPointer,
IncompatiblePointer,
CompatiblePointerDiscardsQualifiers
};
// CheckAssignmentConstraints - Perform type checking for assignment,
// argument passing, variable initialization, and function return values.
// This routine is only used by the following two methods. C99 6.5.16.
AssignmentCheckResult CheckAssignmentConstraints(QualType lhs, QualType rhs);
// CheckSingleAssignmentConstraints - Currently used by ParseCallExpr,
// CheckAssignmentOperands, and ParseReturnStmt. Prior to type checking,
// this routine performs the default function/array converions.
AssignmentCheckResult CheckSingleAssignmentConstraints(QualType lhs,
Expr *&rExpr);
// CheckCompoundAssignmentConstraints - Type check without performing any
// conversions. For compound assignments, the "Check...Operands" methods
// perform the necessary conversions.
AssignmentCheckResult CheckCompoundAssignmentConstraints(QualType lhs,
QualType rhs);
// Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
AssignmentCheckResult CheckPointerTypesForAssignment(QualType lhsType,
QualType rhsType);
/// the following "Check" methods will return a valid/converted QualType
/// or a null QualType (indicating an error diagnostic was issued).
/// type checking binary operators (subroutines of ParseBinOp).
inline void InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
inline QualType CheckMultiplyDivideOperands( // C99 6.5.5
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
inline QualType CheckRemainderOperands( // C99 6.5.5
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
inline QualType CheckAdditionOperands( // C99 6.5.6
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
inline QualType CheckSubtractionOperands( // C99 6.5.6
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
inline QualType CheckShiftOperands( // C99 6.5.7
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
inline QualType CheckCompareOperands( // C99 6.5.8/9
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isRelational);
inline QualType CheckBitwiseOperands( // C99 6.5.[10...12]
Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
inline QualType CheckLogicalOperands( // C99 6.5.[13,14]
Expr *&lex, Expr *&rex, SourceLocation OpLoc);
// CheckAssignmentOperands is used for both simple and compound assignment.
// For simple assignment, pass both expressions and a null converted type.
// For compound assignment, pass both expressions and the converted type.
inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
inline QualType CheckCommaOperands( // C99 6.5.17
Expr *&lex, Expr *&rex, SourceLocation OpLoc);
inline QualType CheckConditionalOperands( // C99 6.5.15
Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
/// type checking unary operators (subroutines of ParseUnaryOp).
/// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc);
QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
QualType CheckSizeOfAlignOfOperand(QualType type, SourceLocation loc,
bool isSizeof);
QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc);
/// type checking primary expressions.
QualType CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc,
IdentifierInfo &Comp, SourceLocation CmpLoc);
/// type checking declaration initializers (C99 6.7.8)
bool CheckInitializer(Expr *&simpleInit_or_initList, QualType &declType,
bool isStatic);
bool CheckSingleInitializer(Expr *&simpleInit, QualType declType);
bool CheckInitExpr(Expr *expr, InitListExpr *IList, unsigned slot,
bool isStatic, QualType ElementType);
void CheckVariableInitList(QualType DeclType, InitListExpr *IList,
QualType ElementType, bool isStatic,
int &nInitializers, bool &hadError);
void CheckConstantInitList(QualType DeclType, InitListExpr *IList,
QualType ElementType, bool isStatic,
int &nInitializers, bool &hadError);
/// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
/// the specified width and sign. If an overflow occurs, detect it and emit
/// the specified diagnostic.
void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
unsigned NewWidth, bool NewSign,
SourceLocation Loc, unsigned DiagID);
//===--------------------------------------------------------------------===//
// Extra semantic analysis beyond the C type system
private:
bool CheckFunctionCall(Expr *Fn,
SourceLocation LParenLoc, SourceLocation RParenLoc,
FunctionDecl *FDecl,
Expr** Args, unsigned NumArgsInCall);
void CheckPrintfArguments(Expr *Fn,
SourceLocation LParenLoc, SourceLocation RParenLoc,
bool HasVAListArg, FunctionDecl *FDecl,
unsigned format_idx, Expr** Args,
unsigned NumArgsInCall);
void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc);
bool CheckBuiltinCFStringArgument(Expr* Arg);
};
} // end namespace clang
#endif

View File

@@ -1,623 +0,0 @@
//===--- SemaChecking.cpp - Extra Semantic Checking -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Ted Kremenek and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements extra semantic analysis beyond what is enforced
// by the C type system.
//
//===----------------------------------------------------------------------===//
#include "Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/LiteralSupport.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
using namespace clang;
/// CheckFunctionCall - Check a direct function call for various correctness
/// and safety properties not strictly enforced by the C type system.
bool
Sema::CheckFunctionCall(Expr *Fn,
SourceLocation LParenLoc, SourceLocation RParenLoc,
FunctionDecl *FDecl,
Expr** Args, unsigned NumArgsInCall) {
// Get the IdentifierInfo* for the called function.
IdentifierInfo *FnInfo = FDecl->getIdentifier();
if (FnInfo->getBuiltinID() ==
Builtin::BI__builtin___CFStringMakeConstantString) {
assert(NumArgsInCall == 1 &&
"Wrong number of arguments to builtin CFStringMakeConstantString");
return CheckBuiltinCFStringArgument(Args[0]);
}
// Search the KnownFunctionIDs for the identifier.
unsigned i = 0, e = id_num_known_functions;
for (; i != e; ++i) { if (KnownFunctionIDs[i] == FnInfo) break; }
if (i == e) return false;
// Printf checking.
if (i <= id_vprintf) {
// Retrieve the index of the format string parameter and determine
// if the function is passed a va_arg argument.
unsigned format_idx = 0;
bool HasVAListArg = false;
switch (i) {
default: assert(false && "No format string argument index.");
case id_printf: format_idx = 0; break;
case id_fprintf: format_idx = 1; break;
case id_sprintf: format_idx = 1; break;
case id_snprintf: format_idx = 2; break;
case id_asprintf: format_idx = 1; HasVAListArg = true; break;
case id_vsnprintf: format_idx = 2; HasVAListArg = true; break;
case id_vasprintf: format_idx = 1; HasVAListArg = true; break;
case id_vfprintf: format_idx = 1; HasVAListArg = true; break;
case id_vsprintf: format_idx = 1; HasVAListArg = true; break;
case id_vprintf: format_idx = 0; HasVAListArg = true; break;
}
CheckPrintfArguments(Fn, LParenLoc, RParenLoc, HasVAListArg,
FDecl, format_idx, Args, NumArgsInCall);
}
return false;
}
/// CheckBuiltinCFStringArgument - Checks that the argument to the builtin
/// CFString constructor is correct
bool Sema::CheckBuiltinCFStringArgument(Expr* Arg) {
// FIXME: This should go in a helper.
while (1) {
if (ParenExpr *PE = dyn_cast<ParenExpr>(Arg))
Arg = PE->getSubExpr();
else if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg))
Arg = ICE->getSubExpr();
else
break;
}
StringLiteral *Literal = dyn_cast<StringLiteral>(Arg);
if (!Literal || Literal->isWide()) {
Diag(Arg->getLocStart(),
diag::err_cfstring_literal_not_string_constant,
Arg->getSourceRange());
return true;
}
const char *Data = Literal->getStrData();
unsigned Length = Literal->getByteLength();
for (unsigned i = 0; i < Length; ++i) {
if (!isascii(Data[i])) {
Diag(PP.AdvanceToTokenCharacter(Arg->getLocStart(), i + 1),
diag::warn_cfstring_literal_contains_non_ascii_character,
Arg->getSourceRange());
break;
}
if (!Data[i]) {
Diag(PP.AdvanceToTokenCharacter(Arg->getLocStart(), i + 1),
diag::warn_cfstring_literal_contains_nul_character,
Arg->getSourceRange());
break;
}
}
return false;
}
/// CheckPrintfArguments - Check calls to printf (and similar functions) for
/// correct use of format strings.
///
/// HasVAListArg - A predicate indicating whether the printf-like
/// function is passed an explicit va_arg argument (e.g., vprintf)
///
/// format_idx - The index into Args for the format string.
///
/// Improper format strings to functions in the printf family can be
/// the source of bizarre bugs and very serious security holes. A
/// good source of information is available in the following paper
/// (which includes additional references):
///
/// FormatGuard: Automatic Protection From printf Format String
/// Vulnerabilities, Proceedings of the 10th USENIX Security Symposium, 2001.
///
/// Functionality implemented:
///
/// We can statically check the following properties for string
/// literal format strings for non v.*printf functions (where the
/// arguments are passed directly):
//
/// (1) Are the number of format conversions equal to the number of
/// data arguments?
///
/// (2) Does each format conversion correctly match the type of the
/// corresponding data argument? (TODO)
///
/// Moreover, for all printf functions we can:
///
/// (3) Check for a missing format string (when not caught by type checking).
///
/// (4) Check for no-operation flags; e.g. using "#" with format
/// conversion 'c' (TODO)
///
/// (5) Check the use of '%n', a major source of security holes.
///
/// (6) Check for malformed format conversions that don't specify anything.
///
/// (7) Check for empty format strings. e.g: printf("");
///
/// (8) Check that the format string is a wide literal.
///
/// All of these checks can be done by parsing the format string.
///
/// For now, we ONLY do (1), (3), (5), (6), (7), and (8).
void
Sema::CheckPrintfArguments(Expr *Fn,
SourceLocation LParenLoc, SourceLocation RParenLoc,
bool HasVAListArg, FunctionDecl *FDecl,
unsigned format_idx, Expr** Args,
unsigned NumArgsInCall) {
// CHECK: printf-like function is called with no format string.
if (format_idx >= NumArgsInCall) {
Diag(RParenLoc, diag::warn_printf_missing_format_string,
Fn->getSourceRange());
return;
}
Expr *OrigFormatExpr = Args[format_idx];
// FIXME: This should go in a helper.
while (1) {
if (ParenExpr *PE = dyn_cast<ParenExpr>(OrigFormatExpr))
OrigFormatExpr = PE->getSubExpr();
else if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(OrigFormatExpr))
OrigFormatExpr = ICE->getSubExpr();
else
break;
}
// CHECK: format string is not a string literal.
//
// Dynamically generated format strings are difficult to
// automatically vet at compile time. Requiring that format strings
// are string literals: (1) permits the checking of format strings by
// the compiler and thereby (2) can practically remove the source of
// many format string exploits.
StringLiteral *FExpr = dyn_cast<StringLiteral>(OrigFormatExpr);
if (FExpr == NULL) {
Diag(Args[format_idx]->getLocStart(),
diag::warn_printf_not_string_constant, Fn->getSourceRange());
return;
}
// CHECK: is the format string a wide literal?
if (FExpr->isWide()) {
Diag(Args[format_idx]->getLocStart(),
diag::warn_printf_format_string_is_wide_literal,
Fn->getSourceRange());
return;
}
// Str - The format string. NOTE: this is NOT null-terminated!
const char * const Str = FExpr->getStrData();
// CHECK: empty format string?
const unsigned StrLen = FExpr->getByteLength();
if (StrLen == 0) {
Diag(Args[format_idx]->getLocStart(),
diag::warn_printf_empty_format_string, Fn->getSourceRange());
return;
}
// We process the format string using a binary state machine. The
// current state is stored in CurrentState.
enum {
state_OrdChr,
state_Conversion
} CurrentState = state_OrdChr;
// numConversions - The number of conversions seen so far. This is
// incremented as we traverse the format string.
unsigned numConversions = 0;
// numDataArgs - The number of data arguments after the format
// string. This can only be determined for non vprintf-like
// functions. For those functions, this value is 1 (the sole
// va_arg argument).
unsigned numDataArgs = NumArgsInCall-(format_idx+1);
// Inspect the format string.
unsigned StrIdx = 0;
// LastConversionIdx - Index within the format string where we last saw
// a '%' character that starts a new format conversion.
unsigned LastConversionIdx = 0;
for ( ; StrIdx < StrLen ; ++StrIdx ) {
// Is the number of detected conversion conversions greater than
// the number of matching data arguments? If so, stop.
if (!HasVAListArg && numConversions > numDataArgs) break;
// Handle "\0"
if(Str[StrIdx] == '\0' ) {
// The string returned by getStrData() is not null-terminated,
// so the presence of a null character is likely an error.
SourceLocation Loc =
PP.AdvanceToTokenCharacter(Args[format_idx]->getLocStart(),StrIdx+1);
Diag(Loc, diag::warn_printf_format_string_contains_null_char,
Fn->getSourceRange());
return;
}
// Ordinary characters (not processing a format conversion).
if (CurrentState == state_OrdChr) {
if (Str[StrIdx] == '%') {
CurrentState = state_Conversion;
LastConversionIdx = StrIdx;
}
continue;
}
// Seen '%'. Now processing a format conversion.
switch (Str[StrIdx]) {
// Characters which can terminate a format conversion
// (e.g. "%d"). Characters that specify length modifiers or
// other flags are handled by the default case below.
//
// TODO: additional checks will go into the following cases.
case 'i':
case 'd':
case 'o':
case 'u':
case 'x':
case 'X':
case 'D':
case 'O':
case 'U':
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
case 'a':
case 'A':
case 'c':
case 'C':
case 'S':
case 's':
case 'p':
++numConversions;
CurrentState = state_OrdChr;
break;
// CHECK: Are we using "%n"? Issue a warning.
case 'n': {
++numConversions;
CurrentState = state_OrdChr;
SourceLocation Loc =
PP.AdvanceToTokenCharacter(Args[format_idx]->getLocStart(),
LastConversionIdx+1);
Diag(Loc, diag::warn_printf_write_back, Fn->getSourceRange());
break;
}
// Handle "%%"
case '%':
// Sanity check: Was the first "%" character the previous one?
// If not, we will assume that we have a malformed format
// conversion, and that the current "%" character is the start
// of a new conversion.
if (StrIdx - LastConversionIdx == 1)
CurrentState = state_OrdChr;
else {
// Issue a warning: invalid format conversion.
SourceLocation Loc =
PP.AdvanceToTokenCharacter(Args[format_idx]->getLocStart(),
LastConversionIdx+1);
Diag(Loc, diag::warn_printf_invalid_conversion,
std::string(Str+LastConversionIdx, Str+StrIdx),
Fn->getSourceRange());
// This conversion is broken. Advance to the next format
// conversion.
LastConversionIdx = StrIdx;
++numConversions;
}
break;
default:
// This case catches all other characters: flags, widths, etc.
// We should eventually process those as well.
break;
}
}
if (CurrentState == state_Conversion) {
// Issue a warning: invalid format conversion.
SourceLocation Loc =
PP.AdvanceToTokenCharacter(Args[format_idx]->getLocStart(),
LastConversionIdx+1);
Diag(Loc, diag::warn_printf_invalid_conversion,
std::string(Str+LastConversionIdx,
Str+std::min(LastConversionIdx+2, StrLen)),
Fn->getSourceRange());
return;
}
if (!HasVAListArg) {
// CHECK: Does the number of format conversions exceed the number
// of data arguments?
if (numConversions > numDataArgs) {
SourceLocation Loc =
PP.AdvanceToTokenCharacter(Args[format_idx]->getLocStart(),
LastConversionIdx);
Diag(Loc, diag::warn_printf_insufficient_data_args,
Fn->getSourceRange());
}
// CHECK: Does the number of data arguments exceed the number of
// format conversions in the format string?
else if (numConversions < numDataArgs)
Diag(Args[format_idx+numConversions+1]->getLocStart(),
diag::warn_printf_too_many_data_args, Fn->getSourceRange());
}
}
//===--- CHECK: Return Address of Stack Variable --------------------------===//
static DeclRefExpr* EvalVal(Expr *E);
static DeclRefExpr* EvalAddr(Expr* E);
/// CheckReturnStackAddr - Check if a return statement returns the address
/// of a stack variable.
void
Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc) {
// Perform checking for returned stack addresses.
if (lhsType->isPointerType()) {
if (DeclRefExpr *DR = EvalAddr(RetValExp))
Diag(DR->getLocStart(), diag::warn_ret_stack_addr,
DR->getDecl()->getIdentifier()->getName(),
RetValExp->getSourceRange());
}
// Perform checking for stack values returned by reference.
else if (lhsType->isReferenceType()) {
// Check for an implicit cast to a reference.
if (ImplicitCastExpr *I = dyn_cast<ImplicitCastExpr>(RetValExp))
if (DeclRefExpr *DR = EvalVal(I->getSubExpr()))
Diag(DR->getLocStart(), diag::warn_ret_stack_ref,
DR->getDecl()->getIdentifier()->getName(),
RetValExp->getSourceRange());
}
}
/// EvalAddr - EvalAddr and EvalVal are mutually recursive functions that
/// check if the expression in a return statement evaluates to an address
/// to a location on the stack. The recursion is used to traverse the
/// AST of the return expression, with recursion backtracking when we
/// encounter a subexpression that (1) clearly does not lead to the address
/// of a stack variable or (2) is something we cannot determine leads to
/// the address of a stack variable based on such local checking.
///
/// EvalAddr processes expressions that are pointers that are used as
/// references (and not L-values). EvalVal handles all other values.
/// At the base case of the recursion is a check for a DeclRefExpr* in
/// the refers to a stack variable.
///
/// This implementation handles:
///
/// * pointer-to-pointer casts
/// * implicit conversions from array references to pointers
/// * taking the address of fields
/// * arbitrary interplay between "&" and "*" operators
/// * pointer arithmetic from an address of a stack variable
/// * taking the address of an array element where the array is on the stack
static DeclRefExpr* EvalAddr(Expr *E) {
// We should only be called for evaluating pointer expressions.
assert (E->getType()->isPointerType() && "EvalAddr only works on pointers");
// Our "symbolic interpreter" is just a dispatch off the currently
// viewed AST node. We then recursively traverse the AST by calling
// EvalAddr and EvalVal appropriately.
switch (E->getStmtClass()) {
case Stmt::ParenExprClass:
// Ignore parentheses.
return EvalAddr(cast<ParenExpr>(E)->getSubExpr());
case Stmt::UnaryOperatorClass: {
// The only unary operator that make sense to handle here
// is AddrOf. All others don't make sense as pointers.
UnaryOperator *U = cast<UnaryOperator>(E);
if (U->getOpcode() == UnaryOperator::AddrOf)
return EvalVal(U->getSubExpr());
else
return NULL;
}
case Stmt::BinaryOperatorClass: {
// Handle pointer arithmetic. All other binary operators are not valid
// in this context.
BinaryOperator *B = cast<BinaryOperator>(E);
BinaryOperator::Opcode op = B->getOpcode();
if (op != BinaryOperator::Add && op != BinaryOperator::Sub)
return NULL;
Expr *Base = B->getLHS();
// Determine which argument is the real pointer base. It could be
// the RHS argument instead of the LHS.
if (!Base->getType()->isPointerType()) Base = B->getRHS();
assert (Base->getType()->isPointerType());
return EvalAddr(Base);
}
// For conditional operators we need to see if either the LHS or RHS are
// valid DeclRefExpr*s. If one of them is valid, we return it.
case Stmt::ConditionalOperatorClass: {
ConditionalOperator *C = cast<ConditionalOperator>(E);
if (DeclRefExpr* LHS = EvalAddr(C->getLHS()))
return LHS;
else
return EvalAddr(C->getRHS());
}
// For implicit casts, we need to handle conversions from arrays to
// pointer values, and implicit pointer-to-pointer conversions.
case Stmt::ImplicitCastExprClass: {
ImplicitCastExpr *IE = cast<ImplicitCastExpr>(E);
Expr* SubExpr = IE->getSubExpr();
if (SubExpr->getType()->isPointerType())
return EvalAddr(SubExpr);
else
return EvalVal(SubExpr);
}
// For casts, we handle pointer-to-pointer conversions (which
// is essentially a no-op from our mini-interpreter's standpoint).
// For other casts we abort.
case Stmt::CastExprClass: {
CastExpr *C = cast<CastExpr>(E);
Expr *SubExpr = C->getSubExpr();
if (SubExpr->getType()->isPointerType())
return EvalAddr(SubExpr);
else
return NULL;
}
// C++ casts. For dynamic casts, static casts, and const casts, we
// are always converting from a pointer-to-pointer, so we just blow
// through the cast. In the case the dynamic cast doesn't fail
// (and return NULL), we take the conservative route and report cases
// where we return the address of a stack variable. For Reinterpre
case Stmt::CXXCastExprClass: {
CXXCastExpr *C = cast<CXXCastExpr>(E);
if (C->getOpcode() == CXXCastExpr::ReinterpretCast) {
Expr *S = C->getSubExpr();
if (S->getType()->isPointerType())
return EvalAddr(S);
else
return NULL;
}
else
return EvalAddr(C->getSubExpr());
}
// Everything else: we simply don't reason about them.
default:
return NULL;
}
}
/// EvalVal - This function is complements EvalAddr in the mutual recursion.
/// See the comments for EvalAddr for more details.
static DeclRefExpr* EvalVal(Expr *E) {
// We should only be called for evaluating non-pointer expressions, or
// expressions with a pointer type that are not used as references but instead
// are l-values (e.g., DeclRefExpr with a pointer type).
// Our "symbolic interpreter" is just a dispatch off the currently
// viewed AST node. We then recursively traverse the AST by calling
// EvalAddr and EvalVal appropriately.
switch (E->getStmtClass()) {
case Stmt::DeclRefExprClass: {
// DeclRefExpr: the base case. When we hit a DeclRefExpr we are looking
// at code that refers to a variable's name. We check if it has local
// storage within the function, and if so, return the expression.
DeclRefExpr *DR = cast<DeclRefExpr>(E);
if (VarDecl *V = dyn_cast<VarDecl>(DR->getDecl()))
if(V->hasLocalStorage()) return DR;
return NULL;
}
case Stmt::ParenExprClass:
// Ignore parentheses.
return EvalVal(cast<ParenExpr>(E)->getSubExpr());
case Stmt::UnaryOperatorClass: {
// The only unary operator that make sense to handle here
// is Deref. All others don't resolve to a "name." This includes
// handling all sorts of rvalues passed to a unary operator.
UnaryOperator *U = cast<UnaryOperator>(E);
if (U->getOpcode() == UnaryOperator::Deref)
return EvalAddr(U->getSubExpr());
return NULL;
}
case Stmt::ArraySubscriptExprClass: {
// Array subscripts are potential references to data on the stack. We
// retrieve the DeclRefExpr* for the array variable if it indeed
// has local storage.
return EvalAddr(cast<ArraySubscriptExpr>(E)->getBase());
}
case Stmt::ConditionalOperatorClass: {
// For conditional operators we need to see if either the LHS or RHS are
// non-NULL DeclRefExpr's. If one is non-NULL, we return it.
ConditionalOperator *C = cast<ConditionalOperator>(E);
if (DeclRefExpr *LHS = EvalVal(C->getLHS()))
return LHS;
else
return EvalVal(C->getRHS());
}
// Accesses to members are potential references to data on the stack.
case Stmt::MemberExprClass: {
MemberExpr *M = cast<MemberExpr>(E);
// Check for indirect access. We only want direct field accesses.
if (!M->isArrow())
return EvalVal(M->getBase());
else
return NULL;
}
// Everything else: we simply don't reason about them.
default:
return NULL;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,45 +0,0 @@
//===--- SemaExprCXX.cpp - Semantic Analysis for Expressions --------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Bill Wendling and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements semantic analysis for C++ expressions.
//
//===----------------------------------------------------------------------===//
#include "Sema.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ASTContext.h"
using namespace clang;
/// ParseCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's.
Action::ExprResult
Sema::ParseCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind,
SourceLocation LAngleBracketLoc, TypeTy *Ty,
SourceLocation RAngleBracketLoc,
SourceLocation LParenLoc, ExprTy *E,
SourceLocation RParenLoc) {
CXXCastExpr::Opcode Op;
switch (Kind) {
default: assert(0 && "Unknown C++ cast!");
case tok::kw_const_cast: Op = CXXCastExpr::ConstCast; break;
case tok::kw_dynamic_cast: Op = CXXCastExpr::DynamicCast; break;
case tok::kw_reinterpret_cast: Op = CXXCastExpr::ReinterpretCast; break;
case tok::kw_static_cast: Op = CXXCastExpr::StaticCast; break;
}
return new CXXCastExpr(Op, QualType::getFromOpaquePtr(Ty), (Expr*)E, OpLoc);
}
/// ParseCXXBoolLiteral - Parse {true,false} literals.
Action::ExprResult
Sema::ParseCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) {
assert((Kind != tok::kw_true || Kind != tok::kw_false) &&
"Unknown C++ Boolean value!");
return new CXXBoolLiteralExpr(Kind == tok::kw_true, Context.BoolTy, OpLoc);
}

View File

@@ -1,617 +0,0 @@
//===--- SemaStmt.cpp - Semantic Analysis for Statements ------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements semantic analysis for statements.
//
//===----------------------------------------------------------------------===//
#include "Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
#include "clang/AST/Stmt.h"
#include "clang/Parse/Scope.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Lex/IdentifierTable.h"
using namespace clang;
Sema::StmtResult Sema::ParseExprStmt(ExprTy *expr) {
Expr *E = static_cast<Expr*>(expr);
assert(E && "ParseExprStmt(): missing expression");
return E;
}
Sema::StmtResult Sema::ParseNullStmt(SourceLocation SemiLoc) {
return new NullStmt(SemiLoc);
}
Sema::StmtResult Sema::ParseDeclStmt(DeclTy *decl) {
if (decl)
return new DeclStmt(static_cast<Decl *>(decl));
else
return true; // error
}
Action::StmtResult
Sema::ParseCompoundStmt(SourceLocation L, SourceLocation R,
StmtTy **elts, unsigned NumElts, bool isStmtExpr) {
Stmt **Elts = reinterpret_cast<Stmt**>(elts);
// If we're in C89 mode, check that we don't have any decls after stmts. If
// so, emit an extension diagnostic.
if (!getLangOptions().C99 && !getLangOptions().CPlusPlus) {
// Note that __extension__ can be around a decl.
unsigned i = 0;
// Skip over all declarations.
for (; i != NumElts && isa<DeclStmt>(Elts[i]); ++i)
/*empty*/;
// We found the end of the list or a statement. Scan for another declstmt.
for (; i != NumElts && !isa<DeclStmt>(Elts[i]); ++i)
/*empty*/;
if (i != NumElts) {
Decl *D = cast<DeclStmt>(Elts[i])->getDecl();
Diag(D->getLocation(), diag::ext_mixed_decls_code);
}
}
// Warn about unused expressions in statements.
for (unsigned i = 0; i != NumElts; ++i) {
Expr *E = dyn_cast<Expr>(Elts[i]);
if (!E) continue;
// Warn about expressions with unused results.
if (E->hasLocalSideEffect() || E->getType()->isVoidType())
continue;
// The last expr in a stmt expr really is used.
if (isStmtExpr && i == NumElts-1)
continue;
/// DiagnoseDeadExpr - This expression is side-effect free and evaluated in
/// a context where the result is unused. Emit a diagnostic to warn about
/// this.
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E))
Diag(BO->getOperatorLoc(), diag::warn_unused_expr,
BO->getLHS()->getSourceRange(), BO->getRHS()->getSourceRange());
else if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(E))
Diag(UO->getOperatorLoc(), diag::warn_unused_expr,
UO->getSubExpr()->getSourceRange());
else
Diag(E->getExprLoc(), diag::warn_unused_expr, E->getSourceRange());
}
return new CompoundStmt(Elts, NumElts, L, R);
}
Action::StmtResult
Sema::ParseCaseStmt(SourceLocation CaseLoc, ExprTy *lhsval,
SourceLocation DotDotDotLoc, ExprTy *rhsval,
SourceLocation ColonLoc, StmtTy *subStmt) {
Stmt *SubStmt = static_cast<Stmt*>(subStmt);
Expr *LHSVal = ((Expr *)lhsval), *RHSVal = ((Expr *)rhsval);
assert((LHSVal != 0) && "missing expression in case statement");
SourceLocation ExpLoc;
// C99 6.8.4.2p3: The expression shall be an integer constant.
if (!LHSVal->isIntegerConstantExpr(Context, &ExpLoc)) {
Diag(ExpLoc, diag::err_case_label_not_integer_constant_expr,
LHSVal->getSourceRange());
return SubStmt;
}
// GCC extension: The expression shall be an integer constant.
if (RHSVal && !RHSVal->isIntegerConstantExpr(Context, &ExpLoc)) {
Diag(ExpLoc, diag::err_case_label_not_integer_constant_expr,
RHSVal->getSourceRange());
RHSVal = 0; // Recover by just forgetting about it.
}
if (SwitchStack.empty()) {
Diag(CaseLoc, diag::err_case_not_in_switch);
return SubStmt;
}
CaseStmt *CS = new CaseStmt(LHSVal, RHSVal, SubStmt, CaseLoc);
SwitchStack.back()->addSwitchCase(CS);
return CS;
}
Action::StmtResult
Sema::ParseDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
StmtTy *subStmt, Scope *CurScope) {
Stmt *SubStmt = static_cast<Stmt*>(subStmt);
if (SwitchStack.empty()) {
Diag(DefaultLoc, diag::err_default_not_in_switch);
return SubStmt;
}
DefaultStmt *DS = new DefaultStmt(DefaultLoc, SubStmt);
SwitchStack.back()->addSwitchCase(DS);
return DS;
}
Action::StmtResult
Sema::ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
SourceLocation ColonLoc, StmtTy *subStmt) {
Stmt *SubStmt = static_cast<Stmt*>(subStmt);
// Look up the record for this label identifier.
LabelStmt *&LabelDecl = LabelMap[II];
// If not forward referenced or defined already, just create a new LabelStmt.
if (LabelDecl == 0)
return LabelDecl = new LabelStmt(IdentLoc, II, SubStmt);
assert(LabelDecl->getID() == II && "Label mismatch!");
// Otherwise, this label was either forward reference or multiply defined. If
// multiply defined, reject it now.
if (LabelDecl->getSubStmt()) {
Diag(IdentLoc, diag::err_redefinition_of_label, LabelDecl->getName());
Diag(LabelDecl->getIdentLoc(), diag::err_previous_definition);
return SubStmt;
}
// Otherwise, this label was forward declared, and we just found its real
// definition. Fill in the forward definition and return it.
LabelDecl->setIdentLoc(IdentLoc);
LabelDecl->setSubStmt(SubStmt);
return LabelDecl;
}
Action::StmtResult
Sema::ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
StmtTy *ThenVal, SourceLocation ElseLoc,
StmtTy *ElseVal) {
Expr *condExpr = (Expr *)CondVal;
assert(condExpr && "ParseIfStmt(): missing expression");
DefaultFunctionArrayConversion(condExpr);
QualType condType = condExpr->getType();
if (!condType->isScalarType()) // C99 6.8.4.1p1
return Diag(IfLoc, diag::err_typecheck_statement_requires_scalar,
condType.getAsString(), condExpr->getSourceRange());
return new IfStmt(IfLoc, condExpr, (Stmt*)ThenVal, (Stmt*)ElseVal);
}
Action::StmtResult
Sema::StartSwitchStmt(ExprTy *cond) {
Expr *Cond = static_cast<Expr*>(cond);
// C99 6.8.4.2p5 - Integer promotions are performed on the controlling expr.
UsualUnaryConversions(Cond);
SwitchStmt *SS = new SwitchStmt(Cond);
SwitchStack.push_back(SS);
return SS;
}
/// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
/// the specified width and sign. If an overflow occurs, detect it and emit
/// the specified diagnostic.
void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val,
unsigned NewWidth, bool NewSign,
SourceLocation Loc,
unsigned DiagID) {
// Perform a conversion to the promoted condition type if needed.
if (NewWidth > Val.getBitWidth()) {
// If this is an extension, just do it.
llvm::APSInt OldVal(Val);
Val.extend(NewWidth);
// If the input was signed and negative and the output is unsigned,
// warn.
if (!NewSign && OldVal.isSigned() && OldVal.isNegative())
Diag(Loc, DiagID, OldVal.toString(), Val.toString());
Val.setIsSigned(NewSign);
} else if (NewWidth < Val.getBitWidth()) {
// If this is a truncation, check for overflow.
llvm::APSInt ConvVal(Val);
ConvVal.trunc(NewWidth);
ConvVal.setIsSigned(NewSign);
ConvVal.extend(Val.getBitWidth());
ConvVal.setIsSigned(Val.isSigned());
if (ConvVal != Val)
Diag(Loc, DiagID, Val.toString(), ConvVal.toString());
// Regardless of whether a diagnostic was emitted, really do the
// truncation.
Val.trunc(NewWidth);
Val.setIsSigned(NewSign);
} else if (NewSign != Val.isSigned()) {
// Convert the sign to match the sign of the condition. This can cause
// overflow as well: unsigned(INTMIN)
llvm::APSInt OldVal(Val);
Val.setIsSigned(NewSign);
if (Val.isNegative()) // Sign bit changes meaning.
Diag(Loc, DiagID, OldVal.toString(), Val.toString());
}
}
namespace {
struct CaseCompareFunctor {
bool operator()(const std::pair<llvm::APSInt, CaseStmt*> &LHS,
const llvm::APSInt &RHS) {
return LHS.first < RHS;
}
bool operator()(const std::pair<llvm::APSInt, CaseStmt*> &LHS,
const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
return LHS.first < RHS.first;
}
bool operator()(const llvm::APSInt &LHS,
const std::pair<llvm::APSInt, CaseStmt*> &RHS) {
return LHS < RHS.first;
}
};
}
Action::StmtResult
Sema::FinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch, ExprTy *Body) {
Stmt *BodyStmt = (Stmt*)Body;
SwitchStmt *SS = SwitchStack.back();
assert(SS == (SwitchStmt*)Switch && "switch stack missing push/pop!");
SS->setBody(BodyStmt, SwitchLoc);
SwitchStack.pop_back();
Expr *CondExpr = SS->getCond();
QualType CondType = CondExpr->getType();
if (!CondType->isIntegerType()) { // C99 6.8.4.2p1
Diag(SwitchLoc, diag::err_typecheck_statement_requires_integer,
CondType.getAsString(), CondExpr->getSourceRange());
return true;
}
// Get the bitwidth of the switched-on value before promotions. We must
// convert the integer case values to this width before comparison.
unsigned CondWidth = Context.getTypeSize(CondType, SwitchLoc);
bool CondIsSigned = CondType->isSignedIntegerType();
// Accumulate all of the case values in a vector so that we can sort them
// and detect duplicates. This vector contains the APInt for the case after
// it has been converted to the condition type.
typedef llvm::SmallVector<std::pair<llvm::APSInt, CaseStmt*>, 64> CaseValsTy;
CaseValsTy CaseVals;
// Keep track of any GNU case ranges we see. The APSInt is the low value.
std::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRanges;
DefaultStmt *TheDefaultStmt = 0;
bool CaseListIsErroneous = false;
for (SwitchCase *SC = SS->getSwitchCaseList(); SC;
SC = SC->getNextSwitchCase()) {
if (DefaultStmt *DS = dyn_cast<DefaultStmt>(SC)) {
if (TheDefaultStmt) {
Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
Diag(TheDefaultStmt->getDefaultLoc(), diag::err_first_label);
// FIXME: Remove the default statement from the switch block so that
// we'll return a valid AST. This requires recursing down the
// AST and finding it, not something we are set up to do right now. For
// now, just lop the entire switch stmt out of the AST.
CaseListIsErroneous = true;
}
TheDefaultStmt = DS;
} else {
CaseStmt *CS = cast<CaseStmt>(SC);
// We already verified that the expression has a i-c-e value (C99
// 6.8.4.2p3) - get that value now.
llvm::APSInt LoVal(32);
CS->getLHS()->isIntegerConstantExpr(LoVal, Context);
// Convert the value to the same width/sign as the condition.
ConvertIntegerToTypeWarnOnOverflow(LoVal, CondWidth, CondIsSigned,
CS->getLHS()->getLocStart(),
diag::warn_case_value_overflow);
// If this is a case range, remember it in CaseRanges, otherwise CaseVals.
if (CS->getRHS())
CaseRanges.push_back(std::make_pair(LoVal, CS));
else
CaseVals.push_back(std::make_pair(LoVal, CS));
}
}
// Sort all the scalar case values so we can easily detect duplicates.
std::stable_sort(CaseVals.begin(), CaseVals.end());
if (!CaseVals.empty()) {
for (unsigned i = 0, e = CaseVals.size()-1; i != e; ++i) {
if (CaseVals[i].first == CaseVals[i+1].first) {
// If we have a duplicate, report it.
Diag(CaseVals[i+1].second->getLHS()->getLocStart(),
diag::err_duplicate_case, CaseVals[i].first.toString());
Diag(CaseVals[i].second->getLHS()->getLocStart(),
diag::err_duplicate_case_prev);
// FIXME: We really want to remove the bogus case stmt from the substmt,
// but we have no way to do this right now.
CaseListIsErroneous = true;
}
}
}
// Detect duplicate case ranges, which usually don't exist at all in the first
// place.
if (!CaseRanges.empty()) {
// Sort all the case ranges by their low value so we can easily detect
// overlaps between ranges.
std::stable_sort(CaseRanges.begin(), CaseRanges.end());
// Scan the ranges, computing the high values and removing empty ranges.
std::vector<llvm::APSInt> HiVals;
for (unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
CaseStmt *CR = CaseRanges[i].second;
llvm::APSInt HiVal(32);
CR->getRHS()->isIntegerConstantExpr(HiVal, Context);
// Convert the value to the same width/sign as the condition.
ConvertIntegerToTypeWarnOnOverflow(HiVal, CondWidth, CondIsSigned,
CR->getRHS()->getLocStart(),
diag::warn_case_value_overflow);
// If the low value is bigger than the high value, the case is empty.
if (CaseRanges[i].first > HiVal) {
Diag(CR->getLHS()->getLocStart(), diag::warn_case_empty_range,
SourceRange(CR->getLHS()->getLocStart(),
CR->getRHS()->getLocEnd()));
CaseRanges.erase(CaseRanges.begin()+i);
--i, --e;
continue;
}
HiVals.push_back(HiVal);
}
// Rescan the ranges, looking for overlap with singleton values and other
// ranges. Since the range list is sorted, we only need to compare case
// ranges with their neighbors.
for (unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
llvm::APSInt &CRLo = CaseRanges[i].first;
llvm::APSInt &CRHi = HiVals[i];
CaseStmt *CR = CaseRanges[i].second;
// Check to see whether the case range overlaps with any singleton cases.
CaseStmt *OverlapStmt = 0;
llvm::APSInt OverlapVal(32);
// Find the smallest value >= the lower bound. If I is in the case range,
// then we have overlap.
CaseValsTy::iterator I = std::lower_bound(CaseVals.begin(),
CaseVals.end(), CRLo,
CaseCompareFunctor());
if (I != CaseVals.end() && I->first < CRHi) {
OverlapVal = I->first; // Found overlap with scalar.
OverlapStmt = I->second;
}
// Find the smallest value bigger than the upper bound.
I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
if (I != CaseVals.begin() && (I-1)->first >= CRLo) {
OverlapVal = (I-1)->first; // Found overlap with scalar.
OverlapStmt = (I-1)->second;
}
// Check to see if this case stmt overlaps with the subsequent case range.
if (i && CRLo <= HiVals[i-1]) {
OverlapVal = HiVals[i-1]; // Found overlap with range.
OverlapStmt = CaseRanges[i-1].second;
}
if (OverlapStmt) {
// If we have a duplicate, report it.
Diag(CR->getLHS()->getLocStart(),
diag::err_duplicate_case, OverlapVal.toString());
Diag(OverlapStmt->getLHS()->getLocStart(),
diag::err_duplicate_case_prev);
// FIXME: We really want to remove the bogus case stmt from the substmt,
// but we have no way to do this right now.
CaseListIsErroneous = true;
}
}
}
// FIXME: If the case list was broken is some way, we don't have a good system
// to patch it up. Instead, just return the whole substmt as broken.
if (CaseListIsErroneous)
return true;
return SS;
}
Action::StmtResult
Sema::ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body) {
Expr *condExpr = (Expr *)Cond;
assert(condExpr && "ParseWhileStmt(): missing expression");
DefaultFunctionArrayConversion(condExpr);
QualType condType = condExpr->getType();
if (!condType->isScalarType()) // C99 6.8.5p2
return Diag(WhileLoc, diag::err_typecheck_statement_requires_scalar,
condType.getAsString(), condExpr->getSourceRange());
return new WhileStmt(condExpr, (Stmt*)Body, WhileLoc);
}
Action::StmtResult
Sema::ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
SourceLocation WhileLoc, ExprTy *Cond) {
Expr *condExpr = (Expr *)Cond;
assert(condExpr && "ParseDoStmt(): missing expression");
DefaultFunctionArrayConversion(condExpr);
QualType condType = condExpr->getType();
if (!condType->isScalarType()) // C99 6.8.5p2
return Diag(DoLoc, diag::err_typecheck_statement_requires_scalar,
condType.getAsString(), condExpr->getSourceRange());
return new DoStmt((Stmt*)Body, condExpr, DoLoc);
}
Action::StmtResult
Sema::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
StmtTy *first, ExprTy *second, ExprTy *third,
SourceLocation RParenLoc, StmtTy *body) {
Stmt *First = static_cast<Stmt*>(first);
Expr *Second = static_cast<Expr*>(second);
Expr *Third = static_cast<Expr*>(third);
Stmt *Body = static_cast<Stmt*>(body);
if (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
// C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
// identifiers for objects having storage class 'auto' or 'register'.
for (Decl *D = DS->getDecl(); D; D = D->getNextDeclarator()) {
BlockVarDecl *BVD = dyn_cast<BlockVarDecl>(D);
if (BVD && !BVD->hasLocalStorage())
BVD = 0;
if (BVD == 0)
Diag(D->getLocation(), diag::err_non_variable_decl_in_for);
// FIXME: mark decl erroneous!
}
}
if (Second) {
DefaultFunctionArrayConversion(Second);
QualType SecondType = Second->getType();
if (!SecondType->isScalarType()) // C99 6.8.5p2
return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar,
SecondType.getAsString(), Second->getSourceRange());
}
return new ForStmt(First, Second, Third, Body, ForLoc);
}
Action::StmtResult
Sema::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
IdentifierInfo *LabelII) {
// Look up the record for this label identifier.
LabelStmt *&LabelDecl = LabelMap[LabelII];
// If we haven't seen this label yet, create a forward reference.
if (LabelDecl == 0)
LabelDecl = new LabelStmt(LabelLoc, LabelII, 0);
return new GotoStmt(LabelDecl, GotoLoc, LabelLoc);
}
Action::StmtResult
Sema::ParseIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
ExprTy *DestExp) {
// FIXME: Verify that the operand is convertible to void*.
return new IndirectGotoStmt((Expr*)DestExp);
}
Action::StmtResult
Sema::ParseContinueStmt(SourceLocation ContinueLoc, Scope *CurScope) {
Scope *S = CurScope->getContinueParent();
if (!S) {
// C99 6.8.6.2p1: A break shall appear only in or as a loop body.
Diag(ContinueLoc, diag::err_continue_not_in_loop);
return true;
}
return new ContinueStmt(ContinueLoc);
}
Action::StmtResult
Sema::ParseBreakStmt(SourceLocation BreakLoc, Scope *CurScope) {
Scope *S = CurScope->getBreakParent();
if (!S) {
// C99 6.8.6.3p1: A break shall appear only in or as a switch/loop body.
Diag(BreakLoc, diag::err_break_not_in_loop_or_switch);
return true;
}
return new BreakStmt(BreakLoc);
}
Action::StmtResult
Sema::ParseReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
Expr *RetValExp = static_cast<Expr *>(rex);
QualType lhsType = CurFunctionDecl->getResultType();
if (lhsType->isVoidType()) {
if (RetValExp) // C99 6.8.6.4p1 (ext_ since GCC warns)
Diag(ReturnLoc, diag::ext_return_has_expr,
CurFunctionDecl->getIdentifier()->getName(),
RetValExp->getSourceRange());
return new ReturnStmt(ReturnLoc, RetValExp);
} else {
if (!RetValExp) {
const char *funcName = CurFunctionDecl->getIdentifier()->getName();
if (getLangOptions().C99) // C99 6.8.6.4p1 (ext_ since GCC warns)
Diag(ReturnLoc, diag::ext_return_missing_expr, funcName);
else // C90 6.6.6.4p4
Diag(ReturnLoc, diag::warn_return_missing_expr, funcName);
return new ReturnStmt(ReturnLoc, (Expr*)0);
}
}
// we have a non-void function with an expression, continue checking
QualType rhsType = RetValExp->getType();
// C99 6.8.6.4p3(136): The return statement is not an assignment. The
// overlap restriction of subclause 6.5.16.1 does not apply to the case of
// function return.
AssignmentCheckResult result = CheckSingleAssignmentConstraints(lhsType,
RetValExp);
// decode the result (notice that extensions still return a type).
switch (result) {
case Compatible:
break;
case Incompatible:
Diag(ReturnLoc, diag::err_typecheck_return_incompatible,
lhsType.getAsString(), rhsType.getAsString(),
RetValExp->getSourceRange());
break;
case PointerFromInt:
// check for null pointer constant (C99 6.3.2.3p3)
if (!RetValExp->isNullPointerConstant(Context)) {
Diag(ReturnLoc, diag::ext_typecheck_return_pointer_int,
lhsType.getAsString(), rhsType.getAsString(),
RetValExp->getSourceRange());
}
break;
case IntFromPointer:
Diag(ReturnLoc, diag::ext_typecheck_return_pointer_int,
lhsType.getAsString(), rhsType.getAsString(),
RetValExp->getSourceRange());
break;
case IncompatiblePointer:
Diag(ReturnLoc, diag::ext_typecheck_return_incompatible_pointer,
lhsType.getAsString(), rhsType.getAsString(),
RetValExp->getSourceRange());
break;
case CompatiblePointerDiscardsQualifiers:
Diag(ReturnLoc, diag::ext_typecheck_return_discards_qualifiers,
lhsType.getAsString(), rhsType.getAsString(),
RetValExp->getSourceRange());
break;
}
if (RetValExp) CheckReturnStackAddr(RetValExp, lhsType, ReturnLoc);
return new ReturnStmt(ReturnLoc, (Expr*)RetValExp);
}

View File

@@ -1,348 +0,0 @@
//===--- SemaType.cpp - Semantic Analysis for Types -----------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements type-related semantic analysis.
//
//===----------------------------------------------------------------------===//
#include "Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Lex/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
using namespace clang;
/// ConvertDeclSpecToType - Convert the specified declspec to the appropriate
/// type object. This returns null on error.
static QualType ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
// FIXME: Should move the logic from DeclSpec::Finish to here for validity
// checking.
switch (DS.getTypeSpecType()) {
default: return QualType(); // FIXME: Handle unimp cases!
case DeclSpec::TST_void: return Ctx.VoidTy;
case DeclSpec::TST_char:
if (DS.getTypeSpecSign() == DeclSpec::TSS_unspecified)
return Ctx.CharTy;
else if (DS.getTypeSpecSign() == DeclSpec::TSS_signed)
return Ctx.SignedCharTy;
else {
assert(DS.getTypeSpecSign() == DeclSpec::TSS_unsigned &&
"Unknown TSS value");
return Ctx.UnsignedCharTy;
}
case DeclSpec::TST_unspecified: // Unspecific typespec defaults to int.
case DeclSpec::TST_int: {
QualType Result;
if (DS.getTypeSpecSign() != DeclSpec::TSS_unsigned) {
switch (DS.getTypeSpecWidth()) {
case DeclSpec::TSW_unspecified: Result = Ctx.IntTy; break;
case DeclSpec::TSW_short: Result = Ctx.ShortTy; break;
case DeclSpec::TSW_long: Result = Ctx.LongTy; break;
case DeclSpec::TSW_longlong: Result = Ctx.LongLongTy; break;
}
} else {
switch (DS.getTypeSpecWidth()) {
case DeclSpec::TSW_unspecified: Result = Ctx.UnsignedIntTy; break;
case DeclSpec::TSW_short: Result = Ctx.UnsignedShortTy; break;
case DeclSpec::TSW_long: Result = Ctx.UnsignedLongTy; break;
case DeclSpec::TSW_longlong: Result = Ctx.UnsignedLongLongTy; break;
}
}
// Handle complex integer types.
if (DS.getTypeSpecComplex() == DeclSpec::TSC_unspecified)
return Result;
assert(DS.getTypeSpecComplex() == DeclSpec::TSC_complex &&
"FIXME: imaginary types not supported yet!");
return Ctx.getComplexType(Result);
}
case DeclSpec::TST_float:
if (DS.getTypeSpecComplex() == DeclSpec::TSC_unspecified)
return Ctx.FloatTy;
assert(DS.getTypeSpecComplex() == DeclSpec::TSC_complex &&
"FIXME: imaginary types not supported yet!");
return Ctx.getComplexType(Ctx.FloatTy);
case DeclSpec::TST_double: {
bool isLong = DS.getTypeSpecWidth() == DeclSpec::TSW_long;
QualType T = isLong ? Ctx.LongDoubleTy : Ctx.DoubleTy;
if (DS.getTypeSpecComplex() == DeclSpec::TSC_unspecified)
return T;
assert(DS.getTypeSpecComplex() == DeclSpec::TSC_complex &&
"FIXME: imaginary types not supported yet!");
return Ctx.getComplexType(T);
}
case DeclSpec::TST_bool: // _Bool or bool
return Ctx.BoolTy;
case DeclSpec::TST_decimal32: // _Decimal32
case DeclSpec::TST_decimal64: // _Decimal64
case DeclSpec::TST_decimal128: // _Decimal128
assert(0 && "FIXME: GNU decimal extensions not supported yet!");
case DeclSpec::TST_enum:
case DeclSpec::TST_union:
case DeclSpec::TST_struct: {
Decl *D = static_cast<Decl *>(DS.getTypeRep());
assert(D && "Didn't get a decl for a enum/union/struct?");
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
DS.getTypeSpecSign() == 0 &&
"Can't handle qualifiers on typedef names yet!");
// TypeQuals handled by caller.
return Ctx.getTagDeclType(cast<TagDecl>(D));
}
case DeclSpec::TST_typedef: {
Decl *D = static_cast<Decl *>(DS.getTypeRep());
assert(D && "Didn't get a decl for a typedef?");
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
DS.getTypeSpecSign() == 0 &&
"Can't handle qualifiers on typedef names yet!");
// FIXME: Adding a TST_objcInterface clause doesn't seem ideal, so
// we have this "hack" for now...
if (isa<ObjcInterfaceDecl>(D))
return Ctx.getObjcInterfaceType(cast<ObjcInterfaceDecl>(D));
// TypeQuals handled by caller.
return Ctx.getTypedefType(cast<TypedefDecl>(D));
}
case DeclSpec::TST_typeofType: {
QualType T = QualType::getFromOpaquePtr(DS.getTypeRep());
assert(!T.isNull() && "Didn't get a type for typeof?");
// TypeQuals handled by caller.
return Ctx.getTypeOfType(T);
}
case DeclSpec::TST_typeofExpr: {
Expr *E = static_cast<Expr *>(DS.getTypeRep());
assert(E && "Didn't get an expression for typeof?");
// TypeQuals handled by caller.
return Ctx.getTypeOfExpr(E);
}
}
}
/// GetTypeForDeclarator - Convert the type for the specified declarator to Type
/// instances.
QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
// long long is a C99 feature.
if (!getLangOptions().C99 && !getLangOptions().CPlusPlus0x &&
D.getDeclSpec().getTypeSpecWidth() == DeclSpec::TSW_longlong)
Diag(D.getDeclSpec().getTypeSpecWidthLoc(), diag::ext_longlong);
QualType T = ConvertDeclSpecToType(D.getDeclSpec(), Context);
// Apply const/volatile/restrict qualifiers to T.
T = T.getQualifiedType(D.getDeclSpec().getTypeQualifiers());
// Walk the DeclTypeInfo, building the recursive type as we go. DeclTypeInfos
// are ordered from the identifier out, which is opposite of what we want :).
for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
const DeclaratorChunk &DeclType = D.getTypeObject(e-i-1);
switch (DeclType.Kind) {
default: assert(0 && "Unknown decltype!");
case DeclaratorChunk::Pointer:
if (T->isReferenceType()) {
// C++ 8.3.2p4: There shall be no ... pointers to references ...
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_pointer_to_reference,
D.getIdentifier()->getName());
D.setInvalidType(true);
T = Context.IntTy;
}
// Apply the pointer typequals to the pointer object.
T = Context.getPointerType(T).getQualifiedType(DeclType.Ptr.TypeQuals);
break;
case DeclaratorChunk::Reference:
if (const ReferenceType *RT = T->getAsReferenceType()) {
// C++ 8.3.2p4: There shall be no references to references ...
Diag(D.getIdentifierLoc(),
diag::err_illegal_decl_reference_to_reference,
D.getIdentifier()->getName());
D.setInvalidType(true);
T = RT->getReferenceeType();
}
T = Context.getReferenceType(T);
break;
case DeclaratorChunk::Array: {
const DeclaratorChunk::ArrayTypeInfo &ATI = DeclType.Arr;
Expr *ArraySize = static_cast<Expr*>(ATI.NumElts);
ArrayType::ArraySizeModifier ASM;
if (ATI.isStar)
ASM = ArrayType::Star;
else if (ATI.hasStatic)
ASM = ArrayType::Static;
else
ASM = ArrayType::Normal;
// C99 6.7.5.2p1: If the element type is an incomplete or function type,
// reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
if (T->isIncompleteType()) {
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_incomplete_type,
T.getAsString());
T = Context.IntTy;
D.setInvalidType(true);
} else if (T->isFunctionType()) {
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions,
D.getIdentifier()->getName());
T = Context.getPointerType(T);
D.setInvalidType(true);
} else if (const ReferenceType *RT = T->getAsReferenceType()) {
// C++ 8.3.2p4: There shall be no ... arrays of references ...
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_references,
D.getIdentifier()->getName());
T = RT->getReferenceeType();
D.setInvalidType(true);
} else if (const RecordType *EltTy = T->getAsRecordType()) {
// If the element type is a struct or union that contains a variadic
// array, reject it: C99 6.7.2.1p2.
if (EltTy->getDecl()->hasFlexibleArrayMember()) {
Diag(DeclType.Loc, diag::err_flexible_array_in_array,
T.getAsString());
T = Context.IntTy;
D.setInvalidType(true);
}
}
// C99 6.7.5.2p1: The size expression shall have integer type.
if (ArraySize && !ArraySize->getType()->isIntegerType()) {
Diag(ArraySize->getLocStart(), diag::err_array_size_non_int,
ArraySize->getType().getAsString(), ArraySize->getSourceRange());
D.setInvalidType(true);
}
llvm::APSInt ConstVal(32);
// If no expression was provided, we consider it a VLA.
if (!ArraySize || !ArraySize->isIntegerConstantExpr(ConstVal, Context))
T = Context.getVariableArrayType(T, ArraySize, ASM, ATI.TypeQuals);
else {
// C99 6.7.5.2p1: If the expression is a constant expression, it shall
// have a value greater than zero.
if (ConstVal.isSigned()) {
if (ConstVal.isNegative()) {
Diag(ArraySize->getLocStart(),
diag::err_typecheck_negative_array_size,
ArraySize->getSourceRange());
D.setInvalidType(true);
} else if (ConstVal == 0) {
// GCC accepts zero sized static arrays.
Diag(ArraySize->getLocStart(), diag::ext_typecheck_zero_array_size,
ArraySize->getSourceRange());
}
}
T = Context.getConstantArrayType(T, ConstVal, ASM, ATI.TypeQuals);
}
// If this is not C99, extwarn about VLA's and C99 array size modifiers.
if (!getLangOptions().C99 &&
(ASM != ArrayType::Normal ||
(ArraySize && !ArraySize->isIntegerConstantExpr(Context))))
Diag(D.getIdentifierLoc(), diag::ext_vla);
break;
}
case DeclaratorChunk::Function:
// If the function declarator has a prototype (i.e. it is not () and
// does not have a K&R-style identifier list), then the arguments are part
// of the type, otherwise the argument list is ().
const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
if (!FTI.hasPrototype) {
// Simple void foo(), where the incoming T is the result type.
T = Context.getFunctionTypeNoProto(T);
// C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition.
if (FTI.NumArgs != 0)
Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);
} else {
// Otherwise, we have a function with an argument list that is
// potentially variadic.
llvm::SmallVector<QualType, 16> ArgTys;
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
QualType ArgTy = QualType::getFromOpaquePtr(FTI.ArgInfo[i].TypeInfo);
assert(!ArgTy.isNull() && "Couldn't parse type?");
//
// Perform the default function/array conversion (C99 6.7.5.3p[7,8]).
// This matches the conversion that is done in
// Sema::ParseParamDeclarator(). Without this conversion, the
// argument type in the function prototype *will not* match the
// type in ParmVarDecl (which makes the code generator unhappy).
//
// FIXME: We still apparently need the conversion in
// Sema::ParseParamDeclarator(). This doesn't make any sense, since
// it should be driving off the type being created here.
//
// FIXME: If a source translation tool needs to see the original type,
// then we need to consider storing both types somewhere...
//
if (const ArrayType *AT = ArgTy->getAsArrayType())
ArgTy = Context.getPointerType(AT->getElementType());
else if (ArgTy->isFunctionType())
ArgTy = Context.getPointerType(ArgTy);
// Look for 'void'. void is allowed only as a single argument to a
// function with no other parameters (C99 6.7.5.3p10). We record
// int(void) as a FunctionTypeProto with an empty argument list.
else if (ArgTy->isVoidType()) {
// If this is something like 'float(int, void)', reject it. 'void'
// is an incomplete type (C99 6.2.5p19) and function decls cannot
// have arguments of incomplete type.
if (FTI.NumArgs != 1 || FTI.isVariadic) {
Diag(DeclType.Loc, diag::err_void_only_param);
ArgTy = Context.IntTy;
FTI.ArgInfo[i].TypeInfo = ArgTy.getAsOpaquePtr();
} else if (FTI.ArgInfo[i].Ident) {
// Reject, but continue to parse 'int(void abc)'.
Diag(FTI.ArgInfo[i].IdentLoc,
diag::err_param_with_void_type);
ArgTy = Context.IntTy;
FTI.ArgInfo[i].TypeInfo = ArgTy.getAsOpaquePtr();
} else {
// Reject, but continue to parse 'float(const void)'.
if (ArgTy.getQualifiers())
Diag(DeclType.Loc, diag::err_void_param_qualified);
// Do not add 'void' to the ArgTys list.
break;
}
}
ArgTys.push_back(ArgTy);
}
T = Context.getFunctionType(T, &ArgTys[0], ArgTys.size(),
FTI.isVariadic);
}
break;
}
}
return T;
}
Sema::TypeResult Sema::ParseTypeName(Scope *S, Declarator &D) {
// C99 6.7.6: Type names have no identifier. This is already validated by
// the parser.
assert(D.getIdentifier() == 0 && "Type name should have no identifier!");
QualType T = GetTypeForDeclarator(D, S);
assert(!T.isNull() && "GetTypeForDeclarator() returned null type");
// In this context, we *do not* check D.getInvalidType(). If the declarator
// type was invalid, GetTypeForDeclarator() still returns a "valid" type,
// though it will not reflect the user specified type.
return T.getAsOpaquePtr();
}
// Called from Parser::ParseParenDeclarator().
Sema::TypeResult Sema::ParseParamDeclaratorType(Scope *S, Declarator &D) {
// Note: parameters have identifiers, but we don't care about them here, we
// just want the type converted.
QualType T = GetTypeForDeclarator(D, S);
assert(!T.isNull() && "GetTypeForDeclarator() returned null type");
// In this context, we *do not* check D.getInvalidType(). If the declarator
// type was invalid, GetTypeForDeclarator() still returns a "valid" type,
// though it will not reflect the user specified type.
return T.getAsOpaquePtr();
}

View File

@@ -1,29 +0,0 @@
//===---------------------------------------------------------------------===//
// Minor random things that can be improved
//===---------------------------------------------------------------------===//
//===---------------------------------------------------------------------===//
Lexer-related diagnostics should point to the problematic character, not the
start of the token. For example:
int y = 0000\
00080;
diag.c:4:9: error: invalid digit '8' in octal constant
int y = 0000\
^
should be:
diag.c:4:9: error: invalid digit '8' in octal constant
00080;
^
This specific diagnostic is implemented, but others should be updated.
//===---------------------------------------------------------------------===//

View File

@@ -1,880 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 42;
objects = {
/* Begin PBXBuildFile section */
1A30A9E90B93A4C800201A91 /* ExprCXX.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A30A9E80B93A4C800201A91 /* ExprCXX.h */; };
1A7342480C7B57D500122F56 /* CGObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7342470C7B57D500122F56 /* CGObjC.cpp */; };
1A869A700BA2164C008DA07A /* LiteralSupport.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A869A6E0BA2164C008DA07A /* LiteralSupport.h */; };
1A869AA80BA21ABA008DA07A /* LiteralSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */; };
1ABC36940C7A4BDC006DB0AB /* CGBuiltin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ABC36930C7A4BDC006DB0AB /* CGBuiltin.cpp */; };
35260CA50C7F75C000D66CE9 /* ExprCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35260CA40C7F75C000D66CE9 /* ExprCXX.cpp */; };
355CF6840C90A8D400A08AA3 /* DeadStores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 355CF6830C90A8D400A08AA3 /* DeadStores.cpp */; };
356EF9B50C8F7DDF006650F5 /* LiveVariables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 356EF9B40C8F7DDF006650F5 /* LiveVariables.cpp */; };
84D9A8880C1A57E100AC7ABC /* AttributeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */; };
84D9A88C0C1A581300AC7ABC /* AttributeList.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 84D9A88B0C1A581300AC7ABC /* AttributeList.h */; };
DE01DA490B12ADA300AC22CE /* PPCallbacks.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE01DA480B12ADA300AC22CE /* PPCallbacks.h */; };
DE06756C0C051CFE00EBBFD8 /* ParseExprCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */; };
DE06B73E0A8307640050E87E /* LangOptions.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE06B73D0A8307640050E87E /* LangOptions.h */; };
DE06BECB0A854E4B0050E87E /* Scope.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE06BECA0A854E4B0050E87E /* Scope.h */; };
DE06D4310A8BB52D0050E87E /* Parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE06D42F0A8BB52D0050E87E /* Parser.cpp */; };
DE06E8140A8FF9330050E87E /* Action.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE06E8130A8FF9330050E87E /* Action.h */; };
DE0FCA630A95859D00248FD5 /* Expr.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE0FCA620A95859D00248FD5 /* Expr.h */; };
DE0FCB340A9C21F100248FD5 /* Expr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE0FCB330A9C21F100248FD5 /* Expr.cpp */; };
DE1733000B068B700080B521 /* ASTContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE1732FF0B068B700080B521 /* ASTContext.cpp */; };
DE17336E0B068DC20080B521 /* DeclSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE17336D0B068DC20080B521 /* DeclSpec.cpp */; };
DE1733700B068DC60080B521 /* DeclSpec.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE17336F0B068DC60080B521 /* DeclSpec.h */; };
DE1F22030A7D852A00FBF588 /* Parser.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE1F22020A7D852A00FBF588 /* Parser.h */; };
DE224FF80C7AA98800D370A5 /* CGExprComplex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE224FF70C7AA98800D370A5 /* CGExprComplex.cpp */; };
DE2252700C7E82D000D370A5 /* CGExprScalar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE22526F0C7E82D000D370A5 /* CGExprScalar.cpp */; };
DE2255FC0C8004E600D370A5 /* ParseDeclCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE2255FB0C8004E600D370A5 /* ParseDeclCXX.cpp */; };
DE344AB80AE5DF6D00DBC861 /* HeaderSearch.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE344AB70AE5DF6D00DBC861 /* HeaderSearch.h */; };
DE344B540AE5E46C00DBC861 /* HeaderSearch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */; };
DE3450D70AEB543100DBC861 /* DirectoryLookup.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3450D60AEB543100DBC861 /* DirectoryLookup.h */; };
DE3451580AEC176100DBC861 /* MacroExpander.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3451570AEC176100DBC861 /* MacroExpander.cpp */; };
DE3452410AEF1A2D00DBC861 /* Stmt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3452400AEF1A2D00DBC861 /* Stmt.cpp */; };
DE3452810AEF1B1800DBC861 /* Stmt.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3452800AEF1B1800DBC861 /* Stmt.h */; };
DE345C1A0AFC658B00DBC861 /* StmtVisitor.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE345C190AFC658B00DBC861 /* StmtVisitor.h */; };
DE345F220AFD347900DBC861 /* StmtNodes.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE345F210AFD347900DBC861 /* StmtNodes.def */; };
DE3460000AFDCC1900DBC861 /* ParseObjc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE345FFF0AFDCC1900DBC861 /* ParseObjc.cpp */; };
DE3460050AFDCC6500DBC861 /* ParseInit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3460040AFDCC6500DBC861 /* ParseInit.cpp */; };
DE34600B0AFDCCBF00DBC861 /* ParseStmt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE34600A0AFDCCBF00DBC861 /* ParseStmt.cpp */; };
DE34600F0AFDCCCE00DBC861 /* ParseDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE34600E0AFDCCCE00DBC861 /* ParseDecl.cpp */; };
DE3460130AFDCCDA00DBC861 /* ParseExpr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3460120AFDCCDA00DBC861 /* ParseExpr.cpp */; };
DE3461270AFE68BE00DBC861 /* MinimalAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE3461260AFE68BE00DBC861 /* MinimalAction.cpp */; };
DE34621D0AFEB19B00DBC861 /* StmtPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE34621C0AFEB19B00DBC861 /* StmtPrinter.cpp */; };
DE3464220B03040900DBC861 /* Type.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3464210B03040900DBC861 /* Type.h */; };
DE4264FC0C113592005A861D /* CGDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE4264FB0C113592005A861D /* CGDecl.cpp */; };
DE46BF280AE0A82D00CC047C /* TargetInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE46BF270AE0A82D00CC047C /* TargetInfo.h */; };
DE4772FA0C10EAE5002239E8 /* CGStmt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE4772F90C10EAE5002239E8 /* CGStmt.cpp */; };
DE4772FC0C10EAEC002239E8 /* CGExpr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE4772FB0C10EAEC002239E8 /* CGExpr.cpp */; };
DE5932D10AD60FF400BC794C /* clang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE5932CD0AD60FF400BC794C /* clang.cpp */; };
DE5932D20AD60FF400BC794C /* clang.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE5932CE0AD60FF400BC794C /* clang.h */; };
DE5932D30AD60FF400BC794C /* PrintParserCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE5932CF0AD60FF400BC794C /* PrintParserCallbacks.cpp */; };
DE5932D40AD60FF400BC794C /* PrintPreprocessedOutput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE5932D00AD60FF400BC794C /* PrintPreprocessedOutput.cpp */; };
DE67E70B0C020EC500F66BC5 /* SemaType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE67E70A0C020EC500F66BC5 /* SemaType.cpp */; };
DE67E70D0C020ECA00F66BC5 /* SemaStmt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE67E70C0C020ECA00F66BC5 /* SemaStmt.cpp */; };
DE67E70F0C020ECF00F66BC5 /* SemaExprCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE67E70E0C020ECF00F66BC5 /* SemaExprCXX.cpp */; };
DE67E7110C020ED400F66BC5 /* SemaExpr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE67E7100C020ED400F66BC5 /* SemaExpr.cpp */; };
DE67E7130C020ED900F66BC5 /* SemaDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE67E7120C020ED900F66BC5 /* SemaDecl.cpp */; };
DE67E7150C020EDF00F66BC5 /* Sema.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE67E7140C020EDF00F66BC5 /* Sema.h */; };
DE67E7170C020EE400F66BC5 /* Sema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE67E7160C020EE400F66BC5 /* Sema.cpp */; };
DE67E71A0C020F4F00F66BC5 /* ASTStreamer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE67E7190C020F4F00F66BC5 /* ASTStreamer.cpp */; };
DE67E7280C02109800F66BC5 /* ASTStreamer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE67E7270C02109800F66BC5 /* ASTStreamer.h */; };
DE6951C70C4D1F5D00A5826B /* RecordLayout.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE6951C60C4D1F5D00A5826B /* RecordLayout.h */; };
DE6954640C5121BD00A5826B /* Token.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE6954630C5121BD00A5826B /* Token.h */; };
DE75ED290B044DC90020CF81 /* ASTContext.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE75ED280B044DC90020CF81 /* ASTContext.h */; };
DE75EDF10B06880E0020CF81 /* Type.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE75EDF00B06880E0020CF81 /* Type.cpp */; };
DE927FFD0C055DE900231DA4 /* LLVMCodegen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE927FFC0C055DE900231DA4 /* LLVMCodegen.cpp */; };
DE928B130C05659200231DA4 /* ModuleBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE928B120C05659200231DA4 /* ModuleBuilder.cpp */; };
DE928B200C0565B000231DA4 /* ModuleBuilder.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE928B1F0C0565B000231DA4 /* ModuleBuilder.h */; };
DE928B7D0C0A615100231DA4 /* CodeGenModule.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE928B7C0C0A615100231DA4 /* CodeGenModule.h */; };
DE928B7F0C0A615600231DA4 /* CodeGenModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE928B7E0C0A615600231DA4 /* CodeGenModule.cpp */; };
DE928B810C0A615B00231DA4 /* CodeGenFunction.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE928B800C0A615B00231DA4 /* CodeGenFunction.h */; };
DE928B830C0A616000231DA4 /* CodeGenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE928B820C0A616000231DA4 /* CodeGenFunction.cpp */; };
DEAEE98B0A5A2B970045101B /* MultipleIncludeOpt.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEAEE98A0A5A2B970045101B /* MultipleIncludeOpt.h */; };
DEAEED4B0A5AF89A0045101B /* NOTES.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEAEED4A0A5AF89A0045101B /* NOTES.txt */; };
DEB0AEB90C2087A700718A22 /* TextDiagnostics.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEB0AEB80C2087A700718A22 /* TextDiagnostics.h */; };
DEB0AEBB0C2087AB00718A22 /* TextDiagnostics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEB0AEBA0C2087AB00718A22 /* TextDiagnostics.cpp */; };
DEC63B1A0C7B940200DBF169 /* CFG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEC63B190C7B940200DBF169 /* CFG.cpp */; };
DEC63B1C0C7B940600DBF169 /* CFG.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC63B1B0C7B940600DBF169 /* CFG.h */; };
DEC82DC40C32D50A00BAC245 /* DiagChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEC82DC30C32D50A00BAC245 /* DiagChecker.cpp */; };
DEC8D9910A9433CD00353FCA /* Decl.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC8D9900A9433CD00353FCA /* Decl.h */; };
DEC8D9A40A94346E00353FCA /* AST.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC8D9A30A94346E00353FCA /* AST.h */; };
DED626C90AE0C065001E80A4 /* TargetInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED626C80AE0C065001E80A4 /* TargetInfo.cpp */; };
DED627030AE0C51D001E80A4 /* Targets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED627020AE0C51D001E80A4 /* Targets.cpp */; };
DED62ABB0AE2EDF1001E80A4 /* Decl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED62ABA0AE2EDF1001E80A4 /* Decl.cpp */; };
DED676D10B6C786700AAD4A3 /* Builtins.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED676D00B6C786700AAD4A3 /* Builtins.def */; };
DED676FA0B6C797B00AAD4A3 /* Builtins.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED676F90B6C797B00AAD4A3 /* Builtins.h */; };
DED677C90B6C854100AAD4A3 /* Builtins.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED677C80B6C854100AAD4A3 /* Builtins.cpp */; };
DED67AEE0B6DB92A00AAD4A3 /* X86Builtins.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED67AED0B6DB92A00AAD4A3 /* X86Builtins.def */; };
DED67AF00B6DB92F00AAD4A3 /* PPCBuiltins.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED67AEF0B6DB92F00AAD4A3 /* PPCBuiltins.def */; };
DED7D7410A524295003AD0FB /* Diagnostic.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7310A524295003AD0FB /* Diagnostic.h */; };
DED7D7420A524295003AD0FB /* DiagnosticKinds.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7320A524295003AD0FB /* DiagnosticKinds.def */; };
DED7D7430A524295003AD0FB /* FileManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7330A524295003AD0FB /* FileManager.h */; };
DED7D7450A524295003AD0FB /* SourceLocation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7350A524295003AD0FB /* SourceLocation.h */; };
DED7D7460A524295003AD0FB /* SourceManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7360A524295003AD0FB /* SourceManager.h */; };
DED7D7470A524295003AD0FB /* TokenKinds.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7370A524295003AD0FB /* TokenKinds.def */; };
DED7D7480A524295003AD0FB /* TokenKinds.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7380A524295003AD0FB /* TokenKinds.h */; };
DED7D7490A524295003AD0FB /* IdentifierTable.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73A0A524295003AD0FB /* IdentifierTable.h */; };
DED7D74A0A524295003AD0FB /* Lexer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73B0A524295003AD0FB /* Lexer.h */; };
DED7D74C0A524295003AD0FB /* MacroExpander.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73D0A524295003AD0FB /* MacroExpander.h */; };
DED7D74D0A524295003AD0FB /* MacroInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73E0A524295003AD0FB /* MacroInfo.h */; };
DED7D74E0A524295003AD0FB /* Pragma.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D73F0A524295003AD0FB /* Pragma.h */; };
DED7D74F0A524295003AD0FB /* Preprocessor.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7400A524295003AD0FB /* Preprocessor.h */; };
DED7D77A0A5242C7003AD0FB /* Diagnostic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D75D0A5242C7003AD0FB /* Diagnostic.cpp */; };
DED7D77B0A5242C7003AD0FB /* FileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D75E0A5242C7003AD0FB /* FileManager.cpp */; };
DED7D7890A5242C7003AD0FB /* SourceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D76D0A5242C7003AD0FB /* SourceManager.cpp */; };
DED7D78A0A5242C7003AD0FB /* TokenKinds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D76E0A5242C7003AD0FB /* TokenKinds.cpp */; };
DED7D7C20A5242E6003AD0FB /* IdentifierTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D79D0A5242E6003AD0FB /* IdentifierTable.cpp */; };
DED7D7C30A5242E6003AD0FB /* Lexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D79E0A5242E6003AD0FB /* Lexer.cpp */; };
DED7D7C50A5242E6003AD0FB /* MacroInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D7A00A5242E6003AD0FB /* MacroInfo.cpp */; };
DED7D7C70A5242E6003AD0FB /* PPExpressions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D7A20A5242E6003AD0FB /* PPExpressions.cpp */; };
DED7D7C80A5242E6003AD0FB /* Pragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D7A30A5242E6003AD0FB /* Pragma.cpp */; };
DED7D7C90A5242E6003AD0FB /* Preprocessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D7A40A5242E6003AD0FB /* Preprocessor.cpp */; };
DED7D7D80A524302003AD0FB /* README.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7D70A524302003AD0FB /* README.txt */; };
DED7D9180A52518C003AD0FB /* ScratchBuffer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D9170A52518C003AD0FB /* ScratchBuffer.h */; };
DED7D9E50A5257F6003AD0FB /* ScratchBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D9E40A5257F6003AD0FB /* ScratchBuffer.cpp */; };
DEEBBD440C19C5D200A9FE82 /* TODO.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEEBBD430C19C5D200A9FE82 /* TODO.txt */; };
DEEBC3BA0C2363B800A9FE82 /* CodeGenTypes.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEEBC3B90C2363B800A9FE82 /* CodeGenTypes.h */; };
DEEBC3BC0C2363BC00A9FE82 /* CodeGenTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEEBC3BB0C2363BC00A9FE82 /* CodeGenTypes.cpp */; };
DEEBCBE30C33702C00A9FE82 /* TextDiagnosticBuffer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEEBCBE20C33702C00A9FE82 /* TextDiagnosticBuffer.h */; };
DEEBCBE50C33703100A9FE82 /* TextDiagnosticBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEEBCBE40C33703100A9FE82 /* TextDiagnosticBuffer.cpp */; };
DEF2E9320C5FB9FB000C4259 /* ASTStreamers.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEF2E9310C5FB9FB000C4259 /* ASTStreamers.h */; };
DEF2E9340C5FBA02000C4259 /* ASTStreamers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEF2E9330C5FBA02000C4259 /* ASTStreamers.cpp */; };
DEF2E95F0C5FBD74000C4259 /* InternalsManual.html in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEF2E95E0C5FBD74000C4259 /* InternalsManual.html */; };
DEF2EDA70C6A4252000C4259 /* StmtDumper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEF2EDA60C6A4252000C4259 /* StmtDumper.cpp */; };
DEF2EFF30C6CDD74000C4259 /* CGExprAgg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEF2EFF20C6CDD74000C4259 /* CGExprAgg.cpp */; };
DEF2F0100C6CFED5000C4259 /* SemaChecking.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEF2F00F0C6CFED5000C4259 /* SemaChecking.cpp */; };
F0226FD20C18084500141F42 /* TextDiagnosticPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F0226FD00C18084500141F42 /* TextDiagnosticPrinter.cpp */; };
F0226FD30C18084500141F42 /* TextDiagnosticPrinter.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F0226FD10C18084500141F42 /* TextDiagnosticPrinter.h */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
8DD76F690486A84900D96B5E /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 8;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
DED7D7410A524295003AD0FB /* Diagnostic.h in CopyFiles */,
DED7D7420A524295003AD0FB /* DiagnosticKinds.def in CopyFiles */,
DED7D7430A524295003AD0FB /* FileManager.h in CopyFiles */,
DED7D7450A524295003AD0FB /* SourceLocation.h in CopyFiles */,
DED7D7460A524295003AD0FB /* SourceManager.h in CopyFiles */,
DED7D7470A524295003AD0FB /* TokenKinds.def in CopyFiles */,
DED7D7480A524295003AD0FB /* TokenKinds.h in CopyFiles */,
DED7D7490A524295003AD0FB /* IdentifierTable.h in CopyFiles */,
DED7D74A0A524295003AD0FB /* Lexer.h in CopyFiles */,
DED7D74C0A524295003AD0FB /* MacroExpander.h in CopyFiles */,
DED7D74D0A524295003AD0FB /* MacroInfo.h in CopyFiles */,
DED7D74E0A524295003AD0FB /* Pragma.h in CopyFiles */,
DED7D74F0A524295003AD0FB /* Preprocessor.h in CopyFiles */,
DED7D7D80A524302003AD0FB /* README.txt in CopyFiles */,
DED7D9180A52518C003AD0FB /* ScratchBuffer.h in CopyFiles */,
DEAEE98B0A5A2B970045101B /* MultipleIncludeOpt.h in CopyFiles */,
DEAEED4B0A5AF89A0045101B /* NOTES.txt in CopyFiles */,
DE1F22030A7D852A00FBF588 /* Parser.h in CopyFiles */,
DE06B73E0A8307640050E87E /* LangOptions.h in CopyFiles */,
DE06BECB0A854E4B0050E87E /* Scope.h in CopyFiles */,
DE06E8140A8FF9330050E87E /* Action.h in CopyFiles */,
DEC8D9910A9433CD00353FCA /* Decl.h in CopyFiles */,
DEC8D9A40A94346E00353FCA /* AST.h in CopyFiles */,
DE0FCA630A95859D00248FD5 /* Expr.h in CopyFiles */,
DE5932D20AD60FF400BC794C /* clang.h in CopyFiles */,
DE46BF280AE0A82D00CC047C /* TargetInfo.h in CopyFiles */,
DE344AB80AE5DF6D00DBC861 /* HeaderSearch.h in CopyFiles */,
DE3450D70AEB543100DBC861 /* DirectoryLookup.h in CopyFiles */,
DE3452810AEF1B1800DBC861 /* Stmt.h in CopyFiles */,
DE345C1A0AFC658B00DBC861 /* StmtVisitor.h in CopyFiles */,
DE345F220AFD347900DBC861 /* StmtNodes.def in CopyFiles */,
DE3464220B03040900DBC861 /* Type.h in CopyFiles */,
DE75ED290B044DC90020CF81 /* ASTContext.h in CopyFiles */,
DE1733700B068DC60080B521 /* DeclSpec.h in CopyFiles */,
DE01DA490B12ADA300AC22CE /* PPCallbacks.h in CopyFiles */,
DED676D10B6C786700AAD4A3 /* Builtins.def in CopyFiles */,
DED676FA0B6C797B00AAD4A3 /* Builtins.h in CopyFiles */,
DED67AEE0B6DB92A00AAD4A3 /* X86Builtins.def in CopyFiles */,
DED67AF00B6DB92F00AAD4A3 /* PPCBuiltins.def in CopyFiles */,
1A30A9E90B93A4C800201A91 /* ExprCXX.h in CopyFiles */,
1A869A700BA2164C008DA07A /* LiteralSupport.h in CopyFiles */,
DE67E7150C020EDF00F66BC5 /* Sema.h in CopyFiles */,
DE67E7280C02109800F66BC5 /* ASTStreamer.h in CopyFiles */,
DE928B200C0565B000231DA4 /* ModuleBuilder.h in CopyFiles */,
DE928B7D0C0A615100231DA4 /* CodeGenModule.h in CopyFiles */,
DE928B810C0A615B00231DA4 /* CodeGenFunction.h in CopyFiles */,
F0226FD30C18084500141F42 /* TextDiagnosticPrinter.h in CopyFiles */,
DEEBBD440C19C5D200A9FE82 /* TODO.txt in CopyFiles */,
84D9A88C0C1A581300AC7ABC /* AttributeList.h in CopyFiles */,
DEB0AEB90C2087A700718A22 /* TextDiagnostics.h in CopyFiles */,
DEEBC3BA0C2363B800A9FE82 /* CodeGenTypes.h in CopyFiles */,
DEEBCBE30C33702C00A9FE82 /* TextDiagnosticBuffer.h in CopyFiles */,
DE6951C70C4D1F5D00A5826B /* RecordLayout.h in CopyFiles */,
DE6954640C5121BD00A5826B /* Token.h in CopyFiles */,
DEF2E9320C5FB9FB000C4259 /* ASTStreamers.h in CopyFiles */,
DEF2E95F0C5FBD74000C4259 /* InternalsManual.html in CopyFiles */,
DEC63B1C0C7B940600DBF169 /* CFG.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1A30A9E80B93A4C800201A91 /* ExprCXX.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ExprCXX.h; path = clang/AST/ExprCXX.h; sourceTree = "<group>"; };
1A7342470C7B57D500122F56 /* CGObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CGObjC.cpp; path = CodeGen/CGObjC.cpp; sourceTree = "<group>"; };
1A869A6E0BA2164C008DA07A /* LiteralSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiteralSupport.h; sourceTree = "<group>"; };
1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = "<group>"; };
1ABC36930C7A4BDC006DB0AB /* CGBuiltin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CGBuiltin.cpp; path = CodeGen/CGBuiltin.cpp; sourceTree = "<group>"; };
3523B4D30C985C53001D6CC3 /* CFGStmtVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFGStmtVisitor.h; path = clang/Analysis/CFGStmtVisitor.h; sourceTree = "<group>"; };
3523B4D50C985DAE001D6CC3 /* DataflowStmtVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataflowStmtVisitor.h; path = clang/Analysis/DataflowStmtVisitor.h; sourceTree = "<group>"; };
35260CA40C7F75C000D66CE9 /* ExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExprCXX.cpp; path = AST/ExprCXX.cpp; sourceTree = "<group>"; };
3547129D0C88881300B3E1D5 /* PrettyPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PrettyPrinter.h; path = clang/AST/PrettyPrinter.h; sourceTree = "<group>"; };
355CF6820C90A8B600A08AA3 /* LocalCheckers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LocalCheckers.h; path = clang/Analysis/LocalCheckers.h; sourceTree = "<group>"; };
355CF6830C90A8D400A08AA3 /* DeadStores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DeadStores.cpp; path = Analysis/DeadStores.cpp; sourceTree = "<group>"; };
356EF9B20C8F7DBA006650F5 /* LiveVariables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LiveVariables.h; path = clang/Analysis/LiveVariables.h; sourceTree = "<group>"; };
356EF9B40C8F7DDF006650F5 /* LiveVariables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LiveVariables.cpp; path = Analysis/LiveVariables.cpp; sourceTree = "<group>"; };
84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = Parse/AttributeList.cpp; sourceTree = "<group>"; };
84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = "<group>"; };
8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = "<group>"; };
DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = "<group>"; };
DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };
DE06BECA0A854E4B0050E87E /* Scope.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Scope.h; path = clang/Parse/Scope.h; sourceTree = "<group>"; };
DE06D42F0A8BB52D0050E87E /* Parser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Parser.cpp; path = Parse/Parser.cpp; sourceTree = "<group>"; };
DE06E8130A8FF9330050E87E /* Action.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Action.h; path = clang/Parse/Action.h; sourceTree = "<group>"; };
DE0FCA620A95859D00248FD5 /* Expr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Expr.h; path = clang/AST/Expr.h; sourceTree = "<group>"; };
DE0FCB330A9C21F100248FD5 /* Expr.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Expr.cpp; path = AST/Expr.cpp; sourceTree = "<group>"; };
DE1732FF0B068B700080B521 /* ASTContext.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ASTContext.cpp; path = AST/ASTContext.cpp; sourceTree = "<group>"; };
DE17336D0B068DC20080B521 /* DeclSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = DeclSpec.cpp; path = Parse/DeclSpec.cpp; sourceTree = "<group>"; };
DE17336F0B068DC60080B521 /* DeclSpec.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = DeclSpec.h; path = clang/Parse/DeclSpec.h; sourceTree = "<group>"; };
DE1F22020A7D852A00FBF588 /* Parser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Parser.h; path = clang/Parse/Parser.h; sourceTree = "<group>"; };
DE224FF70C7AA98800D370A5 /* CGExprComplex.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGExprComplex.cpp; path = CodeGen/CGExprComplex.cpp; sourceTree = "<group>"; };
DE22526F0C7E82D000D370A5 /* CGExprScalar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGExprScalar.cpp; path = CodeGen/CGExprScalar.cpp; sourceTree = "<group>"; };
DE2255FB0C8004E600D370A5 /* ParseDeclCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseDeclCXX.cpp; path = Parse/ParseDeclCXX.cpp; sourceTree = "<group>"; };
DE344AB70AE5DF6D00DBC861 /* HeaderSearch.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HeaderSearch.h; sourceTree = "<group>"; };
DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HeaderSearch.cpp; sourceTree = "<group>"; };
DE3450D60AEB543100DBC861 /* DirectoryLookup.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DirectoryLookup.h; sourceTree = "<group>"; };
DE3451570AEC176100DBC861 /* MacroExpander.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MacroExpander.cpp; sourceTree = "<group>"; };
DE3452400AEF1A2D00DBC861 /* Stmt.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Stmt.cpp; path = AST/Stmt.cpp; sourceTree = "<group>"; };
DE3452800AEF1B1800DBC861 /* Stmt.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Stmt.h; path = clang/AST/Stmt.h; sourceTree = "<group>"; };
DE345C190AFC658B00DBC861 /* StmtVisitor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = StmtVisitor.h; path = clang/AST/StmtVisitor.h; sourceTree = "<group>"; };
DE345F210AFD347900DBC861 /* StmtNodes.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = StmtNodes.def; path = clang/AST/StmtNodes.def; sourceTree = "<group>"; };
DE345FFF0AFDCC1900DBC861 /* ParseObjc.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseObjc.cpp; path = Parse/ParseObjc.cpp; sourceTree = "<group>"; };
DE3460040AFDCC6500DBC861 /* ParseInit.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseInit.cpp; path = Parse/ParseInit.cpp; sourceTree = "<group>"; };
DE34600A0AFDCCBF00DBC861 /* ParseStmt.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseStmt.cpp; path = Parse/ParseStmt.cpp; sourceTree = "<group>"; };
DE34600E0AFDCCCE00DBC861 /* ParseDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseDecl.cpp; path = Parse/ParseDecl.cpp; sourceTree = "<group>"; };
DE3460120AFDCCDA00DBC861 /* ParseExpr.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExpr.cpp; path = Parse/ParseExpr.cpp; sourceTree = "<group>"; };
DE3461260AFE68BE00DBC861 /* MinimalAction.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = MinimalAction.cpp; path = Parse/MinimalAction.cpp; sourceTree = "<group>"; };
DE34621C0AFEB19B00DBC861 /* StmtPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = StmtPrinter.cpp; path = AST/StmtPrinter.cpp; sourceTree = "<group>"; };
DE3464210B03040900DBC861 /* Type.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Type.h; path = clang/AST/Type.h; sourceTree = "<group>"; };
DE4264FB0C113592005A861D /* CGDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGDecl.cpp; path = CodeGen/CGDecl.cpp; sourceTree = "<group>"; };
DE46BF270AE0A82D00CC047C /* TargetInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TargetInfo.h; sourceTree = "<group>"; };
DE4772F90C10EAE5002239E8 /* CGStmt.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGStmt.cpp; path = CodeGen/CGStmt.cpp; sourceTree = "<group>"; };
DE4772FB0C10EAEC002239E8 /* CGExpr.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGExpr.cpp; path = CodeGen/CGExpr.cpp; sourceTree = "<group>"; };
DE5932CD0AD60FF400BC794C /* clang.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = clang.cpp; path = Driver/clang.cpp; sourceTree = "<group>"; };
DE5932CE0AD60FF400BC794C /* clang.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = clang.h; path = Driver/clang.h; sourceTree = "<group>"; };
DE5932CF0AD60FF400BC794C /* PrintParserCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = PrintParserCallbacks.cpp; path = Driver/PrintParserCallbacks.cpp; sourceTree = "<group>"; };
DE5932D00AD60FF400BC794C /* PrintPreprocessedOutput.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = PrintPreprocessedOutput.cpp; path = Driver/PrintPreprocessedOutput.cpp; sourceTree = "<group>"; };
DE67E70A0C020EC500F66BC5 /* SemaType.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = SemaType.cpp; path = Sema/SemaType.cpp; sourceTree = "<group>"; };
DE67E70C0C020ECA00F66BC5 /* SemaStmt.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = SemaStmt.cpp; path = Sema/SemaStmt.cpp; sourceTree = "<group>"; };
DE67E70E0C020ECF00F66BC5 /* SemaExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = SemaExprCXX.cpp; path = Sema/SemaExprCXX.cpp; sourceTree = "<group>"; };
DE67E7100C020ED400F66BC5 /* SemaExpr.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = SemaExpr.cpp; path = Sema/SemaExpr.cpp; sourceTree = "<group>"; };
DE67E7120C020ED900F66BC5 /* SemaDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = SemaDecl.cpp; path = Sema/SemaDecl.cpp; sourceTree = "<group>"; };
DE67E7140C020EDF00F66BC5 /* Sema.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Sema.h; path = Sema/Sema.h; sourceTree = "<group>"; };
DE67E7160C020EE400F66BC5 /* Sema.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Sema.cpp; path = Sema/Sema.cpp; sourceTree = "<group>"; };
DE67E7190C020F4F00F66BC5 /* ASTStreamer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ASTStreamer.cpp; path = Sema/ASTStreamer.cpp; sourceTree = "<group>"; };
DE67E7270C02109800F66BC5 /* ASTStreamer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTStreamer.h; path = clang/Sema/ASTStreamer.h; sourceTree = "<group>"; };
DE6951C60C4D1F5D00A5826B /* RecordLayout.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = RecordLayout.h; path = clang/AST/RecordLayout.h; sourceTree = "<group>"; };
DE6954630C5121BD00A5826B /* Token.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Token.h; sourceTree = "<group>"; };
DE75ED280B044DC90020CF81 /* ASTContext.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTContext.h; path = clang/AST/ASTContext.h; sourceTree = "<group>"; };
DE75EDF00B06880E0020CF81 /* Type.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Type.cpp; path = AST/Type.cpp; sourceTree = "<group>"; };
DE927FFC0C055DE900231DA4 /* LLVMCodegen.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = LLVMCodegen.cpp; path = Driver/LLVMCodegen.cpp; sourceTree = "<group>"; };
DE928B120C05659200231DA4 /* ModuleBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleBuilder.cpp; path = CodeGen/ModuleBuilder.cpp; sourceTree = "<group>"; };
DE928B1F0C0565B000231DA4 /* ModuleBuilder.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ModuleBuilder.h; path = clang/CodeGen/ModuleBuilder.h; sourceTree = "<group>"; };
DE928B7C0C0A615100231DA4 /* CodeGenModule.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CodeGenModule.h; path = CodeGen/CodeGenModule.h; sourceTree = "<group>"; };
DE928B7E0C0A615600231DA4 /* CodeGenModule.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CodeGenModule.cpp; path = CodeGen/CodeGenModule.cpp; sourceTree = "<group>"; };
DE928B800C0A615B00231DA4 /* CodeGenFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CodeGenFunction.h; path = CodeGen/CodeGenFunction.h; sourceTree = "<group>"; };
DE928B820C0A616000231DA4 /* CodeGenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CodeGenFunction.cpp; path = CodeGen/CodeGenFunction.cpp; sourceTree = "<group>"; };
DEAEE98A0A5A2B970045101B /* MultipleIncludeOpt.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MultipleIncludeOpt.h; sourceTree = "<group>"; };
DEAEED4A0A5AF89A0045101B /* NOTES.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = NOTES.txt; sourceTree = "<group>"; };
DEB0AEB80C2087A700718A22 /* TextDiagnostics.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TextDiagnostics.h; path = Driver/TextDiagnostics.h; sourceTree = "<group>"; };
DEB0AEBA0C2087AB00718A22 /* TextDiagnostics.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = TextDiagnostics.cpp; path = Driver/TextDiagnostics.cpp; sourceTree = "<group>"; };
DEC63B190C7B940200DBF169 /* CFG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CFG.cpp; path = AST/CFG.cpp; sourceTree = "<group>"; };
DEC63B1B0C7B940600DBF169 /* CFG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CFG.h; path = clang/AST/CFG.h; sourceTree = "<group>"; };
DEC82DC30C32D50A00BAC245 /* DiagChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = DiagChecker.cpp; path = Driver/DiagChecker.cpp; sourceTree = "<group>"; };
DEC8D9900A9433CD00353FCA /* Decl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Decl.h; path = clang/AST/Decl.h; sourceTree = "<group>"; };
DEC8D9A30A94346E00353FCA /* AST.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AST.h; path = clang/AST/AST.h; sourceTree = "<group>"; };
DED626C80AE0C065001E80A4 /* TargetInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TargetInfo.cpp; sourceTree = "<group>"; };
DED627020AE0C51D001E80A4 /* Targets.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Targets.cpp; path = Driver/Targets.cpp; sourceTree = "<group>"; };
DED62ABA0AE2EDF1001E80A4 /* Decl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Decl.cpp; path = AST/Decl.cpp; sourceTree = "<group>"; usesTabs = 1; };
DED676D00B6C786700AAD4A3 /* Builtins.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = Builtins.def; path = clang/AST/Builtins.def; sourceTree = "<group>"; };
DED676F90B6C797B00AAD4A3 /* Builtins.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Builtins.h; path = clang/AST/Builtins.h; sourceTree = "<group>"; };
DED677C80B6C854100AAD4A3 /* Builtins.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Builtins.cpp; path = AST/Builtins.cpp; sourceTree = "<group>"; };
DED67AED0B6DB92A00AAD4A3 /* X86Builtins.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = X86Builtins.def; path = Driver/X86Builtins.def; sourceTree = "<group>"; };
DED67AEF0B6DB92F00AAD4A3 /* PPCBuiltins.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = PPCBuiltins.def; path = Driver/PPCBuiltins.def; sourceTree = "<group>"; };
DED7D7310A524295003AD0FB /* Diagnostic.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Diagnostic.h; sourceTree = "<group>"; };
DED7D7320A524295003AD0FB /* DiagnosticKinds.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = DiagnosticKinds.def; sourceTree = "<group>"; };
DED7D7330A524295003AD0FB /* FileManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileManager.h; sourceTree = "<group>"; };
DED7D7350A524295003AD0FB /* SourceLocation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SourceLocation.h; sourceTree = "<group>"; };
DED7D7360A524295003AD0FB /* SourceManager.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SourceManager.h; sourceTree = "<group>"; };
DED7D7370A524295003AD0FB /* TokenKinds.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = TokenKinds.def; sourceTree = "<group>"; };
DED7D7380A524295003AD0FB /* TokenKinds.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TokenKinds.h; sourceTree = "<group>"; };
DED7D73A0A524295003AD0FB /* IdentifierTable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IdentifierTable.h; sourceTree = "<group>"; };
DED7D73B0A524295003AD0FB /* Lexer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Lexer.h; sourceTree = "<group>"; };
DED7D73D0A524295003AD0FB /* MacroExpander.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MacroExpander.h; sourceTree = "<group>"; };
DED7D73E0A524295003AD0FB /* MacroInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MacroInfo.h; sourceTree = "<group>"; };
DED7D73F0A524295003AD0FB /* Pragma.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Pragma.h; sourceTree = "<group>"; };
DED7D7400A524295003AD0FB /* Preprocessor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Preprocessor.h; sourceTree = "<group>"; };
DED7D75D0A5242C7003AD0FB /* Diagnostic.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Diagnostic.cpp; sourceTree = "<group>"; };
DED7D75E0A5242C7003AD0FB /* FileManager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FileManager.cpp; sourceTree = "<group>"; };
DED7D76D0A5242C7003AD0FB /* SourceManager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SourceManager.cpp; sourceTree = "<group>"; };
DED7D76E0A5242C7003AD0FB /* TokenKinds.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TokenKinds.cpp; sourceTree = "<group>"; };
DED7D79D0A5242E6003AD0FB /* IdentifierTable.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IdentifierTable.cpp; sourceTree = "<group>"; };
DED7D79E0A5242E6003AD0FB /* Lexer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Lexer.cpp; sourceTree = "<group>"; };
DED7D7A00A5242E6003AD0FB /* MacroInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MacroInfo.cpp; sourceTree = "<group>"; };
DED7D7A20A5242E6003AD0FB /* PPExpressions.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PPExpressions.cpp; sourceTree = "<group>"; };
DED7D7A30A5242E6003AD0FB /* Pragma.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Pragma.cpp; sourceTree = "<group>"; };
DED7D7A40A5242E6003AD0FB /* Preprocessor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Preprocessor.cpp; sourceTree = "<group>"; };
DED7D7D70A524302003AD0FB /* README.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = README.txt; sourceTree = "<group>"; };
DED7D9170A52518C003AD0FB /* ScratchBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ScratchBuffer.h; sourceTree = "<group>"; };
DED7D9E40A5257F6003AD0FB /* ScratchBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ScratchBuffer.cpp; sourceTree = "<group>"; };
DEEBBD430C19C5D200A9FE82 /* TODO.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = TODO.txt; sourceTree = "<group>"; };
DEEBC3B90C2363B800A9FE82 /* CodeGenTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CodeGenTypes.h; path = CodeGen/CodeGenTypes.h; sourceTree = "<group>"; };
DEEBC3BB0C2363BC00A9FE82 /* CodeGenTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CodeGenTypes.cpp; path = CodeGen/CodeGenTypes.cpp; sourceTree = "<group>"; };
DEEBCBE20C33702C00A9FE82 /* TextDiagnosticBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TextDiagnosticBuffer.h; path = Driver/TextDiagnosticBuffer.h; sourceTree = "<group>"; };
DEEBCBE40C33703100A9FE82 /* TextDiagnosticBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = TextDiagnosticBuffer.cpp; path = Driver/TextDiagnosticBuffer.cpp; sourceTree = "<group>"; };
DEF2E9310C5FB9FB000C4259 /* ASTStreamers.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTStreamers.h; path = Driver/ASTStreamers.h; sourceTree = "<group>"; };
DEF2E9330C5FBA02000C4259 /* ASTStreamers.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ASTStreamers.cpp; path = Driver/ASTStreamers.cpp; sourceTree = "<group>"; };
DEF2E95E0C5FBD74000C4259 /* InternalsManual.html */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.html; name = InternalsManual.html; path = docs/InternalsManual.html; sourceTree = "<group>"; };
DEF2EDA60C6A4252000C4259 /* StmtDumper.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = StmtDumper.cpp; path = AST/StmtDumper.cpp; sourceTree = "<group>"; };
DEF2EFF20C6CDD74000C4259 /* CGExprAgg.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CGExprAgg.cpp; path = CodeGen/CGExprAgg.cpp; sourceTree = "<group>"; };
DEF2F00F0C6CFED5000C4259 /* SemaChecking.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = SemaChecking.cpp; path = Sema/SemaChecking.cpp; sourceTree = "<group>"; };
F0226FD00C18084500141F42 /* TextDiagnosticPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = TextDiagnosticPrinter.cpp; path = Driver/TextDiagnosticPrinter.cpp; sourceTree = "<group>"; };
F0226FD10C18084500141F42 /* TextDiagnosticPrinter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TextDiagnosticPrinter.h; path = Driver/TextDiagnosticPrinter.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8DD76F660486A84900D96B5E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
08FB7794FE84155DC02AAC07 /* clang */ = {
isa = PBXGroup;
children = (
DED7D72E0A524295003AD0FB /* include */,
08FB7795FE84155DC02AAC07 /* Source */,
DEAEECAE0A5AF0FA0045101B /* Driver */,
C6859E8C029090F304C91782 /* Documentation */,
1AB674ADFE9D54B511CA2CBB /* Products */,
);
name = clang;
sourceTree = "<group>";
};
08FB7795FE84155DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
DED7D7500A5242C7003AD0FB /* Basic */,
DED7D78C0A5242E6003AD0FB /* Lex */,
DE1F22600A7D8C9B00FBF588 /* Parse */,
DEC8D9920A9433F400353FCA /* AST */,
DE67E7070C020EAB00F66BC5 /* Sema */,
DE927FCC0C0557CD00231DA4 /* CodeGen */,
356EF9B30C8F7DCA006650F5 /* Analysis */,
);
name = Source;
sourceTree = "<group>";
};
1AB674ADFE9D54B511CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8DD76F6C0486A84900D96B5E /* clang */,
);
name = Products;
sourceTree = "<group>";
};
355CF6850C90A8D600A08AA3 /* LocalCheckers */ = {
isa = PBXGroup;
children = (
355CF6830C90A8D400A08AA3 /* DeadStores.cpp */,
);
name = LocalCheckers;
sourceTree = "<group>";
};
356EF9AF0C8F7DA4006650F5 /* Analysis */ = {
isa = PBXGroup;
children = (
3523B4D50C985DAE001D6CC3 /* DataflowStmtVisitor.h */,
3523B4D30C985C53001D6CC3 /* CFGStmtVisitor.h */,
355CF6820C90A8B600A08AA3 /* LocalCheckers.h */,
356EF9B20C8F7DBA006650F5 /* LiveVariables.h */,
);
name = Analysis;
sourceTree = "<group>";
};
356EF9B30C8F7DCA006650F5 /* Analysis */ = {
isa = PBXGroup;
children = (
356EF9B40C8F7DDF006650F5 /* LiveVariables.cpp */,
355CF6850C90A8D600A08AA3 /* LocalCheckers */,
);
name = Analysis;
sourceTree = "<group>";
};
C6859E8C029090F304C91782 /* Documentation */ = {
isa = PBXGroup;
children = (
DEAEED4A0A5AF89A0045101B /* NOTES.txt */,
DED7D7D70A524302003AD0FB /* README.txt */,
DEEBBD430C19C5D200A9FE82 /* TODO.txt */,
DEF2E95E0C5FBD74000C4259 /* InternalsManual.html */,
);
name = Documentation;
sourceTree = "<group>";
};
DE1F21F20A7D84E800FBF588 /* Parse */ = {
isa = PBXGroup;
children = (
84D9A88B0C1A581300AC7ABC /* AttributeList.h */,
DE06E8130A8FF9330050E87E /* Action.h */,
DE17336F0B068DC60080B521 /* DeclSpec.h */,
DE1F22020A7D852A00FBF588 /* Parser.h */,
DE06BECA0A854E4B0050E87E /* Scope.h */,
);
name = Parse;
sourceTree = "<group>";
};
DE1F22600A7D8C9B00FBF588 /* Parse */ = {
isa = PBXGroup;
children = (
84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */,
DE3461260AFE68BE00DBC861 /* MinimalAction.cpp */,
DE06D42F0A8BB52D0050E87E /* Parser.cpp */,
DE3460040AFDCC6500DBC861 /* ParseInit.cpp */,
DE34600E0AFDCCCE00DBC861 /* ParseDecl.cpp */,
DE2255FB0C8004E600D370A5 /* ParseDeclCXX.cpp */,
DE3460120AFDCCDA00DBC861 /* ParseExpr.cpp */,
DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */,
DE34600A0AFDCCBF00DBC861 /* ParseStmt.cpp */,
DE345FFF0AFDCC1900DBC861 /* ParseObjc.cpp */,
DE17336D0B068DC20080B521 /* DeclSpec.cpp */,
);
name = Parse;
sourceTree = "<group>";
};
DE67E7070C020EAB00F66BC5 /* Sema */ = {
isa = PBXGroup;
children = (
DE67E7190C020F4F00F66BC5 /* ASTStreamer.cpp */,
DE67E7140C020EDF00F66BC5 /* Sema.h */,
DE67E7160C020EE400F66BC5 /* Sema.cpp */,
DEF2F00F0C6CFED5000C4259 /* SemaChecking.cpp */,
DE67E7120C020ED900F66BC5 /* SemaDecl.cpp */,
DE67E7100C020ED400F66BC5 /* SemaExpr.cpp */,
DE67E70E0C020ECF00F66BC5 /* SemaExprCXX.cpp */,
DE67E70C0C020ECA00F66BC5 /* SemaStmt.cpp */,
DE67E70A0C020EC500F66BC5 /* SemaType.cpp */,
);
name = Sema;
sourceTree = "<group>";
};
DE67E7260C02108300F66BC5 /* Sema */ = {
isa = PBXGroup;
children = (
DE67E7270C02109800F66BC5 /* ASTStreamer.h */,
);
name = Sema;
sourceTree = "<group>";
};
DE927FCC0C0557CD00231DA4 /* CodeGen */ = {
isa = PBXGroup;
children = (
DE928B800C0A615B00231DA4 /* CodeGenFunction.h */,
DE928B820C0A616000231DA4 /* CodeGenFunction.cpp */,
DE928B7C0C0A615100231DA4 /* CodeGenModule.h */,
DE928B7E0C0A615600231DA4 /* CodeGenModule.cpp */,
DEEBC3BB0C2363BC00A9FE82 /* CodeGenTypes.cpp */,
DEEBC3B90C2363B800A9FE82 /* CodeGenTypes.h */,
1ABC36930C7A4BDC006DB0AB /* CGBuiltin.cpp */,
DE4264FB0C113592005A861D /* CGDecl.cpp */,
DE4772FB0C10EAEC002239E8 /* CGExpr.cpp */,
DEF2EFF20C6CDD74000C4259 /* CGExprAgg.cpp */,
DE224FF70C7AA98800D370A5 /* CGExprComplex.cpp */,
DE22526F0C7E82D000D370A5 /* CGExprScalar.cpp */,
1A7342470C7B57D500122F56 /* CGObjC.cpp */,
DE4772F90C10EAE5002239E8 /* CGStmt.cpp */,
DE928B120C05659200231DA4 /* ModuleBuilder.cpp */,
);
name = CodeGen;
sourceTree = "<group>";
};
DE928B140C05659A00231DA4 /* CodeGen */ = {
isa = PBXGroup;
children = (
DE928B1F0C0565B000231DA4 /* ModuleBuilder.h */,
);
name = CodeGen;
sourceTree = "<group>";
};
DEAEECAE0A5AF0FA0045101B /* Driver */ = {
isa = PBXGroup;
children = (
DE5932CD0AD60FF400BC794C /* clang.cpp */,
DE5932CE0AD60FF400BC794C /* clang.h */,
DEF2E9330C5FBA02000C4259 /* ASTStreamers.cpp */,
DEF2E9310C5FB9FB000C4259 /* ASTStreamers.h */,
DED67AEF0B6DB92F00AAD4A3 /* PPCBuiltins.def */,
DED67AED0B6DB92A00AAD4A3 /* X86Builtins.def */,
DEC82DC30C32D50A00BAC245 /* DiagChecker.cpp */,
DE927FFC0C055DE900231DA4 /* LLVMCodegen.cpp */,
DE5932CF0AD60FF400BC794C /* PrintParserCallbacks.cpp */,
DE5932D00AD60FF400BC794C /* PrintPreprocessedOutput.cpp */,
DED627020AE0C51D001E80A4 /* Targets.cpp */,
DEB0AEBA0C2087AB00718A22 /* TextDiagnostics.cpp */,
DEB0AEB80C2087A700718A22 /* TextDiagnostics.h */,
F0226FD00C18084500141F42 /* TextDiagnosticPrinter.cpp */,
F0226FD10C18084500141F42 /* TextDiagnosticPrinter.h */,
DEEBCBE40C33703100A9FE82 /* TextDiagnosticBuffer.cpp */,
DEEBCBE20C33702C00A9FE82 /* TextDiagnosticBuffer.h */,
);
name = Driver;
sourceTree = "<group>";
};
DEC8D98B0A9433BC00353FCA /* AST */ = {
isa = PBXGroup;
children = (
DEC8D9A30A94346E00353FCA /* AST.h */,
DE75ED280B044DC90020CF81 /* ASTContext.h */,
DED676D00B6C786700AAD4A3 /* Builtins.def */,
DED676F90B6C797B00AAD4A3 /* Builtins.h */,
DEC63B1B0C7B940600DBF169 /* CFG.h */,
DEC8D9900A9433CD00353FCA /* Decl.h */,
DE0FCA620A95859D00248FD5 /* Expr.h */,
1A30A9E80B93A4C800201A91 /* ExprCXX.h */,
DE6951C60C4D1F5D00A5826B /* RecordLayout.h */,
3547129D0C88881300B3E1D5 /* PrettyPrinter.h */,
DE3452800AEF1B1800DBC861 /* Stmt.h */,
DE345F210AFD347900DBC861 /* StmtNodes.def */,
DE345C190AFC658B00DBC861 /* StmtVisitor.h */,
DE3464210B03040900DBC861 /* Type.h */,
);
name = AST;
sourceTree = "<group>";
};
DEC8D9920A9433F400353FCA /* AST */ = {
isa = PBXGroup;
children = (
DE1732FF0B068B700080B521 /* ASTContext.cpp */,
DED677C80B6C854100AAD4A3 /* Builtins.cpp */,
DEC63B190C7B940200DBF169 /* CFG.cpp */,
DED62ABA0AE2EDF1001E80A4 /* Decl.cpp */,
DE0FCB330A9C21F100248FD5 /* Expr.cpp */,
35260CA40C7F75C000D66CE9 /* ExprCXX.cpp */,
DE3452400AEF1A2D00DBC861 /* Stmt.cpp */,
DE75EDF00B06880E0020CF81 /* Type.cpp */,
DEF2EDA60C6A4252000C4259 /* StmtDumper.cpp */,
DE34621C0AFEB19B00DBC861 /* StmtPrinter.cpp */,
);
name = AST;
sourceTree = "<group>";
};
DED7D72E0A524295003AD0FB /* include */ = {
isa = PBXGroup;
children = (
DED7D7300A524295003AD0FB /* Basic */,
DED7D7390A524295003AD0FB /* Lex */,
DE1F21F20A7D84E800FBF588 /* Parse */,
DEC8D98B0A9433BC00353FCA /* AST */,
DE67E7260C02108300F66BC5 /* Sema */,
DE928B140C05659A00231DA4 /* CodeGen */,
356EF9AF0C8F7DA4006650F5 /* Analysis */,
);
path = include;
sourceTree = "<group>";
};
DED7D7300A524295003AD0FB /* Basic */ = {
isa = PBXGroup;
children = (
DED7D7310A524295003AD0FB /* Diagnostic.h */,
DED7D7320A524295003AD0FB /* DiagnosticKinds.def */,
DED7D7330A524295003AD0FB /* FileManager.h */,
DE06B73D0A8307640050E87E /* LangOptions.h */,
DED7D7350A524295003AD0FB /* SourceLocation.h */,
DED7D7360A524295003AD0FB /* SourceManager.h */,
DE46BF270AE0A82D00CC047C /* TargetInfo.h */,
DED7D7370A524295003AD0FB /* TokenKinds.def */,
DED7D7380A524295003AD0FB /* TokenKinds.h */,
);
name = Basic;
path = clang/Basic;
sourceTree = "<group>";
};
DED7D7390A524295003AD0FB /* Lex */ = {
isa = PBXGroup;
children = (
DE3450D60AEB543100DBC861 /* DirectoryLookup.h */,
DE344AB70AE5DF6D00DBC861 /* HeaderSearch.h */,
DED7D73A0A524295003AD0FB /* IdentifierTable.h */,
DED7D73B0A524295003AD0FB /* Lexer.h */,
1A869A6E0BA2164C008DA07A /* LiteralSupport.h */,
DED7D73D0A524295003AD0FB /* MacroExpander.h */,
DED7D73E0A524295003AD0FB /* MacroInfo.h */,
DEAEE98A0A5A2B970045101B /* MultipleIncludeOpt.h */,
DE01DA480B12ADA300AC22CE /* PPCallbacks.h */,
DED7D73F0A524295003AD0FB /* Pragma.h */,
DED7D7400A524295003AD0FB /* Preprocessor.h */,
DED7D9170A52518C003AD0FB /* ScratchBuffer.h */,
DE6954630C5121BD00A5826B /* Token.h */,
);
name = Lex;
path = clang/Lex;
sourceTree = "<group>";
};
DED7D7500A5242C7003AD0FB /* Basic */ = {
isa = PBXGroup;
children = (
DED7D75D0A5242C7003AD0FB /* Diagnostic.cpp */,
DED7D75E0A5242C7003AD0FB /* FileManager.cpp */,
DED7D76D0A5242C7003AD0FB /* SourceManager.cpp */,
DED7D76E0A5242C7003AD0FB /* TokenKinds.cpp */,
DED626C80AE0C065001E80A4 /* TargetInfo.cpp */,
);
path = Basic;
sourceTree = "<group>";
};
DED7D78C0A5242E6003AD0FB /* Lex */ = {
isa = PBXGroup;
children = (
DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */,
DED7D79D0A5242E6003AD0FB /* IdentifierTable.cpp */,
DED7D79E0A5242E6003AD0FB /* Lexer.cpp */,
1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */,
DE3451570AEC176100DBC861 /* MacroExpander.cpp */,
DED7D7A00A5242E6003AD0FB /* MacroInfo.cpp */,
DED7D7A20A5242E6003AD0FB /* PPExpressions.cpp */,
DED7D7A30A5242E6003AD0FB /* Pragma.cpp */,
DED7D7A40A5242E6003AD0FB /* Preprocessor.cpp */,
DED7D9E40A5257F6003AD0FB /* ScratchBuffer.cpp */,
);
path = Lex;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8DD76F620486A84900D96B5E /* clang */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "clang" */;
buildPhases = (
8DD76F640486A84900D96B5E /* Sources */,
8DD76F660486A84900D96B5E /* Frameworks */,
8DD76F690486A84900D96B5E /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = clang;
productInstallPath = "$(HOME)/bin";
productName = clang;
productReference = 8DD76F6C0486A84900D96B5E /* clang */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
projectRoot = "";
targets = (
8DD76F620486A84900D96B5E /* clang */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
8DD76F640486A84900D96B5E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DED7D77A0A5242C7003AD0FB /* Diagnostic.cpp in Sources */,
DED7D77B0A5242C7003AD0FB /* FileManager.cpp in Sources */,
DED7D7890A5242C7003AD0FB /* SourceManager.cpp in Sources */,
DED7D78A0A5242C7003AD0FB /* TokenKinds.cpp in Sources */,
DED7D7C20A5242E6003AD0FB /* IdentifierTable.cpp in Sources */,
DED7D7C30A5242E6003AD0FB /* Lexer.cpp in Sources */,
DED7D7C50A5242E6003AD0FB /* MacroInfo.cpp in Sources */,
DED7D7C70A5242E6003AD0FB /* PPExpressions.cpp in Sources */,
DED7D7C80A5242E6003AD0FB /* Pragma.cpp in Sources */,
DED7D7C90A5242E6003AD0FB /* Preprocessor.cpp in Sources */,
DED7D9E50A5257F6003AD0FB /* ScratchBuffer.cpp in Sources */,
DE06D4310A8BB52D0050E87E /* Parser.cpp in Sources */,
DE0FCB340A9C21F100248FD5 /* Expr.cpp in Sources */,
DE5932D10AD60FF400BC794C /* clang.cpp in Sources */,
DE5932D30AD60FF400BC794C /* PrintParserCallbacks.cpp in Sources */,
DE5932D40AD60FF400BC794C /* PrintPreprocessedOutput.cpp in Sources */,
DED626C90AE0C065001E80A4 /* TargetInfo.cpp in Sources */,
DED627030AE0C51D001E80A4 /* Targets.cpp in Sources */,
DED62ABB0AE2EDF1001E80A4 /* Decl.cpp in Sources */,
DE344B540AE5E46C00DBC861 /* HeaderSearch.cpp in Sources */,
DE3451580AEC176100DBC861 /* MacroExpander.cpp in Sources */,
DE3452410AEF1A2D00DBC861 /* Stmt.cpp in Sources */,
DE3460000AFDCC1900DBC861 /* ParseObjc.cpp in Sources */,
DE3460050AFDCC6500DBC861 /* ParseInit.cpp in Sources */,
DE34600B0AFDCCBF00DBC861 /* ParseStmt.cpp in Sources */,
DE34600F0AFDCCCE00DBC861 /* ParseDecl.cpp in Sources */,
DE3460130AFDCCDA00DBC861 /* ParseExpr.cpp in Sources */,
DE3461270AFE68BE00DBC861 /* MinimalAction.cpp in Sources */,
DE34621D0AFEB19B00DBC861 /* StmtPrinter.cpp in Sources */,
DE75EDF10B06880E0020CF81 /* Type.cpp in Sources */,
DE1733000B068B700080B521 /* ASTContext.cpp in Sources */,
DE17336E0B068DC20080B521 /* DeclSpec.cpp in Sources */,
DED677C90B6C854100AAD4A3 /* Builtins.cpp in Sources */,
1A869AA80BA21ABA008DA07A /* LiteralSupport.cpp in Sources */,
DE67E70B0C020EC500F66BC5 /* SemaType.cpp in Sources */,
DE67E70D0C020ECA00F66BC5 /* SemaStmt.cpp in Sources */,
DE67E70F0C020ECF00F66BC5 /* SemaExprCXX.cpp in Sources */,
DE67E7110C020ED400F66BC5 /* SemaExpr.cpp in Sources */,
DE67E7130C020ED900F66BC5 /* SemaDecl.cpp in Sources */,
DE67E7170C020EE400F66BC5 /* Sema.cpp in Sources */,
DE67E71A0C020F4F00F66BC5 /* ASTStreamer.cpp in Sources */,
DE06756C0C051CFE00EBBFD8 /* ParseExprCXX.cpp in Sources */,
DE927FFD0C055DE900231DA4 /* LLVMCodegen.cpp in Sources */,
DE928B130C05659200231DA4 /* ModuleBuilder.cpp in Sources */,
DE928B7F0C0A615600231DA4 /* CodeGenModule.cpp in Sources */,
DE928B830C0A616000231DA4 /* CodeGenFunction.cpp in Sources */,
DE4772FA0C10EAE5002239E8 /* CGStmt.cpp in Sources */,
DE4772FC0C10EAEC002239E8 /* CGExpr.cpp in Sources */,
DE4264FC0C113592005A861D /* CGDecl.cpp in Sources */,
F0226FD20C18084500141F42 /* TextDiagnosticPrinter.cpp in Sources */,
84D9A8880C1A57E100AC7ABC /* AttributeList.cpp in Sources */,
DEB0AEBB0C2087AB00718A22 /* TextDiagnostics.cpp in Sources */,
DEEBC3BC0C2363BC00A9FE82 /* CodeGenTypes.cpp in Sources */,
DEC82DC40C32D50A00BAC245 /* DiagChecker.cpp in Sources */,
DEEBCBE50C33703100A9FE82 /* TextDiagnosticBuffer.cpp in Sources */,
DEF2E9340C5FBA02000C4259 /* ASTStreamers.cpp in Sources */,
DEF2EDA70C6A4252000C4259 /* StmtDumper.cpp in Sources */,
DEF2EFF30C6CDD74000C4259 /* CGExprAgg.cpp in Sources */,
DEF2F0100C6CFED5000C4259 /* SemaChecking.cpp in Sources */,
1ABC36940C7A4BDC006DB0AB /* CGBuiltin.cpp in Sources */,
DE224FF80C7AA98800D370A5 /* CGExprComplex.cpp in Sources */,
1A7342480C7B57D500122F56 /* CGObjC.cpp in Sources */,
DEC63B1A0C7B940200DBF169 /* CFG.cpp in Sources */,
DE2252700C7E82D000D370A5 /* CGExprScalar.cpp in Sources */,
35260CA50C7F75C000D66CE9 /* ExprCXX.cpp in Sources */,
DE2255FC0C8004E600D370A5 /* ParseDeclCXX.cpp in Sources */,
356EF9B50C8F7DDF006650F5 /* LiveVariables.cpp in Sources */,
355CF6840C90A8D400A08AA3 /* DeadStores.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
1DEB923208733DC60010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = i386;
COPY_PHASE_STRIP = NO;
GCC_CW_ASM_SYNTAX = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_CPP_EXCEPTIONS = NO;
GCC_ENABLE_CPP_RTTI = NO;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_PASCAL_STRINGS = NO;
GCC_ENABLE_SYMBOL_SEPARATION = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "__STDC_LIMIT_MACROS=1";
GCC_STRICT_ALIASING = YES;
GCC_THREADSAFE_STATICS = NO;
GCC_USE_GCC3_PFE_SUPPORT = NO;
HEADER_SEARCH_PATHS = (
"~/llvm/tools/clang/include",
"~/llvm/include",
"$(HEADER_SEARCH_PATHS)",
);
INSTALL_PATH = "$(HOME)/bin";
LIBRARY_SEARCH_PATHS = "~/llvm/Debug/lib";
OTHER_LDFLAGS = (
"-lLLVMSupport",
"-lLLVMSystem",
);
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
PRODUCT_NAME = clang;
ZERO_LINK = NO;
};
name = Debug;
};
1DEB923308733DC60010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = i386;
GCC_CW_ASM_SYNTAX = NO;
GCC_ENABLE_CPP_EXCEPTIONS = NO;
GCC_ENABLE_CPP_RTTI = NO;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_PASCAL_STRINGS = NO;
GCC_ENABLE_SYMBOL_SEPARATION = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G5;
GCC_PREPROCESSOR_DEFINITIONS = "__STDC_LIMIT_MACROS=1";
GCC_STRICT_ALIASING = YES;
GCC_THREADSAFE_STATICS = NO;
GCC_USE_GCC3_PFE_SUPPORT = NO;
HEADER_SEARCH_PATHS = (
"~/llvm/tools/clang/include",
"~/llvm/include",
"$(HEADER_SEARCH_PATHS)",
);
INSTALL_PATH = "$(HOME)/bin";
LIBRARY_SEARCH_PATHS = "~/llvm/Debug/lib";
OTHER_LDFLAGS = (
"-lLLVMSupport",
"-lLLVMSystem",
);
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
PRODUCT_NAME = clang;
ZERO_LINK = NO;
};
name = Release;
};
1DEB923608733DC60010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
name = Debug;
};
1DEB923708733DC60010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "clang" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB923208733DC60010E9CD /* Debug */,
1DEB923308733DC60010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB923608733DC60010E9CD /* Debug */,
1DEB923708733DC60010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
}

Some files were not shown because too many files have changed in this diff Show More