Commit Graph

6522 Commits

Author SHA1 Message Date
Douglas Gregor 30776d419f Template instantiation for IndirectGotoStmt. Now my life is complete.
llvm-svn: 71917
2009-05-16 00:20:29 +00:00
Douglas Gregor 2a2d00f041 Template instantiation for switch statements
llvm-svn: 71916
2009-05-15 23:57:33 +00:00
Fariborz Jahanian 6404c420e5 Removed superfluous code.
llvm-svn: 71909
2009-05-15 23:19:35 +00:00
Fariborz Jahanian 4447e17c03 Early support for __format__attribute on blocks.
Work in progress...

llvm-svn: 71908
2009-05-15 23:15:03 +00:00
Anders Carlsson 789e2cce54 Basic support for member exprs where the base expr type is dependent.
llvm-svn: 71907
2009-05-15 23:10:19 +00:00
Daniel Dunbar 9a017d7fcf Classes with "+load" methods need to go in the non-lazy class list (or
else the method will not be found by the runtime at class load time).

llvm-svn: 71904
2009-05-15 22:33:15 +00:00
Douglas Gregor ca60224bbe Template instantiation for break and continue statements.
llvm-svn: 71903
2009-05-15 22:32:39 +00:00
Douglas Gregor 5d13868263 Template instantiation for "for" loops
llvm-svn: 71901
2009-05-15 22:12:32 +00:00
Douglas Gregor 3daa82dba0 Template instantiation for do-while statements.
llvm-svn: 71899
2009-05-15 21:56:04 +00:00
Daniel Dunbar 19573e7d29 Factor code for adding module-level class lists into separate method.
- No functionality change.

llvm-svn: 71898
2009-05-15 21:48:48 +00:00
Mike Stump 76b824c388 Fixup parsing for (throw,throw) and __extension__ throw 1.
llvm-svn: 71897
2009-05-15 21:47:08 +00:00
Douglas Gregor 8a930c3b73 Template instantiation for WhileStmt and CXXConditionDeclExpr.
llvm-svn: 71896
2009-05-15 21:45:53 +00:00
Douglas Gregor 8d2ad873e7 Make sure that we use the canonical type for the names of instantiated
constructors and destructors. This is a requirement of
DeclarationNameTable::getCXXSpecialName that we weren't assert()'ing,
so it should have been caught much earlier :(

Big thanks to Anders for the test case.

llvm-svn: 71895
2009-05-15 21:18:27 +00:00
Fariborz Jahanian 6802ed9968 improved on diagnosing misplacement of sentinel attributes.
No change in functionality.

llvm-svn: 71894
2009-05-15 21:18:04 +00:00
Douglas Gregor 3f17b47c7e Allow instantiation of NULL expressions and statements
llvm-svn: 71889
2009-05-15 20:47:12 +00:00
Fariborz Jahanian 0aa5c4565d This patch finishes off the sentinel attribute handling for
blocks and function pointers.

llvm-svn: 71888
2009-05-15 20:33:25 +00:00
Anders Carlsson 2cf4387931 I take it back, InstantiateExpr does not check for null.
llvm-svn: 71887
2009-05-15 20:29:28 +00:00
Anders Carlsson 1f911dce22 Instantiation support for 'this'
llvm-svn: 71886
2009-05-15 20:26:03 +00:00
Anders Carlsson 50574f5303 No need to null check the expr, Sema::SemaRef.InstantiateExpr handles all that.
llvm-svn: 71885
2009-05-15 20:10:48 +00:00
Douglas Gregor 1ec5e9f025 Make sure that the type associated with a class template is dependent.
llvm-svn: 71878
2009-05-15 19:11:46 +00:00
Douglas Gregor 9d73cabf22 Template instantiation for "if" statements. Also:
- Skip semantic analysis of the "if" condition if it is type-dependent.
  - Added the location of the "else" keyword into IfStmt, so that we can
    provide it for type-checking after template instantiation.

llvm-svn: 71875
2009-05-15 18:53:42 +00:00
Anders Carlsson 37604a0984 A C++ member function always has either weak linkage (if it's inline or defined inline) or strong linkage (other cases).
llvm-svn: 71873
2009-05-15 18:35:39 +00:00
Douglas Gregor 82049e6bdd Move statement instantiation into its own file. No functionality change
llvm-svn: 71872
2009-05-15 18:22:25 +00:00
Douglas Gregor 12c3a5cedf When word-wrapping, be more defensive about a ridiculously small number of columns. Fixes <rdar://problem/6892178>
llvm-svn: 71870
2009-05-15 18:05:24 +00:00
Douglas Gregor 67da0d97e6 Call ActOnStartOfFunctionDecl/ActOnFinishFunctionBody when
instantiating the definition of a function from a template.

llvm-svn: 71869
2009-05-15 17:59:04 +00:00
Anders Carlsson f6e9ece507 Name mangling for class template specializations and template arguments.
llvm-svn: 71861
2009-05-15 16:09:15 +00:00
Chris Lattner 4579b76ff6 Fix processing of -Ufoo to not inject "#undef foo 1" into the predefines
buffer.  This caused exciting nonsense like this:

$ clang t.c -fsyntax-only -UMACRO
In file included from <built-in>:104:
<command line>:1:14: warning: extra tokens at end of #undef directive [-Wextra-tokens]
#undef MACRO 1
             ^
             //
1 diagnostic generated.

rdar://6891800

llvm-svn: 71860
2009-05-15 16:08:43 +00:00
Ted Kremenek 3281977dbb Fix crash when deriving the enclosing summary of a method whose first selector slot has a null IdentifierInfo*. This happens when analyzing Growl.
llvm-svn: 71857
2009-05-15 15:49:00 +00:00
Ted Kremenek 4785e41c12 Remove extra whitespace character in string literal. Purely cosmetic.
llvm-svn: 71847
2009-05-15 06:02:08 +00:00
Ted Kremenek 3d436c7b35 Use dyn_cast instead of cast to allow our assumptions to be safely wrong.
llvm-svn: 71843
2009-05-15 05:34:49 +00:00
Ted Kremenek 608a6176a1 Cleanup internal checks bug reporting, allowing intermediate diagnostics to be generated for bad argument warnings, bad branches, etc.
llvm-svn: 71838
2009-05-15 05:25:09 +00:00
Ted Kremenek 73777059f0 BugReporter (extensive diagnostics): Do not include the range of target '}'
llvm-svn: 71832
2009-05-15 02:46:13 +00:00
Ted Kremenek 18665fe3c9 PathDiagnosticLocation::asRange(): for a PathDiagnosticLocation, the range of a DeclStmt is only the decl, not
the decl + initializer.

llvm-svn: 71831
2009-05-15 02:05:25 +00:00
Ted Kremenek cfe7d02b2c BugReporter (extensive diagnostics): Add control-flow piece to '}' in
loop body when generating 'Looping back to the head of the loop'
diagnostics.

llvm-svn: 71829
2009-05-15 01:50:15 +00:00
Anders Carlsson 19b8c4ce36 Instantiate return statements.
llvm-svn: 71825
2009-05-15 00:48:27 +00:00
Mike Stump 2c002929b2 Fixup debug information for the location information for __block
variables.  For this to work, the backend needs to handle more complex
forms for locations.

A typical utterance would be:

        %forwarding = getelementptr %0* %use_by_ref, i32 0, i32 1               ; <i8**> [#uses=1]
        %0 = load i8** %forwarding              ; <i8*> [#uses=1]
        %1 = bitcast i8* %0 to %0*              ; <%0*> [#uses=1]
        %x = getelementptr %0* %1, i32 0, i32 4         ; <i32*> [#uses=1]
        %2 = bitcast i32* %x to { }*            ; <{ }*> [#uses=1]
        call void @llvm.dbg.declare({ }* %2, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable to { }*))

Presently when selection finds something it doesn't understand, it
just avoids generating any information, which is safe, just
incomplete.  Radar 6867696

llvm-svn: 71824
2009-05-15 00:29:54 +00:00
Anders Carlsson 03b0dd5913 Add NullStmt::Clone and use it
llvm-svn: 71823
2009-05-15 00:21:21 +00:00
Anders Carlsson f42de874b3 Instantiate goto and label statements. (Very useful, I know)
llvm-svn: 71822
2009-05-15 00:15:26 +00:00
Douglas Gregor 923feac4e2 Implement template instantiation for DeclStmt
llvm-svn: 71818
2009-05-15 00:01:03 +00:00
Fariborz Jahanian 0c20bddc41 Don't warn if result/argument type of an implemented
method is a qualified id which conforms to the matching type
of its method declaration.

llvm-svn: 71817
2009-05-14 23:52:54 +00:00
Douglas Gregor 0555e5fbce Template instantiation for the NULL statement. Lame, I know
llvm-svn: 71816
2009-05-14 23:40:54 +00:00
Douglas Gregor b4850465b7 Introduce basic support for instantiating the definitions of member
functions of class templates. Only compound statements and expression
statements are currently implemented.

llvm-svn: 71814
2009-05-14 23:26:13 +00:00
Anders Carlsson 0a7c01ff2b Check that the function being overridden is virtual.
llvm-svn: 71802
2009-05-14 22:15:41 +00:00
Anders Carlsson e0dd1d57b3 Improvements to the FunctionDecl getters/setters.
llvm-svn: 71800
2009-05-14 21:46:00 +00:00
Douglas Gregor 372565211e Introduce a stack of instantiation scopes that are used to store the mapping from variable declarations that occur within templates to their instantiated counterparts
llvm-svn: 71799
2009-05-14 21:44:34 +00:00
Ted Kremenek f9fa3cb78a Fix <rdar://problem/6859457> [NSData dataWithBytesNoCopy] does not return a retained object.
llvm-svn: 71797
2009-05-14 21:29:16 +00:00
Douglas Gregor 24c332b140 Link FunctionDecls instantiated from the member functions of a class
template to the FunctionDecls from which they were instantiated. This
is a necessary first step to support instantiation of the definitions
of such functions, but by itself does essentially nothing.

llvm-svn: 71792
2009-05-14 21:06:31 +00:00
Fariborz Jahanian 3133a2f08c updated comments.
llvm-svn: 71790
2009-05-14 20:57:28 +00:00
Fariborz Jahanian 6607b21156 Adds recognition of sentinel attribute on block declarations.
llvm-svn: 71788
2009-05-14 20:53:39 +00:00
Anders Carlsson 8fb0b8a2cb Better diagnostics for covariance when checking overriding return types.
llvm-svn: 71786
2009-05-14 19:52:19 +00:00
Sebastian Redl 4d226cf45f When there are any member new operators, global versions aren't looked up at all.
llvm-svn: 71780
2009-05-14 18:11:41 +00:00
Fariborz Jahanian 4a528035fd Diagnose missing sentinel argument on a funciton call
with sentinel attribute.

llvm-svn: 71778
2009-05-14 18:00:00 +00:00
Daniel Dunbar 0a2171ccd5 Skip the asm prefix when storing the name in block info.
- Otherwise we emit internal names with embedded '\01' characters,
   which confuses some tools.

 - Ideally all the code which wants to get a "display name" for the
   given function should follow one code path, but this should be a
   monotonic improvement for now.

llvm-svn: 71774
2009-05-14 16:42:16 +00:00
Douglas Gregor d9034f0b89 In C++, warn when something previously declared as a "struct" is later
declared as a "class", or vice-versa. This warning is under the
control of -Wmismatched-tags, which is off by default.

llvm-svn: 71773
2009-05-14 16:41:31 +00:00
Mike Stump 31f099c8c2 Enhance debug information for block literals. Radar 6867696
llvm-svn: 71763
2009-05-14 02:03:51 +00:00
Daniel Dunbar 7911002bf9 We need to specify the "linkage name" to the subprogram now that we
emit the correct "display name". I suspect we need more work here, see
FIXME for example.

llvm-svn: 71761
2009-05-14 01:45:24 +00:00
Anders Carlsson f2a2e338ff Add return type checking for overriding virtual functions. We currently don't check covariance but that's next.
llvm-svn: 71759
2009-05-14 01:09:04 +00:00
Douglas Gregor 2ec748cd5a Implement explicit instantiations of member classes of class templates, e.g.,
template<typename T>
  struct X {
    struct Inner;
  };

  template struct X<int>::Inner;

This change is larger than it looks because it also fixes some
a problem with nested-name-specifiers and tags. We weren't requiring
the DeclContext associated with the scope specifier of a tag to be
complete. Therefore, when looking for something like "struct
X<int>::Inner", we weren't instantiating X<int>. 

This, naturally, uncovered a problem with member pointers, where we
were requiring the left-hand side of a member pointer access
expression (e.g., x->*) to be a complete type. However, this is wrong:
the semantics of this expression does not require a complete type (EDG
agrees).

Stuart vouched for me. Blame him.

llvm-svn: 71756
2009-05-14 00:28:11 +00:00
Fariborz Jahanian 9e87721d47 Look for and diagnose missing sentinel argument on message
dispatch arguments which have sentinel attribute.

llvm-svn: 71737
2009-05-13 23:20:50 +00:00
Daniel Dunbar 0beb7894c4 Make sure not to include the LLVM asm prefix in function names for
debug info.

llvm-svn: 71736
2009-05-13 23:08:57 +00:00
Anders Carlsson e39935527e Use an iterator type for found_decls_begin/found_decls_end.
llvm-svn: 71721
2009-05-13 21:22:06 +00:00
Anders Carlsson 49d216db15 Add a new, more advanced CheckDerivedToBaseConversion that takes custom diagnostic IDs.
llvm-svn: 71720
2009-05-13 21:11:42 +00:00
Ted Kremenek 3b204e4c2e Add some basic type checking for attributes ns_returns_retained and
cf_returns_retained. Currently this attribute can now be applied to any
Objective-C method or C function that returns a pointer or Objective-C object
type.

Modify the tablegen definition of diagnostic 'warn_attribute_wrong_decl_type' to
expect that the diagnostics infrastructure will add quotes around the attribute
name when appropriate. Alonq with this change, I modified the places where this
warning is issued to passed the attribute's IdentifierInfo* instead of having a
hard-coded C constant string.

llvm-svn: 71718
2009-05-13 21:07:32 +00:00
Douglas Gregor bbbb02d463 Explicit instantiations of templates now instantiate the definitions
of class members (recursively). Only member classes are actually
instantiated; the instantiation logic for member functions and
variables are just stubs.

llvm-svn: 71713
2009-05-13 20:28:22 +00:00
Anders Carlsson 5879fbd933 Disable access control by default. It can be enabled with the -faccess-control option. When we have better support for it, we can enable it by default again.
llvm-svn: 71706
2009-05-13 19:49:53 +00:00
Ted Kremenek bae777254a Enhance diagnostics value tracking logic for null dereferences and uninitialized values.
llvm-svn: 71700
2009-05-13 19:16:35 +00:00
Daniel Dunbar 8a35ef85d8 Driver: Emit an unsupported error on -iframework.
llvm-svn: 71698
2009-05-13 19:05:04 +00:00
Daniel Dunbar ffdb8439d7 ABI handling: Fix invalid assertion, it is possible for a valid
coercion to be specified which truncates padding bits. It would be
nice to still have the assert, but we don't have any API call for the
unpadding size of a type yet.

llvm-svn: 71695
2009-05-13 18:54:26 +00:00
Douglas Gregor f61eca93c0 Improve the semantic checking for explicit instantiations of
templates. In particular:
  - An explicit instantiation can follow an implicit instantiation (we
  were improperly diagnosing this as an error, previously).
  - In C++0x, an explicit instantiation that follows an explicit
  specialization of the same template specialization is ignored. In
  C++98, we just emit an extension warning.
  - In C++0x, an explicit instantiation must be in a namespace
  enclosing the original template. C++98 has no such requirement.

Also, fixed a longstanding FIXME regarding the integral type that is
used for the size of a constant array type when it is being instantiated.

llvm-svn: 71689
2009-05-13 18:28:20 +00:00
Ted Kremenek 5801f65a52 Fix crasher reported in PR 4209 caused by an invalid summary
generation when EvalObjCMessageExpr() did not resolve the
ObjCInterfaceDecl* for a receiver when the receiver's symbolic value
wasn't being explicitly tracked.

llvm-svn: 71685
2009-05-13 18:16:01 +00:00
Fariborz Jahanian 027b886a99 Some early declarations to support sentinel attribute on
message dispatches (and function calls later). No change in
functionality.

llvm-svn: 71683
2009-05-13 18:09:35 +00:00
Fariborz Jahanian 1880136520 Removed 4-letter :) word in comment.
Used simple array for Selector build.

llvm-svn: 71674
2009-05-13 16:19:02 +00:00
Ted Kremenek 4554f9b134 Fix <rdar://problem/6880975> [format string] Assertion failed: (Arg < NumArgs && "Arg access out of range!").
For format string checking, only check the type of the format
specifier for non-vararg functions.

llvm-svn: 71672
2009-05-13 16:06:05 +00:00
Ted Kremenek 051a03d698 Fix crasher in CFRefCount.cpp reported by Nikita Zhuk due to recently added autorelease tracking.
llvm-svn: 71647
2009-05-13 07:12:33 +00:00
Chris Lattner ff96dd0301 Fix rdar://6880630 - # in _Pragma does not start a preprocessor directive.
llvm-svn: 71643
2009-05-13 06:10:29 +00:00
Chris Lattner b70f3de625 Fix rdar://6880951 by rejecting vectors of vectors.
It seems dubious to me that isIntegerType() returns true for
vectors of integers, but not complex integers.  This should 
probably be rethought, I'll file a bugzilla.

llvm-svn: 71640
2009-05-13 05:13:44 +00:00
Chris Lattner df24298b40 reject use of the GNU _Decimal32 extension with a diagnostic, not an abort.
rdar://6880104

llvm-svn: 71639
2009-05-13 05:02:08 +00:00
Chris Lattner 5868c03191 eli correctly points out that this code is dead, just rip it out for
now until someone does it right

llvm-svn: 71638
2009-05-13 04:52:12 +00:00
Chris Lattner afde259240 implement __sync_synchronize and __sync_lock_release,
rdar://6880573

llvm-svn: 71637
2009-05-13 04:46:13 +00:00
Chris Lattner 94578cba76 add support for __sync_nand_and_fetch and __sync_fetch_and_nand,
rdar://6880573

llvm-svn: 71636
2009-05-13 04:37:52 +00:00
Chris Lattner e2df3f9fe5 Fix rdar://6880874 - [sema] crash on array types with different index sizes
llvm-svn: 71634
2009-05-13 04:12:56 +00:00
Chris Lattner 851eb927d7 Fix rdar://6881069, a crash on a form of vector_size that we
don't support.  While it would be nice to support this eventually,
this form is not common at all (just seen in gcc testsuite) and
it might be better to model vector_size as a type attribute anyway.
For now just emit a nice error on it.

llvm-svn: 71633
2009-05-13 04:00:12 +00:00
Chris Lattner 46813bbfa2 Fix rdar://6880259 - invalid function name in block call (__NSConcreteGlobalBlock2)
by using the appropriate CGM interface instead of directly creating a global.

llvm-svn: 71617
2009-05-13 02:50:56 +00:00
Chris Lattner f160b5f9e1 When we expect two arguments but have zero, make sure to add
two empty arguments.  Also, add an assert so that this bug
manifests as an assertion failure, not a valgrind problem.

This fixes rdar://6880648 - [cpp] crash in ArgNeedsPreexpansion

llvm-svn: 71616
2009-05-13 00:55:26 +00:00
Douglas Gregor a1f4997368 Semantic analysis for explicit instantiation of class templates. We
still aren't instantiating the definitions of class template members,
and core issues 275 and 259 will both affect the checking that we do
for explicit instantiations (but are not yet implemented).

llvm-svn: 71613
2009-05-13 00:25:59 +00:00
Douglas Gregor 1b57ff32a8 Implement parsing for explicit instantiations of class templates, e.g.,
template class X<int>;

This also cleans up the propagation of template information through
declaration parsing, which is used to improve some diagnostics.

llvm-svn: 71608
2009-05-12 23:25:50 +00:00
Chris Lattner d98e7cf7c1 improve the diagnostic for uses of the GCC "global variable in a register" extension.
This implements rdar://6880449 - improve diagnostic for usage of "global register variable" GCC extension

llvm-svn: 71599
2009-05-12 21:44:00 +00:00
Douglas Gregor 36312bb5ee Parser::ParseDeclarationOrFunctionDefinition no longer needs to accept
template parameters.

llvm-svn: 71598
2009-05-12 21:43:46 +00:00
Fariborz Jahanian 2bd617c46c Method attributes may only be specified on method
declarations.

llvm-svn: 71597
2009-05-12 21:36:23 +00:00
Douglas Gregor 2399628cea Refactor the parsing of declarations so that template declarations can
parse just a single declaration and provide a reasonable diagnostic
when the "only one declarator per template declaration" rule is
violated. This eliminates some ugly, ugly hackery where we used to
require thatn the layout of a DeclGroup of a single element be the
same as the layout of a single declaration.

llvm-svn: 71596
2009-05-12 21:31:51 +00:00
Chris Lattner e541ea3a61 implement l-value codegen of comma expr
llvm-svn: 71595
2009-05-12 21:28:12 +00:00
Chris Lattner e0be0dfced push GlobalDecl through enough of the CodeGenModule interfaces
to allow us to support generation of deferred ctors/dtors.
It looks like codegen isn't emitting a call to the dtor in 
member-functions.cpp:test2, but when it does, its body should
get emitted.

llvm-svn: 71594
2009-05-12 21:21:08 +00:00
Chris Lattner d035ebda2f add an initial stab at emitting deferred c++ inline functions. This handles static
functions and methods declared inline, but not ctors/dtors or methods not declared
inline (apparently my previous patch wasn't good enough).

llvm-svn: 71591
2009-05-12 21:02:27 +00:00
Chris Lattner eb7466d24a cleanups, no functionality change.
llvm-svn: 71590
2009-05-12 20:58:15 +00:00
Chris Lattner da7a0977d6 Method who have definitions in structs/classes are semantically inline.
Per the FIXME, it might be interesting to track whether the inline keyword
was also used on the method, but for now we don't do this.  Testcase pending.

llvm-svn: 71589
2009-05-12 20:55:07 +00:00
Chris Lattner bea5b622be static methods don't get this pointers.
llvm-svn: 71586
2009-05-12 20:27:19 +00:00
Chris Lattner e7834115eb revert my previous patch, I committed the wrong file.
llvm-svn: 71585
2009-05-12 20:26:52 +00:00
Chris Lattner cd74ffa3eb static methods don't get this pointers.
llvm-svn: 71583
2009-05-12 20:21:39 +00:00
Ted Kremenek 1272f706ca Fix: <rdar://problem/6320065> false positive - init method returns an object owned by caller
Now 'init' methods are treated by the retain/release checker as
claiming their receiver and allocating a new object.

llvm-svn: 71579
2009-05-12 20:06:54 +00:00
Fariborz Jahanian e4128642a7 Fixed typos, used DenseSet for keeping track of
selectors which need use Nonfrgile API for
message dispatch.

llvm-svn: 71578
2009-05-12 20:06:41 +00:00
Chris Lattner b61448d490 accept "#pragma clang foo" where we accept "#pragma GCC foo".
llvm-svn: 71572
2009-05-12 18:21:11 +00:00
Fariborz Jahanian 0f44d81a4c Patch to implement ivar synthesis of properties declared in protocols
only and used in class imllementations (objc2 Nonfragile ABI specific).

llvm-svn: 71571
2009-05-12 18:14:29 +00:00
Daniel Dunbar bbfd054746 Darwin x86-32 ABI: Now that structure passing is farther along, we
don't need special treatment for unions.

llvm-svn: 71559
2009-05-12 17:00:20 +00:00
Daniel Dunbar 203e2e8dd8 x86-64 ABI: clang incorrectly passes union { long double, float } in
register.
 - Merge algorithm was returning MEMORY as it should.

llvm-svn: 71556
2009-05-12 15:22:40 +00:00
Zhongxing Xu 08a2ede018 Add logic for invalidating array region to CFRefCount.cpp. When invalidating
array region, set its default value to conjured symbol. When retrieving its
element, create new region value symbol for the element.

Also fix some 80 columns violations.

llvm-svn: 71548
2009-05-12 10:10:00 +00:00
Ted Kremenek 95d181936a Fix <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects
This was accomplished by having	'isTypeRef' recursively walk the typedef stack.

llvm-svn: 71538
2009-05-12 04:53:03 +00:00
Douglas Gregor 45fe0364aa Make precompiled headers work with -E. When we're only preprocessing
(with -E), we turn the PCH include into an implicit include of the
file from which the PCH file was generated.

llvm-svn: 71534
2009-05-12 01:31:05 +00:00
Douglas Gregor d002c7bc58 Encapsulate template arguments lists in a new class,
TemplateArgumentList. This avoids the need to pass around
pointer/length pairs of template arguments lists, and will eventually
make it easier to introduce member templates and variadic templates.

llvm-svn: 71517
2009-05-11 23:53:27 +00:00
Ted Kremenek 5fb7847fbf BugReport::getEndPath() - Only add a Stmt's range to the constructed PathDiagnosticEventPiece if the BugReport contained no explicit ranges.
llvm-svn: 71516
2009-05-11 23:50:59 +00:00
Anders Carlsson bd7d11f770 Factor code that's common to EmitCXXMemberCallExpr and EmitCXXConstructorCall out into a EmitCXXMemberCall function.
llvm-svn: 71514
2009-05-11 23:37:08 +00:00
Daniel Dunbar 097353cbb5 Darwin x86-32: Multi-dimensional arrays were not handled correctly,
spotted by Eli!

llvm-svn: 71490
2009-05-11 23:01:34 +00:00
Anders Carlsson 3881170898 Friend declarations are only valid inside class definitions.
llvm-svn: 71489
2009-05-11 22:55:49 +00:00
Ted Kremenek 97f75f8bda When stripping element regions for invalidating region values, treat FieldRegions and ObjCIvarRegions as "base" regions in addition to VarRegions.
llvm-svn: 71488
2009-05-11 22:55:17 +00:00
Anders Carlsson 076fc36419 Fix test case by always setting the type spec type, even for friend decls.
llvm-svn: 71486
2009-05-11 22:42:30 +00:00
Anders Carlsson f83c9faa2f Add an ActOnFriendDecl and call it for friend class decls.
llvm-svn: 71482
2009-05-11 22:27:47 +00:00
Anders Carlsson 22e3784c79 For friend class decls, always use TK_Reference so we'll try to look up existing class decls first.
llvm-svn: 71481
2009-05-11 22:25:03 +00:00
Ted Kremenek 2ee73b86c0 EdgeBuilder: DeclStmts and BinaryOperators are not the enclosing location context when they are used as initialization code for loops.
llvm-svn: 71480
2009-05-11 22:19:32 +00:00
Ted Kremenek c0b879b4a7 EdgeBuilder::cleanUpLocation() should used the PathDiagnosticLocation constructor for a single point, not a range.
llvm-svn: 71477
2009-05-11 21:42:34 +00:00
Douglas Gregor c9f9b86732 Implement the notions of the "current instantiation" and "unknown
specialization" within a C++ template, and permit name lookup into the
current instantiation. For example, given:

  template<typename T, typename U>
  struct X {
    typedef T type;

    X* x1;  // current instantiation
    X<T, U> *x2; // current instantiation
    X<U, T> *x3; // not current instantiation
    ::X<type, U> *x4; // current instantiation
    X<typename X<type, U>::type, U>: *x5; // current instantiation
  };

llvm-svn: 71471
2009-05-11 19:58:34 +00:00
Ted Kremenek c14b594b14 BugReporter (extensive diagnostics): Add EdgeBuilder::cleanUpLocation for canonicalization locations and use this in both popLocation and rawAddEdge.
llvm-svn: 71470
2009-05-11 19:50:47 +00:00
Ted Kremenek d4dacb05cc Add ParentMap:getParentIgnoreParens().
llvm-svn: 71469
2009-05-11 19:49:27 +00:00
Fariborz Jahanian 5d5ed2d800 Patch to allow Nonfragile ABI to use 32-bit style legacy
message dispage API for all but a few messages. This is 
a runtime performance improvement and there is not meant
to be a functional change.

llvm-svn: 71467
2009-05-11 19:25:47 +00:00
Daniel Dunbar 2ce6b3f91c Darwin x86_32: Treat records with unnamed bit-fields as "empty".
llvm-svn: 71461
2009-05-11 18:58:49 +00:00
Ted Kremenek d0e3ab2196 Fix regression reported in <rdar://problem/6866843>. The analyzer should extend the lifetime of an object stored to a container.
llvm-svn: 71452
2009-05-11 18:30:24 +00:00
Chris Lattner 9fea944f26 More improvements for GNU runtime objc EH, patch by David Chisnall!
llvm-svn: 71451
2009-05-11 18:16:28 +00:00
Ted Kremenek dc7853cd98 Fix a bug found by Thomas Clement where 'return [[[NSString alloc] init] autorelease]' would emit a false 'too many overreleases' error.
llvm-svn: 71432
2009-05-11 15:26:06 +00:00
Zhongxing Xu 52091db11f TypedRegion is a too general assumption. Usually we only want to invalidate
the VarRegion as a super region of an ElementRegion.

llvm-svn: 71431
2009-05-11 14:28:14 +00:00
Zhongxing Xu c012656266 When retrieving an ElementRegion, if its super region is a StringRegion,
retrieve the string value.

llvm-svn: 71430
2009-05-11 14:23:36 +00:00
Zhongxing Xu bf938d3160 Fix a bug that leads to infinite loop. Set the correct element type to
ElementRegion.

llvm-svn: 71428
2009-05-11 12:48:56 +00:00
Douglas Gregor 862d28e59c With the introduction of nullptr, a template argument that refers to a declaration can now be NULL. Use cast_or_null appropriately
llvm-svn: 71412
2009-05-10 23:27:08 +00:00
Douglas Gregor 5e4e50c280 The canonical declaration of a NULL declaration is NULL
llvm-svn: 71409
2009-05-10 22:59:12 +00:00
Douglas Gregor e362cea568 Implement the semantics of the injected-class-name within a class
template. The injected-class-name is either a type or a template,
depending on whether a '<' follows it. As a type, the
injected-class-name's template argument list contains its template
parameters in declaration order.

As part of this, add logic for canonicalizing declarations, and be
sure to canonicalize declarations used in template names and template
arguments. 

A TagType is dependent if the declaration it references is dependent.

I'm not happy about the rather complicated protocol needed to use
ASTContext::getTemplateSpecializationType.

llvm-svn: 71408
2009-05-10 22:57:19 +00:00
Sebastian Redl 576fd424df Implement C++0x nullptr.
llvm-svn: 71405
2009-05-10 18:38:11 +00:00
Ted Kremenek 1f8e4346fa Add special warning about returning a retained object where a GC'ed object is expected.
llvm-svn: 71397
2009-05-10 16:52:15 +00:00
Ted Kremenek dee56e37fc retain/release checker: Flag a warning for non-owned objects returned
where an owned one is expected.  Also add preliminary checking for
returning a positive retain count object in GC mode where an owned GC
object is expected.

llvm-svn: 71388
2009-05-10 06:25:57 +00:00
Ted Kremenek 3978f7972d analyzer:
- Improve -autorelease diagnostics.
- Improve VLA diagnostics.
- Use "short description" for bug when outputting to TextDiagnostics

llvm-svn: 71383
2009-05-10 05:11:21 +00:00
Zhongxing Xu c9c3dab491 When casting VarRegion, if the var type is aggregate type and the cast-to
pointee type is scalar type, create element region regardless with the sizes
of types.

llvm-svn: 71360
2009-05-09 15:34:29 +00:00
Zhongxing Xu 4131114d99 Remove the rest TypedViewRegion processing code. There should be no
TypedViewRegion usage in region store.

llvm-svn: 71359
2009-05-09 15:23:42 +00:00
Zhongxing Xu d6daef9165 When evaluating pointer arithmetic, if the base location is a symbolic region,
convert it to the first element region.
Also do not assume the array region is typed.

llvm-svn: 71358
2009-05-09 15:18:12 +00:00
Zhongxing Xu b18d7cab0c Do not create a TypedViewRegion when the base struct region is a symbolic
region. In the future we may set the cast-to type as the same time. But for
now, we simply leave it as it is.

llvm-svn: 71357
2009-05-09 13:36:16 +00:00
Zhongxing Xu 7c3826484e Do not layer a TypedViewRegion when casting symbolic or alloca regions.
Modify getLValueElement accordingly. Now we don't require base region 
to be a typed region. Do not create TypedViewRegion when base region is 
symbolic or alloca region. We can do so because each element region has 
its type information.

llvm-svn: 71355
2009-05-09 13:20:07 +00:00
Zhongxing Xu e3e94bbf19 Remove the case for casting to compatible type in
RegionStoreManager::CastRegion(). This case should be subsumed by others.

llvm-svn: 71353
2009-05-09 10:03:08 +00:00
Duncan Sands c76fe8b611 Correct for renaming PaddedSize -> AllocSize in
LLVM.

llvm-svn: 71350
2009-05-09 07:08:47 +00:00
Zhongxing Xu 91e2ab496f Rename:
SymbolRegionRValue => SymbolRegionValue
  SymExpr::RegionRValue => SymExpr::RegionValueKind

llvm-svn: 71322
2009-05-09 04:08:27 +00:00
Zhongxing Xu 34d04b3ca9 As discussed with Ted, rename TypedRegion::getObjectType() to
TypedRegion::getValueType().

llvm-svn: 71321
2009-05-09 03:57:34 +00:00
Ted Kremenek 669604cded Add back attribute string lookup for 'ns_returns_retained' and
'cf_returns_retained'.

llvm-svn: 71311
2009-05-09 03:08:29 +00:00
Ted Kremenek c2de72776c Add back analyzer support for ns_returns_retained and cf_returns_retained.
llvm-svn: 71309
2009-05-09 02:58:13 +00:00
Ted Kremenek 9ecdfaf66d Add back Parse/Sema support for attributes cf_returns_retained and
ns_returns_retained, but do not include the other ownership attributes
we previously had.

llvm-svn: 71308
2009-05-09 02:44:38 +00:00
Ted Kremenek 2d0ff62a0d It lives! The retain/release checker now tracks objects that are sent
'autorelease'.

llvm-svn: 71307
2009-05-09 01:50:57 +00:00
Zhongxing Xu 8038f7b30f rename: MemRegion:
RValueType => ObjectType
 LValueType => LocationType

No functionality change.

llvm-svn: 71304
2009-05-09 00:50:33 +00:00
Ted Kremenek 9ec08aa3f7 More hacking on autorelease errors. We now can emit basic errors (disabled for
now until ready).

llvm-svn: 71303
2009-05-09 00:44:07 +00:00
Ted Kremenek d35272f96b Put most of the boilerplate logic in place for reporting autorelease errors.
llvm-svn: 71301
2009-05-09 00:10:05 +00:00
Fariborz Jahanian 5276014db2 We want to diagnose sending message to a forward class
and we also want to tell which message is actually 
being sent.

llvm-svn: 71296
2009-05-08 23:45:49 +00:00
Ted Kremenek 8c8fb488e6 retain/release checker: Add stub for HandleAutoreleaseCounts.
llvm-svn: 71290
2009-05-08 23:32:51 +00:00
Zhongxing Xu ca143e73ea Fix PR4182.
llvm-svn: 71288
2009-05-08 23:28:07 +00:00
Ted Kremenek 884a8996c5 retain/release checker: Refactor error-reporting code in EvalDeadSymbols and
EvalEndPath. This sets the stage for handling autorelease counts.

llvm-svn: 71283
2009-05-08 23:09:42 +00:00
Ted Kremenek c218c84a80 Make BlockEntrace program points taggable.
llvm-svn: 71280
2009-05-08 23:08:34 +00:00
Fariborz Jahanian 1bd844da80 Warn if forward class is used as a receiver.
llvm-svn: 71278
2009-05-08 23:02:36 +00:00
Daniel Dunbar b997f3bcc3 x86_64 ABI: Ignore padding bit-fields during classification.
- {return-types,single-args}-{32,64} pass the first 1k ABI tests with
   bit-fields enabled.

llvm-svn: 71272
2009-05-08 22:26:44 +00:00
Daniel Dunbar 4752783057 Darwin x86_32: When coercing a "single element" structure, make sure
to use a wide enough type. This might be wider than the "single
element"'s type in the presence of padding bit-fields.
 - Darwin x86_32 now passes the first 1k ABI tests with bit-field
   generation enabled.

llvm-svn: 71270
2009-05-08 21:30:11 +00:00
Fariborz Jahanian 3e68a1facc Fixes a bug in my last patch. Order of types reversed.
llvm-svn: 71267
2009-05-08 21:10:00 +00:00
Daniel Dunbar fdda3501a0 Darwin x86_32: Ignore padding bit-fields when looking for "single
element" structures.

llvm-svn: 71266
2009-05-08 21:04:47 +00:00
Daniel Dunbar 4861346c44 Darwin x86_32: Improve bit-field handling for returning records.
- This turns out to be a no-op now that most of the handling for
   everything else is in place.

llvm-svn: 71261
2009-05-08 20:55:49 +00:00
Daniel Dunbar 85f4028f2e Darwin x86_32: Ignore arrays of empty structures inside records.
- This eliminates 5/1000 failures on return-types-32, on the current
   ABITest config.

llvm-svn: 71250
2009-05-08 20:21:04 +00:00
Fariborz Jahanian fe9e3940eb Refactoring of my last patch.
llvm-svn: 71248
2009-05-08 20:20:55 +00:00
Ted Kremenek 3a0516b25a retain checker: Track the number of times a tracked object is sent
'autorelease'. This isn't used yet to flag errors.

llvm-svn: 71244
2009-05-08 20:01:42 +00:00
Fariborz Jahanian b2ab73d93c More type checking for properties, accessors and
use of dot-syntax expression. This is to match gcc's.

llvm-svn: 71243
2009-05-08 19:36:34 +00:00
Anton Korobeynikov 2f910827eb Provide dummy va_list typedef for msp430
llvm-svn: 71233
2009-05-08 18:24:57 +00:00
Chris Lattner 96afab520b further improvements to gnu objc EH stuff, patch by David Chisnall!
llvm-svn: 71227
2009-05-08 17:36:08 +00:00
Chris Lattner a02cb80f99 "This patch fixes message sends to super in categories for the GNU runtime. This used to work, but I broke it when I modified the code to emit the same thing as GCC for message sends to super in classes."
Patch by David Chisnall!

llvm-svn: 71220
2009-05-08 15:39:58 +00:00
Chris Lattner 5b9241b2a6 Fix the atomics sema code to convert operands to the argument types
of the underlying _N builtin, not the the type of the pointee of the
actual type.  This ensures that atomics involving pointers end up
using the correct integer type when they are resolved, avoiding
aborts in codegen.

llvm-svn: 71218
2009-05-08 15:36:58 +00:00
Ted Kremenek 062c14ba24 Remove experimental ownership attributes from Clang.
llvm-svn: 71216
2009-05-08 15:19:25 +00:00
Zhongxing Xu d2e8fa14df Region store: when casting VarRegions, if the cast-to pointee type is
incomplete, do not compute its size and return the original region.

llvm-svn: 71213
2009-05-08 07:28:25 +00:00
Chris Lattner dc04654697 reimplement __sync_* builtins to be variadic and to follow the same
semantic rules that gcc and icc use.  This implements the variadic
and concrete versions as builtins and has sema do the 
disambiguation.  There are probably a bunch of details to finish up
but this seems like a large monotonic step forward :)

llvm-svn: 71212
2009-05-08 06:58:22 +00:00
Zhongxing Xu afc875c766 Replace the heuristic isSmallerThan with ASTContext::getTypeSize().
llvm-svn: 71206
2009-05-08 02:12:59 +00:00
Zhongxing Xu c0c074655d Replace getTypeWidth() with ASTContext::getTypeSize().
llvm-svn: 71205
2009-05-08 02:00:55 +00:00
Zhongxing Xu 1ba79dfeea Revert r71079.
llvm-svn: 71202
2009-05-08 01:33:18 +00:00
Ted Kremenek 3975f17f04 Fix <rdar://problem/6845148>. Signed integers compared against pointers should
implicitly be changed to unsigned values in GRSimpleVals.cpp. This can happen
when the comparison involves logic in specialized transfer functions (e.g.,
OSAtomicCompareAndSwap).

llvm-svn: 71200
2009-05-08 00:32:39 +00:00
Chris Lattner b6e9eb6956 initial support for ObjC exceptions with the GNU runtime:
"This patch is a first pass at adding support for exceptions for the GNU runtime.  There are a few limitations at present:

- @synchronized() is not yet supported at all.  gcc currently emits calls to runtime library functions that don't exist for this directive.

- Only id @catch statements are currently working.  This is enough for NS_DURING and friends, but I need to spend more time reading the output from gcc -S to work out how it finds the class pointer to make arbitrary class type catch statements work.

- I've tested it with a few common cases[1] and the clang test suite (which doesn't test exceptions for the GNU runtime, but shows I haven't broken anything else), but there are probably a lot of cases I've missed."

Patch by David Chisnall!

llvm-svn: 71198
2009-05-08 00:11:50 +00:00
Eli Friedman 7ce29a18e1 Fix crash with constant initialization of bit-fields in unions.
llvm-svn: 71194
2009-05-07 23:42:42 +00:00
Ted Kremenek 9157fbb6a6 Minor code cleanup in retain/release checker in preparation for some
other changes.  Instead of repeatedly checking for GC mode when
getting the return effect, just do this computation once.

llvm-svn: 71193
2009-05-07 23:40:42 +00:00
Mike Stump 5580bdcaa2 Add a warning for a missing copy attribute on a property that is a
block pointer.  Radar 6441502

llvm-svn: 71190
2009-05-07 23:06:50 +00:00
Daniel Dunbar 81ded69511 Remove -fobjc-tight-layout, seems to work!
llvm-svn: 71184
2009-05-07 21:58:26 +00:00
Mike Stump 5e16a0d9e7 Allow qualifiers on blocks. Radar 6441502
llvm-svn: 71183
2009-05-07 21:56:17 +00:00
Ted Kremenek ba53fe98e7 More attribute renaming:
- Rename 'ns_returns_owned' -> 'ns_returns_retained'.
- Rename 'cf_returns_owned' -> 'cf_returns_retained'.

llvm-svn: 71182
2009-05-07 21:49:45 +00:00
Fariborz Jahanian 0d451813f9 a forward class declaration matching a typedef name of a class
refers to the underlying class.
This is radar 6859726. Steve, please read the radar for my rational.

llvm-svn: 71181
2009-05-07 21:49:26 +00:00
Mike Stump f70bcf7d1a Tighten up relationals with blocks and ints. Radar 6441502
llvm-svn: 71171
2009-05-07 18:43:07 +00:00
Ted Kremenek a6e08327c0 analyzer: Add ProgramPoint 'PostLValue' just to distinguish (for
analysis introspection) when we computed an lvalue.  This shouldn't
effect the current analysis results in any way.

llvm-svn: 71169
2009-05-07 18:27:16 +00:00
Sebastian Redl fb23ddf661 Fix a FIXME in new expression checking.
llvm-svn: 71163
2009-05-07 16:14:23 +00:00
Douglas Gregor ae1e53c87b Compute the canonical template name when building a template
specialization type for a dependent template name.

llvm-svn: 71153
2009-05-07 06:49:52 +00:00
Douglas Gregor 6bc50585e3 Start canonicalizing template names. This is not yet complete, but it
improves type identity with dependent types.

llvm-svn: 71152
2009-05-07 06:41:52 +00:00
Chris Lattner ed58599a7e Add support for LLLi -> int128 in builtins.def
llvm-svn: 71148
2009-05-07 04:47:06 +00:00
Mike Stump 1b821b4fc5 Improve semantic checking for blocks. Radar 6441502
llvm-svn: 71145
2009-05-07 03:14:14 +00:00
Ted Kremenek 9abe474852 Add preliminary support for enhancing null-pointer dereference diagnostics.
llvm-svn: 71135
2009-05-07 00:45:33 +00:00
Sebastian Redl f08aa62c80 Back out r70506 (exception spec in AST) again. We won't have exception specs until we've had a lot more discussion.
llvm-svn: 71125
2009-05-06 23:27:55 +00:00
Daniel Dunbar f9d90275f9 Handle -march for the LLVM recognized cpu names.
- x86 target feature handling should not be feature complete, even if
   the code quality is lacking.

llvm-svn: 71123
2009-05-06 21:56:32 +00:00
Ted Kremenek bb8d546208 Refactor BugReporter interface to have a new 'BugReporterContext' and
'BugReporterVisitor'. This simplifies callbacks from BugReporter to BugReports
(via VisitNode). It also lays the foundation for arbitrary visitor "call backs"
that can be registered to a BugReporterContext as a PathDiagnostic is
constructed. These call backs can help operate as separate "experts" that can
work on constructed pieces of a PathDiagnostic for which they possess special
knowledge.

llvm-svn: 71121
2009-05-06 21:39:49 +00:00
Daniel Dunbar bb36aed06b More x86 target feature support.
- Apologies for the extremely gross code duplication, I want to get
   this working and then decide how to get this information out of the
   back end.

 - This replaces -m[no-]sse4[12] by -m[no-]sse4, it appears gcc
   doesn't distinguish them?

 - -msse, etc. now properly disable/enable related features.

 - Don't always define __SSE3__...

 - The main missing functionality bit here is that we don't initialize
   the features based on the CPU for all -march options.

llvm-svn: 71117
2009-05-06 21:07:50 +00:00
Ted Kremenek 0626df4eeb Fix analyzer regression reported in PR 4164:
- Update the old StoreManager::CastRegion to strip off 'ElementRegions' when
  casting to void* (Zhongxing: please validate)
- Pass-by-reference argument invalidation logic in CFRefCount.cpp:
  - Strip ElementRegions when the ElementRegion is just a 'raw data' view
    on top of the underlying typed region.

llvm-svn: 71094
2009-05-06 18:19:24 +00:00
Zhongxing Xu ea8c48d5a1 Improve RegionStoreManager::getSizeInElements()
- add a static function getTypeWidth(), which computes the width of a type
   with the help of TargetInfo.
 - no-outofbounds.c now passes for region store.

llvm-svn: 71080
2009-05-06 11:51:48 +00:00
Zhongxing Xu c98868136f Add a GDM for recording the cast type of regions.
llvm-svn: 71076
2009-05-06 08:33:50 +00:00
Zhongxing Xu 24ed0b28a8 The super region of ElementRegion no longer needs to be TypedRegion. In the
future we would create ElementRegion directly on top of typeless regions.

llvm-svn: 71075
2009-05-06 08:15:46 +00:00
Zhongxing Xu 1813e23a52 Implement a heuristic type size comparison method for now.
llvm-svn: 71074
2009-05-06 08:08:27 +00:00
Daniel Dunbar e5ae096bf8 Tweak x86 -mcpu defaults.
- Default to yonah on Darwin (to get SSE3).

 - Default to Pentium4 (32-bit) and x86-64 (64-bit) on
   non-Darwin. Welcome to the 21st century.

llvm-svn: 71069
2009-05-06 04:58:14 +00:00
Anders Carlsson cd8db41c52 Add parsing of friend specifiers.
llvm-svn: 71067
2009-05-06 04:46:28 +00:00
Douglas Gregor 080fe61d64 Eliminate extra vertical space in Clang diagnostics
llvm-svn: 71066
2009-05-06 04:43:47 +00:00
Chris Lattner dbcc5ca57f Fix rdar://6860124 - invalid input constraint 'J' in asm
This recognizes all the target-independent constant constraints
that have target-specific meanings.

llvm-svn: 71064
2009-05-06 04:33:31 +00:00
Daniel Dunbar 4dbaaa6f43 Improve handling of (X86) target features.
- This is a WIP...

 - This adds -march= handling to the driver, and fixes the defaulting
   of -mcpu on Darwin (which was using the wrong test).

Instead of handling -m{sse, ...} in the driver, pass them to clang-cc as
 -target-feature [+-]name

In clang-cc, communicate with the (clang) target to discover the legal
features of a target, and the features which are enabled based on
-mcpu. This is currently hardcoded just enough to not be a feature
regression, we need to get this information from the backend's
TableGen information somehow.

This is used to construct the full list of features which are being
used, which is in turn used to initialize the predefines.

llvm-svn: 71061
2009-05-06 03:16:41 +00:00
Zhongxing Xu b2d4a52e3f remove commented code.
llvm-svn: 71060
2009-05-06 02:54:11 +00:00
Zhongxing Xu d5e09be293 Make StoreManager::CastRegion() virtual and implement a new CastRegion() for
RegionStore.

This CastRegion() performs casts according to the kind of the region being 
cast instead of the type that is cast to.

llvm-svn: 71058
2009-05-06 02:42:32 +00:00
Daniel Dunbar 5e051f9a86 Add --analyze-auto.
- Currently just an alias for --analyze, eventually we want to refit
   --analyze so that it is less automatic (i.e., does not force plist
   output and does not hard code the list of checks).

llvm-svn: 71056
2009-05-06 02:12:32 +00:00
Fariborz Jahanian a16904bc41 Fixes a bug for objc2's gc in the presense of type-casts.
llvm-svn: 71041
2009-05-05 23:28:21 +00:00
Ted Kremenek a8106efce9 BugReporter (extensive diagnostics): improve location context generation for the
start of 'do' and '@synchronized' statements.

llvm-svn: 71038
2009-05-05 23:13:38 +00:00
Ted Kremenek b3c657bbd4 source-level CFG: have the body for the @synchronized start with its own basic
block. This makes it a little easier for diagnostics generation.

llvm-svn: 71037
2009-05-05 23:11:51 +00:00
Ted Kremenek 98017051ae BugReporter (extensive diagnostics): Fix getEnclosingStmtLocation to reason
about Exprs that are not consumed and fix where the loop iteration diagnostic
goes.

llvm-svn: 71027
2009-05-05 22:19:17 +00:00
Ted Kremenek 90a6145ad1 Fix subtle bug in ParentMap::isConsumedExpr(): correctly ignore *parents* that
are ParenExpr or CastExprs.

llvm-svn: 71026
2009-05-05 22:16:12 +00:00
Chris Lattner c45529b17b Fix rdar://6849429 - -Wunused-value with deeply nested macro expansion generates untraceable warnings
The "instantiated from" messages coming from the caret diagnostics system are 
basically walking the macro expansion tree, emitting each level as it goes.  However, it was
skipping certain leaves in the tree by skipping up the entire instantiation arm every time
it went up one spelling arm.  This caused it to miss some things.  For example, in this
testcase:

#define M1(x) x
#define M2 1;

void foo() {
 M1(M2)
}

we now print:

/Users/sabre/Desktop/clang-unused-value-macro.c:6:2: warning: expression result unused

 M1(M2)
 ^~~~~~
/Users/sabre/Desktop/clang-unused-value-macro.c:6:5: note: instantiated from:

 M1(M2)
    ^~
/Users/sabre/Desktop/clang-unused-value-macro.c:3:12: note: instantiated from:

#define M2 1;
           ^

Previously we didn't print the last line, so we never emitted the caret pointing to the 1!

Incidentally, the spaces between the lines is really noisy, I think we should reconsider
this heuristic (which adds them when the printed code starts too close to the start of the
line).

The regression test can't use -verify, because -verify doesn't catch notes for macro
instantiation history.

llvm-svn: 71025
2009-05-05 22:03:18 +00:00
Fariborz Jahanian f3648b8913 Patch to support Gnu runtime's typed selectors.
Patch by David Chisnall.

llvm-svn: 71023
2009-05-05 21:36:57 +00:00
Ted Kremenek 213ff5a98e Implement attribute 'ns_autorelease'.
llvm-svn: 70990
2009-05-05 18:44:20 +00:00
Fariborz Jahanian 3baaffba6b Issue a warning in odd case of instance method used
in a 'Class' receiver which is not a root instance
method.

llvm-svn: 70987
2009-05-05 18:34:37 +00:00
Chris Lattner 36797ab251 When defining a function whose type has no prototype, make an effort
to go back and clean up existing uses of the bitcasted function.  This
is not just an optimization: it is required for correctness to get
always inline functions to work, see testcases in function-attributes.c.

llvm-svn: 70971
2009-05-05 06:16:31 +00:00
Chris Lattner 448a228521 fix some more cases where we'd emit a file with a line of 0 for implicit
types.  In this case, it was objc_selector and objc_class.  This fixes
rdar://6852754 - clang sometimes generates incorrect/unknown file/line info for DW_TAG__structure_type dies

llvm-svn: 70969
2009-05-05 05:16:17 +00:00
Chris Lattner f216fd96fe Do not generate bogus location info for DW_TAG_inheritance
DIEs.  We were generating a loc with line of 0 and a file.
These tags do not need locations at all, just remove it.
this fixes rdar://6852792 - Clang generates incorrect (and unnecessary) file and line info for DW_TAG_inheritance dies

llvm-svn: 70966
2009-05-05 05:05:36 +00:00
Chris Lattner 362d8ae328 Fix generated debug info for decls with no location (which include self/_cmd
in ObjC) to not emit file/line location information.  Previously
we would output a file with bogus line information.  This fixes:
rdar://6852814 - Clang generates incorrect file & line info for automatic/understood formal parameters for objc-programs

llvm-svn: 70965
2009-05-05 04:57:08 +00:00
Douglas Gregor b8420464c6 Turns out that Sebastian already implemented the logic to compute the
composite pointer type, and his is better! Updated relational- and
equality-operator checking accordingly.

llvm-svn: 70963
2009-05-05 04:50:50 +00:00
Anders Carlsson dae1abc7ac Refactor global decls to hold either a regular Decl or a CXXConstructorDecl + ctor type or a CXXDestructorDecl + dtor type.
llvm-svn: 70962
2009-05-05 04:44:02 +00:00
Ted Kremenek 94c464ef22 Implement attribute 'cf_returns_owned' (mirrors 'ns_returns_owned').
llvm-svn: 70952
2009-05-05 00:46:09 +00:00
Daniel Dunbar 3f86b9cb06 Remove an unneeded lookup routine.
llvm-svn: 70951
2009-05-05 00:36:57 +00:00
Ted Kremenek de1aa1e4dd Rename ownership attributes:
ns_ownership_returns -> ns_returns_owned
 ns_ownership_retain -> ns_retains
 ns_ownership_release -> ns_releases
 cf_ownership_retain ->  cf_retains
 cf_ownership_release -> cf_releases

llvm-svn: 70949
2009-05-05 00:21:59 +00:00
Ted Kremenek e5c315826e Fix unused variable warning
llvm-svn: 70946
2009-05-05 00:06:16 +00:00
Ted Kremenek 6ae5615d80 Remove possibly incorrect assertion that doesn't matter.
llvm-svn: 70943
2009-05-05 00:02:18 +00:00
Ted Kremenek bbec22d2b2 Rename attribute 'ns_ownership_returns' to 'ns_returns_ownership'.
llvm-svn: 70941
2009-05-04 23:52:59 +00:00
Ted Kremenek 6bdfcf47ad Remove experimental attribute 'ns_ownership_make_collectable.'
llvm-svn: 70940
2009-05-04 23:46:06 +00:00
Fariborz Jahanian 32ff7aeefa Provide basic support for generation of objc2's
objc_assign_global API when assigning to global
objective-c object pointer.

llvm-svn: 70939
2009-05-04 23:27:20 +00:00
Daniel Dunbar 9b042e06ee Fix the field count in interface record layout (it was incorrectly
compensating for super classes). This was making the reported class
sizes for empty classes very, very wrong.
 - Also, we now report the size info for an empty class like gcc (as
   the offset of the start, not as 0, 0).

 - Add a few more test cases we were mishandling before (padding bit
   field at end of struct, for example).

llvm-svn: 70938
2009-05-04 23:23:09 +00:00
Daniel Dunbar 9252ee1779 Compute interface instanceStart and instanceSize using the record
layout.
 - This is much simpler / more efficient.

 - This also properly computes the size in the presence of bit-fields.

llvm-svn: 70916
2009-05-04 21:26:30 +00:00
Fariborz Jahanian 60637985de ignore weak_import attribute on objc method decls.
llvm-svn: 70901
2009-05-04 19:35:12 +00:00
Ted Kremenek 0836a19931 Rename attributes 'objc_ownership...' to 'ns_ownership...'.
llvm-svn: 70897
2009-05-04 19:10:19 +00:00
Chris Lattner 23d5a39195 "Fix" a problem with debug info in the presence of always_inline
function calls.  For a program like this:

#include <stdio.h>
static __inline__ __attribute__((always_inline)) 
int bar(int x) { return 4; }
int main() { 
  int X = bar(4);
  printf("%d\n", X);
}

clang was not outputing any debug info for the body of main().  This is
because the backend is getting confused by the region_start/end that clang
is emitting for block scopes.  For now, just disable these (matching llvm-gcc),
this stuff is in progress of rework anyway.

llvm-svn: 70889
2009-05-04 18:27:04 +00:00
Ted Kremenek e396f72ec7 BugReporter (extensive diagnostics): don't mark location contexts that are
control-flow expressions as dead.

llvm-svn: 70887
2009-05-04 18:15:17 +00:00
Ted Kremenek 250d59f33f Fix false positive null dereference by unifying code paths in GRSimpleVals for
'==' and '!=' (some code in the '!=' was not replicated in the '==' code,
causing some constraints to get lost).

llvm-svn: 70885
2009-05-04 17:53:11 +00:00
Ted Kremenek 5dbfa3fadd Rename attributes:
'objc_ownership_cfretain' -> 'cf_ownership_retain'
'objc_ownership_cfrelease' -> 'cf_ownership_release'

Motivation: Core Foundation objects can be used in isolation from Objective-C,
and this forces users to reason about the separate semantics of CF objects. More
Sema support pending.

llvm-svn: 70884
2009-05-04 17:29:57 +00:00
Ted Kremenek bc76c72f94 Remove support for ObjCMethodDecl attributes that appear between the
return type and the selector.  This is inconsistent with C functions
(where such attributes would be placed on the return type, not the the
FunctionDecl), and is inconsistent with what people are use to seeing.

llvm-svn: 70878
2009-05-04 17:04:30 +00:00
Chris Lattner bef2ee4322 "The attached diff fixes the //FIXME in message send to super. This should now be faster, and works in the presence of class posing. This is now the same approach as used in GCC (the earlier code was a quick hack to get something working)."
Patch by David Chisnall!

llvm-svn: 70877
2009-05-04 16:56:33 +00:00
Ted Kremenek 49a844e1a6 retain checker: Add checker support for FunctionDecl ownership annotations. Need to add Sema support.
llvm-svn: 70873
2009-05-04 16:43:50 +00:00
Ted Kremenek 863f68aa06 retain checker: Pull out logic for parameter annotations into a
separate method.

llvm-svn: 70870
2009-05-04 15:40:58 +00:00
Ted Kremenek df76e6d09d retain checker: Don't treat function's declared in macros differently.
llvm-svn: 70869
2009-05-04 15:34:07 +00:00
Daniel Dunbar 566421c8a3 Patch from David Chisnall:
The attached diff fixes the //FIXME in message send to super.  This
should now be faster, and works in the presence of class posing.  This
is now the same approach as used in GCC (the earlier code was a quick
hack to get something working).

llvm-svn: 70868
2009-05-04 15:31:17 +00:00
Ted Kremenek a68556c4cc Add array index assertion: BasicStore should not expect any fancy
ElementRegions that have non-zero array indices.

llvm-svn: 70867
2009-05-04 15:25:46 +00:00
Ted Kremenek d795b02be7 Rename 'makeZeroIndex' to 'makeZeroArrayIndex'.
llvm-svn: 70865
2009-05-04 15:17:38 +00:00