Commit Graph

12072 Commits

Author SHA1 Message Date
Douglas Gregor 98c1018337 Implement AST importing and merging for enumeration types and
enumerators, along with ImplicitCastExprs to make it work.

llvm-svn: 96024
2010-02-12 22:17:39 +00:00
Fariborz Jahanian 5ec502e35b Complain if block-literal expression's parameter name is
missing (in c/objc mode). Fixes radar 7528255.

llvm-svn: 96017
2010-02-12 21:53:14 +00:00
Fariborz Jahanian e5c118f60d Don't error when setting a sub-structure variable via objc properties
in objective-c++ mode (do it for objective-c only).

llvm-svn: 96012
2010-02-12 21:02:28 +00:00
Chris Lattner 5647d3192c fix a bug in SourceManager::getInstantiationLocSlowCase, where
we'd add an offset from the spelling location space to the 
instantiation location, which doesn't make sense and would
lead up to the text diagnostics crashing when presented with
non-sensical locations.

This fixes rdar://7597492, a crash on 255.vortex.

llvm-svn: 96004
2010-02-12 19:31:35 +00:00
Fariborz Jahanian dc68f9539c Patch to fix a warning which exposed a bug in building
a qualified objective-c pointer type. Fixes radar 7638810.
(Also removes a FIXME).

llvm-svn: 96003
2010-02-12 19:27:33 +00:00
Chris Lattner fc38aa7091 restructure code a bit: there are two potential issues
worth asserting about in this code: 1) if the source range
is bogus (begin loc after end loc), and 2) if the client
is trying to highlight a range that is purely whitespace.

It is possible to just silently ignore #2, but it seems like
it is always a bug, so lets keep asserting on this condition,
but with a better assert message.

llvm-svn: 95998
2010-02-12 18:52:52 +00:00
Anders Carlsson 0760481f26 Fix a refacto that broke the clang-on-clang build.
llvm-svn: 95994
2010-02-12 18:14:46 +00:00
Fariborz Jahanian a459c4453d Fixes a rewriter bug rewriting function decl.
with block-pointer-type as one or more of its
arguments. Fixes radar 7638400.

llvm-svn: 95992
2010-02-12 17:52:31 +00:00
Douglas Gregor 5089c769bb Improve representation of tag declarations first declared or defined
within the declarator of another declaration, from Enea Zaffanella!

llvm-svn: 95991
2010-02-12 17:40:34 +00:00
Anders Carlsson 5272c2574a Start stubbing out more of the covariant thunk support.
llvm-svn: 95990
2010-02-12 17:37:14 +00:00
Douglas Gregor 56521c5e8c Simplify incomplete-array merging code in the AST importer, thanks to
Daniel's suggestion.

llvm-svn: 95987
2010-02-12 17:23:39 +00:00
Douglas Gregor 8870a49310 Fix a latent bug found by Ahmed Charles, where we were calling
ASTContext::getFunctionType with the wrong set of arguments.

llvm-svn: 95986
2010-02-12 17:17:28 +00:00
Anders Carlsson 8e661e15f2 Keep track of whether a final overrider needs a return type adjustment.
llvm-svn: 95985
2010-02-12 17:13:23 +00:00
Anders Carlsson 136bd19224 Move overrider out into a separate struct.
llvm-svn: 95984
2010-02-12 16:55:34 +00:00
Chris Lattner aa1cccbbef Fix PR6282: the include guard optimization cannot happen if the
guard macro is already defined for the first occurrence of the
header.  If it is, the body will be skipped and not be properly
analyzed for the include guard optimization.

llvm-svn: 95972
2010-02-12 08:03:27 +00:00
Anders Carlsson e8a9756e63 Keep track of the address points for all primary bases, and add the ability to dump multiple address points for a single offset.
llvm-svn: 95970
2010-02-12 07:43:48 +00:00
Douglas Gregor f40863caff Work around an annoying, non-standard optimization in the glibc
headers, where malloc (and many other libc functions) are declared
with empty throw specifications, e.g.,  

  extern void *malloc (__SIZE_TYPE__ __size) throw () __attribute__
  ((__malloc__)) ;

The C++ standard doesn't seem to allow this, and redeclaring malloc as
the standard permits (as follows) resulted in Clang (rightfully!)
complaining about mis-matched exception specifications.

  void *malloc(size_t size);

We work around this by silently propagating an empty throw
specification "throw()" from a function with C linkage declared in a
system header to a redeclaration that has no throw specifier.

Ick.

llvm-svn: 95969
2010-02-12 07:32:17 +00:00
John McCall 84c416b9f6 Fix a bug causing an assertion when a covariant return type differed from
an overriden type only by reduced qualification.

llvm-svn: 95968
2010-02-12 06:15:07 +00:00
Douglas Gregor d3a5918742 In C++, allow builtins to be referred to via qualified name lookup, e.g.,
::__builtin_va_copy

Fixes one of the Firefox issues in PR5511.

llvm-svn: 95966
2010-02-12 05:48:04 +00:00
Anders Carlsson 65b4978f7f More work on vtable layout. We can now layout vtables with primary bases.
llvm-svn: 95965
2010-02-12 05:25:12 +00:00
John McCall 62d5d64ce9 Waste two bits in every clang::Type so that the type class can be read
in a single byte-load rather than some crazy bitmunging operation.

llvm-svn: 95964
2010-02-12 03:41:30 +00:00
Anders Carlsson 09da3372b6 When dumping vtables, dump whether a virtual member function is pure or not.
llvm-svn: 95963
2010-02-12 02:38:13 +00:00
Anders Carlsson 9fbf6d95f6 More work on the final overriders.
llvm-svn: 95954
2010-02-12 01:40:03 +00:00
Devang Patel f4df65cf60 Do not ignore anonymous records.
llvm-svn: 95953
2010-02-12 01:31:06 +00:00
Devang Patel e003dd1721 Cache new compile unit.
llvm-svn: 95952
2010-02-12 01:30:31 +00:00
Douglas Gregor 2579105c4e Handle AST merges of incomplete class types.
llvm-svn: 95941
2010-02-12 00:09:27 +00:00
Tanya Lattner 90073804fb Implementing unused function warning.
llvm-svn: 95940
2010-02-12 00:07:30 +00:00
Charles Davis a90f7ca591 Warn about using the new force_align_arg_pointer attribute on a function
pointer. If you don't like the new warning, you can turn it off with
-Wno-force-align-arg-pointer.

llvm-svn: 95939
2010-02-11 23:57:08 +00:00
Fariborz Jahanian 4c4ca5a9d3 Fixes a rewriting bug where order of constructor expression arguments did not match
order of constructor arguments (all block API specific). This was exposed only in 
a large block literal expression in a large file where PtrSet container size 
execceded its limit and required reallocation.  Fixes radar 7638294

llvm-svn: 95936
2010-02-11 23:35:57 +00:00
Douglas Gregor 50dc219e8b When we have a dependent direct initializer but not a dependent
variable type, we can (and should) still check for completeness of the
variable's type. Do so, to work around an assertion that shows up in
Boost's shared_ptr.

llvm-svn: 95934
2010-02-11 22:55:30 +00:00
Ted Kremenek 9d6eb40ce7 Fix leak in CXXNewExpr where the SubExprs array would get allocated directly using 'new[]' instead of the allocator associated with ASTContext.
llvm-svn: 95933
2010-02-11 22:51:03 +00:00
Ted Kremenek 9c8a6f5a8e Fix re-allocation in AttrWithString::ReplaceString() to use the allocator assosciated with ASTContext.
llvm-svn: 95931
2010-02-11 22:44:22 +00:00
Ted Kremenek 2c809308ca Allocate the SubExprs array in ObjCMessageExpr using the allocator associated with ASTContext. This fixes yet another leak (<rdar://problem/7639260>).
llvm-svn: 95930
2010-02-11 22:41:21 +00:00
Anders Carlsson e8ac42ad5c Stub out the final overriders class.
llvm-svn: 95922
2010-02-11 21:24:32 +00:00
Anders Carlsson dd27b5d7bb Use getAs instead of cast/dyn_cast on types. (I'm sure Doug will appreciate this).
llvm-svn: 95911
2010-02-11 19:45:15 +00:00
Anders Carlsson 727ffb14a1 Move two functions to the top. No functionality change.
llvm-svn: 95908
2010-02-11 19:39:49 +00:00
Ted Kremenek 23a26d244d Uncomment lines I never meant to have left commented in a commit.
llvm-svn: 95906
2010-02-11 19:37:25 +00:00
Douglas Gregor 7eeb59752a When AST merging for record declarations fails, warn about the
incompatibility and show where the structural differences are. For
example:

struct1.c:36:8: warning: type 'struct S7' has incompatible definitions
in different translation units
struct S7 { int i : 8; unsigned j : 8; } x7;
       ^
struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
struct S7 { int i : 8; unsigned j : 8; } x7;
                                ^
struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 16 here
struct S7 { int i : 8; unsigned j : 16; } x7;
                                ^

There are a few changes to make this work:
  - ASTImporter now has only a single Diagnostic object, not multiple
  diagnostic objects. Otherwise, having a warning/error printed via
  one Diagnostic and its note printed on the other Diagnostic could
  cause the note to be suppressed.
  - Implemented import functionality for IntegerLiteral (along with
  general support for statements and expressions)

llvm-svn: 95900
2010-02-11 19:21:55 +00:00
Anders Carlsson 5bd8d19291 More vtable layout dumper improvements. Handle destructors, dump the complete function type of the member functions (using PredefinedExpr::ComputeName.
llvm-svn: 95887
2010-02-11 18:20:28 +00:00
Daniel Dunbar bcd554f908 Driver: Fix clang -ccc-no-clang -x c++-header foo.h on Darwin.
llvm-svn: 95876
2010-02-11 17:33:45 +00:00
Anders Carlsson 932c2f2a9a Keep track of, and dump, vtable address points.
llvm-svn: 95874
2010-02-11 17:18:51 +00:00
John McCall be089fa86b Suppress warnings if their instantiation location is in a system header, not
their spelling location.  This prevents warnings from being swallowed just
because the caret is on the first parenthesis in, say, NULL.

This is an experiment;  the risk is that there might be a substantial number
of system headers which #define symbols to expressions which inherently cause
warnings.  My theory is that that's rare enough that it can be worked
around case-by-case, and that producing useful warnings around NULL is worth 
it.  But I'm willing to accept that I might be empirically wrong.

llvm-svn: 95870
2010-02-11 10:04:29 +00:00
Ted Kremenek d31b2637ab Patch by Cristian Draghici:
Enhance the printf format string checking when using the format
specifier flags ' ', '0', '+' with the 'p' or 's' conversions (since
they are nonsensical and undefined).  This is similar to GCC's
checking.

Also warning when a precision is used with the 'p' conversin
specifier, since it has no meaning.

llvm-svn: 95869
2010-02-11 09:27:41 +00:00
Anders Carlsson 5d40c6f658 Check in the beginnings of my new vtable layout builder idea.
Right now, it's off by default but can be tested by passing -fdump-vtable-layouts to clang -cc1. This option will cause all vtables that will normally be emitted as part of codegen to also be dumped using the new layout code.

I've also added a very simple new vtable layout test case.

llvm-svn: 95865
2010-02-11 08:02:13 +00:00
Ted Kremenek 510ee2594e Use the allocator associated with ASTContext to allocate the args
array associated with NonNullAttr.  This fixes yet another leak when
ASTContext uses a BumpPtrAllocator.

Fixes: <rdar://problem/7637150>
llvm-svn: 95863
2010-02-11 07:31:47 +00:00
Ted Kremenek da4e0d350c Have ~ASTContext() delete StoredDeclsMap (internal to DeclContext) by
storing the set of StoredDeclsMaps in an internal vector of void*.
This isn't an ideal solution, but for the time being this fixes a
major memory leak with these DenseMaps not being freed.

Fixes: <rdar://problem/7634755>
llvm-svn: 95861
2010-02-11 07:12:28 +00:00
Ted Kremenek 7f4945aa9c Remove use of 'std::string' from Attr objects, using instead a byte
array allocated using the allocator in ASTContext.  This addresses
these strings getting leaked when using a BumpPtrAllocator (in
ASTContext).

Fixes: <rdar://problem/7636765>
llvm-svn: 95853
2010-02-11 05:28:37 +00:00
Daniel Dunbar aeea8ac3d8 Driver: Add -rewrite-objc, which is an interface to clang -cc1 -rewrite-objc.
llvm-svn: 95849
2010-02-11 03:16:21 +00:00
Daniel Dunbar 84f22f9da1 Driver: Fix infinite loop and wrong message on invalid -ccc-clang-arch argument.
llvm-svn: 95848
2010-02-11 03:16:07 +00:00
Ted Kremenek c162e8e193 Clean up ownership of 'AttributeList' objects in Parser. Apparently
we would just leak them all over the place, with no clear ownership of
these objects at all.  AttributeList objects would get leaked on both
error and non-error paths.

Note: I introduced the usage of llvm::OwningPtr<AttributeList> to
manage these objects, which is particularly useful for methods with
multiple return sites.  In at least one method I used them even when
they weren't strictly necessary because it clarified the ownership
semantics and made the code easier to read.  Should the excessive
'take()' and 'reset()' calls become a performance issue we can always
re-evaluate.

Note+1: I believe I have not introduced any double-frees, but it would
be nice for someone to review this.

This fixes <rdar://problem/7635046>.

llvm-svn: 95847
2010-02-11 02:19:13 +00:00
John McCall 4f7ced69ff Strip attributes and 'inline' off the "previous declaration" of a
template explicit specialization.  Complete an apparently stalled refactor
towards using CheckSpecializationInstantiationRedecl().

llvm-svn: 95845
2010-02-11 01:33:53 +00:00
Douglas Gregor 4a62bdfb2a Remove another redundant ASTContext parameter
llvm-svn: 95843
2010-02-11 01:30:34 +00:00
Douglas Gregor d505812422 Eliminate a bunch of unnecessary ASTContexts from members functions of
Decl subclasses. No functionality change.

llvm-svn: 95841
2010-02-11 01:19:42 +00:00
Fariborz Jahanian 13b9782cc0 Diagnose when user provided getter is being used as lvalue
using property dot-syntax. Fixes radar 7628953.

llvm-svn: 95838
2010-02-11 01:11:34 +00:00
Douglas Gregor 0a5a2216e2 Eliminate the ASTContext parameter from RecordDecl::getDefinition()
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.

llvm-svn: 95836
2010-02-11 01:04:33 +00:00
Ted Kremenek da4abf11bf Allocate 'ObjCMethodList' objects (owned by Sema) using Sema's BumpPtrAllocator. Previously they were not getting freed. Fixes <rdar://problem/7635663>.
llvm-svn: 95834
2010-02-11 00:53:01 +00:00
Douglas Gregor 5c73e918c5 Implement basic AST merging for classes, structs, and unions in C.
llvm-svn: 95833
2010-02-11 00:48:18 +00:00
Fariborz Jahanian 989908fbac Generate the objc_read_weak API when calling
a __weak block. Fixes radar 7628591.

llvm-svn: 95822
2010-02-10 23:34:57 +00:00
Charles Davis 42b3842429 Fix a potential null-pointer use, and fix the style of my new function.
Thanks, Anton!

llvm-svn: 95821
2010-02-10 23:26:12 +00:00
Charles Davis bbc0aa5166 Add support for the force_align_arg_pointer attribute. This is an x86-specific
attribute, so it uses Anton's new target-specific attribute support. It's
supposed to ensure that the stack is 16-byte aligned, but since necessary
support is lacking from LLVM, this is a no-op for now.

llvm-svn: 95820
2010-02-10 23:06:52 +00:00
Chris Lattner c55042c20f hopefully silence a warning on the clang-i386-darwin9 tester.
llvm-svn: 95812
2010-02-10 21:41:43 +00:00
Douglas Gregor 5fa74c3b1d Move TypedefDecl importer to match the ordering in DeclNodes. No functionality change.
llvm-svn: 95805
2010-02-10 21:10:29 +00:00
Fariborz Jahanian c3bdefa08d Patch to rewrite blocks into unique api names.
Fixes radar 7630551

llvm-svn: 95796
2010-02-10 20:18:25 +00:00
Douglas Gregor bb7930c17e Implement basic support for merging function declarations across
translation units.

llvm-svn: 95794
2010-02-10 19:54:31 +00:00
Fariborz Jahanian bbf4320390 Provide rewriting suppport for use of __typeof__
in a declaration statement. Fixes radar 7628153.

llvm-svn: 95788
2010-02-10 18:54:22 +00:00
Daniel Dunbar 3241d400c8 Switch to using -fsjlj-exceptions instead of hard-coding it. Notably, this fixes
calls to the UnwindResumeOrRethrow function for C++/Obj-C exception handling,
for Darwin ARM.

llvm-svn: 95787
2010-02-10 18:49:11 +00:00
Devang Patel 535fdaf020 Refactor code that generates debug info for variables that has BlocksAttr.
llvm-svn: 95786
2010-02-10 18:49:08 +00:00
Daniel Dunbar 925152c2d0 clang -cc1: Add -fsjlj-exceptions, which requires far too much button pushing.
llvm-svn: 95785
2010-02-10 18:48:44 +00:00
Douglas Gregor fa7a0e5198 Implement AST importing and merging for typedefs. As part of this, provide a lame implementation for importing TypeSourceInfos.
llvm-svn: 95783
2010-02-10 17:47:19 +00:00
Douglas Gregor 2fbe558cfe Teach AST merging that variables with incomplete array types can be
merged with variables of constant array types. Also, make sure that we
call DiagnosticClient's BeginSourceFile/EndSourceFile, so that it has
a LangOptions to work with.

llvm-svn: 95782
2010-02-10 17:16:49 +00:00
John McCall 5b0829a321 Improve access control diagnostics. Perform access control on member-pointer
conversions.  Fix an access-control bug where privileges were not considered
at intermediate points along the inheritance path.  Prepare for friends.

llvm-svn: 95775
2010-02-10 09:31:12 +00:00
Ted Kremenek fb45d35108 Convert tabs to spaces.
llvm-svn: 95756
2010-02-10 02:16:30 +00:00
Zhongxing Xu bc1d4ae206 Add comment.
llvm-svn: 95755
2010-02-10 02:02:10 +00:00
Fariborz Jahanian 68ebe63865 Comment out category's property decls. in rewrite.
Fixes radar 7630636.

llvm-svn: 95744
2010-02-10 01:15:09 +00:00
Devang Patel 1b5330afe9 Use current location as the location of compiler generated arguments, e.g. self, _cmd etc.
llvm-svn: 95743
2010-02-10 01:09:50 +00:00
Fariborz Jahanian 113b8ad7cf Reverse a partial fix patch for radar 7214820. It broke some code and
I don't have time to refix it for now.

llvm-svn: 95733
2010-02-10 00:32:12 +00:00
Douglas Gregor 811663eb11 Implement basic support for importing source locations from one AST
into another AST, including their include history. Here's an example
error that involves a conflict merging a variable with different types
in two translation units (diagnosed in the third AST context into
which everything is merged).

/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var2.c:3:5:
error: external variable 'x2' declared with incompatible types in
different translation units ('int' vs. 'double')
int x2;
    ^
In file included from
/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var1.c:3:
/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var1.h:1:8:
note: declared here with type 'double'
double x2;
       ^

Although we maintain include history, we do not maintain macro
instantiation history across a merge. Instead, we map down to the
spelling location (for now!).

llvm-svn: 95732
2010-02-10 00:15:17 +00:00
Douglas Gregor e4c83e4e2e Complain about types and declarations that we don't know how to import.
llvm-svn: 95706
2010-02-09 22:48:33 +00:00
Douglas Gregor 6b2a474531 Hook up the diagnostics-argument printer when merging AST files, so
that we get readable diagnostics such as:

error: external variable 'x1' declared with incompatible types in
different translation units ('double *' vs. 'float **')

However, there is no translation of source locations, yet.

llvm-svn: 95704
2010-02-09 22:37:58 +00:00
Douglas Gregor 639cccc4c0 Move the diagnostic argument formatting function out of Sema and make
it available within the AST library, of which Sema is one client. No
functionality change.

llvm-svn: 95701
2010-02-09 22:26:47 +00:00
Fariborz Jahanian 5db5281db8 Finish implementing property synthesis by default.
(radar 7381956).

llvm-svn: 95695
2010-02-09 21:49:50 +00:00
Fariborz Jahanian 4587803919 Implement synthesizing properties by default.
This is a non-fragile-abi feature only. Since it
breaks existing code, it is currently placed under
-fobjc-nonfragile-abi2 option for test purposes only
until further notice. WIP.

llvm-svn: 95685
2010-02-09 19:31:38 +00:00
Benjamin Kramer f3a499ad88 StringRefize two random methods, remove a dead variable and a weird constructor call.
This maybe fixes some of the errors GCC 4.5 gives on this code.

llvm-svn: 95684
2010-02-09 19:31:24 +00:00
Douglas Gregor 62d311fdf4 Introduce a testbed for merging multiple ASTs into a single AST
context with the AST importer. WIP, still useless but at least it has
a test.

llvm-svn: 95683
2010-02-09 19:21:46 +00:00
Ted Kremenek 499b4e3387 Fix lookup of fields from lazy bindings to check if the region is
NULL, not the store, to determine if a lookup succeeded.  The store
can be null if it contained no bindings.  This fixes a false positive
reported to me by a user of the analyzer.

llvm-svn: 95679
2010-02-09 19:11:53 +00:00
Devang Patel 0ae70d16b8 Fix virtual bases' debug info.
llvm-svn: 95678
2010-02-09 19:09:28 +00:00
Devang Patel cce7e85165 Mark implicit "this" argument as an artificial argument.
llvm-svn: 95673
2010-02-09 17:57:50 +00:00
Douglas Gregor e6565625f4 Migrate the mish-mash of declaration checks in
Sema::ActOnUninitializedDecl over to InitializationSequence (with
default initialization), eliminating redundancy. More importantly, we
now check that a const definition in C++ has an initilizer, which was
an #if 0'd code for many, many months. A few other tweaks were needed
to get everything working again:

  - Fix all of the places in the testsuite where we defined const
    objects without initializers (now that we diagnose this issue)
  - Teach instantiation of static data members to find the previous
    declaration, so that we build proper redeclaration
    chains. Previously, we had the redeclaration chain but built it
    too late to be useful, because...
  - Teach instantiation of static data member definitions not to try
    to check an initializer if a previous declaration already had an
    initializer. This makes sure that we don't complain about static
    const data members with in-class initializers and out-of-line
    definitions.
  - Move all of the incomplete-type checking logic out of
    Sema::FinalizeDeclaratorGroup; it makes more sense in
    ActOnUnitializedDecl.

There may still be a few places where we can improve these
diagnostics. I'll address that as a separate commit.

llvm-svn: 95657
2010-02-09 07:26:29 +00:00
Daniel Dunbar a7566f163a IRgen: Add CreateMemTemp, for creating an temporary memory object for a particular type, and flood fill. - CreateMemTemp sets the alignment on the alloca correctly, which fixes a great many places in IRgen where we were doing the wrong thing.
- This fixes many many more places than the test case, but my feeling is we need to audit alignment systematically so I'm not inclined to try hard to test the individual fixes in this patch. If this bothers you, patches welcome!

PR6240.

llvm-svn: 95648
2010-02-09 02:48:28 +00:00
John McCall 6f891400c2 Reset the found-virtual-base state unless the *current* base produces a path,
not *any* base up to now has produced a path.  Fixes PR 6254.

I'll do the access-control part of this patch RSN.

llvm-svn: 95638
2010-02-09 00:57:12 +00:00
Douglas Gregor 34c0a90265 Be more careful when checking initializer lists that involve reference
types; we don't want to give an expression reference type. Fixes PR6177.

llvm-svn: 95635
2010-02-09 00:50:06 +00:00
Douglas Gregor 92354b6b55 Implement a specific diagnostic when a class template partial
specialization does not use any of its template parameters, then
recover far more gracefully. Fixes PR6181.

llvm-svn: 95629
2010-02-09 00:37:32 +00:00
Jakob Stoklund Olesen 819e54b65c Pass inline keyword to optimizer as the new InlineHint function attribute.
At the moment the inlinehint attribute is ignored by the Inliner unless you
pass a -respect-inlinehint option.  This will soon be the default.

The inlinehint attribute is set if the inline keyword is explicitly specified
on any declaration.

llvm-svn: 95623
2010-02-09 00:10:00 +00:00
Ted Kremenek 2a0cd59f8e Convert tabs to spaces.
llvm-svn: 95621
2010-02-09 00:04:09 +00:00
Douglas Gregor 6c379e2aa6 When substituting a declaration non-type template argument for a
non-type template parameter that has reference type, augment the
qualifiers of the non-type template argument with those of the
referenced type. Fixes PR6250.

llvm-svn: 95607
2010-02-08 23:41:45 +00:00
John McCall bc077cf589 Thread a source location into the template-argument deduction routines. There
may be some other places that could take advantage of this new information,
but I haven't really looked yet.

llvm-svn: 95600
2010-02-08 23:07:23 +00:00
Douglas Gregor f85bee621b Eliminate a pointer of storage in each ObjCInterfaceType and
ObjCObjectPointerType AST node by allocating the list of protocols
after the type node itself. No functionality change.

llvm-svn: 95597
2010-02-08 22:59:26 +00:00
Daniel Dunbar 3d33fab7fc Reapply r95393, without the change to CGExpr. I was wrong in assuming that the
element type always matched the converted LLVM type for ExprType.

llvm-svn: 95596
2010-02-08 22:53:07 +00:00
Douglas Gregor bd683973c1 Warn when cases are missing from a switch on a value of enumeration
type (-Wswitch), from Michal! 

llvm-svn: 95592
2010-02-08 22:24:16 +00:00
Douglas Gregor 586d0f926c Keep track of whether a tag was defined in a declarator vs. being
defined by itself, from Enea Zaffanella!

llvm-svn: 95586
2010-02-08 22:07:33 +00:00
John McCall 340aafaac6 Emit global references with constant initializers as constants. Fixes PR5585.
The standard actually says that such references should have internal linkage,
but gcc doesn't do that, so we probably can't get away with it.

llvm-svn: 95577
2010-02-08 21:46:50 +00:00
Fariborz Jahanian 04477f3de9 Merge block/function pointer types with objc's __weak
attribute properly and avoid bogus warning. This is
an objective-c fix only. objective-c++ follows different code
pass and requires separate fix (which will come at a later time).
Fixes radar 7214820.

llvm-svn: 95571
2010-02-08 21:09:39 +00:00
Douglas Gregor 3aed6cdd5e Implement basic importing and merging of variable declarations within
the AST importer. This doesn't actually do anything (yet), because we
don't have driver logic for merging ASTs.

llvm-svn: 95570
2010-02-08 21:09:39 +00:00
Daniel Dunbar ddf1445134 Fix -Asserts warning.
llvm-svn: 95563
2010-02-08 20:24:21 +00:00
Benjamin Kramer 16fe0bcb26 Simplify another switch/strcmp construct. No functionality/performance change.
llvm-svn: 95561
2010-02-08 19:51:59 +00:00
Sebastian Redl b0e3e1bf67 When placing an annotation token over an existing annotation token, make sure that the new token's range extends to the end of the old token. Assert that in AnnotateCachedTokens. Fixes PR6248.
llvm-svn: 95555
2010-02-08 19:35:18 +00:00
John McCall 69f9dbc3e4 Fix the crash-on-invalid from PR6259.
llvm-svn: 95554
2010-02-08 19:26:07 +00:00
Chandler Carruth 75cc359fdc Ensure that a operator delete overload is rocognized regardless of cv-quals.
llvm-svn: 95553
2010-02-08 18:54:05 +00:00
Benjamin Kramer eaabbd8b46 Reapply r95546, no intended change in performance or functionality.
llvm-svn: 95552
2010-02-08 18:38:55 +00:00
Ted Kremenek ac5ab79555 Revert 95546 since it changed the algorithmic characteristics of the convention lookup.
llvm-svn: 95547
2010-02-08 16:45:01 +00:00
Benjamin Kramer 30949dd9f9 Simplify code with StringRef.
3 files changed, 76 insertions(+), 153 deletions(-)

llvm-svn: 95546
2010-02-08 16:39:00 +00:00
Ted Kremenek 57f0989c16 Revert 95541.
llvm-svn: 95545
2010-02-08 16:18:51 +00:00
Douglas Gregor f65bbb31e8 Cache imported types
llvm-svn: 95543
2010-02-08 15:18:58 +00:00
Zhongxing Xu 500f49fe25 Rename: GRState::getSVal(Stmt*) => getExprVal(),
GRState::getSVal(MemRegion*) => Load().

llvm-svn: 95541
2010-02-08 09:30:02 +00:00
Zhongxing Xu c5f825eacd BindInternal is redundant. Remove it.
llvm-svn: 95540
2010-02-08 08:48:05 +00:00
Zhongxing Xu 8ca2dc05a3 Like for symbolic region, automatically create a element zero region for
alloca region.

llvm-svn: 95539
2010-02-08 08:43:02 +00:00
Zhongxing Xu b02d4a0d11 Unify the implementation of getLValueElement of store managers.
It's more sophisticated than the original one of BasicStore. But it does
matter. 

llvm-svn: 95536
2010-02-08 08:17:02 +00:00
Zhongxing Xu f7f0cdc517 Unify the implementation of getLValueIvar and getLValueField of store managers.
llvm-svn: 95535
2010-02-08 07:58:06 +00:00
Zhongxing Xu 08515a5242 Move common methods to the base StoreManager class.
llvm-svn: 95534
2010-02-08 07:10:35 +00:00
Chandler Carruth 794da4c236 This doesn't seem to be used code as it didn't break any tests, but fix the
glaring logic bug anyways. =D

llvm-svn: 95533
2010-02-08 06:42:49 +00:00
Zhongxing Xu 8ffee4d5f8 ASTContext is now a reference member of StoreManager.
llvm-svn: 95531
2010-02-08 06:00:22 +00:00
Zhongxing Xu 000a859f05 Add support for binding and retrieving VarRegions in flat store.
llvm-svn: 95529
2010-02-08 05:40:07 +00:00
Chandler Carruth c126311d3e Require a complete type before examining base classes during template argument
deduction. This requires refactoring the deduction to have access to the Sema
object instead of merely the ASTContext. Still leaves something to be desired
due to poor source location.

Fixes PR6257 and half of PR6259.

llvm-svn: 95528
2010-02-07 21:33:28 +00:00
Anders Carlsson ff8cce4395 Make sure to set vtable pointers in the destructors as well.
llvm-svn: 95525
2010-02-07 19:45:40 +00:00
Anders Carlsson 6d0e5bd8f3 Use the right type when taking the address of a non-virtual member function pointer. Fixes PR6258.
llvm-svn: 95524
2010-02-07 17:37:13 +00:00
Douglas Gregor 0e027fb32b Workaround for friend template instantiation crash in PR5848, from Keir Mierle!
llvm-svn: 95517
2010-02-07 10:31:35 +00:00
Douglas Gregor b65a913c35 Fix assertion failure when parsing linkage specifications (PR5921),
from Keir Mierle!

llvm-svn: 95516
2010-02-07 08:38:28 +00:00
Sam Weinig e83b3aca0b Roll r95513 back in.
llvm-svn: 95515
2010-02-07 06:32:43 +00:00
Sam Weinig e911058bb5 Roll out r95513, it seems to have broken self hosting.
llvm-svn: 95514
2010-02-07 05:26:25 +00:00
Sam Weinig db3758c40d Add PCH support for CXXBoolLiteralExpr and CXXNullPtrLiteralExpr.
llvm-svn: 95513
2010-02-07 04:44:10 +00:00
Anders Carlsson cee2d2f016 Use the right linkage for static variables inside C++ inline functions.
llvm-svn: 95512
2010-02-07 02:03:08 +00:00
Anders Carlsson 10d369d1a2 Improved handling of the visibility attribute. Declarations now inherit their parent's visibility.
(This is kind of a risky change, but I did a self-host build and everything appears to work fine!)

llvm-svn: 95511
2010-02-07 01:44:36 +00:00
Anders Carlsson a7bcade229 Add attributes to namespace decls.
llvm-svn: 95510
2010-02-07 01:09:23 +00:00
Anders Carlsson 9878f9f73b Make EmitStartEHSpec and EmitEndEHSpec return early when exceptions are disabled.
llvm-svn: 95509
2010-02-06 23:59:05 +00:00
Anders Carlsson fcd764a168 Add support for threadsafe statics, and make them the default (matching gcc).
Daniel, I'd appreciate a review of the driver/cc1 parts.

llvm-svn: 95508
2010-02-06 23:23:06 +00:00
Anders Carlsson 5ade5d39b4 Call destructors for constructed bases as well.
llvm-svn: 95502
2010-02-06 20:00:21 +00:00
Anders Carlsson ba63167b64 If a constructor throws an exception we need to execute the destructors for all fully constructed members. Fixes ctor_dtor_count.cpp in the test suite.
llvm-svn: 95501
2010-02-06 19:50:17 +00:00
John McCall 15dda3701a Use a substituted type when determining how to substitute in non-type template
params.  Don't insert addrof operations when matching against a pointer;
array/function conversions should take care of this for us, assuming the
argument type-checked in the first place.  Add a fixme where we seem to be
using a less-restrictive reference type than we should.

Fixes PR 6249.

llvm-svn: 95495
2010-02-06 10:23:53 +00:00
Benjamin Kramer 4692faa7a4 Silence GCC warning and stay in 80 cols.
llvm-svn: 95494
2010-02-06 09:59:24 +00:00
John McCall 13481c56c3 Extract a function to instantiate references to value template parameters.
llvm-svn: 95491
2010-02-06 08:42:39 +00:00
Anders Carlsson 96c15b1816 Don't diagnose missing noreturns for uninstantiated templates. Fixes PR6247.
llvm-svn: 95487
2010-02-06 05:31:15 +00:00
Douglas Gregor 61f6db54e1 Switch CodeGen's "is this variable declaration a definition?" logic
over to VarDecl::isThisDeclarationADefinition(), which handles
variables declared with linkage specifications better (among other
things). CMake 2.9 (from CVS) now builds with clang++ and is somewhat
functional.

llvm-svn: 95486
2010-02-06 05:15:45 +00:00
Anders Carlsson 2c4de4c31e Only append 'L' for internal variable declarations, not all declarations. (Found by the mangle checker, yay)
llvm-svn: 95485
2010-02-06 04:52:27 +00:00
Ted Kremenek bdfcacbe8f Also teach RegionStore::RetrieveVar() to handle 'static' pointers that are implicitly initialized to NULL.
llvm-svn: 95479
2010-02-06 04:04:46 +00:00
Ted Kremenek 30fe9ecac2 Fix regression in RegionStore (from BasicStore) where static variables were not treated as being implicitly initialized to 0 (and instead were getting symbolicated).
llvm-svn: 95478
2010-02-06 03:57:59 +00:00
Ted Kremenek 9c193965ba Remove unused variable.
llvm-svn: 95476
2010-02-06 03:29:18 +00:00
Anders Carlsson 6710c5351e Use the correct function info for constructors when applying function attributes. Fixes PR6245.
llvm-svn: 95474
2010-02-06 02:44:09 +00:00
Anders Carlsson 0da714a3e2 Implement a warning diagnostic for weak vtables. Fixes PR6116.
llvm-svn: 95472
2010-02-06 02:27:10 +00:00
John McCall ce410662ce Teach Sema how to instantiate a local function declaration properly. Fixes
PR 5517.

llvm-svn: 95470
2010-02-06 01:50:47 +00:00
Douglas Gregor cae03b1e6d Assert when we try to mangle a dependent template name, rather than
crashing unceremoniously.

llvm-svn: 95464
2010-02-06 01:09:36 +00:00
John McCall 52cc0897f3 Per discussion, remove the explicit restriction on static const data members with
out-of-line initializers as integer constant expressions.  Fixes PR6206.

llvm-svn: 95463
2010-02-06 01:07:37 +00:00
Ted Kremenek 5abd69d946 Teach RegionStore::InvalidateRegions() to also invalidate static variables referenced by blocks.
llvm-svn: 95459
2010-02-06 00:30:00 +00:00
John McCall ca972cd1f1 Rearrange some checks to avoid call to isCopyConstructor() and clarify path
taken for non-trivial constructors.

llvm-svn: 95457
2010-02-06 00:25:16 +00:00
Douglas Gregor d320e03eed Fix a bogus assertion after adjusting the type of a substituted
non-type template argument for a non-type template parameter of
pointer type. Fixes PR6244.

llvm-svn: 95447
2010-02-05 22:49:09 +00:00
Douglas Gregor d225fa05bd Cope with finding the "instantiated" declaration when we are
type-checking within a template definition. In this case, the
"instantiated" declaration is just the declaration itself, found
within the current instantiation. Fixes PR6239.

llvm-svn: 95442
2010-02-05 22:40:03 +00:00
John McCall ab26cfa58d Standardize the parsing of function type attributes in a way that
follows (as conservatively as possible) gcc's current behavior:  attributes
written on return types that don't apply there are applied to the function
instead, etc.  Only parse CC attributes as type attributes, not as decl attributes;
don't accepet noreturn as a decl attribute on ValueDecls, either (it still
needs to apply to other decls, like blocks).  Consistently consume CC/noreturn
information throughout codegen;  enforce this by removing their default values
in CodeGenTypes::getFunctionInfo().

llvm-svn: 95436
2010-02-05 21:31:56 +00:00
Ted Kremenek 31e7f0f293 Add guard in RewriteObjC::HandleTopLevelSingleDecl() to not do
anything when Sema has issued an error.  This matches the behavior in
RewriteObjC::HandleTranslationUnit().

llvm-svn: 95434
2010-02-05 21:28:51 +00:00
Douglas Gregor a643780483 Revert r95393, which broke Clang's self-host.
llvm-svn: 95430
2010-02-05 21:10:36 +00:00
Douglas Gregor a16b0cae9a Implement name mangling for template template parameters
llvm-svn: 95427
2010-02-05 20:45:00 +00:00
Daniel Dunbar 9c4e4651d5 IRgen: A few more ConvertType cleanups.
llvm-svn: 95423
2010-02-05 20:02:42 +00:00
Douglas Gregor b9397108c5 Fix two issues with the substitution of template template parameters
when instantiating the declaration of a member template:
  - Only check if the have a template template argument at a specific position
  when we already know that we have template arguments at that level;
  otherwise, we're substituting for a level-reduced template template
  parameter. 
  - When trying to find an instantiated declaration for a template
  template parameter, look into the instantiated scope. This was a
  typo, where we had two checks for TemplateTypeParmDecl, one of
  which should have been a TemplateTemplateParmDecl.

With these changes, tramp3d-v4 passes -fsyntax-only.

llvm-svn: 95421
2010-02-05 19:54:12 +00:00
Daniel Dunbar d0bc7b9d13 IRgen: Factor out EmitAggExprToLValue.
llvm-svn: 95416
2010-02-05 19:38:31 +00:00
Fariborz Jahanian df506b934e Fix a code gen bug accessing 'isa' field via a message call
(Fixes radar 7609722).

llvm-svn: 95406
2010-02-05 19:18:30 +00:00
Douglas Gregor 7df89f5d18 When we're parsing an expression that may have looked like a
declaration, we can end up with template-id annotation tokens for
types that have not been converted into type annotation tokens. When
this is the case, translate the template-id into a type and parse as
an expression.

llvm-svn: 95404
2010-02-05 19:11:37 +00:00
Daniel Dunbar 8848175547 IRgen: Fix some CreateTempAlloca calls to use ConvertTypeForMem when that is
conceptually correct. Review appreciated (Chris, Eli, Anders).

llvm-svn: 95401
2010-02-05 18:56:49 +00:00
Anders Carlsson cb86e1088a Fix the bug that was breaking self-host, and re-land the static ctor fixes.
llvm-svn: 95400
2010-02-05 18:38:45 +00:00
Charles Davis 5a5473f0f8 Now that we store calling conventions in the types, use them instead of
getting the calling convention from the target function, which may or may not
exist. Fixes PR5280.

llvm-svn: 95399
2010-02-05 18:13:10 +00:00
Douglas Gregor 96e578d29d Initial skeleton of an AST "importer", which will take AST elements from
one context and import them into another context, merging them
according to language-specific rules. This is a skeleton. It doesn't
work, it isn't testable, but I want it in version control.

llvm-svn: 95395
2010-02-05 17:54:41 +00:00
Charles Davis e4e604b5d6 Testing, 1, 2, 3...
Also make the comments I added in r95291 consistent.

llvm-svn: 95394
2010-02-05 17:53:51 +00:00
Daniel Dunbar 363589bded IRgen: Use hasAggregateLLVMType instead of isSingleValueType() for cases that
need to deal with aggregates specially; this is consistent with the rest of IRgen.

Also, simplify EmitParmDecl and don't worry about using Decl::getNameAsString.

llvm-svn: 95393
2010-02-05 17:51:33 +00:00
Fariborz Jahanian 314333847e Fixes a minor rewriter bug messaging inside a function call.
Fixes radar 7617047.

llvm-svn: 95392
2010-02-05 17:48:10 +00:00
Fariborz Jahanian a7e1dcdc0e Some clean up of replacement text API no longer needed by
my recent changes.

llvm-svn: 95391
2010-02-05 16:43:40 +00:00
Douglas Gregor af77cd220a Revert r95363 and r95375, which broke self-host.
llvm-svn: 95389
2010-02-05 16:18:08 +00:00
Douglas Gregor 0ab7af6c28 A dependent initializer with zero arguments should return a NULL
initializer (for no initialization) rather than a ParenListExpr with
zero arguments in it.

llvm-svn: 95382
2010-02-05 07:56:11 +00:00
Chandler Carruth bc50da6360 Revert the unused TST_pixel entry from r95335 as it is not listed in the Sema
switch, triggering warnings.

llvm-svn: 95381
2010-02-05 07:38:55 +00:00
Douglas Gregor 8c702534cb Default function arguments for function template specializations
always come from the primary template, so gather the instantiation
template arguments from the primary template.

llvm-svn: 95380
2010-02-05 07:33:43 +00:00
Daniel Dunbar 4e9083260b Tweak inliner thresholds to match llvm-gcc, see r95321.
llvm-svn: 95379
2010-02-05 07:32:37 +00:00
Anders Carlsson c6eec40189 Check in a mangle checker that's turned off by default.
llvm-svn: 95377
2010-02-05 07:31:37 +00:00
Douglas Gregor 3ce7493c35 Teach C++ name lookup that it's okay to look in a scope without a
context. This happens fairly rarely (which is why we got away with
this bug). Fixes PR6184, where we skipped over the template parameter
scope while tentatively parsing.

llvm-svn: 95376
2010-02-05 07:07:10 +00:00
Anders Carlsson 893555ce66 Fix array initialization test.
llvm-svn: 95375
2010-02-05 07:00:11 +00:00
Douglas Gregor 1aa3edbb99 A function declarator with a non-identifier name in an anonymous class
is a constructor for that class, right? Fixes PR6238. 

llvm-svn: 95367
2010-02-05 06:12:42 +00:00
Zhongxing Xu ad0ef84040 More GRState* -> Store changes.
llvm-svn: 95365
2010-02-05 05:34:29 +00:00
Zhongxing Xu 0d081f373a Remove unused parameter.
llvm-svn: 95364
2010-02-05 05:24:20 +00:00
Anders Carlsson ecac409cb0 If a global initializer has a non-trivial destructor it can't be emitted as a constant (even if it has a trivial constructor).
llvm-svn: 95363
2010-02-05 05:19:42 +00:00
Zhongxing Xu f668204a6a More GRState* -> Store changes.
llvm-svn: 95362
2010-02-05 05:18:47 +00:00
Douglas Gregor 6ec89d4953 When adding ADL candidates for overloaded
post-increment/post-decrement operators, be sure to consider both
arguments. Fixes PR6237.

llvm-svn: 95361
2010-02-05 05:15:43 +00:00
Zhongxing Xu 7fcd8acbf8 More GRState* -> Store changes.
llvm-svn: 95360
2010-02-05 05:06:13 +00:00
Douglas Gregor 8a6d15d5ed When determining whether a scope specifier is complete, consider a
dependent DeclContext to be "complete". Fixes PR6236.

llvm-svn: 95359
2010-02-05 04:39:02 +00:00
Zhongxing Xu c7b9f950d7 More GRState* -> Store changes.
llvm-svn: 95357
2010-02-05 03:01:53 +00:00
Zhongxing Xu bd96bf1e78 Change LazyCompoundVal to a <Store, MemRegion*> pair. We really don't need to
spread GRState* everywhere.

llvm-svn: 95354
2010-02-05 02:26:30 +00:00
Ted Kremenek 2f2692f8ca Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.
llvm-svn: 95348
2010-02-05 02:06:54 +00:00
Ted Kremenek b6e400c87c Rename -cc1 option '-warn-objc-missing-dealloc' to '-analyzer-check-objc-missing-dealloc'.
llvm-svn: 95347
2010-02-05 01:59:21 +00:00
Ted Kremenek 61b506aa8f Rename -cc1 option '-warn-objc-methodsigs' to '-analyzer-check-objc-methodsigs'.
llvm-svn: 95346
2010-02-05 01:57:44 +00:00
Ted Kremenek 2d8ef71ae6 Rename -cc1 option '-warn-objc-unused-ivars' to '-analyzer-check-objc-unused-ivars'.
llvm-svn: 95345
2010-02-05 01:55:01 +00:00
Ted Kremenek d519b83757 Rename -cc1 option '-warn-dead-stores' to '-analyzer-check-dead-stores'.
llvm-svn: 95343
2010-02-05 01:52:40 +00:00
Ted Kremenek ec5b3d45c1 Rename -cc1 option '-warn-security-syntactic' to '-analyzer-check-security-syntactic'.
llvm-svn: 95342
2010-02-05 01:50:36 +00:00
Fariborz Jahanian 80fadb5069 Fix a nested ivar reference rewriting bug.
(Fixes radar 7607605).

llvm-svn: 95341
2010-02-05 01:35:00 +00:00
John McCall ae580fede3 Always start tag definitions before completing them. Assert same.
Fixes latent and not-so-latent objc++ and blocks++ bugs.

llvm-svn: 95340
2010-02-05 01:33:36 +00:00
John Thompson 2233460de6 First stage of adding AltiVec support
llvm-svn: 95335
2010-02-05 00:12:22 +00:00
Douglas Gregor 0c8a172911 Fix a crash with ill-formed code within a method in an ill-formed
category implementation, which showed up during (attempted) typo
correction. Fixes <rdar://problem/7605289>.

llvm-svn: 95334
2010-02-04 23:42:48 +00:00
John McCall 67da35c832 Extract a common structure for holding information about the definition
of a C++ record.  Exposed a lot of problems where various routines were
silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order)
when presented with a non-definition.  Also cuts down on memory usage.

llvm-svn: 95330
2010-02-04 22:26:26 +00:00
Ted Kremenek 1de1707bfc Move ParseFormatString() and FormatStringHandler back into the analyze_printf namespace.
llvm-svn: 95324
2010-02-04 20:46:58 +00:00
Douglas Gregor c42075a164 Fix an obscure crash found in the Boost.MPL test suite, along with a
ton of potential crashes of the same kind. The fundamental problem is
that type creation was following a dangerous pattern when using its
FoldingSets:
  1) Use FindNodeOrInsertPos to see if the type is available
  2) If not, and we aren't looking at a canonical type, build the
  canonical type
  3) Build and insert the new node into the FoldingSet

The problem here is that building the canonical type can, in very rare
circumstances, force the hash table inside the FoldingSet to
reallocate. That invalidates the insertion position we computed in
step 1, and in step 3 we end up inserting the new node into the wrong
place. BOOM!

I've audited all of ASTContext, fixing this problem everywhere I found
it. The vast majority of wrong code was C++-specific (and *ahem*
written by me), so I also audited other major folding sets in the C++
code (e.g., template specializations), but found no other instances of
this problem.

llvm-svn: 95315
2010-02-04 18:10:26 +00:00
Anders Carlsson 824e0613de When binding an lvalue to a reference, we always need to pop temporaries.
With this fix, and the other fixes committed today a make check-all with a clang-built LLVM now gives:

Expected Passes    : 6933
Expected Failures  : 46
Unsupported Tests  : 40
Unexpected Failures: 27

which means that we pass 99.96% of all tests :) The resulting 27 tests are all LLVMC tests and seem to be because of differences in the clang and gcc drivers.

llvm-svn: 95313
2010-02-04 17:32:58 +00:00
Anders Carlsson 9b942c65a5 Fix a bug where we would not mark temporaries as conditional when emitting a conditional operator as an lvalue.
llvm-svn: 95311
2010-02-04 17:26:01 +00:00
Douglas Gregor eca8f5a49c When substituting the template argument for a pointer non-type
template parameter, perform array/function decay (if needed), take the
address of the argument (if needed), perform qualification conversions
(if needed), and remove any top-level cv-qualifiers from the resulting
expression. Fixes PR6226.

llvm-svn: 95309
2010-02-04 17:21:48 +00:00
Anders Carlsson ae612d22ac Rename StartConditionalBranch/FinishConditionalBranch to BeginConditionalBranch/EndConditionalBranch.
llvm-svn: 95308
2010-02-04 17:18:07 +00:00
Anders Carlsson c4325486b9 Fix another pointer-to-member function miscompile, this time when trying to call a virtual member function.
llvm-svn: 95307
2010-02-04 17:08:48 +00:00
Anders Carlsson 7914dad72d Calculate offset correctly when taking the address of a virtual member function.
llvm-svn: 95305
2010-02-04 16:38:05 +00:00
John McCall cddbad000d Allow calling convention attributes to apply to types. Patch by Chip Davis!
llvm-svn: 95291
2010-02-04 05:44:44 +00:00
Zhongxing Xu 319deb83d2 Cast evaluation no longer touch GRState.
llvm-svn: 95290
2010-02-04 04:56:43 +00:00
Ted Kremenek 49f878524c Specially handle casts to 'void' in AdjustedReturnValueChecker.
llvm-svn: 95287
2010-02-04 04:18:55 +00:00
Ted Kremenek 33617e055a Remove stray typo.
llvm-svn: 95286
2010-02-04 04:14:49 +00:00
John McCall d061b4429e Mangle member expressions. Also invented.
llvm-svn: 95284
2010-02-04 02:56:29 +00:00
Zhongxing Xu 4f8b9899bb Now that CastRetrievedVal returns SVal, there is no need to use CastResult.
llvm-svn: 95279
2010-02-04 02:39:47 +00:00
John McCall 11ef09f8b5 Add a cautionary note about the mangling I just invented.
llvm-svn: 95275
2010-02-04 01:48:38 +00:00
John McCall 09de8ecd88 Add mangling support for calls, sizeof/alignof, constructor calls,
float literals, and unresolved lookups (which required hand-wavey extensions).

llvm-svn: 95273
2010-02-04 01:42:13 +00:00
Ted Kremenek 1e3b95580c static analyzer: handle casts of a function to a function pointer with
a different return type.  While we don't emit any errors (yet), at
least we avoid cases where we might crash because of an assertion
failure later on (when the return type differs from what is expected).

llvm-svn: 95268
2010-02-04 00:47:48 +00:00
Fariborz Jahanian b8355e3b9f Fix rewriting of 'const' __block variables in
the rewriter. (Fixes radar 7607781).

llvm-svn: 95267
2010-02-04 00:07:58 +00:00
Anders Carlsson b0695ef011 Don't try to fold DeclRefExprs that point to ParmVarDecls. This had the side-effect of always folding the expression to the default argument of the parameter. For example:
void f(int a = 10) {
  return a;
}

would always return 10, regardless of the passed in argument.

This fixes another 600 test failures. We're now down to only 137 failures!

llvm-svn: 95262
2010-02-03 21:58:41 +00:00
Fariborz Jahanian 80c54b05a0 Fix more rewriting of protocol-quialified 'id' type.
(Fixes radar 7607413).

llvm-svn: 95257
2010-02-03 21:29:28 +00:00
Sebastian Redl 2b37272c11 In some contexts, type declarations cannot occur. Pass this information down to ParseClassSpecifier, to make its decision easier. Fixes PR6200.
llvm-svn: 95255
2010-02-03 21:21:43 +00:00
Chris Lattner 93ddf80eb7 don't inform comment handlers about comments in #if 0 blocks,
doing so invalidates the file guard optimization and is not
in the spirit of "#if 0" because it is supposed to completely
skip everything, even if it isn't lexically valid. Patch by
Abramo Bagnara!

llvm-svn: 95253
2010-02-03 21:06:21 +00:00
Douglas Gregor 21e771e96e Define two types to be "compatible" in C++ if they are the same, and
remove some age-old FIXMEs and C++ workarounds within the
type-compatibility logic.

llvm-svn: 95249
2010-02-03 21:02:30 +00:00
Chris Lattner 5e854b95f3 Declarators can have grouping parens. This fixes rdar://7608537.
llvm-svn: 95246
2010-02-03 20:41:24 +00:00
Fariborz Jahanian 8c3f06d09c Patch to allow reinterpret_cast on objective-c pointers.
(partial fix for radar 7591784).

llvm-svn: 95245
2010-02-03 20:32:31 +00:00
Daniel Dunbar 45858d2d59 Revert "Numerous changes to selector handling:", this breaks a whole bunch of
working code, for no apparent reason.

llvm-svn: 95244
2010-02-03 20:11:42 +00:00
Sebastian Redl cbdffb1585 Top-level const changes do not make a qualification conversion. Fixes PR6089.
llvm-svn: 95239
2010-02-03 19:36:07 +00:00
Douglas Gregor 2973d406ba When determining whether a function without a prototype is compatible
with a function with a prototype, treat parameters of enumeration type
based on the enumeration type's promotion type.

llvm-svn: 95238
2010-02-03 19:27:29 +00:00
Anders Carlsson 66498388a7 Handle reference binding in aggregate initializers. Fixes another 47 tests.
llvm-svn: 95235
2010-02-03 19:13:55 +00:00
Anders Carlsson 9b92ef90f0 Add a band-aid fix for clang self-hosting. A better fix will follow shortly.
llvm-svn: 95232
2010-02-03 18:54:13 +00:00
Eli Friedman eb1df70bdc Fix for PR6220: compute the correct type for multicharacter literals.
llvm-svn: 95228
2010-02-03 18:21:45 +00:00
Anders Carlsson b247350ef7 More cleanup.
llvm-svn: 95226
2010-02-03 17:33:16 +00:00
Anders Carlsson 3b227bd629 Revert the new reference binding code; I came up with a way simpler solution for the reference binding bug that is preventing self-hosting.
llvm-svn: 95223
2010-02-03 16:38:03 +00:00
David Chisnall 5bb4efdf3c First pass at adding GC support for GNU runtime. GC ivar maps not yet constructed, GC flag not set.
Please don't try using this yet - the runtime support is still very immature and your code will almost certainly crash if you do.  

llvm-svn: 95222
2010-02-03 15:59:02 +00:00
Chandler Carruth 935384217d Teach the allocation function overload handling to deal with templates, and
prevent a crash on templates when looking for an existing declaration of the
predefined global operators. This fixes PR5918.

Added an easy test case for the overload handling, but testing the crash is
a bit trickier. Created a new test that can use multiple runs with a define to
trigger which test case is used so we can test this type of issue.

llvm-svn: 95220
2010-02-03 11:02:14 +00:00
Chandler Carruth 7ceffab64d Fix PR6149 by looking at the qualifiers on the referred to type for non-type
reference template arguments. Adds test cases for the cv-quals of reference
arguments.

llvm-svn: 95217
2010-02-03 09:37:33 +00:00
Douglas Gregor 7dc5c17d92 When a function or variable somehow depends on a type or declaration
that is in an anonymous namespace, give that function or variable
internal linkage.

This change models an oddity of the C++ standard, where names declared
in an anonymous namespace have external linkage but, because anonymous
namespace are really "uniquely-named" namespaces, the names cannot be
referenced from other translation units. That means that they have
external linkage for semantic analysis, but the only sensible
implementation for code generation is to give them internal
linkage. We now model this notion via the UniqueExternalLinkage
linkage type. There are several changes here:

  - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage
    when the declaration is in an anonymous namespace.
  - Added Type::getLinkage() to determine the linkage of a type, which
    is defined as the minimum linkage of the types (when we're dealing
    with a compound type that is not a struct/class/union).
  - Extended NamedDecl::getLinkage() to consider the linkage of the
    template arguments and template parameters of function template
    specializations and class template specializations.
  - Taught code generation to rely on NamedDecl::getLinkage() when
    determining the linkage of variables and functions, also
    considering the linkage of the types of those variables and
    functions (C++ only). Map UniqueExternalLinkage to internal
    linkage, taking out the explicit checks for
    isInAnonymousNamespace().

This fixes much of PR5792, which, as discovered by Anders Carlsson, is
actually the reason behind the pass-manager assertion that causes the
majority of clang-on-clang regression test failures. With this fix,
Clang-built-Clang+LLVM passes 88% of its regression tests (up from
67%). The specific numbers are:

LLVM:
  Expected Passes    : 4006
  Expected Failures  : 32
  Unsupported Tests  : 40
  Unexpected Failures: 736

Clang:
  Expected Passes    : 1903
  Expected Failures  : 14
  Unexpected Failures: 75

Overall:
  Expected Passes    : 5909
  Expected Failures  : 46
  Unsupported Tests  : 40
  Unexpected Failures: 811

Still to do:
  - Improve testing
  - Check whether we should allow the presence of types with
  InternalLinkage (in addition to UniqueExternalLinkage) given
  variables/functions internal linkage in C++, as mentioned in
  PR5792. 
  - Determine how expensive the getLinkage() calls are in practice;
  consider caching the result in NamedDecl.
  - Assess the feasibility of Chris's idea in comment #1 of PR5792.

llvm-svn: 95216
2010-02-03 09:33:45 +00:00
Chandler Carruth 54a0f48e0b Add FlatStore.cpp (from r95214) to CMake build. Don't forget about it! =D
llvm-svn: 95215
2010-02-03 09:31:39 +00:00
Zhongxing Xu 5df3f53616 Add skeleton of flat store manager.
llvm-svn: 95214
2010-02-03 09:10:32 +00:00
Douglas Gregor 4a2f5464a7 Look through CXXExprWithTemporaries when digging out the original
initializer. Grrr....

llvm-svn: 95211
2010-02-03 09:01:59 +00:00
Chris Lattner 78c8eaa4cb update for llvm api change.
llvm-svn: 95203
2010-02-03 05:55:22 +00:00
Chris Lattner eb1e610d00 remove a big chunk of #if 0 code.
llvm-svn: 95201
2010-02-03 05:28:17 +00:00
Ted Kremenek d960564b76 Fix regression in RegionStore due to recent changes in
RegionStoreManager::InvalidateRegions() by adjusting the worklist to
iterate over BindingKeys instead of MemRegions.  We also only need to
do the actual invalidation work on base regions, and for non-base
regions just blow away their bindings.

llvm-svn: 95200
2010-02-03 04:16:00 +00:00
Sam Weinig a16b0dd1ae Implement Doug's suggestion. Eliminate the Stmts pointer from CXXTryStmt and instead allocate the statements after the object.
llvm-svn: 95199
2010-02-03 03:56:39 +00:00
Daniel Dunbar c434394d18 Driver: Add -[no-]integrated-as for clang.
- Requires backend support, which only exists for i386--darwin currently.

No 'as' required:
--
ddunbar@ozzy:tmp$ cat t.c
int main() { return 42; }
ddunbar@ozzy:tmp$ clang -m32 -integrated-as t.c


ddunbar@ozzy:tmp$ ./a.out; echo $?
42
ddunbar@ozzy:tmp$
--

The random extra whitespace is how you know its working! :)

llvm-svn: 95194
2010-02-03 03:07:56 +00:00
Ted Kremenek 64efd0d213 Rework RegionStoreManager's implementation of InvalidateRegions() to
not build a subregion map and instead do a single scan of the store.
This is done by building "region clusters" that represent the
collection of regions that have the same base region.  Invalidating
any region in a cluster means that they all should get invalidated.

This change brought out a point that Zhongxing mentioned to me
offline: the flattened memory binding has issues distinguishing
between direct and default bindings.  For example, setting the default
value for an entire struct is the same as binding to the first
element.  To address this problem, I moved the binding "tag" (Direct
or Default) from BindingVal to BdingKey (and removed BindingVal
entirely).  This requires us to do double lookups in some cases; and
there is still much more cleanup that can be done.

This change produced a noticeable speedup when analyzing sqlite3 (a
reduction of 4% in running time).

llvm-svn: 95193
2010-02-03 03:06:46 +00:00
Douglas Gregor db56b919e5 Provide a real fix for PR6199, reverting the old workaround. Here, we
realize that CXXConstructExpr is always implicit, so we should just
return its argument (if there is only one) rather than directly
invoking the constructor.

llvm-svn: 95192
2010-02-03 03:01:57 +00:00
Sam Weinig ebcea988c2 Remove the SmallVector from CXXTryStmt.
llvm-svn: 95190
2010-02-03 02:09:59 +00:00
David Chisnall 92b762e256 Numerous changes to selector handling:
- Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon.  This also simplifies the code generated by the GNU runtime a bit.  

- Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant.

- Recognise @selector() expressions as valid static initialisers (as GCC does).

- Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants.  These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load.

- Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector.  This is needed for generating typed selectors from @selector() expressions (as GCC does).  Ideally, this information should be stored in the Selector, but that would be an invasive change.  We should eventually add checks for common uses of @selector() expressions.  Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this:

- (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL)
           withObject: (id)object;

Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature.  We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes.

- Made @selector() expressions emit type info if available and the runtime supports it.

Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac.  This currently just assert()s.

llvm-svn: 95189
2010-02-03 02:09:30 +00:00