Commit Graph

2044 Commits

Author SHA1 Message Date
Oscar Fuentes 07d9f9a6ec CMake: Builds and installs clang binary and libs (no docs yet). It
must be under the `tools' subdirectory of the LLVM *source* tree.

llvm-svn: 58180
2008-10-26 00:56:18 +00:00
Ted Kremenek e69a1fa342 Do not crash when performing VisitLValue on union types.
This fixes PR 2948.

llvm-svn: 58148
2008-10-25 20:09:21 +00:00
Zhongxing Xu 195839dd53 Add a note file for SCA module. Is it the right place?
llvm-svn: 58140
2008-10-25 14:56:36 +00:00
Zhongxing Xu 0d2706f6b8 Add code for get the lvalue for string literals. Now we return a StringRegion
for StringLiteral lvalue evaluation, instead of directly returning a
loc::StringLiteralVal by the Environment.

llvm-svn: 58138
2008-10-25 14:18:57 +00:00
Zhongxing Xu d1aac353e5 Add StringRegion to MemRegions.
llvm-svn: 58137
2008-10-25 14:13:41 +00:00
Zhongxing Xu ad20b671fc Now we can handle arrays.
llvm-svn: 58135
2008-10-25 10:26:46 +00:00
Argyrios Kyrtzidis 962c20e6f3 Add a quote from the standard about the type of 'this'.
llvm-svn: 58124
2008-10-24 22:28:18 +00:00
Argyrios Kyrtzidis 22c40fa285 -Add support for cv-qualifiers after function declarators.
-Add withConst/withVolatile/withRestrict methods to QualType class, that return the QualType plus the respective qualifier.

llvm-svn: 58120
2008-10-24 21:46:40 +00:00
Ted Kremenek 920406b5ca Use "followsFundamentalRule" to determine if an instance method allocates memory.
llvm-svn: 58114
2008-10-24 21:22:44 +00:00
Ted Kremenek 01acb6284e followsFundamentalRule() returns true if "alloc" or "new" appear at the beginning of the string, not anywhere within it.
llvm-svn: 58112
2008-10-24 21:18:08 +00:00
Ted Kremenek 8d8a14a3fc Expand bubble size by 50%.
llvm-svn: 58111
2008-10-24 21:17:16 +00:00
Ted Kremenek 6e09d8f632 Implicit conversions from arrays can also be conversions to references (will add a test case shortly).
llvm-svn: 58110
2008-10-24 21:10:49 +00:00
Ted Kremenek 03466c2273 Issue warnings about owned objects returned from a method that does not match the established Cocoa naming conventions.
llvm-svn: 58108
2008-10-24 20:32:50 +00:00
Ted Kremenek f3be44f191 Added method "getSelfRegion" to Store. This method returns the region associated with the "this" or "self" object (C++ and Objective-C respectively).
llvm-svn: 58107
2008-10-24 20:32:16 +00:00
Ted Kremenek 8921d930d4 Added region ObjCObjectRegion that represents an instance of an Objective-C object.
llvm-svn: 58106
2008-10-24 20:30:08 +00:00
Douglas Gregor 3dfef1f2a3 Move viewInheritance to CXXRecordDecl, and make sure it builds in Release mode, too
llvm-svn: 58105
2008-10-24 19:53:54 +00:00
Douglas Gregor a8aa7a08b8 PR2942: FunctionDecls by typedef crash the C++ front-end
llvm-svn: 58100
2008-10-24 18:09:54 +00:00
Douglas Gregor cea4e74340 Some cleanups for the ambiguous derived-to-base conversion checks
llvm-svn: 58096
2008-10-24 16:17:19 +00:00
Douglas Gregor 08d918a6c3 Semantic analysis for C++ reinterpret_cast and const_cast. Patch by Sebastian Redl.
llvm-svn: 58094
2008-10-24 15:36:09 +00:00
Zhongxing Xu e834fc1249 The Decl of an array region can be VarDecl or FieldDecl. Handle this in RegionStoreManager::ArrayToPointer().
llvm-svn: 58086
2008-10-24 09:06:51 +00:00
Zhongxing Xu 729518be3a Implement struct initialization. Make it into a recursive function. Also make
the array initialization code into a function.

llvm-svn: 58083
2008-10-24 08:42:28 +00:00
Daniel Dunbar dec8a89d37 Don't crash on invalid source locations in
CGDebugInfo::getOrCreateCompileUnit.

llvm-svn: 58081
2008-10-24 08:38:36 +00:00
Daniel Dunbar d7be95d60a PR2919: __builtin_types_compatible_p strips CRV qualifiers.
llvm-svn: 58079
2008-10-24 08:07:57 +00:00
Zhongxing Xu a14262862f Add printing method to ElementRegion.
llvm-svn: 58077
2008-10-24 06:30:07 +00:00
Zhongxing Xu 1359e00f9c Add printing method to RegionStoreManager.
llvm-svn: 58074
2008-10-24 06:01:33 +00:00
Zhongxing Xu 509bd9e30a Add printing with llvm::raw_ostream methods to SVals.
llvm-svn: 58073
2008-10-24 06:00:12 +00:00
Douglas Gregor 39c16d445e First non-embarrassing cut at checking for ambiguous derived-to-base
conversions.

Added PerformImplicitConversion, which follows an implicit conversion sequence
computed by TryCopyInitialization and actually performs the implicit
conversions, including the extra check for ambiguity mentioned above.

llvm-svn: 58071
2008-10-24 04:54:22 +00:00
Zhongxing Xu c7796d347d Fix 80-col violation.
llvm-svn: 58070
2008-10-24 04:33:15 +00:00
Zhongxing Xu cebb741f68 Add a bunch of dummy methods to make RegionStoreManager non-virtual.
llvm-svn: 58061
2008-10-24 01:38:55 +00:00
Zhongxing Xu a8d2cbe47f Added getLValueElement() to RegionStore. Only handle constant array for now.
llvm-svn: 58058
2008-10-24 01:09:32 +00:00
Ted Kremenek 6779f893b9 Make the analyzer store (memory model) a command line option.
llvm-svn: 58056
2008-10-24 01:04:59 +00:00
Daniel Dunbar 607f67b16c Map compilation units using FileEntry pointers instead of
FileIDs. This seems better conceptually and lets the SourceManager
handle details of mapping the location to a file ID.
 - In practice, fixes an assert because this code wasn't using
   getPhysicalLoc.

llvm-svn: 58055
2008-10-24 00:46:51 +00:00
Ted Kremenek 1507dbfbfc Use llvm::errs() instead of cerr.
llvm-svn: 58054
2008-10-23 23:55:40 +00:00
Ted Kremenek 40fcc594b8 Convert InheritanceHierarchyWriter to use llvm::raw_ostream instead of std::ostream.
llvm-svn: 58053
2008-10-23 23:51:23 +00:00
Daniel Dunbar 340b5ddcf9 Fix regression in comparison of qualified id; == operator was being
created with LHS and RHS whose types didn't match.

llvm-svn: 58049
2008-10-23 23:30:52 +00:00
Douglas Gregor 9d6290baf1 Clean up and document the representation of C++ base classes
llvm-svn: 58040
2008-10-23 18:13:27 +00:00
Zhongxing Xu 9c4bc9dd33 Add an assertion to make our intention more clear.
llvm-svn: 58030
2008-10-23 04:19:25 +00:00
Douglas Gregor 01bef3c016 If NDEBUG is set, don't include any of the code for visualizing inheritance hierarchies
llvm-svn: 58029
2008-10-23 03:52:39 +00:00
Zhongxing Xu b0a4875b42 Let StoreManager do different cast on arrays. BasicStore will just keep it intact.
llvm-svn: 58028
2008-10-23 03:10:39 +00:00
Ted Kremenek cc3d18877a Disable warning about potential leaks of returned values until we test it a little more (lots of noise).
llvm-svn: 58021
2008-10-23 01:56:15 +00:00
Douglas Gregor 5c407d9a9b Add support for conversions from a pointer-to-derived to a
pointer-to-base. Also, add overload ranking for pointer conversions
(for both pointer-to-void and derived-to-base pointer conversions).

Note that we do not yet diagnose derived-to-base pointer conversion
errors that stem from ambiguous or inacessible base classes. These
aren't handled during overload resolution; rather, when the conversion
is actually used we go ahead and diagnose the error.

llvm-svn: 58017
2008-10-23 00:40:37 +00:00
Ted Kremenek 631ff239fc Warn about potentially leaked objects that are returned from methods whose names do not follow the Cocoa Memory Management guidelines.
llvm-svn: 58012
2008-10-22 23:56:21 +00:00
Argyrios Kyrtzidis 1a527ea1e5 Restrict creation of OverloadedFunctionDecl only to C++ (it was getting used for invalid redeclarations on C).
llvm-svn: 58008
2008-10-22 23:08:24 +00:00
Steve Naroff b0c653a649 Fix <rdar://problem/6311947> clang on xcode (regression): error: use of undeclared identifier 'expandedValue'.
Mea culpa: I introduced this regresson in the following 2 commits: r57529 (10/14), r57841 (10/20).

llvm-svn: 58007
2008-10-22 22:40:28 +00:00
Douglas Gregor d8c7476bf3 Remove the GraphWriter-based version of the C++ class inheritance visualization, since it isn't being used and can't handle virtual bases properly
llvm-svn: 58002
2008-10-22 21:25:12 +00:00
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
Ted Kremenek 9a96bf22ec Enhance reference-count checker to correctly identify CG "release" functions. This fixes <rdar://problem/6303488>.
llvm-svn: 57997
2008-10-22 20:54:52 +00:00
Steve Naroff 1df62692f2 Fix <rdar://problem/6257675> error: member reference base type ('NSUserDefaults *') is not a structure or union.
Teach Sema::ActOnMemberReferenceExpr() to look through local category implementations associated with the class.

llvm-svn: 57995
2008-10-22 19:16:27 +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 e1eb9d8cc4 Implement ranking of standard conversion sequences by their qualification
conversions (e.g., comparing int* -> const int* against 
int* -> const volatile int*); see C++ 13.3.3.2p3 bullet 3.

Add Sema::UnwrapSimilarPointerTypes to simplify the control flow of
IsQualificationConversion and CompareQualificationConversion (and fix
the handling of the int* -> volatile int* conversion in the former).
 

llvm-svn: 57978
2008-10-22 14:17:15 +00:00
Zhongxing Xu 2fbc35443d Add a bunch of getLValue* methods to RegionStore.
llvm-svn: 57977
2008-10-22 13:44:38 +00:00
Zhongxing Xu c5382eae80 Adjust parameter order to more natural one.
llvm-svn: 57964
2008-10-22 09:00:19 +00:00
Zhongxing Xu c272152919 Exprs of function type is another special case for ImplicitCast.
llvm-svn: 57963
2008-10-22 08:02:16 +00:00
Douglas Gregor bc55da5768 Move Sema::GetNonReferenceType to QualType::getNonReferenceType and make it inline
llvm-svn: 57951
2008-10-22 04:14:44 +00:00
Chris Lattner b795443082 some minor cleanups to ParseObjCTypeName:
1. Remove a bogus assertion, clients other than sema can return a
   null pointer from actions that result in ParseTypeName returning null.
2. Remove dead RParenLoc variable.
3. Simplify control flow handling error conditions.
4. On a major failure, we should skip until ')' not until '}'.

llvm-svn: 57949
2008-10-22 03:52:06 +00:00
Douglas Gregor ea2d4211e5 Fix a thinko in the qualification-conversion check when the qualificaitons are disjoint, and add some overloading-based tests of qualification conversions
llvm-svn: 57942
2008-10-22 00:38:21 +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
Daniel Dunbar 445693afaf Fix use of dyn_cast.
llvm-svn: 57927
2008-10-21 21:22:32 +00:00
Daniel Dunbar 30c514e763 Add GetModule accessor to ModuleBuilder
llvm-svn: 57924
2008-10-21 19:55:09 +00:00
Ted Kremenek 677fba12a5 When conjuring symbols for compound assignments, use the promoted type to determine if the symbolic value as a "loc::" or "nonloc::" value.
llvm-svn: 57917
2008-10-21 19:49:01 +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 209ad9dc70 Cosmetic patch from João Paulo Rechi Vita
llvm-svn: 57910
2008-10-21 16:14:35 +00:00
Douglas Gregor 5251f1b283 Preliminary support for function overloading
llvm-svn: 57909
2008-10-21 16:13:35 +00:00
Ted Kremenek 0747e7e025 Handle [NSAutoreleasePool addObject:] (an alternative way to add objects to the current autorelease pool).
Added initial code for tracking stack of autorelease pools.

llvm-svn: 57908
2008-10-21 15:53:15 +00:00
Steve Naroff 90255b4f54 Fix a crasher during error recovery in Parser::ParseObjCTypeName().
Found this while fixing another unrelated radar.

llvm-svn: 57904
2008-10-21 14:15:04 +00:00
Steve Naroff 9ebc050ca7 Fix typo.
llvm-svn: 57899
2008-10-21 10:50:19 +00:00
Steve Naroff a0ed165a84 Fix <rdar://problem/6261178> clang-on-xcode: [sema] multiple method warning is over enthusiastic.
Fix <rdar://problem/6265257> warnings for ambiguous message send swamp other warnings.

Reworked Sema::MatchTwoMethodDeclarations() to optionally match based on method size and alignment (the default in GCC). Changed Sema::LookupInstanceMethodInGlobalPool() to use this feature.

Added -Wno-struct-selector-match to driver, however didn't hook it up yet. Added a FIXME that says this.

llvm-svn: 57898
2008-10-21 10:37:50 +00:00
Zhongxing Xu dab76fd822 Localize the special processing of array variable inside
GRExprEngine::VisitCast() so that other parts of the analyzer can be ignorant.
When we cast "array of type T" to "pointer to T", we get the loc::MemRegionVal
corresponding to the array variable. This is sufficient for BasicStore, but not
for RegionStore. RegionStore should get the element region for the first array
element in the cast. So next comes to the revamping of transfer functions for
different store model.

llvm-svn: 57897
2008-10-21 06:54:23 +00:00
Zhongxing Xu 8f6855e642 Modify Store interface: GetSVal/SetSVal => Retrieve/Bind.
llvm-svn: 57896
2008-10-21 06:27:32 +00:00
Zhongxing Xu 7ff32d0955 Rename:
RValues.h/cpp => SVals.h/cpp

llvm-svn: 57893
2008-10-21 05:41:03 +00:00
Zhongxing Xu 83aff7079f Process decls in RegionStore. Individual elements of fixed size arrays are
initialized to UndefinedVal.

llvm-svn: 57892
2008-10-21 05:29:26 +00:00
Zhongxing Xu d8fe46b496 Add ElementRegion to represent memory chunks for array elements.
llvm-svn: 57891
2008-10-21 05:27:10 +00:00
Ted Kremenek c32ec3a0c4 Further improve path-sensitivity with divide-by-zero checking by assuming that a denominator cannot be zero even when the result of an '/' or '%' expression is unknown.
llvm-svn: 57855
2008-10-20 23:40:25 +00:00
Ted Kremenek 7f8a87f4a9 Used conjured symbols to recover path-sensitivity when the result of a compound assignment is UnknownVal().
llvm-svn: 57851
2008-10-20 23:13:25 +00:00
Steve Naroff bca9fd755d Fix <rdar://problem/6268365> Parser rejects property (dot notation) access on id<protocol>.
llvm-svn: 57850
2008-10-20 22:53:06 +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
Chris Lattner 2dfde91064 eliminate ObjCPropertyAttrs an corresponding enums, just use
strcmp when needed.

llvm-svn: 57817
2008-10-20 07:43:01 +00:00
Chris Lattner 825bca174d rearrange some code.
llvm-svn: 57816
2008-10-20 07:39:53 +00:00
Chris Lattner 1db3354d89 more simplifications to error recovery in ParseObjCPropertyAttribute
llvm-svn: 57815
2008-10-20 07:37:22 +00:00
Chris Lattner 18ffde822f remove extraneous braces
llvm-svn: 57814
2008-10-20 07:36:58 +00:00
Chris Lattner beca77018a move some code around to make it fall through more, no functionality change.
llvm-svn: 57813
2008-10-20 07:24:39 +00:00
Chris Lattner 7661923999 reject properties completely in objc1 instead of emitting
weird errors about property attributes being unknown.

llvm-svn: 57812
2008-10-20 07:22:18 +00:00
Chris Lattner 64b1f2f030 More property attribute recovery improvements. Instead of this:
crash.m:8:12: error: type name requires a specifier or qualifier
@property (readonlyx, getter=isAwesome) int _awesome;
           ^
crash.m:8:29: error: expected ';' at end of declaration list
@property (readonlyx, getter=isAwesome) int _awesome;
                            ^
crash.m:8:39: error: expected identifier or '('
@property (readonlyx, getter=isAwesome) int _awesome;
                                      ^

we now get:

crash.m:8:12: error: unknown property attribute 'readonlyx'
@property (readonlyx, getter=isAwesome) int _awesome;
           ^

Also, we can eliminate isObjCPropertyAttribute now.

llvm-svn: 57811
2008-10-20 07:15:22 +00:00
Chris Lattner 43c76c38fa significantly simplify and clean up error recovery in
ParseObjCPropertyAttribute.  Before, on this code (where
a comma was forgotten):

@property (readonly getter=isAwesome) int _awesome;

we emitted:

crash.m:9:11: error: expected ')'
@property (readonly getter=isAwesome) int _awesome;
          ^
crash.m:9:37: error: type name requires a specifier or qualifier
@property (readonly getter=isAwesome) int _awesome;
                                    ^
crash.m:9:37: error: expected identifier or '('
crash.m:9:37: error: expected ';' at end of declaration list
crash.m:9:1: error: @property requires fields to be named
@property (readonly getter=isAwesome) int _awesome;
^

now we emit:

crash.m:9:21: error: expected ')'
@property (readonly getter=isAwesome) int _awesome;
                    ^
crash.m:9:11: error: to match this '('
@property (readonly getter=isAwesome) int _awesome;
          ^

llvm-svn: 57809
2008-10-20 07:00:43 +00:00
Chris Lattner 1ff6e73651 simplify some other code for __extension__ processing.
llvm-svn: 57807
2008-10-20 06:51:33 +00:00
Chris Lattner f02ef3e6d4 implement a couple fixme's by implementing __extension__ properly.
llvm-svn: 57806
2008-10-20 06:45:43 +00:00
Chris Lattner 93429b047b fix a crash on unnamed properties like:
@property (readonly) int : 4;

llvm-svn: 57805
2008-10-20 06:33:53 +00:00
Chris Lattner e0d3fe9b97 simplify some code by using ExpectAndConsume. When an error
occurs, skip to an @ or ; instead of to a } or ;.  Properties
don't necessarily live in {}'s.

llvm-svn: 57804
2008-10-20 06:15:13 +00:00
Chris Lattner da9fb15b90 refactor a bunch of code:
Check for @end in ParseObjCInterfaceDeclList instead of in each caller
Handle @required and @optional with the same code

Add some fixmes about some apparently objc2 code that is being accepted
in objc1.

llvm-svn: 57803
2008-10-20 06:10:06 +00:00
Chris Lattner bb8cc18788 fix some minor error recovery bugs in ParseObjCInterfaceDeclList
where it would reject @required in non-protocols, but then go
ahead and tag methods with required anyway.  Instead, if we see
this in something other than a protocol, just ignore the request.

Also, improve error recovery a bit when we see something bogus 
inside an interface.

llvm-svn: 57798
2008-10-20 05:57:40 +00:00
Chris Lattner 038a3e349d restructure the body of the ParseObjCInterfaceDeclList loop
to make it easier to understand.  No functionality change.

llvm-svn: 57797
2008-10-20 05:46:22 +00:00
Chris Lattner 2a9d9897b7 Fix rdar://6257721 by tightening up the block "snapshot" check, and
move it to its own predicate to make it more clear.

llvm-svn: 57796
2008-10-20 05:16:36 +00:00
Chris Lattner 29e6f2b674 Support attributes in *yet another* place. Is there any place you
can't stick an attributes?

llvm-svn: 57795
2008-10-20 04:57:38 +00:00
Chris Lattner 8ff2c6c9f0 Fix a parser bug where we let attributes interfere with our disambiguation
of whether a '(' was a grouping paren or the start of a function declarator.
This is PR2796.

Now we eat the attribute before deciding whether the paren is grouping or
not, then apply it to the resultant decl or to the first argument as needed.

One somewhat surprising aspect of this is that attributes interact with
implicit int in cases like this:

void a(x, y) // k&r style function
void b(__attribute__(()) x, y); // function with two implicit int arguments
void c(x, __attribute__(()) y); // error, can't have attr in identifier list.

Fun stuff.

llvm-svn: 57790
2008-10-20 02:05:46 +00:00
Chris Lattner 4b13d3f2f2 fix indentation
llvm-svn: 57789
2008-10-20 02:01:50 +00:00
Chris Lattner fcc390a9df fix indentation
llvm-svn: 57788
2008-10-20 02:01:34 +00:00
Chris Lattner 409bf7d03a Remove an implemented fixme, only treat < as a type specifier
when ObjC is turned on.

llvm-svn: 57787
2008-10-20 00:25:30 +00:00
Daniel Dunbar 70e3ebafdb Improve attribute parsing & tests.
- Support noreturn on function-typed variables.

 - Extend isFunctionOrMethod to return true for K&R functions and
   provide hasFunctionProto to check if a decl has information about
   its arguments. This code needs some serious cleaning, but works.

 - Add/improve test cases for noreturn and unused.

llvm-svn: 57778
2008-10-19 02:04:16 +00:00
Ted Kremenek f8d65a30d6 Add support in GRExprEngine for UnaryOperator::AlignOf. This fixes one crash report in PR 2796.
llvm-svn: 57777
2008-10-18 22:20:20 +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
Daniel Dunbar 354d278518 Debug info bug fix, function start wasn't getting generated correctly
for Obj-C methods.

llvm-svn: 57769
2008-10-18 18:22:23 +00:00
Ted Kremenek 850422e5d2 Generalize VisitLValue: not only can CallExprs and ObjCMessageExprs return aggregate temporaries, so can many other expressions.
llvm-svn: 57761
2008-10-18 04:15:35 +00:00
Ted Kremenek 8f5dc295ce Function calls and ObjC message expressions can be used in a lvalue context if they return a structure. E.g foo().x == 1. We don't really support, however, such temporaries yet in the environment or the store.
llvm-svn: 57760
2008-10-18 04:08:49 +00:00
Ted Kremenek e86755e14f retain/release checker: Check if a tracked value escapes if we also try binding it to the store and the store doesn't support that binding (i.e., it cannot track it). This has the nice feature that the checker will automatically get more powerful if we use a more powerful store model.
llvm-svn: 57755
2008-10-18 03:49:51 +00:00
Ted Kremenek fef1f30ea2 Use "VisitLValue" when processing the base for "x.f" field accesses, and "Visit" when processing the base for "x->f" field accesses.
llvm-svn: 57754
2008-10-18 03:28:48 +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
Argyrios Kyrtzidis 3a0558af9a Just do a diagIfAmbiguous -> warnIfAmbiguous rename.
No functionality change.

llvm-svn: 57746
2008-10-17 23:23:35 +00:00
Daniel Dunbar 1ea1aa2cc1 Emit more descriptive unsupported error message on dot-syntax use of super.
llvm-svn: 57745
2008-10-17 23:05:02 +00:00
Daniel Dunbar cf56c2b7bd Add FIXME about potential problem in how property ref lvalues are handled.
llvm-svn: 57743
2008-10-17 23:02:24 +00:00
Ted Kremenek db5ae0aa1c Hack: have BasicStore::getLValueElement return the "Base" lvalue. This restores null dereference checking with array accesses.
BasicStore::RemoveDeadBindings: handle regions besides VarRegions (we now have FieldRegions).

llvm-svn: 57741
2008-10-17 22:52:40 +00:00
Ted Kremenek 213873232d When conjuring symbols to recover path-sensitivity, don't conjure symbols that represent an entire struct. We need to implement struct temporaries as an actual "region", and then bind symbols to the FieldRegion of those temporaries.
llvm-svn: 57739
2008-10-17 22:23:12 +00:00
Daniel Dunbar b35174727f Lift CodeGenFunction::EmitPredefinedFunctioName out of EmitPredefinedLValue.
- Shouldn't assume predefined expr is a function printing one.
 - Uses CGM functionality to cache function names per module.

llvm-svn: 57737
2008-10-17 21:58:32 +00:00
Daniel Dunbar dfcf599dfa Add option argument to GetAddrOfConstantString to use for name of
(first) global holding the string.
 - No functionality change.

llvm-svn: 57736
2008-10-17 21:56:50 +00:00
Chris Lattner f0a5f84c42 fix rdar://6288301: custom warnings don't respect -Werror.
llvm-svn: 57731
2008-10-17 21:24:47 +00:00
Ted Kremenek 1416a521b5 Enhance "Assumption" logic in BasicConstraintManager when reasoning about regions and symbolic regions. When assuming whether or not a location is non-null, walk up the region hierarchy until we hit a symbolic region (and test it for null). This may not be the end all solution, as the notion of what a "symbolic region" is really belongs in the specific subclass of StoreManager.
llvm-svn: 57730
2008-10-17 21:22:20 +00:00
Ted Kremenek fe15bedff4 Add pretty-printing support for FieldRegions.
llvm-svn: 57724
2008-10-17 21:05:44 +00:00
Daniel Dunbar 1e75408d89 Emit error unsupported when asm string conversion fails instead of
assert.

llvm-svn: 57721
2008-10-17 20:58:01 +00:00
Ted Kremenek a196618ad0 Fixed an elusive caching bug in ExplodedGraph construction when a PostStmtKind was used instead of a PostStoreKind.
llvm-svn: 57719
2008-10-17 20:49:23 +00:00
Ted Kremenek 8b103c65c6 - constify some uses of MemRegion* (MemRegion should be immutable).
- Added new region "SymbolicRegion", which maps symbol values to the region domain.
- Enhanced BasicStore::getFieldLValue() to return a FieldRegion (using SymbolicRegion)
- Added some utility methods to GRState for fetch svals from the store.
- Fixed regression in CheckNSError (we weren't getting the value bound to the parameter)

llvm-svn: 57717
2008-10-17 20:28:54 +00:00
Daniel Dunbar fc1066db81 Remove unneeded EncodingRecordTypes argument to getObjCEncodingForType.
llvm-svn: 57716
2008-10-17 20:21:44 +00:00
Ted Kremenek 5870046c43 "Implement" GRExprEngine::VisitLValue for ObjCPropertyRefExpr. This is only a bandid; we need to properly handle properties by using locv/nonloc objects and specially handling property assignments in the transfer function for BinaryOperator.
llvm-svn: 57693
2008-10-17 17:24:14 +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 b9fd902fdc Change CGDebugInfo::setLocation to just ignore invalid locations. This
simplifies clients.

Also, add assert that RegionStack is empty when the CGDebugInfo is
destroyed.

llvm-svn: 57684
2008-10-17 16:15:48 +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
Zhongxing Xu 27f174214d This patch did the following renaming. There should be no functional changes.
RVal => SVal
LVal => Loc
NonLVal => NonLoc
lval => loc
nonlval => nonloc

llvm-svn: 57671
2008-10-17 05:57:07 +00:00
Daniel Dunbar 3c683f5bf2 NeXT: Use objc_msgSend_fpret for calling functions which return
floating point. This is only correct for x86-32 at the moment.

llvm-svn: 57667
2008-10-17 03:24:53 +00:00
Zhongxing Xu 252fe5c9f1 Get array's lvalue through standard interface.
llvm-svn: 57666
2008-10-17 02:20:14 +00:00
Zhongxing Xu 9fe408057a Return the corresponding MemRegionVal for both rvalue and lvalue of array of
type T.

llvm-svn: 57665
2008-10-17 02:14:42 +00:00
Zhongxing Xu 4e500455c9 Array and struct variables do have lvalue. For example,
struct s {};
void f() {
  int a[10];
  int (*p)[10];
  p = &a;
  (*p)[3] =1;

  struct s d;
  struct s *q;
  q = &d;
}

We return the corresponding MemRegionVal for them.

llvm-svn: 57664
2008-10-17 01:51:27 +00:00
Daniel Dunbar 380827cfa1 Quick patch for PR2784, assert genereting debug info for opaque
structure.
 - I'm not sure yet about the behavior, but this at least prevents the
   crash.

Add some asserts on RegionStack usage.

llvm-svn: 57661
2008-10-17 01:07:56 +00:00
Ted Kremenek 357c63ab37 Remove an untrue assertion: lval::FuncVals can be returned in both rvalue and lvalue contexts.
llvm-svn: 57659
2008-10-17 00:55:33 +00:00
Ted Kremenek 3ad391d800 Remove lval::FieldOffset, lval::ArrayOffset. These will be replaced with regions.
Remove GRExprEngine::getLVal and RValues::MakeVal.
Enhance StoreManager "GetLValue" methods to dispatch for specific kinds of lvalue queries, as opposed to interogating the expression tree (GRExprEngine already does this).

Added FIXMEs.  In particular, we no longer "assume" that a base pointer in a field/array access is null (this logic was removed).  Perhaps we should do this when fetching the lvalue for fields and array elements?

llvm-svn: 57657
2008-10-17 00:51:01 +00:00
Ted Kremenek 12dd55b23d Add transfer function support for ObjCIvarRefExpr.
llvm-svn: 57654
2008-10-17 00:03:18 +00:00
Argyrios Kyrtzidis 2c021aa573 In C++, an empty parameter list indicates a function that takes no parameters.
llvm-svn: 57646
2008-10-16 17:31:08 +00:00
Chris Lattner 3c3e2cc77f Add basic FreeBSD target support, patch by Roman Divacky!
llvm-svn: 57645
2008-10-16 17:04:31 +00:00
Daniel Dunbar 33d29b3eae Add --disable-free flag to clang.
- Disables the freeing of the ASTContext and the TranslationUnit
   after parsing & sema.
 - Primarily for timing the impact on -fsyntax-only timings.

llvm-svn: 57643
2008-10-16 16:54:18 +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
Steve Naroff 9546eee50a Fix <rdar://problem/6239726> Parser rejects: type of property 'list' does not match type of ivar
and
http://llvm.org/bugs/show_bug.cgi?id=2893

llvm-svn: 57640
2008-10-16 14:59:30 +00:00
Daniel Dunbar be947083d2 Speed up NumericLiteralParser::GetIntegerValue.
- Implement fast path when value easily fits in a uint64.
 - ~6x faster, translates to 1-2% on Cocoa.h

llvm-svn: 57632
2008-10-16 07:32:01 +00:00
Daniel Dunbar b1f64426a0 Simplify overflow-on-add check in NumericLiteralParser::GetIntegerValue.
llvm-svn: 57629
2008-10-16 06:39:30 +00:00
Zhongxing Xu 232c7929a2 This is the first step to build a better evaluation model for GRExprEngine. A
new VisitLValue method is added to replace the old VisitLVal. The semantics
model becomes more explicit to separate rvalue evaluation from lvalue
evaluation.  

llvm-svn: 57627
2008-10-16 06:09:51 +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
Argyrios Kyrtzidis 84a4df8c92 Issue a warning when there's an ambiguous function declarator (that could be a direct initializer for a variable defition).
Idea originated from here: http://thread.gmane.org/gmane.comp.gcc.devel/101524

llvm-svn: 57609
2008-10-15 23:21:32 +00:00
Argyrios Kyrtzidis 2e3e756304 Fix this bug:
typedef int f();
struct S {
   f *x; // incorrectly assuming this is function decl, leading to failed assertions.
};

llvm-svn: 57598
2008-10-15 20:23:22 +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
Mon P Wang d05269d13c Added pinsrd, pinsrq, and some other vector intrinsics
llvm-svn: 57563
2008-10-15 06:18:34 +00:00
Ted Kremenek bb7818b666 Enhance dead store checker to not flag preincrements to dead variables where the preincrement is a subexpression, e.g. foo(++x); This can cause false negatives, but will remove a whole class of false positives.
llvm-svn: 57554
2008-10-15 05:23:41 +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
Steve Naroff 8afa98916a Downgrade incompatibilities with objc qualified types (e.g. id <P>) to warnings.
Note: One day, we should consider moving the actual diags to ObjCQualifiedIdTypesAreCompatible(), since it has more information on the actual problem. GCC currently emits slightly more instructive errors for some cases involving protocols. I added a FIXME to the code.

llvm-svn: 57529
2008-10-14 22:18:38 +00:00
Argyrios Kyrtzidis ab3633b626 Revert my previous change, got stupidly confused with my local changes.
llvm-svn: 57514
2008-10-14 18:28:48 +00:00
Argyrios Kyrtzidis 23d5426c67 Fix a call to Sema::LookupDecl that had incorrect parameters.
llvm-svn: 57511
2008-10-14 17:28:09 +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
Daniel Dunbar 5460374cd9 Add Sema implementation of #pragma pack stack.
- Follows the MSVC (original) implementation, including support of
   pack(show) (useful for testing).
 - Implements support for named pack records which gcc seems to
   ignore (or implements incorrectly).
 - Not currently wired to anything, only functionality change is the
   type checking of the pragma.

llvm-svn: 57476
2008-10-14 05:35:18 +00:00
Daniel Dunbar d9eff3d4e4 Lift out ABIInfo abstract base class.
- Currently still lives in CGCall.cpp but is intended to be the
   target specific place for hooking ABI information.
 - Select ABIInfo to use based on Target's prefix and pointer width.

llvm-svn: 57445
2008-10-13 17:02:26 +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 f6a3bda65e make the -rewrite-test a bit more interesting: it now
wraps comments in <i> tags.  Extend rewrite tokens to support
this minimal functionality.

llvm-svn: 57409
2008-10-12 06:09:52 +00:00
Chris Lattner b6aa53b7de start implementing a token rewriter. At this point, it just reads in a file
and lets a client iterate over it. 

llvm-svn: 57407
2008-10-12 05:44:03 +00:00
Chris Lattner b11c3233d8 Change FormTokenWithChars to take the token kind to form, since all clients
were setting a kind and then forming it.  This is just a minor API cleanup, 
no functionality change.

llvm-svn: 57404
2008-10-12 04:51:35 +00:00
Chris Lattner 99e7d23455 When in keep whitespace mode, make sure to return block comments that are
unterminated.

llvm-svn: 57403
2008-10-12 04:19:49 +00:00
Chris Lattner e01e758e11 Change SkipBlockComment and SkipBCPLComment to return true when in
keep comment mode, instead of returning false.  This matches SkipWhitespace.

llvm-svn: 57402
2008-10-12 04:15:42 +00:00
Chris Lattner 4d96344c19 Add a new mode to the lexer which enables it to return all characters,
even whitespace, as tokens from the file.  This is enabled with
L->SetKeepWhitespaceMode(true) on a raw lexer.  In this mode, you too
can use clang as a really complex version of 'cat' with code like this:

  Lexer RawLex(SourceLocation::getFileLoc(SM.getMainFileID(), 0),
               PP.getLangOptions(), File.first, File.second);
  
  RawLex.SetKeepWhitespaceMode(true);
  
  Token RawTok;
  RawLex.LexFromRawLexer(RawTok);
  while (RawTok.isNot(tok::eof)) {
    std::cout << PP.getSpelling(RawTok);
    RawLex.LexFromRawLexer(RawTok);
  }

This will emit exactly the input file, with no canonicalization or other
translation.  Realistic clients actually do something with the tokens of
course :)

llvm-svn: 57401
2008-10-12 04:05:48 +00:00
Chris Lattner 924efdf623 Stop the preprocessor from poking the lexer's private parts.
llvm-svn: 57399
2008-10-12 03:31:33 +00:00
Chris Lattner 097a8b8777 Fix a couple more places that poke KeepCommentMode unnecesarily.
llvm-svn: 57398
2008-10-12 03:27:19 +00:00
Chris Lattner 8637abd333 add a new inKeepCommentMode() accessor to abstract the KeepCommentMode
ivar.

llvm-svn: 57397
2008-10-12 03:22:02 +00:00
Chris Lattner e3f863a388 fix misleading comment.
llvm-svn: 57396
2008-10-12 01:34:51 +00:00
Chris Lattner 7c2e9809b1 Simplify raw mode lexing by treating an unterminate /**/ comment the
same we we do an unterminated string or character literal.  This makes
it so we can guarantee that the lexer never calls into the 
preprocessor (which would be suicide for a raw lexer).

llvm-svn: 57395
2008-10-12 01:31:51 +00:00
Chris Lattner 6b0c5ad096 add a comment.
llvm-svn: 57394
2008-10-12 01:23:27 +00:00
Chris Lattner 50c9050037 Change how raw lexers are handled: instead of creating them and then
using LexRawToken, create one and use LexFromRawLexer.  This avoids
twiddling the RawLexer flag around and simplifies some code (even 
speeding raw lexing up a tiny bit).

This change also improves the token paster to use a Lexer on the stack
instead of new/deleting it. 

llvm-svn: 57393
2008-10-12 01:15:46 +00:00
Chris Lattner 5d3e26a4f6 silence release-assert warnings.
llvm-svn: 57392
2008-10-12 00:31:50 +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
Chris Lattner 87e97ea7b8 improve a comment.
llvm-svn: 57389
2008-10-12 00:23:07 +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
Daniel Dunbar eca513d945 Lift EmitTargetBuiltinExpr out of EmitBuiltinExpr.
llvm-svn: 57335
2008-10-10 00:24:54 +00:00
Dale Johannesen c48814bc98 Adjust calls to APFloat conversion for new interface.
llvm-svn: 57332
2008-10-09 23:02:32 +00:00
Zhongxing Xu cc06b463f5 Check some cases for previous patch. Make the code more robust.
llvm-svn: 57317
2008-10-09 03:19:06 +00:00
Argyrios Kyrtzidis 1207d31952 Fix a bug that crashed clang when parsing this:
class C {
  static const int number = 50;
  static int arr[number];
};

Here's how it worked:
-GetTypeForDeclarator was called from both Sema::ActOnCXXMemberDeclarator and Sema::ActOnDeclarator.
-VariableArrayTypes are not uniqued so two VariableArrayTypes were created with the same DeclRefExpr.
-On exit they both tried to destroy that one DeclRefExpr.

The fix is not to use GetTypeForDeclarator from the Sema::ActOnCXXMemberDeclarator.

llvm-svn: 57313
2008-10-08 22:20:31 +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
Zhongxing Xu d9959aee34 This is the first step to implement a field-sensitive store model. Other things are simplified: no heap shape assumption, no parameter alias assumption, etc.
llvm-svn: 57285
2008-10-08 02:50:44 +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 5ee6292e32 Add #include (introduced by dependence on DeclGroup)
llvm-svn: 57274
2008-10-07 23:08:39 +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
Argyrios Kyrtzidis 8ae3684aa9 In ParseParenDeclarator match "D.setGroupingParens(true);" with another setGroupingParens call after the ')' is parsed.
Fixes this bug:
  int (x)(0); // error, expected function declarator where the '(0)' initializer is

llvm-svn: 57241
2008-10-07 10:21:57 +00:00
Zhongxing Xu de7509f01a Added a function call case that generates sink nodes.
llvm-svn: 57240
2008-10-07 10:06:03 +00:00
Zhongxing Xu f5e7c90c46 Migrate MemRegionManager from StateManager to StoreManager.
llvm-svn: 57225
2008-10-07 01:31:04 +00:00
Ted Kremenek 6553748599 Added prototype serialization code for DeclGroup.
llvm-svn: 57222
2008-10-06 23:49:24 +00:00
Argyrios Kyrtzidis 7b41f721b4 Use getCustomDiagID() instead of specifying the diagnostic in the 'DiagnosticKinds.def' file.
llvm-svn: 57220
2008-10-06 23:16:35 +00:00
Argyrios Kyrtzidis 997d00dd13 Simplify handling of direct initializers by letting Sema::AddInitializerToDecl handle conversions, instead of using Sema::ActOnCXXTypeConstructExpr.
Additional benefit is that diagnostics are the same for both direct-initialization and copy-initialization.

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

llvm-svn: 57219
2008-10-06 23:08:37 +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 3fef35736e Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when processing the Decl of an Objective-C foreach statement.
llvm-svn: 57209
2008-10-06 20:59:48 +00:00
Ted Kremenek a7297be859 Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when processing the Decl of a @catch statement.
llvm-svn: 57208
2008-10-06 20:58:56 +00:00
Ted Kremenek 11b004216c When processing Objective-C foreach statements, first check to see if the statement has a DeclStmt with a single Decl. Afterwards, use DeclStmt::getSolitaryDecl() to access that Decl (thus avoiding an assertion being triggered). These changes remove an unneeded use of ScopedDecl::getNextDeclarator() and DeclStmt::getDecl().
llvm-svn: 57207
2008-10-06 20:58:11 +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 7c2d69f007 Use "unsigned" instead of "int" for i to remove a "comparison between unsigned and signed" warning (potential integer overflow).
llvm-svn: 57201
2008-10-06 20:35:04 +00:00
Anders Carlsson 5f7ee680f8 Add 'x' constraint character.
llvm-svn: 57198
2008-10-06 19:17:39 +00:00
Ted Kremenek dcd6632463 Use the DeclStmt::decl_iterator to get the first decl in a DeclStmt instead of using DeclStmt::getDecl().
llvm-svn: 57196
2008-10-06 18:48:35 +00:00
Ted Kremenek 4db44b62ad Don't use DeclStmt::getDecl(); this will eventually disappear. Just fetch the first decl using the DeclStmt::decl_iterator.
llvm-svn: 57194
2008-10-06 18:43:53 +00:00
Ted Kremenek 704a2505db In EmitDeclStmt: use DeclStmt::const_decl_iterator instead of walking the scoped decl chain.
llvm-svn: 57192
2008-10-06 18:42:27 +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
Ted Kremenek fae8cb0736 Use DeclStmt::decl_iterator instead of using Decl::getDecl(). Soon DeclStmts will wrap group of Decls.
Added FIXME.

llvm-svn: 57189
2008-10-06 18:37:46 +00:00
Argyrios Kyrtzidis 153d967d14 The current semantic process for direct initializers won't work properly for class types.
Add a FIXME until class constructors are supported.

llvm-svn: 57188
2008-10-06 18:37:09 +00:00
Argyrios Kyrtzidis 9a1191c047 Implement support for C++ direct initializers in declarations, e.g. "int x(1);".
This is how this kind of initializers appear in the AST:
-The Init expression of the VarDecl is a functional type construction (of the VarDecl's type).
-The new VarDecl::hasCXXDirectInitializer() returns true.

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

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

llvm-svn: 57178
2008-10-06 17:10:33 +00:00
Chris Lattner 1b0a00a4c9 __CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
won't expand to the builtin.  This fixes rdar://6248329

llvm-svn: 57164
2008-10-06 07:43:09 +00:00
Chris Lattner a97132a9c4 Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue.  Implement this in codegen by moving the code out of CGBuiltin
into EmitConstantExpr.

llvm-svn: 57163
2008-10-06 07:26:43 +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 24355b5240 always try to fold a builtin before emitting it. In the future
it is possible that a builtin could sometimes be folded (e.g. __builtin_clz)
if it's operand is a constant.

llvm-svn: 57161
2008-10-06 06:56:41 +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 a1518b1dfe remove some code where CGBuiltin folds constants, and use tryEvaluate to
do it instead.  We should still handle __builtin_nan etc, but don't yet.
This fixes incorrect evaluation of __builtin_constant_p, a FIXME.

llvm-svn: 57156
2008-10-06 06:09:18 +00:00
Chris Lattner e50e90142e instead of making codegen try to know about all of the builtins to generate
constants for them, just use the constant evaluator to do the job.  This
also fixes crashes on 'unknown constant builtins'.

llvm-svn: 57155
2008-10-06 05:59:01 +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 c43467526d "Enhance" CheckArithmeticConstantExpression to accept ?: with a constant
condition as a constant even if the unevaluated side is a not a constant.
We don't do this when extensions are off, and we emit a warning when this 
happens:

t.c:22:11: warning: expression is not a constant, but is accepted as one by GNU extensions
short t = __builtin_constant_p(5353) ? 42 : somefunc();
          ^                                 ~~~~~~~~~~

suggestions for improvement are welcome.  This is obviously horrible, but
is required for real-world code.

llvm-svn: 57153
2008-10-06 05:42:39 +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
Anders Carlsson 1e18220dc4 Actually use the mmintrin.h header, it's good enough now.
llvm-svn: 57150
2008-10-06 04:49:00 +00:00
Chris Lattner d1d152a613 a more efficient test for __builtin_classify_type
llvm-svn: 57149
2008-10-06 04:48:17 +00:00
Zhongxing Xu a4bbcd302e Fix typos.
llvm-svn: 57146
2008-10-06 03:03:33 +00:00
Anders Carlsson f407150c06 Apparently gcc uses pi64 for the shift intrinsics.
llvm-svn: 57145
2008-10-06 02:07:50 +00:00
Anders Carlsson 83661acf30 Add the 'y' assembler constraint.
llvm-svn: 57144
2008-10-06 00:41:45 +00:00
Argyrios Kyrtzidis e8addf5e04 Allow variadic arguments without named ones for C++, e.g. "void(...);"
llvm-svn: 57143
2008-10-06 00:07:55 +00:00
Anders Carlsson b83162840f Implement support for the const and pure attributes.
llvm-svn: 57142
2008-10-05 23:32:53 +00:00
Argyrios Kyrtzidis 4217c7ec81 A tiny optimization; use isCXXFunctionDeclarator only when it's appropriate.
llvm-svn: 57141
2008-10-05 23:15:41 +00:00
Chris Lattner 09d98f5d8a miscellaneous cleanups
llvm-svn: 57140
2008-10-05 21:50:58 +00:00
Chris Lattner ac7ed9a71a move __FLT_EVAL_METHOD__, __FLT_RADIX__, and __DECIMAL_DIG__ into
target indep code.

llvm-svn: 57139
2008-10-05 21:49:27 +00:00
Chris Lattner c34a35d56f it helps when I save the file before testing and committing.
llvm-svn: 57138
2008-10-05 21:42:17 +00:00
Chris Lattner 6da2f0dd2e suck the rest of the FP macros out of the targets into the PP
llvm-svn: 57137
2008-10-05 21:40:58 +00:00
Argyrios Kyrtzidis 279d9814e5 Add some text from the C++ standard and additional ambiguity resolution tests.
No funcitonality change.

llvm-svn: 57136
2008-10-05 21:10:08 +00:00
Chris Lattner 5cd8351808 start moving fp macros over
llvm-svn: 57134
2008-10-05 20:40:30 +00:00
Chris Lattner 6512a88984 move a bunch more integer sizing out of target-specific code into
target indep code.  

Note that this changes functionality on PIC16: it defines __INT_MAX__
correctly for it, and it changes sizeof(long) to 16-bits (to match
the size of pointer).

llvm-svn: 57132
2008-10-05 20:06:37 +00:00
Argyrios Kyrtzidis 2b1ef227f5 Handle ambiguities between expressions and type-ids that occur inside parentheses, e.g.:
sizeof(int()) -> "int()" is type-id
sizeof(int()+1) -> "int()+1" is expression.

llvm-svn: 57131
2008-10-05 19:56:22 +00:00
Chris Lattner 4ecd753486 eliminate __USER_LABEL_PREFIX__ from the Targets.cpp file, start moving
integer size #defines over to the Preprocessor.

llvm-svn: 57130
2008-10-05 19:44:25 +00:00
Chris Lattner 248d3c4192 gcc no longer defines __block to nothing when blocks aren't enabled.
llvm-svn: 57129
2008-10-05 19:32:52 +00:00
Chris Lattner 1f7e2d5430 rearrange preprocessor macro definitions into language-specific
then target specific.

llvm-svn: 57128
2008-10-05 19:32:22 +00:00
Chris Lattner f37bafc5ca Implement PR2773, support for __USER_LABEL_PREFIX__
llvm-svn: 57127
2008-10-05 19:22:37 +00:00