Commit Graph

16981 Commits

Author SHA1 Message Date
Benjamin Kramer fc305988b8 Update CMake build.
llvm-svn: 119741
2010-11-18 21:19:52 +00:00
Argyrios Kyrtzidis bc4679335c Remove the hack where, to get the return status, we had special case for VerifyDiagnosticsClient
and just check the number of errors from the DiagnosticClient.

llvm-svn: 119736
2010-11-18 21:13:57 +00:00
Argyrios Kyrtzidis 6d35b5a210 Keep track of errors/warnings in FixItRewriter.
llvm-svn: 119735
2010-11-18 21:13:54 +00:00
Argyrios Kyrtzidis c79346a57c Since multiple diagnostics can share one diagnostic client, have the client keeping track
of the total number of warnings/errors reported.

llvm-svn: 119731
2010-11-18 20:06:46 +00:00
Argyrios Kyrtzidis d004064864 Refactoring of Diagnostic class.
-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
   SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.

llvm-svn: 119730
2010-11-18 20:06:41 +00:00
John McCall 4bc41aee2b Add an assertion, fix a whole bunch of bugs, comment the assertion
out because there are still bugs left.

llvm-svn: 119722
2010-11-18 19:01:18 +00:00
Argyrios Kyrtzidis 745f9996d0 Remove the getDiagnosticLevel check since it doesn't buy us much.
llvm-svn: 119719
2010-11-18 18:51:03 +00:00
Benjamin Kramer 5a3f1cfafd Fix a typo in the UTF-8 BOM (PR8645). Use a StringSwitch while at it.
llvm-svn: 119698
2010-11-18 12:46:39 +00:00
Craig Silverstein 9bc166ac86 In some situations, TemplateArgumentLoc wasn't setting TypeSourceLoc (see
http://llvm.org/bugs/show_bug.cgi?id=8558).  This patch fixes it.  Thanks to
rjmccall for all the coaching!

Approved by rjmccall

llvm-svn: 119697
2010-11-18 08:32:02 +00:00
John McCall 7decc9e4ea Calculate the value kind of an expression when it's created and
store it on the expression node.  Also store an "object kind",
which distinguishes ordinary "addressed" l-values (like
variable references and pointer dereferences) and bitfield,
@property, and vector-component l-values.

Currently we're not using these for much, but I aim to switch
pretty much everything calculating l-valueness over to them.
For now they shouldn't necessarily be trusted.

llvm-svn: 119685
2010-11-18 06:31:45 +00:00
Marcin Swiderski e5a1e8ae12 Added method for handling CXXOperatorCallExpr differently from CallExpr if CXXOperatorCallExpr represents method call.
Also fixed returning ExpolodedNodeSet from VisitCXXMethodCallExpr.

llvm-svn: 119684
2010-11-18 06:29:23 +00:00
Anton Yartsev 3f8f2886c1 comparison of AltiVec vectors now gives bool result (fix for 7533)
llvm-svn: 119678
2010-11-18 03:19:30 +00:00
Argyrios Kyrtzidis ef6c8da50f -Rename -Wargument-larger-than -> -Wlarge-by-value-copy
-Improve the diagnostic message
-Add some comments

Suggestions by Chris.

llvm-svn: 119594
2010-11-18 00:20:36 +00:00
Argyrios Kyrtzidis af84ec0a96 Introduce option -Wargument-larger-than[=N] which warns about function definitions if they take by-value
or return by-value any POD that is larger than some threshold (default is 64 bytes).

Implements rdar://8548050.

llvm-svn: 119583
2010-11-17 23:11:54 +00:00
Rafael Espindola d47ac23154 Implement -pie.
llvm-svn: 119577
2010-11-17 22:26:15 +00:00
Rafael Espindola cfaaddaee0 Don't warn about
clang -w -c foo.s
Helps with the gdb testsuite.

llvm-svn: 119574
2010-11-17 22:13:25 +00:00
Douglas Gregor b4a7c0385d Do not produce "purely informative" code completion results for
Objective-C message sends, which have only whitespace in their
TypedText chunk. Such results have no purpose.

llvm-svn: 119569
2010-11-17 21:36:08 +00:00
Marcin Swiderski af56739355 In EvalArguments allow for evaluation of first argument always as a lvalue. Will be used for CXXOperatorCallExpr that represents method call.
llvm-svn: 119567
2010-11-17 21:27:36 +00:00
Rafael Espindola f92614c578 Don't warn about -w not being used in a link. Necessary to get sane
results in the gdb testsuite.

llvm-svn: 119552
2010-11-17 20:37:10 +00:00
Fariborz Jahanian 8046af7d50 Warn if direct accessing synthesized ivar backing the property in
nonofragile-abi2. Fixes //rdar://8673791

llvm-svn: 119543
2010-11-17 19:41:23 +00:00
Argyrios Kyrtzidis 56e879d1da Don't emit warn_logical_and_in_logical_or for cases like "a && b || 0".
llvm-svn: 119540
2010-11-17 19:18:19 +00:00
Argyrios Kyrtzidis b94e5a33b3 Don't emit warn_logical_and_in_logical_or for macros. Fixes rdar://8678458
llvm-svn: 119537
2010-11-17 18:54:22 +00:00
Argyrios Kyrtzidis 14a96625b8 Don't warn for parentheses for the '&&' inside '||' for cases like:
assert(a || b && "bad");

since this is safe. This way we avoid a big source of such warnings which in this case are practically useless.

Note that we don't handle *all* cases where precedence wouldn't matter because of constants since
this is a bit costly to check, and IMO clarifying precedence with parentheses is good for
readability in general.

llvm-svn: 119533
2010-11-17 18:26:36 +00:00
Dan Gohman f41b525161 Drop the warning about __attribute__((may_alias)) being used
on a non-type declaration, as GCC permits it on variables too.
This fixes PR8635.

llvm-svn: 119517
2010-11-17 17:21:47 +00:00
Rafael Espindola 9b6fae5d6d Silence warning for "clang -O2 -O0 -c foo.c -o foo.o.
Fixes PR8607.

llvm-svn: 119498
2010-11-17 15:16:14 +00:00
Zhongxing Xu 33d7ea9355 Add skeleton for handling various cfg dtors.
llvm-svn: 119491
2010-11-17 09:16:19 +00:00
Chris Lattner 11feaf5921 When forming the !srcloc mdnode for an inline asm, add the SourceLocations
of all the lines of the inline asm.  With the refactoring and enhancement
of the backend, we can now reports errors on the correct source line when
an asm contains multiple lines of text.  For something like this:

void foo() {
  asm("push %rax\n"
      ".code32\n");
}

we used to get this: (note that the line 4 in t.c isn't helpful)

t.c:4:7: error: warning: ignoring directive for now
  asm("push %rax\n"
      ^
<inline asm>:2:1: note: instantiated into assembly here
.code32
^

now we get:

t.c:5:8: error: warning: ignoring directive for now
      ".code32\n"
       ^
<inline asm>:2:1: note: instantiated into assembly here
.code32
^

Note that we're pointing to line 5 properly now.  This implements
rdar://7839391 - inline asm errors should point to the right line in the asm
and makes the error message in PR8595 much less confusing.

llvm-svn: 119489
2010-11-17 08:25:26 +00:00
Chris Lattner 068f2ab10f adjust for llvm mainline, yay type safety
llvm-svn: 119487
2010-11-17 08:13:04 +00:00
Chris Lattner e925d61785 a metric ton of refactoring later, Sema::getLocationOfStringLiteralByte
no longer depends on Preprocessor, so we can move it out of Sema into
a nice new StringLiteral::getLocationOfByte method that can be used by
any AST client.

llvm-svn: 119481
2010-11-17 07:37:15 +00:00
Zhongxing Xu 35d023164c do not do post checks. Because at this point we just enter the call.
llvm-svn: 119480
2010-11-17 07:31:08 +00:00
Chris Lattner 39720111e0 move getSpelling from Preprocessor to Lexer, which it is more conceptually related to.
llvm-svn: 119479
2010-11-17 07:26:20 +00:00
Zhongxing Xu 366340298e Remove comments. We are already doing actual method call by inlining it.
llvm-svn: 119477
2010-11-17 07:21:49 +00:00
Chris Lattner 6bab435db6 propagate preprocessor out of StringLiteralParser. It is now
possible to create one without a preprocessor.

llvm-svn: 119476
2010-11-17 07:21:13 +00:00
Chris Lattner 2be8aa9611 push the preprocessor out of EncodeUCNEscape
llvm-svn: 119475
2010-11-17 07:12:42 +00:00
Chris Lattner 2a6ee91619 move AdvanceToTokenCharacter and getLocForEndOfToken from
Preprocessor to Lexer where they make more sense.

llvm-svn: 119474
2010-11-17 07:05:50 +00:00
Chris Lattner b1ab2c2d3d add a static version of PP::AdvanceToTokenCharacter.
llvm-svn: 119472
2010-11-17 06:55:10 +00:00
Chris Lattner bde1b81eb8 push use of Preprocessor out farther.
llvm-svn: 119471
2010-11-17 06:46:14 +00:00
Chris Lattner 3a324d3232 push use of Preprocessor out of getOffsetOfStringByte
llvm-svn: 119470
2010-11-17 06:35:43 +00:00
Chris Lattner 30d4c928ac add a static form of the efficient PP::getSpelling method.
llvm-svn: 119469
2010-11-17 06:31:48 +00:00
Chris Lattner 7a02bfdfce refactor the interface to StringLiteralParser::getOffsetOfStringByte,
pushing the dependency on the preprocessor out a bit.

llvm-svn: 119468
2010-11-17 06:26:08 +00:00
Marcin Swiderski 2b2cd0e6b4 Added mapping from 'this' to it's SymbolicRegion in BasicStoreManager::getInitialStore.
llvm-svn: 119467
2010-11-17 06:22:54 +00:00
Chris Lattner 776a30ddfc factor some code out to a helper function, no functionality change.
llvm-svn: 119464
2010-11-17 05:58:54 +00:00
Douglas Gregor b1b71e50a0 For an Objective-C @synthesize statement, e.g.,
@synthesize foo = _foo;

keep track of the location of the ivar ("_foo"). Teach libclang to
visit the ivar as a member reference.

llvm-svn: 119447
2010-11-17 01:03:52 +00:00
Ted Kremenek 32195d9a58 Add comments.
llvm-svn: 119436
2010-11-17 00:50:34 +00:00
Rafael Espindola 2abb162631 Add support for distros that like x86_64-unknown-linux-gnu.
llvm-svn: 119425
2010-11-17 00:25:26 +00:00
Fariborz Jahanian a00076cda5 Fixes synthesis of type for the object which holds info.
about a __block cxx object.

llvm-svn: 119411
2010-11-17 00:21:28 +00:00
Douglas Gregor 68dbaead7b Fix source-range information for Objective-C properties. Previously,
we were just getting a range covering only the property name, which is
certainly not correct (and broke token annotation, among other
things). 

Also, teach libclang about the relationship between
@synthesize/@dynamic and @property, so we get property name and
cursor-reference information for @synthesize and @dynamic.

llvm-svn: 119409
2010-11-17 00:13:31 +00:00
John McCall 5b26f65b3d Reset the lifetime-managed flag between emission of the agg conditional
branches.  Fixes PR8623.

llvm-svn: 119408
2010-11-17 00:07:33 +00:00
Dan Gohman bbb7d62546 Front-end support for __attribute__((may_alias)). This is not
yet hooked up to anything yet.

llvm-svn: 119407
2010-11-17 00:03:07 +00:00
John McCall 4f29b49de1 Support compound complex operations as l-values in C++. Add a test
case based on CodeGen/volatile-1.c which tests the current C++
semantics, and note the many, many places we fall short of them.

llvm-svn: 119402
2010-11-16 23:07:28 +00:00
Argyrios Kyrtzidis f89a56c74b Warn about arg1 && arg2 || arg3, as GCC 4.3+ does. Fixes rdar://8659922
llvm-svn: 119381
2010-11-16 21:00:12 +00:00
Douglas Gregor 3edb16765d Use an OwningPtr for the preamble buffer in ASTUnit. This plugs a leak
where we failed to free this buffer along one of the paths, and
detangles the code a little.

llvm-svn: 119379
2010-11-16 20:45:51 +00:00
Anton Yartsev f2a1345a34 turned pointers into pointers to const in function parameters in all functions/builtins accepting pointers to a const-qualified type according to PIM and "Language Extensions for CBEA"
llvm-svn: 119376
2010-11-16 20:09:36 +00:00
Fariborz Jahanian a3e54bd33e Implements __block API for c++ objects. There is still
issue with runtime which I am discussing it with Blaine.
This is wip (so no test yet).

llvm-svn: 119368
2010-11-16 19:29:39 +00:00
Ted Kremenek 0c27bcfd05 Static analyzer: Catch calls to malloc() with
allocation sizes of 0 bytes.

Fixes PR 2899.

llvm-svn: 119364
2010-11-16 18:47:04 +00:00
Argyrios Kyrtzidis 20ee5ae871 Emit a specific diagnostic when typedefing C++ bool, mirroring gcc.
Fixes rdar://8365458

llvm-svn: 119359
2010-11-16 18:18:13 +00:00
Nico Weber 1610d47048 Add gcc-4.4.4 headers on Gentoo systems. Patch by Bertjan Broeksema!
llvm-svn: 119348
2010-11-16 12:42:55 +00:00
Chandler Carruth 40c98640e1 Remove an unintended restriction on sysroots introduced during the Path
conversion.

llvm-svn: 119346
2010-11-16 11:30:11 +00:00
John McCall 07bb19667a Simplify some complex emission and implement correct semantics for
assignment to volatiles in C.  This in effect reverts some of mjs's
work in and around r72572.  Basically, the C++ standard is quite
clear, except that it lies about volatile behavior approximating
C's, whereas the C standard is almost actively misleading.

llvm-svn: 119344
2010-11-16 10:08:07 +00:00
Chandler Carruth 5eef9ba483 Futher reduce the includes of our builtin headers, and teach limits.h to avoid
include_next when not hosted or unavailable. This follows the pattern in
stdint.h and allows these headers to work even in a freestanding configuration
without a standard library.

llvm-svn: 119343
2010-11-16 10:07:43 +00:00
John McCall 6dd263e31b Reverting r119341: doesn't compile, no obvious fix.
llvm-svn: 119342
2010-11-16 09:18:38 +00:00
Marcin Swiderski 76e66c1d60 Refactored GRExprEngine::getCXXThisRegion to use CXXMethodDecl::getThisType instead of calculating it by hand.
llvm-svn: 119341
2010-11-16 08:50:38 +00:00
Chandler Carruth 1c8383dccd Fix PR8625 and correctly interpret member-calls to static members when
producing warnings.

This feels really fragile, and I've not audited all other argument index-based
warnings. I suspect we'll grow this bug on another warning eventually. It might
be nice to adjust the argument indices when building up the attribute AST node,
as we already have to remember about the 'this' argument within that code to
produce correct errors.

llvm-svn: 119340
2010-11-16 08:49:43 +00:00
Chandler Carruth 743682bb9f Re-work the handling of implicit 'this' arguments and silly GCC-style attribute
argument indexes. This handles the offsets in a consistent manner for all of
the attributes which I saw working with these concepts. I've also added tests
for the attribute that motivated this: nonnull.

I consolidated the tests for format attributes into one file, and fleshed them
out a bit to trigger more of the warning cases. Also improved the quality of
some of the diagnostics that occur with invalid argument indices.

The only really questionable change here is supporting the implicit this
argument for the ownership attribute. I'm not sure it's really a sensible
concept there, but implemented the logic for consistency.

llvm-svn: 119339
2010-11-16 08:35:43 +00:00
Argyrios Kyrtzidis 9813d3221d Improve diagnostic for calling non-const method on const object. Fixes rdar://7743000
llvm-svn: 119336
2010-11-16 08:04:45 +00:00
Zhongxing Xu 1ade3267d7 Handle member initializer in C++ ctor.
- Add a new Kind of ProgramPoint: PostInitializer.
 - Still use GRStmtNodeBuilder. But special handling PostInitializer in 
   GRStmtNodeBuilder::GenerateAutoTransition().
 - Someday we should clean up the interface of GRStmtNodeBuilder.

llvm-svn: 119335
2010-11-16 07:52:17 +00:00
Craig Silverstein 9e448da324 Have CXXDeleteExpr::getDestroyedType return the actual destroyed type
in more situations.  In particular, for code like

   template<class T> void Fn() { T* x; delete x; }

getDestroyedType() will now return T rather than T*, as it would
before this change.  On the other hand, for code like this:

   template<class T> void Fn() { T x; delete x; }

getDestroyedType() will return an empty QualType(), since it doesn't
know what the actual destroyed type would be.  Previously, it would
return T.

OKed by rjmccall

llvm-svn: 119334
2010-11-16 07:16:25 +00:00
Marcin Swiderski 4098598ca8 Basic support for C++ in BasicStore:
- CXXThisRegion treated like VarRegion and ObjCIVarRegion in various places,
- Reference treated like pointer in BindDeclInternal.

llvm-svn: 119333
2010-11-16 07:15:33 +00:00
John McCall 3eba6e67ec Now that we have reliable cast kinds, simplify scalar cast IR gen.
llvm-svn: 119332
2010-11-16 06:21:14 +00:00
John McCall d50a27111c Kill CK_Unknown and flesh out the documentation for the existing CastKinds.
llvm-svn: 119331
2010-11-16 05:46:29 +00:00
John McCall fa8edb11e1 Teach complex compound assignment IR-generation that the RHS of
a compound assignment is always already in the computation type.

llvm-svn: 119330
2010-11-16 05:45:35 +00:00
John McCall 29600e160e Kill off the remaining places which generate CK_Unknown casts.
llvm-svn: 119326
2010-11-16 02:32:08 +00:00
John McCall 2489379756 Add an ExternalASTSource hook to complete a type on demand.
llvm-svn: 119316
2010-11-16 01:44:35 +00:00
Bob Wilson 77ad2c4164 Update TypePrinter::PrintVector to handle new Neon vector types.
llvm-svn: 119302
2010-11-16 00:32:26 +00:00
Bob Wilson 118baf7611 Add support for "neon_vector_type" and "neon_polyvector_type" attributes
to create the special Neon vector types.  These are intended to be used in
Clang's version of <arm_neon.h> to define special Neon vector types that will
be mangled according to ARM's ABI.

llvm-svn: 119301
2010-11-16 00:32:24 +00:00
Bob Wilson 7795480992 ASTContext::getVectorType should preserve the vector kind for canonical types.
This is needed for Neon types when it is most natural to define them in terms
of a typedef.  For example, Neon poly8_t is a typedef for "signed char", and
we want to define polynomial vectors as vectors of that typedef.  Without this
change, the result will be a generic GCC-style vector.  I think this is safe
for other vector types as well, but I would appreciate a review of this.

llvm-svn: 119300
2010-11-16 00:32:20 +00:00
Bob Wilson e4652b1f22 Change CXXNameMangler::mangleNeonVectorType to require the vector type to be
one of the special Neon types.  We'll check for invalid Neon vectors when
they are created, so there's no point in handling them when mangling.

llvm-svn: 119299
2010-11-16 00:32:18 +00:00
Bob Wilson 4348a800ca Fix a comment typo.
llvm-svn: 119298
2010-11-16 00:32:16 +00:00
Bob Wilson 59f9dec8cd Use getTypeSize() method.
llvm-svn: 119297
2010-11-16 00:32:12 +00:00
John McCall 8d69a2160e Add a new expression kind, OpaqueValueExpr, which is useful for
certain internal type-checking procedures as well as for representing
certain implicitly-generated operations.  Uses to follow.

llvm-svn: 119289
2010-11-15 23:31:06 +00:00
Zhanyong Wan 24f6742b34 Adds a README for the Clang static analyzer to document its design and work flow. The contents are taken from email notes by kremenek and xuzhongxing.
llvm-svn: 119288
2010-11-15 23:19:25 +00:00
Douglas Gregor c65929299d Tweak libclang's heuristics for building precompiled preambles and
caching global code-completion results. In particular, don't perform
either operation the first time we parse, but do both after the first
reparse. 

llvm-svn: 119285
2010-11-15 23:00:34 +00:00
Ted Kremenek 18fb1665bf Remove invalid assertion from CFG builder. When building the CFG pieces for a ternary '?' expression,
it is possible for the confluence block to only have a single predecessor due to calls to 'noreturn'
functions.  Fixes assertion failure reported in PR 8619.

llvm-svn: 119284
2010-11-15 22:59:22 +00:00
Ted Kremenek 43f50695a8 Add method ParentMap::addStmt().
llvm-svn: 119181
2010-11-15 20:54:24 +00:00
Ted Kremenek db73d599b7 Relax assertion in SValuator so that we don't crash when analyzing a call via a function pointer that
casts the return value to something completely different.  While we need better reasoning here,
we should definately not crash.

llvm-svn: 119177
2010-11-15 20:09:42 +00:00
Fariborz Jahanian 9db7b8b1ef Some cleanup of block API code.
llvm-svn: 119174
2010-11-15 19:19:38 +00:00
Rafael Espindola d1002f6fce Fixes PR8611.
Silence warning about -g not being used during linking. I couldn't find any
change in behavior in gcc liking when given -g. Please open another bug if
I missed something.

llvm-svn: 119166
2010-11-15 18:28:16 +00:00
Douglas Gregor ee430a39c3 Implement C++0x [temp.func.order]p3 (aka DR532) properly. In
particular, we only add the implement object parameter type if only
one of the function templates is a non-static member function
template.

Moreover, since this DR differs from existing practice in C++98/03,
this commit implements the existing practice (which ignores the
first parameter of the function template that is not the non-static
member function template) in C++98/03 mode.

llvm-svn: 119145
2010-11-15 15:41:16 +00:00
Chandler Carruth 99da11cf04 Silence an unused variable warning during release builds by folding the
expression into the assert.

llvm-svn: 119143
2010-11-15 13:54:43 +00:00
John McCall 3065d046b5 Yes, vector conversions are bitcasts.
llvm-svn: 119141
2010-11-15 10:08:00 +00:00
John McCall f608debd9b Kill CK_Unknown references in the ObjC rewriter. The actual
choice of cast doesn't matter here, but I've tried to choose
the right one anyway.

llvm-svn: 119140
2010-11-15 09:46:46 +00:00
Chandler Carruth 3b702674f4 Fix a think-o. Fixes PR8606.
llvm-svn: 119139
2010-11-15 09:28:23 +00:00
John McCall 8cb679e4e1 Assorted work leading towards the elimination of CK_Unknown.
llvm-svn: 119138
2010-11-15 09:13:47 +00:00
Zhongxing Xu 14776cf96a Add driver support for Ubuntu 9.10.
llvm-svn: 119137
2010-11-15 09:01:52 +00:00
Zhongxing Xu 5d30c69813 Add skeleton for handling other kinds of CFGElements.
llvm-svn: 119135
2010-11-15 08:48:43 +00:00
Chandler Carruth eb84200747 Clean up some names and fix the handling of default sysroots on Windows and
other platforms where the textual default of '/' isn't the system's root
directory. We should probably still make the textual default platform specific,
but this should avoid the particularly bad problem with the previous state: we
applied a sysroot of '/' to '/usr/local/google' which added
'//usr/local/include' to the windows header search path, a share on another
machine named 'usr'. Oops.

llvm-svn: 119131
2010-11-15 07:15:26 +00:00
Chandler Carruth 03ac1b09d1 Switch the sysroot logic to use the Path interface, resolving a FIXME and
making the code less gross.

llvm-svn: 119099
2010-11-15 00:48:13 +00:00
Chandler Carruth c4d6fd5b03 Make sysroot only apply to baked in paths which start with a '/'.
llvm-svn: 119095
2010-11-15 00:05:18 +00:00
Zhongxing Xu fee455fcf5 Revert r118991.
Elidable CXXConstructExpr should inhibit calling destructor for temporary 
that is copied, not the one created. This is because eliding copy constructor 
means that the object that was to be copied will be constructed directly in 
memory the copy would be constructed in.

llvm-svn: 119044
2010-11-14 15:23:50 +00:00
John McCall 83fe49d1e1 Always emit full loads from volatile complex l-values.
Return the result of a complex assignment with the original values,
not by performing a load from the l-value;  this is the correct
semantics in C, although not in C++.

llvm-svn: 119037
2010-11-14 09:40:28 +00:00
John McCall d764625448 Add a few more complex-related cast kinds that arise due to arbitrary
implicit conversions;  the last batch was specific to promotions.
I think this is the full set we need.  I do think dividing the cast
kinds into floating and integral is probably a good idea.

Annotate a *lot* more C casts with useful cast kinds.

llvm-svn: 119036
2010-11-14 08:17:51 +00:00
Fariborz Jahanian 574940e16f Removed unnecessary initialization of a flag which
somehow got several block tests fail with a linux built
compiler.

llvm-svn: 119027
2010-11-14 05:25:15 +00:00
Fariborz Jahanian 9ffe24f186 Initialize couple of fields.
llvm-svn: 119014
2010-11-13 23:48:30 +00:00
Fariborz Jahanian e988bdac44 Block API patch to do copy ctor of copied-in cxx objects in
copy helper function and dtor of copied cxx objects
in dispose helper functions. __block variables
TBD next.

llvm-svn: 119011
2010-11-13 21:53:34 +00:00
Douglas Gregor 052caec1f3 When complaining about ambiguous overload resolution for a unary or
binary operator, provide the types.

llvm-svn: 119008
2010-11-13 20:06:38 +00:00
Douglas Gregor 72ebdabc5d When we're type-checking the result of calling a conversion function
(while computing user conversion sequences), make sure that a result
of class type is a complete class type. Had we gone through
ActOnCallExpr, this would have happened when we built the CallExpr.

Fixes PR8425.

llvm-svn: 119005
2010-11-13 19:36:57 +00:00
Daniel Dunbar fc8aefb0ba Driver: Support -Oz as an alias for -Os.
llvm-svn: 119003
2010-11-13 18:17:11 +00:00
John McCall c5e62b47af Introduce five new cast kinds for various conversions into and
between complex types.

llvm-svn: 118994
2010-11-13 09:02:35 +00:00
John McCall d005ac937e Bring UsualArithmeticConversionsType back into Sema and cast the
operands appropriately.  There are a lot of missing complex-related
cast kinds.

llvm-svn: 118993
2010-11-13 08:17:45 +00:00
Zhongxing Xu 1b038fa00f Do not add implicit dtors for CXXBindTemporaryExpr with elidable
CXXConstructExpr.

llvm-svn: 118991
2010-11-13 07:30:59 +00:00
John McCall 528729872e Pre-compute all possible usual-arithmetic-conversions results for the
promoted arithmetic types for which builtin operator candidates are
emitted.  A few of these need further analysis.

Removes all the uses of UsualArithmeticConversionsType except the
core function in SemaExpr.cpp.

llvm-svn: 118988
2010-11-13 05:51:15 +00:00
Ted Kremenek f2819198d2 Refine IdempotentOperationChecker::PathWasCompletelyAnalyzed() to also check
BlockEdges, BlockEntrances, and BlockExits for the target block value.

llvm-svn: 118984
2010-11-13 05:12:26 +00:00
Ted Kremenek cf9dbe9c20 Teach IdempotentOperations::PathWasCompletelyAnalyzed to also consider items remaining in the
worklist that could have impacted the evaluation of a block.

Fixes <rdar://problem/8663596>.

llvm-svn: 118983
2010-11-13 05:04:52 +00:00
Ted Kremenek b02788dbee Add GRWorkList::VisitItemsInWorkList() to allow a client to introspect the contents of a worklist.
This API required changing the BFS worklist to use a deque instead of a queue, but that is better
for performance reasons anyway.

llvm-svn: 118982
2010-11-13 05:04:49 +00:00
John McCall 988ffb7a11 Store the list of arithmetic types as a static array of member pointers
instead of copying them all out at the start.  Not a significant
optimization.

llvm-svn: 118967
2010-11-13 02:01:09 +00:00
John McCall e84af4e486 Introduce a null-to-pointer implicit cast kind.
llvm-svn: 118966
2010-11-13 01:35:44 +00:00
Douglas Gregor 52773dcef6 Implement C++ [over.match.funcs]p4 as it concerns partial ordering of
function templates. Fixes PR8130.

llvm-svn: 118944
2010-11-12 23:44:13 +00:00
Benjamin Kramer c78d86a2af Reduce string thrashing.
llvm-svn: 118915
2010-11-12 18:45:23 +00:00
Bob Wilson e6aeebb9d8 Generalize ASTContext::areCompatibleVectorTypes to handle new Neon vector types.
llvm-svn: 118901
2010-11-12 17:24:54 +00:00
Bob Wilson f58e8a4db7 Use ASTContext::getTypeInfo to find the vector element size.
llvm-svn: 118899
2010-11-12 17:24:49 +00:00
Bob Wilson 8470b33762 Add a separate NeonPolyVector kind to distinguish polynomial vector types.
Add support for mangling those types according to ARM's ABI.

llvm-svn: 118898
2010-11-12 17:24:46 +00:00
Bob Wilson c155521a96 Add special-case mangling for Neon vector types.
llvm-svn: 118897
2010-11-12 17:24:43 +00:00
Benjamin Kramer 8c173cc364 Use a twine.
llvm-svn: 118892
2010-11-12 15:42:18 +00:00
John McCall 31f82720d0 Replace one hack with a different hack: strip out the ObjectType
parameters to the Transform*Type functions and instead call out
the specific cases where an object type and the unqualified lookup
results are important.  Fixes an assert and failed compile on
a testcase from PR7248.

llvm-svn: 118887
2010-11-12 08:19:04 +00:00
Douglas Gregor 453b012513 Make sure to always check the result of
SourceManager::getPresumedLoc(), so that we don't try to make use of
an invalid presumed location. Doing so can cause crashes.

llvm-svn: 118885
2010-11-12 07:15:47 +00:00
Douglas Gregor cbd0710a12 When performing initialization of a copy of a temporary object, use
direct-initialization (rather than copy-initialization) to initialize
the temporary, allowing explicit constructors. Fixes PR8342.

llvm-svn: 118880
2010-11-12 03:34:06 +00:00
Rafael Espindola 9aa60e964e Add support for -nostdlib in the linux toolchain.
llvm-svn: 118878
2010-11-12 03:00:39 +00:00
Ted Kremenek 843c53828f RegionStore/BasicStore: do not return UndefinedVal for accesses to concrete addresses; instead return UnknownVal. This
leads it up to checkers (e.g., DereferenceChecker) to guard against illegal accesses (e.g., null dereferences).

Fixes PR 5272 and <rdar://problem/6839683>.

llvm-svn: 118852
2010-11-11 23:10:10 +00:00
Douglas Gregor ad3832e213 Teach debug-info generation that SourceManager::getPresumedLoc() can
produce an invalid location even when given a valid location, if the
file system has changed underneath us. Recovery more gracefully.

llvm-svn: 118834
2010-11-11 20:45:16 +00:00
Rafael Espindola 34d77dc49a Add support for -s, -pthread and -pthreads. Thanks to Hans Wennborg and
Cosmin Truta for reporting it.

llvm-svn: 118826
2010-11-11 19:34:42 +00:00
Daniel Dunbar aeed5fe6a2 Driver: Allow build system override of default non-fragile ABI version.
llvm-svn: 118786
2010-11-11 16:08:59 +00:00
John McCall deebbcf20d Undo a refactor-o and base the bitfield-truncation warning on the
uncoerced value.  Also, whitelist bool bitfields, which aren't
really a truncation.

llvm-svn: 118778
2010-11-11 05:33:51 +00:00
John McCall 1f425648ca Extend the bitfield-truncation warning to initializations.
rdar://problem/8652606

llvm-svn: 118773
2010-11-11 03:21:53 +00:00
Rafael Espindola 7ba97afc4d Add -rdynamic to freebsd and openbsd. Patch by Ruben.
llvm-svn: 118771
2010-11-11 02:17:51 +00:00
Rafael Espindola 124798484a Add support for Exherbo. Patch by Elias Pipping.
llvm-svn: 118769
2010-11-11 02:07:13 +00:00
John McCall 643169b280 Unnest; no functionality change.
llvm-svn: 118753
2010-11-11 00:46:36 +00:00
Douglas Gregor 44c6ee7729 Improve ASTUnit's capture of diagnostics so that the
diagnostic-capturing client lives as long as the ASTUnit itself
does. Otherwise, we can end up with crashes when we get a diagnostic
outside of parsing/code completion. The circumstances under which this
happen are really hard to reproduce, because a file needs to change
from under us.

llvm-svn: 118751
2010-11-11 00:39:14 +00:00
Fariborz Jahanian 2a5deb56a4 Adding couple of Block API, a bug fix and
a test change, all for blocks. wip.

llvm-svn: 118745
2010-11-11 00:11:38 +00:00
John McCall 817d4af557 When -Wconversion computes the range of a type, it uses the (bit-)range
of the enumerators rather than the actual expressible range.  This is 
great when dealing with opaque *values* of that type, but when computing
the range of the type for purposes of converting *into* it, it produces
warnings in cases we don't care about (e.g. enum_t x = 500;).  Divide 
the logic into these two cases and use the more conservative range for
targets.    

llvm-svn: 118735
2010-11-10 23:38:19 +00:00
Bob Wilson aeb56444f9 Add a variant of GCC-style vector types for ARM NEON.
NEON vector types need to be mangled in a special way to comply with ARM's ABI,
similar to some of the AltiVec-specific vector types.  This patch is mostly
just renaming a bunch of "AltiVecSpecific" things, since they will no longer
be specific to AltiVec.  Besides that, it just adds the new "NeonVector" enum.

llvm-svn: 118724
2010-11-10 21:56:12 +00:00
Douglas Gregor 869853eea1 Instantiate class member template partial specialization declarations
in the order they occur within the class template, delaying
out-of-line member template partial specializations until after the
class has been fully instantiated. This fixes a regression introduced
by r118454 (itself a fix for PR8001).

llvm-svn: 118704
2010-11-10 19:44:59 +00:00
Fariborz Jahanian a0a9d85a5d Check for duplicate declaration of a property in current and
other class extensions. // rdar://7629420

llvm-svn: 118689
2010-11-10 18:01:36 +00:00
John McCall ad31b5f2cb Propagate the deprecated and unavailable attributes from a
@property declaration to the autogenerated methods.  I'm uncertain
whether this should apply to attributes in general, but these are
a reasonable core.

Implements rdar://problem/8617301

llvm-svn: 118676
2010-11-10 07:01:40 +00:00
Ted Kremenek 5eec2b0bd3 Region-allocate all AttributeList objects from a factory object instead of manually managing them
using new/delete and OwningPtrs.  After memory profiling Clang, I witnessed periodic leaks of these
objects; digging deeper into the code, it was clear that our management of these objects was a mess.  The ownership rules were murky at best, and not always followed.  Worse, there are plenty of error paths where we could screw up.

This patch introduces AttributeList::Factory, which is a factory class that creates AttributeList
objects and then blows them away all at once.  While conceptually simple, most of the changes in
this patch just have to do with migrating over to the new interface.  Most of the changes have resulted in some nice simplifications.

This new strategy currently holds on to all AttributeList objects during the lifetime of the Parser
object.  This is easily tunable.  If we desire to have more bound the lifetime of AttributeList
objects more precisely, we can have the AttributeList::Factory object (in Parser) push/pop its
underlying allocator as we enter/leave key methods in the Parser.  This means that we get
simple memory management while still having the ability to finely control memory use if necessary.

Note that because AttributeList objects are now BumpPtrAllocated, we may reduce malloc() traffic
in many large files with attributes.

This fixes the leak reported in: <rdar://problem/8650003>

llvm-svn: 118675
2010-11-10 05:59:39 +00:00
Argyrios Kyrtzidis 2703bebc58 Replace UsingDecl's SmallPtrSet of UsingShadowDecls with a linked list to avoid leaking memory.
Fixes rdar://8649963.

llvm-svn: 118674
2010-11-10 05:40:41 +00:00
Rafael Espindola 66b291a41b Add support for Ubuntu Jaunty.
llvm-svn: 118673
2010-11-10 05:00:22 +00:00
John McCall a8987a294d Friend function declarations can overload with tag declarations.
Fixes PR7915.

llvm-svn: 118670
2010-11-10 03:01:53 +00:00
John McCall 9b72f89f0f Diagnose attempst to template using declarations and using directives.
Recover from the latter and fail early for the former.  Fixes PR8022.

llvm-svn: 118669
2010-11-10 02:40:36 +00:00
Chris Lattner 49609d56d7 make sure #pragma clang is treated the same way as #pragma gcc in -E mode,
unknown pragmas should just be passed through to the .i file.

llvm-svn: 118659
2010-11-10 01:00:49 +00:00
John McCall fd81c52947 Tweak to bitfield-overflow warning: don't warn about storing
a positive value into a signed bitfield of the exact width of
the value.

llvm-svn: 118657
2010-11-10 00:26:50 +00:00
John McCall d2a5312e14 Add a warning for implicit truncation of constant values due to
bitfield assignment.

Implements rdar://problem/7809123

llvm-svn: 118647
2010-11-09 23:24:47 +00:00
John McCall 18a2c2c0b9 Split out -Wconversion warnings about constant precision into their
own subcategory, -Wconstant-conversion, which is on by default.

Tweak the constant folder to give better results in the invalid
case of a negative shift amount.

Implements rdar://problem/6792488

llvm-svn: 118636
2010-11-09 22:22:12 +00:00
Fariborz Jahanian b332ba3a51 Test moved to its correct place.
llvm-svn: 118635
2010-11-09 21:40:30 +00:00
Fariborz Jahanian d11da7e52a Restore patch reversed in r118475. Fixes
// rdar://8632525

llvm-svn: 118634
2010-11-09 21:38:20 +00:00
Douglas Gregor 0124e9ba9a Attempt to resolve overloaded functions in comma expressions and
conditional operators. Fixes PR7863.

llvm-svn: 118631
2010-11-09 21:07:58 +00:00
Fariborz Jahanian dbee986290 Issues good diagnostic when @end is missing.
// rdar://8283484

llvm-svn: 118629
2010-11-09 20:38:00 +00:00
Chris Lattner 8ea6442f92 tidy up
llvm-svn: 118626
2010-11-09 20:15:55 +00:00
Chris Lattner 0786544ac5 fix PR8380, a crash on invalid due to an illogical DeclSpec SourceRange being constructed.
llvm-svn: 118625
2010-11-09 20:14:26 +00:00
Douglas Gregor 928479e727 Revert the fix for PR8013.
That bug concerned the well-formedness of code such as (&ovl)(a, b,
c). GCC rejects the code, while EDG accepts it. On further study of the
standard, I see no support for EDG's position: in particular, C++
[over.over] does not list this as a context where we can take the
address of an overloaded function, C++ [over.call.func] does not
reference the address-of operator at any point, and C++ [expr.call]
claims that the function argument in a call is either a function
lvalue or a pointer-to-function; (&ovl) is neither.

llvm-svn: 118620
2010-11-09 20:03:54 +00:00
Benjamin Kramer f2e5a91ffb Simplify code.
llvm-svn: 118619
2010-11-09 20:00:56 +00:00
Charles Davis 99202b358f Use the right calling convention when mangling names in the Microsoft C++
mangler. Now member functions and pointers thereof have their calling
convention mangled as __thiscall if they have the default CC (even though,
they technically still have the __cdecl CC).

llvm-svn: 118598
2010-11-09 18:04:24 +00:00
Bruno Cardoso Lopes e7f211c89f Add support for soft/hard float options to the Sparc target
llvm-svn: 118514
2010-11-09 17:21:19 +00:00
Rafael Espindola c55be6d317 Include System/DataTypes.h in Diagnostic.h to get intptr_t.
Set Haiku's UserLabelPrefix to "".
Patch by Paul Davey.

llvm-svn: 118510
2010-11-09 16:41:02 +00:00
Douglas Gregor 8f225bb508 Handle overload resolution when calling an overloaded function set
with, e.g., (&f)(a, b, c). Fixes PR8013.

llvm-svn: 118508
2010-11-09 16:13:15 +00:00
Douglas Gregor ba57154614 Make #pragma unused work for static local variables.
llvm-svn: 118500
2010-11-09 14:57:47 +00:00
David Chisnall 82f755c58d Remove the use of aliases in outputted code from ObjC (GNU runtime).
llvm-svn: 118498
2010-11-09 11:21:43 +00:00
Nick Lewycky 30d939681c Remove debugging printf.
Fix linux build.

llvm-svn: 118497
2010-11-09 09:53:02 +00:00
NAKAMURA Takumi c0d7d99cc1 lib/Lex/PPMacroExpansion.cpp: Fixup to appease MSVC.
Confirmed on MSVS10.

llvm-svn: 118496
2010-11-09 06:27:32 +00:00
Douglas Gregor ae674f3148 Appeasing MSVC, take 3
llvm-svn: 118493
2010-11-09 05:43:53 +00:00
Anders Carlsson c1351cac17 Introduce the concept of a non-virtual base type to CGRecordLayoutBuilder as a first step towards fixing PR6995.
llvm-svn: 118491
2010-11-09 05:25:47 +00:00
Douglas Gregor 416463f7f3 Try to appease MSVC
llvm-svn: 118487
2010-11-09 04:38:09 +00:00
Douglas Gregor 6215889e91 Add missing include
llvm-svn: 118485
2010-11-09 04:06:42 +00:00
Douglas Gregor 2927c0c817 Teach code completion not to include out-of-line declarations and
definitions in its results. The original declarations will be visible
wherever they are declared.

llvm-svn: 118484
2010-11-09 03:59:40 +00:00
Douglas Gregor 23ab745e79 Fix source locations in unnamed bitfield diagnostic, from Jakub
Wieczorek! Fixes PR8025.

llvm-svn: 118481
2010-11-09 03:31:16 +00:00
Douglas Gregor 9169dcb7a9 sprintf -> snprintf conversion, from Vladimir Kirillov
llvm-svn: 118478
2010-11-09 03:20:07 +00:00
Fariborz Jahanian 3655e59688 Reverse patch for // rdar://8632525. It might
has broken a build.

llvm-svn: 118475
2010-11-09 02:24:08 +00:00
Ted Kremenek dcf85a8d18 Teach AttrNonNullChecker about transparent unions. Fixes crash reported in <rdar://problem/8642434>.
llvm-svn: 118473
2010-11-09 02:11:43 +00:00
Ted Kremenek 16e6026f01 Fix InitListExpr::getSourceRange() to work in the case of no locations for '(' and ')'. This can happen
in the case of transparent unions.

llvm-svn: 118472
2010-11-09 02:11:40 +00:00
Argyrios Kyrtzidis 8909686b22 Fix miscompilation regarding VLAs; subscription of VLA pointers was incorrect.
Fixes rdar://8644873 & http://llvm.org/PR8567.

llvm-svn: 118468
2010-11-09 01:30:48 +00:00
John McCall 478382521e When re-using a vtable slot for the nearest overridden method, just because
there's no return adjustment from the overridden to the overrider doesn't
mean there isn't a return adjustment from the overrider to the final
overrider.  This matters if we're emitting a virtual this-adjustment thunk
because the overrider virtually inherits from the class providing the
nearest overridden method.  Do the appropriate return adjustment in this case.

Fixes PR7611.

llvm-svn: 118466
2010-11-09 01:18:05 +00:00
Nick Lewycky 14d88eb41f Fix warning about unused variable 'Fn' in no-asserts builds. Also reflow this
block so that it looks more like the rest of the file. No functional change.

llvm-svn: 118459
2010-11-09 00:19:31 +00:00
Nick Lewycky 6147891648 Don't lose track of previous-declarations when instantiating a class template.
Fixes PR8001.

llvm-svn: 118454
2010-11-08 23:29:42 +00:00
Fariborz Jahanian 94ad274c24 Provide a precise builtin declaration for objc_msgSend
to avoid a bogus warning. Fixes //rdar: //8632525

llvm-svn: 118451
2010-11-08 22:53:18 +00:00
Douglas Gregor dc520b0f08 If an instance method messages is sending to an expression of type Class,
and we statically can compute a bound on the actual type (e.g.,
because it's a send to the the magic "class" instance method), code
complete as if we were performing a class message send to that class.

llvm-svn: 118443
2010-11-08 21:12:30 +00:00
John McCall f71b45367f Document Clang's support for attributes on individual enumerators and
tweak the documentation for deprecation-with-message.  Provide __has_feature
tests for both.  rdar://problem/8605692

llvm-svn: 118435
2010-11-08 19:48:17 +00:00
Roman Divacky b45d2672f7 Add a forgotten break. Found by Rafael Espindola!
llvm-svn: 118433
2010-11-08 19:39:10 +00:00
Argyrios Kyrtzidis 8566356acb When building a compound literal, check that the base element of the array is complete.
Fixes rdar://8620582 & http://llvm.org/PR7905

llvm-svn: 118428
2010-11-08 19:14:19 +00:00
Fariborz Jahanian 086a24a2be Fixes a rewrite bug, rewriting nested property usage
inside blocks. Fixes //rdar: //8608293.

llvm-svn: 118425
2010-11-08 18:37:50 +00:00
Roman Divacky 137426a42f Use integrated-as for processing .s files on FreeBSD. Copied
from Linux/OpenBSD code.

llvm-svn: 118419
2010-11-08 17:46:39 +00:00
Douglas Gregor bd6b17f4ef Improve our handling of C++ [class.copy]p3, which specifies that a
constructor template will not be used to copy a class object to a
value of its own type. We were eliminating all constructor templates
whose specializations look like a copy constructor, which eliminated
important candidates. Fixes PR8182.

llvm-svn: 118418
2010-11-08 17:16:59 +00:00
Ted Kremenek 14715b7f2f Only enable the ObjCAtSyncChecker when the translation unit uses Objective-C.
llvm-svn: 118414
2010-11-08 16:52:54 +00:00
Douglas Gregor bcd625305b When attempting reference binding to an overloaded function, also
consider that we might be trying to bind a reference to a class type,
which involves a constructor call. Fixes PR7425.

llvm-svn: 118407
2010-11-08 15:20:28 +00:00
Rafael Espindola c5688628d8 Pass "-z relro" as two arguments. This works with both gnu ld and gold.
Patch by Frits van Bommel.

llvm-svn: 118406
2010-11-08 14:48:47 +00:00
Douglas Gregor e81f58e180 Properly diagnose invalid casts to function references. Patch by
Faisal Vali, tweaked by me. Fixes PR8230.

llvm-svn: 118400
2010-11-08 03:40:48 +00:00
Rafael Espindola 96aef794ba Use the integrated assembler when procession .s files on OpenBSD and Linux.
Original patch for OpenBSD by Vladimir Kirillov.

llvm-svn: 118386
2010-11-07 23:13:01 +00:00
Douglas Gregor 1ccc8416a0 Remove broken support for variadic templates, along with the various
abstractions (e.g., TemplateArgumentListBuilder) that were designed to
support variadic templates. Only a few remnants of variadic templates
remain, in the parser (parsing template type parameter packs), AST
(template type parameter pack bits and TemplateArgument::Pack), and
Sema; these are expected to be used in a future implementation of
variadic templates.

But don't get too excited about that happening now.

llvm-svn: 118385
2010-11-07 23:05:16 +00:00
Rafael Espindola 1c76c59bbc Add support for -rdynamic.
llvm-svn: 118384
2010-11-07 22:57:16 +00:00
Rafael Espindola c8f008f649 Use ld directly on linux. Changes from the previous try:
*) Try to detect as much as possible from the system itself, not the distro.
   This should make it easier to port to a new distro and more likely to
   work on a unknown one.
*) The distro enum now doesn't include the arch. Just use the existing
   host detection support in LLVM.
*) Correctly handle --sysroot.

A small regression is that now clang will pass bitcode file to the linker.
This is necessary for the gold plugin support to work.

It might be better to detect this at configure/cmake time, but doing it in
c++ first is a lot easier.

llvm-svn: 118382
2010-11-07 20:14:31 +00:00
Anders Carlsson 2ceb347e8b A union cannot contain static data members or data members of reference type.
llvm-svn: 118381
2010-11-07 19:13:55 +00:00
Ted Kremenek 6a15337ded Change the StringSet used by CalculateHiddenNames() to use a BumpPtrAllocator.
llvm-svn: 118372
2010-11-07 06:11:36 +00:00