Commit Graph

20243 Commits

Author SHA1 Message Date
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
Sebastian Redl d85be0cc60 Don't do an expensive definition check where a cheap 'is this C?' check suffices.
llvm-svn: 95188
2010-02-03 02:08:48 +00:00
Chris Lattner 35af0ab3eb fix PR6216
llvm-svn: 95185
2010-02-03 01:45:03 +00:00
Daniel Dunbar 92db0fbe5a clang -cc1: Wire up -emit-obj, for emitting object files.
llvm-svn: 95182
2010-02-03 01:18:43 +00:00
John McCall 2adddcae7e Remove abstract expression kinds from the StmtClass enum. Update a few users
appropriately.  Call out a few missing cases in the expression mangler.

llvm-svn: 95176
2010-02-03 00:55:45 +00:00
Fariborz Jahanian e165191990 Simplify setting of DeclContext for @catch variable
(per Doug's comment).

llvm-svn: 95169
2010-02-03 00:32:51 +00:00
Douglas Gregor b92a1565c3 Implement the lvalue-to-rvalue conversion where needed. The
lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class
type to rvalue expressions of the unqualified variant of that
type. For example, given:

  const int i;
  (void)(i + 17);

the lvalue-to-rvalue conversion for the subexpression "i" will turn it
from an lvalue expression (a DeclRefExpr) with type 'const int' into
an rvalue expression with type 'int'. Both C and C++ mandate this
conversion, and somehow we've slid through without implementing it. 

We now have both DefaultFunctionArrayConversion and
DefaultFunctionArrayLvalueConversion, and which gets used depends on
whether we do the lvalue-to-rvalue conversion or not. Generally, we do
the lvalue-to-rvalue conversion, but there are a few notable
exceptions:
  - the left-hand side of a '.' operator
  - the left-hand side of an assignment
  - a C++ throw expression
  - a subscript expression that's subscripting a vector

Making this change exposed two issues with blocks:
  - we were deducing const-qualified return types of non-class type
  from a block return, which doesn't fit well
  - we weren't always setting the known return type of a block when it
  was provided with the ^return-type syntax

Fixes the current Clang-on-Clang compile failure and PR6076.

llvm-svn: 95167
2010-02-03 00:27:59 +00:00
Fariborz Jahanian 08d614d92e Fix DeclContext of an objective-c @catch variable
declaration. Fixes radar 7590273.

llvm-svn: 95164
2010-02-03 00:01:43 +00:00
Ted Kremenek b251eb6901 Remove RegionStoreSubRegionMap::iterator and RegionStoreSubRegionMap::begin_end(). This is a precursor to using DenseSet to represent region sets instead of ImmutableSet.
llvm-svn: 95151
2010-02-02 22:38:47 +00:00
Ted Kremenek 416b923786 Explicitly check for casts to double or complex types instead of possibly asserting in SValuator.
llvm-svn: 95128
2010-02-02 21:11:40 +00:00
Chris Lattner 60272554aa update for llvm api changes.
llvm-svn: 95125
2010-02-02 21:06:50 +00:00
Douglas Gregor a71cc15361 Implement promotion for enumeration types.
WHAT!?!

It turns out that Type::isPromotableIntegerType() was not considering
enumeration types to be promotable, so we would never do the
promotion despite having properly computed the promotion type when the
enum was defined. Various operations on values of enum type just
"worked" because we could still compute the integer rank of an enum
type; the oddity, however, is that operations such as "add an enum and
an unsigned" would often have an enum result type (!). The bug
actually showed up as a spurious -Wformat diagnostic
(<rdar://problem/7595366>), but in theory it could cause miscompiles.

In this commit:
  - Enum types with a promotion type of "int" or "unsigned int" are
  promotable.
  - Tweaked the computation of promotable types for enums
  - For all of the ABIs, treat enum types the same way as their
  underlying types (*not* their promotion types) for argument passing
  and return values
  - Extend the ABI tester with support for enumeration types

llvm-svn: 95117
2010-02-02 20:10:50 +00:00
Anders Carlsson 5dc86337fb Set the correct vtable pointers _before_ generating code for any member initializers. Fixes about ~2000 clang/LLVM tests in the clang-on-clang build.
llvm-svn: 95116
2010-02-02 19:58:43 +00:00
Chris Lattner f3c1b08508 update for llvm api change.
llvm-svn: 95110
2010-02-02 19:14:34 +00:00
Anders Carlsson 8345a07c25 Fix test.
llvm-svn: 95108
2010-02-02 19:09:34 +00:00
John McCall eba90cd682 Dump the constructor type for a CXXConstructExpr.
llvm-svn: 95106
2010-02-02 19:03:45 +00:00
John McCall c17ae44b09 Fix this comment.
llvm-svn: 95104
2010-02-02 19:02:38 +00:00
Sebastian Redl f184291fec Check for redefinitions in MergeVarDecl. This finds redefinitions of globals without an initializer in C++ and thus fixes PR5451.
llvm-svn: 95098
2010-02-02 18:35:11 +00:00
Fariborz Jahanian 06769f9197 Fix up rewriting of protocol qualified types in objc rewriter.
Fixes radar 7589414.

llvm-svn: 95097
2010-02-02 18:35:07 +00:00
Sebastian Redl ccdb5ff17d Fix a C++ regression where redefinitions weren't diagnosed.
llvm-svn: 95096
2010-02-02 17:55:12 +00:00
Douglas Gregor efbaf99dca Include <stdlib.h>, so that we're sure to get atoi.
llvm-svn: 95095
2010-02-02 17:49:52 +00:00
Chris Lattner afe6a840d4 the declspec of a declaration can have storage-class specifiers,
type qualifiers and type specifiers in any order.   For example,
this is valid: struct x {...} typedef y;

This fixes PR6208.

llvm-svn: 95094
2010-02-02 17:32:27 +00:00
Daniel Dunbar ffa70e8b27 Driver/Darwin: Don't error/warn on conflicting deployment targets. Apparently
this is still a popular thing to do.

llvm-svn: 95093
2010-02-02 17:31:12 +00:00
Chandler Carruth 173bfe477b Use the Arg variable rather than re-computing it. This also silences GCC's
unused variable warning.

llvm-svn: 95085
2010-02-02 12:15:55 +00:00
John McCall 03c4848bf4 Mark dtors for parameter variables and eliminate some redundant type munging.
llvm-svn: 95079
2010-02-02 09:10:11 +00:00
John McCall 6781b05a92 Access control for implicit destructor calls. Diagnostic could be orders of
magnitude clearer.

llvm-svn: 95078
2010-02-02 08:45:54 +00:00
John McCall 49786a6c31 Codegen CXXConstructExprs with trivial constructors as constants.
Eliminates a lot of spurious global initializers, fixing PR6205.

llvm-svn: 95077
2010-02-02 08:02:49 +00:00
Anders Carlsson 75b1f959da Check in a test case and a nasty workaround for PR6199.
llvm-svn: 95076
2010-02-02 07:10:35 +00:00
John McCall 1acbbb5a4c Extract a common base class between UnresolvedLookupExpr and
UnresolvedMemberExpr and employ it in a few places where it's useful.

llvm-svn: 95072
2010-02-02 06:20:04 +00:00
Daniel Dunbar c4c7db6b71 XFAIL two tests on Win32 until some cares to investigate... the problem on
dyncast is just due to \r\n newline interaction w/ regexps. The remap-load.c
failure is a bit stranger (the end of the extent is on the next line), but I
don't care to investigate.

llvm-svn: 95071
2010-02-02 05:41:30 +00:00
Chris Lattner 0b8ecb511c this is reasonably complete by now.
llvm-svn: 95069
2010-02-02 05:23:01 +00:00
Daniel Dunbar a43a1eea87 CIndex: Use 'env' instead of relying on bash environment-variable setting
syntax.

llvm-svn: 95068
2010-02-02 05:20:37 +00:00