Commit Graph

383 Commits

Author SHA1 Message Date
Douglas Gregor dff6a8eeef Added GraphViz visualization of C++ inheritance hierarchies.
Factored the QualTypeOrdering predicate into its own header
(TypeOrdering.h), now that it is used in two places.

llvm-svn: 58001
2008-10-22 21:13:31 +00:00
Argyrios Kyrtzidis 2147e7d88b Now that DeclRefExpr accepts a NamedDecl, use a DeclRefExpr for when a CXXFieldDecl is referenced inside a method.
llvm-svn: 58000
2008-10-22 21:00:29 +00:00
Douglas Gregor 29a9247ec2 Add representation of base classes in the AST, and verify that we
don't have duplicated direct base classes.

Seriliazation of base class specifiers is not yet implemented.

llvm-svn: 57991
2008-10-22 17:49:05 +00:00
Douglas Gregor 4b62ec6353 QualType::isMoreQualifiedThan and isAtLeastAsQualifiedAs assert that we
aren't trying to compare with address-space qualifiers (for now).

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

llvm-svn: 57980
2008-10-22 15:04:37 +00:00
Douglas Gregor 293a3c6778 Functions can be lvalues in C++, but not modifiable lvalues
llvm-svn: 57941
2008-10-22 00:03:08 +00:00
Douglas Gregor 9a6579340f Initial step toward supporting qualification conversions (C++ 4.4).
Changes:
  - Sema::IsQualificationConversion determines whether we have a qualification
    conversion.
  - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++,
    performing an implicit conversion from the right-hand side to the type of
    the left-hand side rather than checking based on the C notion of 
    "compatibility". We now rely on the implicit-conversion code to
    determine whether the conversion can happen or
    not. Sema::TryCopyInitialization has an ugly reference-related
    hack to cope with the initialization of references, for now.
  - When building DeclRefExprs, strip away the reference type, since
    there are no expressions whose type is a reference. We'll need to
    do this throughout Sema.
  - Expr::isLvalue now permits functions to be lvalues in C++ (but not
  in C).

llvm-svn: 57935
2008-10-21 23:43:52 +00:00
Steve Naroff 5cfa5af630 Fix <rdar://problem/6257645> clang static analyzer crashes when encountering blocks as objects
ASTContext::isObjCObjectPointerType() needs to consider blocks as objects.

Note: My previous commit was done in the test directory...as a result, this commit was necessary.
llvm-svn: 57914
2008-10-21 18:24:04 +00:00
Douglas Gregor 5251f1b283 Preliminary support for function overloading
llvm-svn: 57909
2008-10-21 16:13:35 +00:00
Steve Naroff ea54d9ef72 Sema::CheckCompareOperands() and ASTContext::mergeTypes(): Change handling of ObjC qualified id types to be consistent with gcc. This changes a handful of test case errors into warnings (diff will tell you which cases have changed).
llvm-svn: 57841
2008-10-20 18:19:10 +00:00
Ted Kremenek d36e552245 Fix incorrect release of Decl* array referenced by DeclGroup.
Patch by Timo Sirainen!

llvm-svn: 57772
2008-10-18 19:20:54 +00:00
Mon P Wang 8f477106a4 Make llvm memory barrier available as an intrinsic
llvm-svn: 57751
2008-10-18 02:49:28 +00:00
Daniel Dunbar fc1066db81 Remove unneeded EncodingRecordTypes argument to getObjCEncodingForType.
llvm-svn: 57716
2008-10-17 20:21:44 +00:00
Daniel Dunbar ff3c6747ef More Obj-C type encoding improvements.
- Encode unions and bit-fields correctly.
 - Accept option to name record fields (used for NeXT runtime).

llvm-svn: 57685
2008-10-17 16:17:37 +00:00
Daniel Dunbar 3cd9a29c64 Fix bug in Obj-C type encoding for structures.
- Mechanism for detecting if a structure should be expanded wasn't
   reliable. Simplified by just keeping track of what we should be
   expanding.

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

llvm-svn: 57675
2008-10-17 07:30:50 +00:00
Daniel Dunbar 40cac777b9 Anonymous structures print as '?=' in Obj-C type encoding.
llvm-svn: 57674
2008-10-17 06:22:57 +00:00
Argyrios Kyrtzidis 89656d2298 Using dyn_cast_or_null here is redundant, use dyn_cast instead.
llvm-svn: 57642
2008-10-16 16:50:47 +00:00
Daniel Dunbar c3d79cf6b3 Teach tryEvaluate that fabs, copysign, and unary +/- are constants for
floats.
 - With testcase, which also has some other things GCC folds but we
   don't commented out in it.

llvm-svn: 57624
2008-10-16 03:51:50 +00:00
Daniel Dunbar 4290d46bd4 Implement #pragma pack use in structure packing. The general approach
is to encode the state of the #pragma pack stack as an attribute when
the structure is declared. 

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

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

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

llvm-svn: 57623
2008-10-16 02:34:03 +00:00
Daniel Dunbar a0dcd78081 Use BatchEmitOwnedPtrs for writing multiple child exprs, per review.
Also added serialization support to OverloadExpr.

llvm-svn: 57588
2008-10-15 17:52:29 +00:00
Argyrios Kyrtzidis 88e1b97f16 Simplify handling of struct/union/class tags.
Instead of using two sets of Decl kinds (Struct/Union/Class and CXXStruct/CXXUnion/CXXClass), use one 'Record' and one 'CXXRecord' Decl kind and make tag kind a property of TagDecl.
Cleans up the code a bit and better reflects that Decl class structure.

llvm-svn: 57541
2008-10-15 00:42:39 +00:00
Daniel Dunbar cbdf409c2c Add serialization support in several missing places.
llvm-svn: 57502
2008-10-14 16:57:09 +00:00
Daniel Dunbar d5420e3bef Move Type::EmitImpl into header, add FIXME to make abstract.
llvm-svn: 57501
2008-10-14 16:55:17 +00:00
Daniel Dunbar 1be9f88a2f Fix test suite regression, getFloatTypeSemantics shouldn't be called
on non-float types.

llvm-svn: 57477
2008-10-14 05:41:12 +00:00
Argyrios Kyrtzidis 01622642d3 Improve the const-ness of a few methods.
No functionality change.

llvm-svn: 57417
2008-10-12 18:40:01 +00:00
Argyrios Kyrtzidis 3768ad6d58 Implement more efficient Decl <-> DeclContext conversions.
When the static type on the Decl side is a subclass of DeclContext the compiler will use a "inlinable" static_cast, instead of always using an out-of-line function call.

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

llvm-svn: 57415
2008-10-12 16:14:48 +00:00
Chris Lattner 79ef843533 silence some release-assert warnings.
llvm-svn: 57391
2008-10-12 00:28:42 +00:00
Chris Lattner e05f534628 silence a bunch of warnings in a release-assert build.
llvm-svn: 57390
2008-10-12 00:26:57 +00:00
Steve Naroff 1d95e5a531 Final phase of converting BlockDecls over to DeclContext. This is unfortunately a largish/complex diff, however it was necessry to pass all the current block tests.
llvm-svn: 57337
2008-10-10 01:28:17 +00:00
Dale Johannesen c48814bc98 Adjust calls to APFloat conversion for new interface.
llvm-svn: 57332
2008-10-09 23:02:32 +00:00
Steve Naroff 44078b95ee Instantiate the BlockDecl in ActOnBlockStart() so we can use it as a DeclContext.
This required changes to attach the compound statement later on (like we do for functions).

llvm-svn: 57304
2008-10-08 18:44:00 +00:00
Steve Naroff 415d3d570a - Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.

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

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

llvm-svn: 57298
2008-10-08 17:01:13 +00:00
Ted Kremenek 587a44fe3d A little more tweaking with StmtIterator and SizeOfAlignofExpr. A recent commit actually introduced a regression, not fixed a bug.
llvm-svn: 57282
2008-10-07 23:35:42 +00:00
Ted Kremenek 9bb286ff43 Migrate DeclStmt over to using a DeclGroup instead of a pointer to a ScopedDecl*.
This also removes the ugly hack needed in CFG.cpp for subclassing DeclStmt to create a DeclStmt with one Decl*.

llvm-svn: 57275
2008-10-07 23:09:49 +00:00
Ted Kremenek 4faf673d7f Fixed a masked bug when iterating over the child expressions of SizeOfAlignOfTypeExpr. This bug was unmasked by recent changes to StmtIterator.
llvm-svn: 57273
2008-10-07 23:07:10 +00:00
Ted Kremenek 12183e25aa Add const_iterator to DeclGroup.
Serialization for OwningDeclGroupRefs now works.

llvm-svn: 57272
2008-10-07 23:06:01 +00:00
Ted Kremenek f9638bac59 Add StmtIterator support for DeclGroups.
llvm-svn: 57271
2008-10-07 23:04:14 +00:00
Ted Kremenek 6553748599 Added prototype serialization code for DeclGroup.
llvm-svn: 57222
2008-10-06 23:49:24 +00:00
Ted Kremenek 6d60a4ec19 Modified DeclGroupRef to always load/store the internal pointer value as Decl*. This hopefully will obviate any concerns with violating strict type-aliasing issues.
llvm-svn: 57213
2008-10-06 22:17:16 +00:00
Ted Kremenek ef52c641e7 Use DeclStmt::decl_iterator to walk a group of Decl*'s instead of using the ScopedDecl chain.
llvm-svn: 57206
2008-10-06 20:56:19 +00:00
Ted Kremenek a86db10563 Don't use DeclStmt::getDecl() to serialize out DeclStmt; use TheDecl directly.
This patch precedes removing getDecl() DeclStmt::entirely.

llvm-svn: 57205
2008-10-06 20:55:44 +00:00
Ted Kremenek acf920dd39 Add DeclStmt::hasSolitaryDecl() and DeclStmt::getSolitaryDecl()
llvm-svn: 57204
2008-10-06 20:54:44 +00:00
Ted Kremenek 15e6b40832 Added PrintRawDeclStmt; use this method to print out DeclStmt instead of using PrintRawDecl (which falsely assumes DeclStmts have only one Decl).
llvm-svn: 57191
2008-10-06 18:39:36 +00:00
Ted Kremenek 62408480d9 Use Decl::decl_iterator instead of walking the ScopedDecl chain (which will soon be removed).
llvm-svn: 57190
2008-10-06 18:38:35 +00:00
Chris Lattner 2c091b1ead ExprConstant should not abort when it sees a pointer constant that isn't.
llvm-svn: 57162
2008-10-06 07:20:11 +00:00
Chris Lattner cb13691a62 Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExpr
which is checking for something that can be inconsistent with
what we can constant fold.

llvm-svn: 57159
2008-10-06 06:49:02 +00:00
Chris Lattner 86ee286b09 Move folding of __builtin_classify_type out of the CallExpr
interface into the constant folding interface.

llvm-svn: 57158
2008-10-06 06:40:35 +00:00
Chris Lattner 0b7282eafc Move handling of __builtin_nan("") out of CGBuiltin.cpp into ExprConstant.cpp
llvm-svn: 57157
2008-10-06 06:31:58 +00:00
Chris Lattner 37346e081c Teach FloatExprEvaluator to evaluate __builtin_huge_val and inf.
llvm-svn: 57154
2008-10-06 05:53:16 +00:00
Chris Lattner 4deaa4ea24 Add a comment that describes tryEvaluate. Make tryEvaluate fold
__builtin_constant_p properly, and add some scaffolding for
FloatExprEvaluator to eventually handle huge_val and inf.

llvm-svn: 57152
2008-10-06 05:28:25 +00:00
Chris Lattner 01ff98a48a add a new CallExpr::isBuiltinCall() method, and use it to simplify some existing
code.

llvm-svn: 57151
2008-10-06 05:00:53 +00:00