Commit Graph

6458 Commits

Author SHA1 Message Date
Steve Naroff 4adbe3116e Fix <rdar://problem/6210791> clang ObjC rewriter: @try / @catch block with no @finally does not call objc_exception_try_exit.
Need a couple tweaks to RewriteObjCTryStmt(). Need to deal with implicit finally clauses (to make sure objc_exception_try_exit is called). Also fixed a related bug where we need to generate an implicit @catch else clause (to again make sure objc_exception_try_exit is called).

llvm-svn: 56104
2008-09-11 15:29:03 +00:00
Douglas Gregor 27a907eb8c bool is not an extension in C++
llvm-svn: 56103
2008-09-11 12:06:59 +00:00
Anders Carlsson 9396a89899 Make sure to store the exception in the catch parameter.
llvm-svn: 56102
2008-09-11 09:15:33 +00:00
Anders Carlsson b5130d8588 Make sure to emit the catch parameter as well as the catch body.
llvm-svn: 56101
2008-09-11 08:21:54 +00:00
Anders Carlsson 3a3c2444d6 Fix stupid mistake I made in the exception handling code
llvm-svn: 56100
2008-09-11 06:35:14 +00:00
Argyrios Kyrtzidis 176edb5490 Do implicit conversion to bool for the condition in a do-while statement.
llvm-svn: 56096
2008-09-11 05:16:22 +00:00
Argyrios Kyrtzidis fea38016a9 Fix do-while scoping in C++.
llvm-svn: 56095
2008-09-11 04:46:46 +00:00
Argyrios Kyrtzidis 9321c74bd0 Allow array-to-pointer conversion for rvalues.
llvm-svn: 56094
2008-09-11 04:25:59 +00:00
Argyrios Kyrtzidis 0fdbd6cf25 CXXConditionDeclExpr expression node is an lvalue.
llvm-svn: 56093
2008-09-11 04:22:26 +00:00
Argyrios Kyrtzidis e7092bafc2 LangOptions.C99 should be false in C++.
llvm-svn: 56092
2008-09-11 04:21:06 +00:00
Argyrios Kyrtzidis 504bb844ba Revert r56078, getLang().C99 being true in C++ is a bug that will be fixed.
llvm-svn: 56090
2008-09-11 03:06:46 +00:00
Douglas Gregor e972aa471d Add support for expected-note to Clang's -verify option
llvm-svn: 56089
2008-09-11 02:46:36 +00:00
Daniel Dunbar d3674e6f40 Use ABIArgInfo for decisions about function arguments (not just return
value).
 - Added ABIArgInfo::ByVal (mostly supported) and ABIArgInfo::Expand
   (asserted out).

 - Added classifyArgumentType which currently just uses
   ABIArgInfo::Default or ByVal. This nearly matches old behavior, but
   we now set ByVal in a few situations we may have left it off before
   (on complex, for example).

llvm-svn: 56086
2008-09-11 01:48:57 +00:00
Daniel Dunbar ce05c8eb49 Fix two bugs exposed by array passing assert:
(1) Additional arguments to variadic methods should have default
promotions applied.

(2) Additional arguments to non-variadic methods were allowed.

llvm-svn: 56084
2008-09-11 00:50:25 +00:00
Daniel Dunbar 16211a2cc7 Add ObjCMethodDecl::getSourceRange.
llvm-svn: 56083
2008-09-11 00:47:15 +00:00
Argyrios Kyrtzidis f01fa82423 Fold Parser::ParseTag into Parser::ParseEnumSpecifier, as suggested in this post:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-September/002721.html

llvm-svn: 56081
2008-09-11 00:21:41 +00:00
Daniel Dunbar 83876b4594 Bug fix, apply default argument promotion in message sends for which
no method declaration was found.
 - This was allowing arrays to pass "by value" among other things.

Add assert in CodeGen that arguments cannot have array type.

llvm-svn: 56080
2008-09-11 00:04:36 +00:00
Daniel Dunbar aa9326c7e2 Refactor common Obj-C message send checking code into
CheckMessageArgumentTypes.
 - No functionality change.

llvm-svn: 56079
2008-09-11 00:01:56 +00:00
Argyrios Kyrtzidis 48dea3b9f5 -getLang().C99 is true in C++ too, remove the use of the C99orCXX variable.
-Scoping in C99 works good for C++ too, remove the C++-specific comments.

If someone thinks that the C++-specific comments are necessary for clarification, let me know and I'll put them back on.

llvm-svn: 56078
2008-09-10 23:46:08 +00:00
Argyrios Kyrtzidis 996677e12d In the 'condition.cpp' test case, make sure that condition declarations are local to the statement.
llvm-svn: 56077
2008-09-10 23:34:50 +00:00
Daniel Dunbar b034bc71d4 Add XFAIL test case for:
<rdar://problem/6211479> [sema] array type invalid for Obj-C property

llvm-svn: 56075
2008-09-10 23:11:23 +00:00
Steve Naroff 2752a17a00 More semantic analysis for blocks...
llvm-svn: 56064
2008-09-10 19:17:48 +00:00
Steve Naroff 3ef15b5c2a Sema::ActOnIdentifierExpr(): Lookup block arguments.
llvm-svn: 56063
2008-09-10 18:33:00 +00:00
Argyrios Kyrtzidis eece3fe4fd Add some C++-specific comments in the parsing methods of if/switch/while/for.
llvm-svn: 56060
2008-09-10 17:38:35 +00:00
Daniel Dunbar 573884eaf7 Implement ABIArgType::Coerce support.
- As a test, enable basic usage for some common x86-32 cases. This
    increases our x86-32 compliance (on other targets our compliance
    will just be broken in a different way).

llvm-svn: 56051
2008-09-10 07:04:09 +00:00
Daniel Dunbar b8b4759462 Add CodeGenTypes::GetFunctionType overload for getting the effective
type of a call.

Change NeXT runtime to use this instead of trying to bitcasting
internally (which doesn't respect the ABI).

Fix subtle bug, use of ConvertTypeRecursive instead of ConvertType is
bad inside GetFunctionType.

llvm-svn: 56050
2008-09-10 07:00:50 +00:00
Daniel Dunbar 7a95ca3197 Move FunctionType conversion into CGCall.cpp:
- Added CodeGenTypes::GetFunctionType, taking a CGFunctionInfo.
 - Updated Obj-C runtimes to use this instead of rolling the
   llvm::FunctionType by hand.
 - Killed CodeGenTypes::{ConvertReturnType, DecodeArgumentTypes}.

Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
 - Will move to target sometime soon.

llvm-svn: 56047
2008-09-10 04:01:49 +00:00
Daniel Dunbar a72d4aece6 Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
 - Will move to target sometime soon.

llvm-svn: 56046
2008-09-10 02:41:04 +00:00
Argyrios Kyrtzidis 07052350f0 Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, which represents a 'condition' declaration, e.g: "if (int x=0) {...}".
llvm-svn: 56045
2008-09-10 02:36:38 +00:00
Argyrios Kyrtzidis 7620ee4550 Implement Sema support for the 'condition' part of C++ selection-statements and iteration-statements (if/switch/while/for).
llvm-svn: 56044
2008-09-10 02:17:11 +00:00
Argyrios Kyrtzidis 791dc3cd4e Change line endings: CRLF -> LF
llvm-svn: 56043
2008-09-10 02:14:49 +00:00
Argyrios Kyrtzidis ac1f2abd93 Use Sema::isDeclInScope instead of IdentifierResolver::isDeclInScope.
llvm-svn: 56042
2008-09-10 02:11:07 +00:00
Daniel Dunbar c68897d2c3 Tweak CGCall functions again:
- Realized these functions will eventually need access to more data,
   moved to CodeGenModule. Eventually they should probably live
   together in some other helper class.

llvm-svn: 56039
2008-09-10 00:41:16 +00:00
Daniel Dunbar 76c8eb75b1 Tweak CGCall functions:
- Move actual param attr list creation to
   CodeGenFunction::ConstructParamAttrList.
 - Make ReturnTypeUsesSret static.

llvm-svn: 56038
2008-09-10 00:32:18 +00:00
Daniel Dunbar 81cf67fa0b Add CodeGenFunction::ReturnTypeUsesSret
- Hook so NeXT runtime doesn't depend on ABI.

llvm-svn: 56034
2008-09-09 23:48:28 +00:00
Argyrios Kyrtzidis aa479138ea Add new 'CXXConditionDeclExpr' expression node used for a 'condition' declaration, e.g: "if (int x=0) {...}".
It is a subclass of DeclRefExpr and the main difference is that CXXConditionDeclExpr owns the declaration that it references.

llvm-svn: 56033
2008-09-09 23:47:53 +00:00
Daniel Dunbar 613855c8af Move ABI specific code for functions / calls to CGCall.cpp:
- Factor out EmitFunction{Pro,Epi}log

llvm-svn: 56031
2008-09-09 23:27:19 +00:00
Daniel Dunbar bc915f4025 Factor CodeGenFunction::StartFunction out of GenerateCode and
StartObjCMethod.

llvm-svn: 56030
2008-09-09 23:14:03 +00:00
Argyrios Kyrtzidis 2bdac73591 Make IdentifierResolver::isDeclInScope regard declarations of a parent 'control' scope as part of the current scope.
The 'control' scope is the 'condition' scope of if/switch/while statements and the scope that contains the for-init-statement and 'condition' of a for statement.

e.g:
if (int x = 0 /*'control' scope*/) {
  // x will be regarded as part of this substatement scope.
} else {
  // and as part of this substatement scope too.
}

llvm-svn: 56020
2008-09-09 21:57:58 +00:00
Argyrios Kyrtzidis f4b92e6924 Add a LangOptions member to IdentifierResolver.
Make Sema pass the LangOptions to IdentifierResolver's constructor.

llvm-svn: 56015
2008-09-09 21:32:02 +00:00
Argyrios Kyrtzidis 5b144d5cc4 Add Sema::isDeclInScope which wraps IdentifierResolver::isDeclInScope.
No functionality change.

llvm-svn: 56014
2008-09-09 21:18:04 +00:00
Daniel Dunbar 54bb1933b1 Use a unified return block.
- For the time being this means our emitted code is somewhat worse,
   especially for aggregates. This will be fixed.

llvm-svn: 56013
2008-09-09 21:00:17 +00:00
Argyrios Kyrtzidis f602e427e9 Fix test case.
llvm-svn: 56012
2008-09-09 20:56:12 +00:00
Daniel Dunbar 0bc8e86d6e Move EmitAggregate{Copy,Clear} into CodeGenFunction.
- No functionality change.

llvm-svn: 56010
2008-09-09 20:49:46 +00:00
Argyrios Kyrtzidis 2b4072fe55 Implement parser support for the 'condition' part of C++ selection-statements and iteration-statements (if/switch/while/for).
Add new 'ActOnCXXConditionDeclarationExpr' action, called when the 'condition' is a declaration instead of an expression.

llvm-svn: 56007
2008-09-09 20:38:47 +00:00
Steve Naroff fac18fe2ee Fix <rdar://problem/6197841> try, finally with no catch stops the exception from being propagated
llvm-svn: 56004
2008-09-09 19:59:12 +00:00
Argyrios Kyrtzidis 4f11d78fcc IdentifierResolver cleanup. Make some methods out-of-line.
llvm-svn: 56002
2008-09-09 19:28:27 +00:00
Anders Carlsson 4f1c7c3773 Check in half-assed implementation of @try/@catch.
llvm-svn: 55994
2008-09-09 17:59:25 +00:00
Anders Carlsson e005aa13f1 Simple @throw support.
llvm-svn: 55991
2008-09-09 16:16:55 +00:00
Steve Naroff 44cfcb6fb1 Tweak implementation for allowing ObjC builtin type redefinitions.
- Replace string comparisons with pre-defined idents.
- Avoid calling isBuiltinObjCType() to avoid two checks. 
- Remove isBuiltinObjCType(), since it was only used in Sema::MergeTypeDefDecl().
- Have Sema::MergeTypeDefDecl() set the new type.

This is a moidified version of an patch by David Chisnall.

llvm-svn: 55990
2008-09-09 14:32:20 +00:00
Steve Naroff 58d5ea7ac9 Simplify typesAreBlockCompatible().
llvm-svn: 55989
2008-09-09 13:47:19 +00:00
Argyrios Kyrtzidis 03849a2c5b Update VC++ project files.
llvm-svn: 55986
2008-09-09 11:39:45 +00:00
Anders Carlsson 9ff22483fd Add types and functions related to exceptions.
llvm-svn: 55984
2008-09-09 10:10:21 +00:00
Anders Carlsson 1963b0c38f Move handling of @try and @throw to the runtime class.
llvm-svn: 55983
2008-09-09 10:04:29 +00:00
Mon P Wang 919d1b3ff3 Added SSE4.1 packusdw
llvm-svn: 55978
2008-09-09 02:49:09 +00:00
Daniel Dunbar 41cf9dedc6 Change CodeGen to emit calls using (RValue,Type) list:
- Add CodeGenFunction::EmitAnyExprToTemp
   o Like EmitAnyExpr, but emits aggregates to a temporary location if
     none is available. Seems like this should be simpler (even aside
     from using first class aggregates).

 - Killed CodeGenFunction::EmitCallArg (just append the pair)

 - Conversion of RValues to actual call arguments is now isolated in
   CodeGenFunction::EmitCall.

llvm-svn: 55970
2008-09-09 01:06:48 +00:00
Mon P Wang b1851271a4 Added SSE41 pmovsx pmovzx intrinsics
llvm-svn: 55967
2008-09-09 00:19:01 +00:00
Daniel Dunbar 0beedc1684 Fix a number of issues w.r.t. emission of global for functions and
aliases.
 - Attributes specific to a definition are only set when the
   definition is seen.
 - Alias generation is delayed until the end of the module; necessary
   since the alias may reference forward.
 - Fixes: PR2743, <rdr://6140807&6094512>
 - Improves: <rdr://6095112> (added XFAIL)

Also, print module on verification failures.

llvm-svn: 55966
2008-09-08 23:44:31 +00:00
Daniel Dunbar 3d7c90b8ec Refactor parameter attribute handling:
- Add CGCall.h for dealing with ABI issues related to calls.
  - Add CGFunctionInfo and CGCallInfo for capturing ABI relevant
    information about functions and calls.
  - Isolate LLVM parameter attribute handling inside CGCall.cpp

llvm-svn: 55963
2008-09-08 21:33:45 +00:00
Daniel Dunbar 1e6ff5f37f Add ThreadSpecified bit to Decl.
- Patch from Kevin Tew.

llvm-svn: 55940
2008-09-08 20:05:47 +00:00
Daniel Dunbar 47be094138 Add missing RUN line
llvm-svn: 55934
2008-09-08 18:01:15 +00:00
Argyrios Kyrtzidis dee8291a14 Support C++'s declaration-statement.
llvm-svn: 55888
2008-09-07 18:58:01 +00:00
Nico Weber b0920374ca rename libclangSEMA to libclangSema
llvm-svn: 55887
2008-09-07 17:09:06 +00:00
Nuno Lopes fc8c680b89 skip test if llvm-gcc is requires but not found on the path.
someone with llvm-gcc installed please test if the Codegen/function-attributes.c test isn't skip in your system. thanks.

llvm-svn: 55871
2008-09-06 16:42:14 +00:00
Daniel Dunbar a46348c51b Key LLVM types for TagDecl's off of the clang Type, since there is now
a many-to-one relationship between TagDecl's and types.

llvm-svn: 55870
2008-09-06 02:26:43 +00:00
Eli Friedman 6565d45b5f Per PR2773, define __USER_LABEL_PREFIX__ for x86-32 Linux and Windows.
If you're on some other platform, the correct definition for this macro 
would be appreciated; to find the correct definition, just run the 
following command:

echo | gcc -dM -E - | grep USER_LABEL_PREFIX

llvm-svn: 55869
2008-09-06 01:37:51 +00:00
Steve Naroff 8de9c3affe More type checking for blocks. Still incomplete (will hopefully finish up this weekend).
llvm-svn: 55862
2008-09-05 22:11:13 +00:00
Ted Kremenek 6ddf53e4bd Add comment back that Argiris pointed out that I mistakenly removed (the comments below it were stale, so I accidently removed the whole thing).
llvm-svn: 55841
2008-09-05 17:39:33 +00:00
Ted Kremenek 2147570258 Change struct forward declarations and definitions to use unique RecordDecls, as opposed to creating a single RecordDecl and reusing it.
This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet).

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

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

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

    typedef struct { ... } x;  

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

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

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

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

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

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

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

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

llvm-svn: 55839
2008-09-05 17:16:31 +00:00
Argyrios Kyrtzidis 2545aeb710 Support "typeof unary-expression" (GNU C++ extension).
llvm-svn: 55833
2008-09-05 11:26:19 +00:00
Argyrios Kyrtzidis 971dd236f0 Set different header search paths for the Windows platform.
llvm-svn: 55832
2008-09-05 09:41:20 +00:00
Argyrios Kyrtzidis 624cab87dc Add header search paths for Mingw32 (GCC version 4).
llvm-svn: 55830
2008-09-05 09:03:53 +00:00
Argyrios Kyrtzidis 91c3f526dc Line endings: CRLF -> LF
llvm-svn: 55829
2008-09-05 08:53:53 +00:00
Daniel Dunbar 7de5e3b111 Fix placement of const on a number of X86 builtins.
llvm-svn: 55827
2008-09-05 05:56:16 +00:00
Daniel Dunbar 0335024c4a Test case for previous commit (Workaround gcc bug causing crash on our
preprocessed outputs)

llvm-svn: 55826
2008-09-05 03:23:51 +00:00
Daniel Dunbar 98e0e535bd Workaround gcc bug causing crash on our preprocessed outputs.
- gcc is not happy if we start a preprocessed file with
#line 1 "XXX" 1
 - Workaround by making sure file starts with a simple #line change.

Also, factored WriteLineInfo out.

Also, fixed bug where FileType was not being correctly updated.

llvm-svn: 55825
2008-09-05 03:22:57 +00:00
Ted Kremenek cb36325316 Remove stale comments.
llvm-svn: 55822
2008-09-05 01:38:34 +00:00
Ted Kremenek 47923c7e59 Remove "NextDecl" from RecordDecl. This change touches many files that where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration.
The motivation behind this change is that chaining the RecordDecls is simply unnecessary.  Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType.

llvm-svn: 55821
2008-09-05 01:34:33 +00:00
Daniel Dunbar 2ffee610da Set sext/zext on function result.
- <rdar://problem/6156739>

llvm-svn: 55815
2008-09-05 00:57:45 +00:00
Ted Kremenek c92c134563 Patch to scan-build by Jordan Breeding:
- Don't remove $BaseDir; may be unsafe
- Always create HTML directory with parents

llvm-svn: 55813
2008-09-04 23:56:36 +00:00
Daniel Dunbar 449a339ffd Set function attributes (sext, zext, etc.) on Objective-C methods.
llvm-svn: 55812
2008-09-04 23:41:35 +00:00
Ted Kremenek f82dab1a7a Updated checker build.
llvm-svn: 55810
2008-09-04 23:13:30 +00:00
Daniel Dunbar 98982ef954 Fix unintended use of doxygen comment strings.
llvm-svn: 55805
2008-09-04 21:54:53 +00:00
Daniel Dunbar 56b936ba32 Fix infinite loop in for ... in code generation.
- Patch via Thomas Clement, thanks!

llvm-svn: 55804
2008-09-04 21:54:37 +00:00
Ted Kremenek 72c06446bb Added test case for the dead stores checker that was originally an FP reported in PR 2763.
llvm-svn: 55801
2008-09-04 21:52:52 +00:00
Ted Kremenek b0746ca90b Fix CFG construction bug:
- Within for loops, 'continue' should jump to a basic block containing the
  increment code

llvm-svn: 55800
2008-09-04 21:48:47 +00:00
Daniel Dunbar 217836527c Fix FindSpecRefs to be Python 2.4 compatible and get the SVN revision
in a more obvious fashion.

llvm-svn: 55791
2008-09-04 20:26:14 +00:00
Daniel Dunbar c7dfbfd544 Prevent invalid warnings about incomplete implementations for methods
which are inherited from base clases or protocols.

llvm-svn: 55790
2008-09-04 20:01:15 +00:00
Nuno Lopes 92c4bc8873 fix running tests with valgrind (there were a lot of bogus failures and warnings)
currently clang passes all tests under valgrind with the leak checker disabled :P (and fails most otherwise)

llvm-svn: 55782
2008-09-04 18:33:57 +00:00
Ted Kremenek e9354c6029 scan-build:
- Only set the environment variable 'CXX' if the user specifies --use-c++.
- Fix regression when setting LDPLUSPLUS: add a 'which' to determine the location of g++.  This regression was pointed out by Jordan Breeding!

llvm-svn: 55780
2008-09-04 17:52:41 +00:00
Steve Naroff 4b19157ba9 Touchup CheckSingleAssignmentConstraints() and CheckCompareOperands() to check for block pointers.
Added a couple FIXME's wrt PointLikeType. If the author reads this, it would be great to get some background on this class (thanks in advance).

llvm-svn: 55778
2008-09-04 16:56:14 +00:00
Steve Naroff 991e99d980 Fix a handful of typos (closure->block) to avoid confusion.
llvm-svn: 55768
2008-09-04 15:31:07 +00:00
Steve Naroff 081c7422b2 Add type checking for blocks.
llvm-svn: 55767
2008-09-04 15:10:53 +00:00
Mon P Wang 74b3207e67 Generate error if we try to implicit cast between different address
spaces

llvm-svn: 55765
2008-09-04 08:38:01 +00:00
Daniel Dunbar c01f56c8de Add some Objective-C code generation tests.
- Note that these don't really test anything other than that code
   generation doesn't fail or crash. Better than nothing though!

llvm-svn: 55761
2008-09-04 04:36:23 +00:00
Daniel Dunbar 7050c55415 NeXT: Emit lazy reference to Protocol class for forward protocol
references (to match gcc).

llvm-svn: 55760
2008-09-04 04:33:15 +00:00
Daniel Dunbar f2cf6d16e6 Avoid superfluous errors regarding variable-length arrays (casts).
llvm-svn: 55759
2008-09-04 03:43:08 +00:00
Daniel Dunbar 8cde00a510 Implement codegen of aggregates as lvalues in binary expressions,
e.g. "(a = b).somefield".

llvm-svn: 55758
2008-09-04 03:20:13 +00:00
Ted Kremenek 82aa5aba93 Updated checker build.
llvm-svn: 55757
2008-09-04 02:36:37 +00:00
Ted Kremenek 3cbb3b2920 Capture 'uname' and 'gcc -v' output to .info files.
llvm-svn: 55752
2008-09-04 00:41:45 +00:00
Daniel Dunbar 0f99912868 Update TestRunner to not report failure for XFAIL tests
llvm-svn: 55751
2008-09-04 00:30:11 +00:00
Ted Kremenek 5047f71f3e Output "ANALYZE:" diagnostics to STDOUT instead of STDERR.
llvm-svn: 55750
2008-09-04 00:02:50 +00:00
Ted Kremenek 370de84b50 ccc-analyzer:
- Capture the STDERR output of 'clang' to a file for use with crash reporting.

llvm-svn: 55749
2008-09-04 00:02:34 +00:00
Daniel Dunbar 0ff4192f3a Set register storage class correctly for function parameters.
- PR2730

llvm-svn: 55739
2008-09-03 21:54:21 +00:00
Ted Kremenek b44763456c Following gcc's behavior, only enable trigraphs if '-trigraphs' or '-ansi' is
specified, or -std is set to a conforming mode.

llvm-svn: 55738
2008-09-03 21:22:16 +00:00
Daniel Dunbar 20e5db77a3 Add two test cases for builtins (mostly related to object size
builtins).

llvm-svn: 55736
2008-09-03 21:17:21 +00:00
Daniel Dunbar b0d34c8e4a Add __builtin_object_size support.
- Currently CodeGen always returns a conservative value for this (-1
   or 0 depending on the context).

llvm-svn: 55735
2008-09-03 21:13:56 +00:00
Daniel Dunbar bec27e2c8b Modify object size checking builtins to lower to libc calls.
llvm-svn: 55721
2008-09-03 20:28:50 +00:00
Steve Naroff c540d66940 Add semantic analysis for "blocks".
Highlights...

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

Next steps...

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

llvm-svn: 55710
2008-09-03 18:15:37 +00:00
Ted Kremenek 3060d98ad0 Fix 80 col violations.
llvm-svn: 55707
2008-09-03 18:03:35 +00:00
Ted Kremenek f4fd23f635 Added --use-cxx option to scan-build.
llvm-svn: 55706
2008-09-03 17:59:35 +00:00
Daniel Dunbar de1ec9cdcd Improve type-checking of ?: for Objective-C types.
- Allow any Objective-C object types to devolve to type id in a ?:
   expression. This matches gcc behavior more closely.

llvm-svn: 55705
2008-09-03 17:53:25 +00:00
Ted Kremenek 1b9e10390b Store: (static analyzer)
- Change definition of store::Region and store::Binding (once again) to make
  them real classes that just wrap pointers. This makes them more strictly
  typed, and allows specific implementations of Regions/Bindings to just
  subclass them.
- minor renamings to RegionExtent and its subclasses
- added a bunch of doxygen comments

StoreManager: (static analyzer)
- added 'iterBindings', an iteration method for iterating over the bindings of a
  store. It that takes a callback object (acting like a poor man's closure).
- added 'getRVal' version for store::Binding. Will potentially phase the other
  versions of GetRVal in StoreManager out.
- reimplemented 'getBindings' to be non-virtual and to use 'iterBindings'

BasicStoreManager: (static analyzer)
- implemented 'iterBindings' for BasicStoreManager

llvm-svn: 55688
2008-09-03 03:06:11 +00:00
Daniel Dunbar ef89086c12 Restore Objective-C dot-syntax access of methods.
- Now also searches for correct setter method.
 - There are still some issues regarding validation of the setter
   method and access of read-only properties.

llvm-svn: 55686
2008-09-03 01:05:41 +00:00
Daniel Dunbar c5d330400f Fix ObjCPropertRefExpr to be able to encode all the information for
uses which refer to methods not properties.
 - Not yet wired in Sema.

llvm-svn: 55681
2008-09-03 00:27:26 +00:00
Ted Kremenek ceb3ca94b7 When creating CXXRecordDecls and RecordDecls within ActOnTag, hook up the new [CXX]RecordDecl with the RecordDecl chain.
llvm-svn: 55652
2008-09-02 21:26:19 +00:00
Ted Kremenek 52baf50f62 RecordDecl:
- Remove method 'isForwardDecl'; this functionality is already provided by
  'isDefinition()'
- Move method definitions to be co-located with other RecordDecl methods.

llvm-svn: 55649
2008-09-02 21:12:32 +00:00
Ted Kremenek 478f6baf0d RecordDecl serialization:
- Don't serialize out the NextDeclarator field.  It is unused and deprecated.
- Serialize out the NextDecl pointer.

llvm-svn: 55644
2008-09-02 20:42:52 +00:00
Ted Kremenek 318d78f50b RecordDecl:
- Added method 'isForwardDeclaration', a predicate method that returns true
  if a RecordDecl represents a forward declaration.
- Added method 'getDefinitionDecl', a query method that returns a pointer to
  the RecordDecl that provides the actual definition of a struct/union.

llvm-svn: 55642
2008-09-02 20:25:22 +00:00
Ted Kremenek 123f025b29 CXXRecordDecl and RecordDecl:
- Change constructor and create methods to accept a CXXRecordDecl* (RecordDecl*)
  instead of a ScopedDecl* for PrevDecl.  This causes the type checking
  to be more tight and doesn't break any code.
  
RecordDecl:

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

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

llvm-svn: 55640
2008-09-02 20:13:32 +00:00
Steve Naroff c84e8b779e - Implement __block.
- Replace FIXME in Preprocessor::HandleIdentifier() with a check that avoids diagnosing extension tokens that originate from macro definitions.

llvm-svn: 55639
2008-09-02 18:50:17 +00:00
Steve Naroff d450bffcf1 Pull code from last commit. will put back soon.
llvm-svn: 55637
2008-09-02 18:04:36 +00:00
Steve Naroff 95bffc74da Implement block pseudo-storage class modifiers (__block, __byref).
llvm-svn: 55635
2008-09-02 15:20:19 +00:00
Nuno Lopes d63db4063a recognise .s/.S file extensions. add default value for CCC_LANGUAGES
llvm-svn: 55630
2008-09-02 10:27:37 +00:00
Nuno Lopes dd30e2c677 add the other test case for completeness and to avoid regressions in the future
llvm-svn: 55629
2008-09-02 10:10:14 +00:00
Eli Friedman de09ce03c4 Fix for PR2747: allow pointer->int casts with a null base; these are
offset-of-like expressions.

llvm-svn: 55627
2008-09-02 09:37:00 +00:00
Eli Friedman ee29c9c2fc Fix for PR2750; don't check for an 'e' in the trash after the token.
Note that this isn't really a complete fix; I think there are other 
potential overrun situations.  I don't really know what the best 
systematic fix is, though.

llvm-svn: 55622
2008-09-02 05:29:22 +00:00
Eli Friedman 7c9ba6a1e3 An extremely hacky version of transparent_union support; it isn't
anywhere near correct in terms of missing cases and missing 
diagnostics, but it's good enough to handle the uses in the 
Linux system headers, which are currently a constant pain for compiling 
applications on Linux.

llvm-svn: 55621
2008-09-02 05:19:23 +00:00
Eli Friedman e7175d83dc Make sure to take the unqualified versions of the canonical types for
type-checking pointer subtraction; if the canonical types aren't used,
the qualifiers won't always get stripped off correctly.

llvm-svn: 55620
2008-09-02 05:09:35 +00:00
Zhongxing Xu a1035df101 Fit the comments into 80 columns.
llvm-svn: 55619
2008-09-02 03:29:51 +00:00
Ted Kremenek fd8ede33db Updated checker build.
llvm-svn: 55618
2008-09-01 22:51:34 +00:00
Nuno Lopes 4e630967fc readd test as it passes correctly. nice, but weird
llvm-svn: 55615
2008-09-01 22:28:55 +00:00
Eli Friedman 4c55e2c4ed Backing out r55607 due to logic errors and test regression.
I'll try to come up with a correct fix for the testcase sometime soon.

llvm-svn: 55614
2008-09-01 22:08:17 +00:00
Ted Kremenek 8af7e8b650 Updated checker build.
llvm-svn: 55613
2008-09-01 20:13:28 +00:00
Ted Kremenek c4f6d90ba1 Tidy up sema processing of attribute "nonull":
- warn about nonnull being applied to functions with no pointer arguments
- continue processing argument list in the attribute when we encounter a non-pointer parameter being marked as nonnull
- when no argument list is specified, only mark pointers as nonnull.  This fixes PR 2732 and radar 6188814.

llvm-svn: 55610
2008-09-01 19:57:52 +00:00
Nuno Lopes 2c5208c59f fix one more this-is-not-a-constant error. test included
llvm-svn: 55609
2008-09-01 18:42:41 +00:00
Nuno Lopes feac637074 make CheckArithmeticConstantExpression() aware of &foo and pointers
llvm-svn: 55607
2008-09-01 14:47:06 +00:00
Nuno Lopes f380a0de07 codegen constant data as such. add QualType::isConstant()
llvm-svn: 55603
2008-09-01 11:33:04 +00:00
Ted Kremenek afe2a9fe77 Patch by Kovarththanan Rajaratnam!
"This minor patch adds markup of string literals with a red colour."

llvm-svn: 55589
2008-08-31 16:37:56 +00:00
Anders Carlsson 3f35a266da Handle mutation while enumerating correctly. Fix some bugs.
llvm-svn: 55583
2008-08-31 04:05:03 +00:00
Anders Carlsson 756585963b Initial support for CodeGen of for ... in statements.
llvm-svn: 55580
2008-08-31 02:33:12 +00:00
Anders Carlsson 2e744e8aa6 Stub out CodeGenFunction::EmitObjCForCollectionStmt.
Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it.

llvm-svn: 55573
2008-08-30 19:51:14 +00:00
Anders Carlsson d89ba7d058 Add code to create the fast enumeration state type
llvm-svn: 55572
2008-08-30 19:34:46 +00:00
Daniel Dunbar e0a09432cc Temporarily disable some tests which due to dot-syntax
access of methods.

llvm-svn: 55569
2008-08-30 16:22:34 +00:00
Anders Carlsson 35ba57dad7 Fix indentation on files in CodeGen and Sema.
llvm-svn: 55568
2008-08-30 16:18:10 +00:00
Anders Carlsson 7e1e57103e Simplify some calls to Builder.CreateCall
llvm-svn: 55567
2008-08-30 16:17:45 +00:00
Daniel Dunbar 4b8c6db927 Add Objective-C property setter support.
- Change Obj-C runtime message API, drop the ObjCMessageExpr arg in
   favor of just result type and selector. Necessary so it can be
   reused in situations where we don't want to cons up an
   ObjCMessageExpr.
 - Update aggregate binary assignment to know about special property
   ref lvalues.
 - Add CodeGenFunction::EmitCallArg overload which takes an already
   emitted rvalue.

Add CodeGenFunction::StoreComplexIntoAddr.

Disabled logic in Sema for parsing Objective-C dot-syntax that
accesses methods. This code does not search in the correct order and
the AST node has no way of properly representing its results.

Updated StmtDumper to print a bit more information about
ObjCPropertyRefExprs.

llvm-svn: 55561
2008-08-30 05:35:15 +00:00
Daniel Dunbar c722b8565c Refactor handling of calls:
- Added CodeGenFunction::EmitCall which just takes the callee, return
   type, and a list of (Value*,QualType) pairs.
 - Added CodeGenFunction::EmitCallArg which handles emitting code for
   a call argument and turning it into an appropriate
   (Value*,QualType) pair.
 - Changed Objective-C runtime interface so that the actual emission
   of arguments for message sends is (once again) done in the code to
   emit a message send.

No intended functionality change, this is prep work for better ABI
support and for Objective-C property setter support.

llvm-svn: 55560
2008-08-30 03:02:31 +00:00
Daniel Dunbar c62cf79290 Add newline at end of file.
llvm-svn: 55559
2008-08-30 02:06:22 +00:00
Daniel Dunbar 2e5225818a Improve ccc:
- Support environment variable CCC_LANGUAGES to control which
   languages clang is invoked on. If unset clang is invoked for all
   languages, otherwise CCC_LANGUAGES should be a comma separated list
   of the languages (as accepted by -x) for which clang should be
   invoked. Useful for only building C and Objective-C parts of a
   project with clang, for example.

 - Add environment variable CCC_FALLBACK. If set and non-empty then
   ccc will try and compile using the regular compiler if compilation
   with clang fails.

 - A few other tweaks to add options, flush stdout, recognize .mm as
   objective-c++, and infer languages for compile+link style
   invocations.

llvm-svn: 55547
2008-08-29 21:03:27 +00:00
Daniel Dunbar a799807dea Downgrade a number of FIXME asserts to ErrorUnsupported.
- Notably VLAs

llvm-svn: 55544
2008-08-29 17:28:43 +00:00
Nico Weber febdb0bc46 fix a comment that was forgotten in r54071
llvm-svn: 55543
2008-08-29 17:24:46 +00:00
Nico Weber fa5856a936 minor cleanup
llvm-svn: 55538
2008-08-29 17:02:23 +00:00
Zhongxing Xu 4c23963de8 Added LLVM comment header.
llvm-svn: 55537
2008-08-29 15:09:12 +00:00
Zhongxing Xu c1bd3a5f8b Migrate the rest symbolic analysis stuff to BasicConstraintManager.
llvm-svn: 55536
2008-08-29 14:52:36 +00:00
Daniel Dunbar 9e22c0d317 Add special "property reference" CodeGen::LValue type for emitting
Objective-C property references.
 - This handles property references "more correctly" but setters still
   don't work.

llvm-svn: 55534
2008-08-29 08:11:39 +00:00
Ted Kremenek 5043680da4 Remove dead method.
llvm-svn: 55526
2008-08-29 03:55:31 +00:00
Daniel Dunbar 9a0ea046db Add newline to end of file.
llvm-svn: 55525
2008-08-29 03:45:59 +00:00
Daniel Dunbar a545f466e8 Add utils/FindSpecRefs, Python script for generating specification
references HTML page.

llvm-svn: 55524
2008-08-29 01:07:08 +00:00
Ted Kremenek c83e755d78 Added "getBindings" and "BindingAsString" to GRStateManager and StoreManager.
Migrated CFRefCount.cpp to use getBindings and BindingsAsString instead of
making assumptions about the Store (removed dependence on GRState::vb_iterator).

llvm-svn: 55522
2008-08-29 00:47:32 +00:00
Ted Kremenek f011e10d6a Remove BasicStore.h from Xcode project.
llvm-svn: 55520
2008-08-28 23:40:08 +00:00
Ted Kremenek 5909059524 Remove BasicStore.h (migrated function prototype for CreateBasicStore() to Store.h)
llvm-svn: 55519
2008-08-28 23:39:42 +00:00
Ted Kremenek 4360f3b553 Remove Regions.cpp from VS project file.
llvm-svn: 55517
2008-08-28 23:34:54 +00:00
Ted Kremenek 85a401ea15 Removed Regions.[h,cpp] from the Xcode project.
llvm-svn: 55516
2008-08-28 23:33:36 +00:00
Ted Kremenek 75d2ac956f Remove Regions.h and Regions.cpp, since we are now using an even more abstract representation of "memory regions" in the static analyzer.
llvm-svn: 55515
2008-08-28 23:32:43 +00:00
Ted Kremenek e91874f71f Make store "Regions" and "Bindings" more abstract instead of concrete variants.
Their precise semantics will be implemented by a specific StoreManager.

Use function pointer to create the StoreManager in GRStateManager.  This matches how we create ConstraintsManager.

llvm-svn: 55514
2008-08-28 23:31:31 +00:00
Daniel Dunbar 5888e603c3 Allow 'make TESTDIRS=Sema' in test/ directory for only running a
subset of tests.

llvm-svn: 55513
2008-08-28 23:28:16 +00:00
Ted Kremenek c400511a55 Updated analyzer build.
llvm-svn: 55505
2008-08-28 22:15:34 +00:00
Ted Kremenek 1bb387e056 Use explicit variable instead of $?
llvm-svn: 55501
2008-08-28 21:28:55 +00:00
Steve Naroff 0ac012835f Add parser/action support for block literal expressions.
Parser support for blocks is almost complete...just need to add support for the __block() storage class qualifier.

llvm-svn: 55495
2008-08-28 19:20:44 +00:00
Ted Kremenek f1b9209a34 Fixed analyzer caching bug involving the transfer function for loads.
llvm-svn: 55494
2008-08-28 18:43:46 +00:00
Daniel Dunbar 8c8616377d Fix isIntegerConstantExpr eval of __builtin_offsetof to return result
with correct width.
 - PR2728.

Also, fix PR2727 test case.

llvm-svn: 55493
2008-08-28 18:42:20 +00:00
Ted Kremenek 2eb49f295d Always print out the function we're analyzing.
llvm-svn: 55488
2008-08-28 18:34:41 +00:00
Ted Kremenek b45e6b91c6 Fixed analyzer caching bug in DeclStmt.
llvm-svn: 55487
2008-08-28 18:34:26 +00:00
Daniel Dunbar 3e1888e8bd Fix double-free error with sizeof applied to VLA types.
- PR2727.

Also, fix warning in CodeGenTypes for new BlockPointer type.

llvm-svn: 55479
2008-08-28 18:02:04 +00:00
Steve Naroff 94e3ab20b7 Fix Parser::ParseDeclaratorInternal(): add langopts test when recognizing blocks.
llvm-svn: 55468
2008-08-28 10:07:06 +00:00
Argyrios Kyrtzidis 41f1dbc66d Fix compilation error on MSVC.
llvm-svn: 55465
2008-08-28 07:45:57 +00:00
Ted Kremenek 803e7e1e47 Ubigraph visualization: represent cached nodes with a different style.
llvm-svn: 55463
2008-08-28 05:02:09 +00:00
Ted Kremenek de8008a130 Enhance ubiviz to support vertex styles.
llvm-svn: 55462
2008-08-28 05:01:37 +00:00
Daniel Dunbar 4932b36f54 NeXT: Emit mostly-correct property type encoding.
- Added ASTContext::getObjCEncodingForPropertyDecl.

llvm-svn: 55461
2008-08-28 04:38:10 +00:00
Ted Kremenek 266ec3fb4e Automatically execute ubiviz.
Cleanup ubigraph files when don't drawing the graphs.

llvm-svn: 55459
2008-08-28 03:54:51 +00:00
Ted Kremenek c1cf430051 Update checker build.
llvm-svn: 55455
2008-08-28 01:42:51 +00:00
Ted Kremenek 1a42278a19 Fix regression: immediately terminate ccc-analyzer when gcc reports an error.
llvm-svn: 55452
2008-08-28 01:18:44 +00:00
Ted Kremenek 3a01c1eb8e Update Xcode project.
llvm-svn: 55449
2008-08-27 23:13:22 +00:00
Ted Kremenek b5ef37f28e Make the destructor of ConstraintManager virtual.
llvm-svn: 55448
2008-08-27 23:13:01 +00:00
Ted Kremenek 5bc033b934 Update checker build.
llvm-svn: 55447
2008-08-27 22:49:55 +00:00
Ted Kremenek c8288b408a Ubigraph-rendered ExplodedGraphs now have arrows and are oriented downward.
llvm-svn: 55446
2008-08-27 22:46:55 +00:00
Ted Kremenek d461d7ad7e Added Ubigraph visualization for the static analyzer (this is pretty alpha quality).
llvm-svn: 55442
2008-08-27 22:31:43 +00:00
Ted Kremenek 5cc989dad1 Update Xcode project.
llvm-svn: 55441
2008-08-27 22:31:20 +00:00
Ted Kremenek 7b62806272 Remove regression where the analyzer was not called.
llvm-svn: 55440
2008-08-27 22:30:34 +00:00
Steve Naroff ec33ed9ced First wave of changes to support "blocks" (an extension to C).
This commit adds the declaration syntax (and associated type).

llvm-svn: 55417
2008-08-27 16:04:49 +00:00
Zhongxing Xu f71b5f39bb Refactor Assume logic into a separate class ConstraintManager.
llvm-svn: 55412
2008-08-27 14:03:33 +00:00
Daniel Dunbar 55310df79c Initial support for Obj-C dot-syntax for getters.
llvm-svn: 55410
2008-08-27 06:57:25 +00:00
Daniel Dunbar e0a673e60f Update test case (we were missing a warning here)
llvm-svn: 55408
2008-08-27 05:41:04 +00:00
Daniel Dunbar 4684f37333 Add synthesized property methods to protocols and categories in Sema.
- It is not clear that this is the right approach, but this is at
   least consistent with how interfaces are handled.

 - This means NeXT now emits the correct metadata for properties in
   protocols.

 - This currently introduces a spurious warning involving inherited
   properties in protocols or categories; however, it also fixes some
   situations where we were failing to emit a warning. I will scrub
   this code tomorrow and fix this issue as well as number of other
   missed warnings / error situations that appear to exist.

llvm-svn: 55407
2008-08-27 05:40:03 +00:00
Daniel Dunbar c4adb70968 Fix "possibly uninitialized" warning.
llvm-svn: 55406
2008-08-27 05:13:46 +00:00
Daniel Dunbar eb1f9a2566 NeXT: Refactor protocol method metadata emission.
Also, fix category protocol list metadata.

llvm-svn: 55405
2008-08-27 02:31:56 +00:00
Daniel Dunbar e7ecbc539e Add addPropertyMethods implementations for
ObjC{Category,Protocol}Decl.
 - No functionality change.

llvm-svn: 55404
2008-08-27 02:09:39 +00:00
Ted Kremenek 912c28444f Added "Auditor" interface for auditing the construction of ExplodedGraphs.
llvm-svn: 55403
2008-08-27 01:56:11 +00:00
Ted Kremenek 6f7c419308 Make implementation of ExplodedNodeImpl::addPredecessor out-of-line.
llvm-svn: 55402
2008-08-27 01:27:52 +00:00