Commit Graph

16538 Commits

Author SHA1 Message Date
John McCall d37d35b571 Avoid calculating linkage until the more obvious checks have run when
deciding whether to queue a decl for unused-declaration warnings.

llvm-svn: 117431
2010-10-27 01:41:35 +00:00
John McCall 6fe024052b Don't compute linkage for a declaration as part of the #pragma weak
forward-declaration support unless there's really a mapping for that
name.

llvm-svn: 117426
2010-10-27 00:59:00 +00:00
Dan Gohman 2f76cd756a Add support for code completion on stdin.
llvm-svn: 117414
2010-10-26 23:21:25 +00:00
Fariborz Jahanian 67ca8c4c7b Patch to provide guard when initializing instances
of static data member of a class template.
Fixes //rdar :// 8562966 and pr8409.

llvm-svn: 117410
2010-10-26 22:47:47 +00:00
John McCall 6bde954f47 Extract procedures to do scalar-to-memory and memory-to-scalar conversions
in IR gen, and use those to fix a correctness issue with bool atomic
intrinsics.  rdar://problem/8461234

llvm-svn: 117403
2010-10-26 22:09:15 +00:00
Dan Gohman 52765215d0 Simplify this code: don't check for the same error two
different ways. Check once, and use an assert to handle
consistency checking.

llvm-svn: 117397
2010-10-26 21:13:51 +00:00
Dan Gohman 5d223dcb2f getOrCreateContentCache never returns null, so overrideFileContents
doesn't need its return value.

llvm-svn: 117393
2010-10-26 20:47:28 +00:00
Dan Gohman 8fc50c296a Factor out the code for emitting code to load vtable pointer members
so that it's done in one place.

llvm-svn: 117386
2010-10-26 18:44:08 +00:00
Douglas Gregor 2a1d72d078 Teach typo correction not to return the same keyword that matches a
typo. This can happen with context-sensitive keywords like "super",
when typo correction didn't know that "super" wasn't permitted in this
context.

llvm-svn: 117372
2010-10-26 17:18:00 +00:00
John McCall 925b16629d Optimize field space usage in CompoundStmt, LabelStmt, Expr, and CastExpr.
There's probably still significant padding waste on x86-64 UNIXen, but
the difference in 32-bit compiles should be significant.

There are a lot of Expr nodes left that could lose a word this way.

llvm-svn: 117359
2010-10-26 08:39:16 +00:00
John McCall c3007a2145 No really, we don't have a retain/release system for statements/expressions
anymore.

llvm-svn: 117357
2010-10-26 07:05:15 +00:00
John McCall 75851b1a7f Actually, that doesn't really work, and anyway we should choose
conversion to id over conversion to void*.

llvm-svn: 117355
2010-10-26 06:40:27 +00:00
John McCall f28e83a73a Consider conversions of Objective-C pointers to 'id' to be basically of
the same rank as conversions of normal pointers to 'void*'.

Also, resurrect a test case.

Fixes rdar://problem/8592139

llvm-svn: 117354
2010-10-26 06:23:29 +00:00
Douglas Gregor 8302541401 Delay complete-type checking for arguments to no-prototype functions
until after we've checked/promoted the argument. Hopefully fixes the
Emacs regression due to my recent change that expanded type-checking
in the presence of K&R function definitions.

llvm-svn: 117353
2010-10-26 05:45:40 +00:00
John McCall 5fe84129e2 A couple of tweaks to the visibility rules:
- tags with C linkage should ignore visibility=hidden
  - functions and variables with explicit visibility attributes should
    ignore the linkage of their types
Either of these should be sufficient to fix PR8457.

Also, FileCheck-ize a test case.

llvm-svn: 117351
2010-10-26 04:59:26 +00:00
John McCall 710d2a831c Pending further discussion, re-enable warnings for Objective C
covariant/contravariant overrides and implementations, but do so under
control of a new flag (-Wno-objc-covariant-overrides, which yes does cover
contravariance too).

*At least* the covariance cases will probably be enabled by default shortly,
but that's not totally uncontroversial.

llvm-svn: 117346
2010-10-26 00:53:53 +00:00
Douglas Gregor f86c939bff When de-serializing a type that is supposed to be canonical, call
getCanonicalType() to make sure that the type we got back is actually
canonical. This is the case for most types, which always build a
canonical type when given canonical components. However, some types that
involve expressions in their canonicalization (e.g., array types with
dependent sizes) don't always build canonical types from canonical
components, because there is no such thing as a "canonical"
expression. Therefore, we do this extra mapping to ensure that the
canonical types we store are actually canonical.

llvm-svn: 117344
2010-10-26 00:51:02 +00:00
Ted Kremenek 6348dac7a0 Fix lazy symbolication bug in RegionStore involving fields of global variables. When invalidated, the entire
globals memory space gets assigned a symbolic value, but that value was not being used for lazy symbolication
of fields of globals.  This could result in cases where bogus null dereferences were being reported.

Fixes PR 8440.

llvm-svn: 117336
2010-10-26 00:06:17 +00:00
Ted Kremenek f59449e790 Move 'includeGlobals' as a field into ClusterAnalysis.
llvm-svn: 117335
2010-10-26 00:06:15 +00:00
Ted Kremenek 731310e13e Tweak null dereference checker to give better diagnostics for null dereferences resulting from array accesses.
llvm-svn: 117334
2010-10-26 00:06:13 +00:00
Dan Gohman dc2c4db598 Add infrastructure for emitting TBAA metadata with the "constant" flag.
llvm-svn: 117328
2010-10-25 23:51:23 +00:00
Fariborz Jahanian 56143ae715 Patch for mis-compile of statement expressions with
non-trivial copy constructors. // rdar: //8540501.
A test will be added to llvm nightly tests.

llvm-svn: 117324
2010-10-25 23:27:26 +00:00
Dan Gohman d831356635 Trim an unnecessary #include.
llvm-svn: 117321
2010-10-25 21:59:29 +00:00
Dan Gohman 7dfd13c167 Factor out the code for creating the Root and Char nodes, so that
they can be used outside of the main getTBAAInfo function.

llvm-svn: 117320
2010-10-25 21:48:30 +00:00
Douglas Gregor 59f16ed082 Look through the address-of operator to find the function being
called. Fixes another aspect of PR8314.

llvm-svn: 117308
2010-10-25 20:48:33 +00:00
Douglas Gregor 8e09a72f13 When we're calling a function that we know based on its K&R-style
function definition, we should still use a prototype to type-check and
convert the function arguments, if such a prototype exists. Fixes
PR8314.

llvm-svn: 117305
2010-10-25 20:39:23 +00:00
Ted Kremenek c07d8353e1 Add check for UnknownVals for mutexes in ObjCAtSyncChecker. Fixes crash reported in PR 8458.
llvm-svn: 117300
2010-10-25 20:20:56 +00:00
David Chisnall b62d15c24e Only warn for mismatched types in Objective-C methods when they are incompatible, not when they are simply different. Now we test whether the difference in types breaks the principle of substitutability, rather than whether they are different.
A common idiom in Objective-C is to provide a definition of a method in a subclass that returns a more-specified version of an object than the superclass.  This does not violate the principle of substitutability, because you can always use the object returned by the subclass anywhere that you could use the type returned by the superclass.  It was, however, generating warnings with clang, leading people to believe that semantically correct code was incorrect and requiring less accurate type specification and explicit down-casts (neither of which is a good thing to encourage).

This change ensures that any method definition has parameter and return types that make it accept anything that something conforming to the declaration may pass and return something that the caller will expect, but allows stricter definitions.  

llvm-svn: 117271
2010-10-25 17:23:52 +00:00
Chandler Carruth 0171815ae1 Improve the tracking of source locations for parentheses in constructor calls.
This adds them where missing, and traces them through PCH. We fix at least one
bug in the extents found by the Index library, and make a lot of refactoring
tools which care about the exact formulation of a constructor call easier to
write. Also some minor cleanups to more consistently follow the friend pattern
instead of the setter pattern when rebuilding a serialized AST.

Patch originally by Samuel Benzaquen.

llvm-svn: 117254
2010-10-25 08:47:36 +00:00
Marcin Swiderski 01769904d3 Added generation of destructors for member constant size arrays.
There's only one destructor call generated for each not empty array (at least for now this should be enough).

llvm-svn: 117252
2010-10-25 07:05:54 +00:00
Marcin Swiderski 52e4bc1fed Added generation of destructors for constant size arrays.
There's only one destructor call generated for each not empty array (at least for now this should be enough).

llvm-svn: 117251
2010-10-25 07:00:40 +00:00
Peter Collingbourne a99fdcf93e Implement GNU C extension: two types are compatible if they appear
as a function argument, one of the types is a transparent union type
and the other type is compatible with a union member

llvm-svn: 117243
2010-10-24 18:30:18 +00:00
Argyrios Kyrtzidis e16a5300ba Keep track in chained PCH of implicit members that were added after the definition was completed.
llvm-svn: 117240
2010-10-24 17:26:54 +00:00
Argyrios Kyrtzidis d170d844c4 Start fleshing out ASTMutationListener; notify when a tag definition is completed.
In that case a chained PCH will record the updates to the DefinitionData pointer of forward references.
If a forward reference mutated into a definition re-write it into the chained PCH, this is too big of a change.

llvm-svn: 117239
2010-10-24 17:26:50 +00:00
Argyrios Kyrtzidis 3ba70b89cf Introduce a DeclsToRewrite field in ASTWrite, used for collecting the decls that will be replaced in the chained PCH.
llvm-svn: 117238
2010-10-24 17:26:46 +00:00
Argyrios Kyrtzidis 97bfda9b9b Some method renaming, no functionality change.
llvm-svn: 117237
2010-10-24 17:26:43 +00:00
Argyrios Kyrtzidis eb39d9a9ec Refactoring.
- Pass around RecordDataImpl instead of the concrete RecordData so that any SmallVector can be used.
- Move ASTDeclWriter::WriteCXXDefinitionData to ASTWriter::AddCXXDefinitionData.

llvm-svn: 117236
2010-10-24 17:26:40 +00:00
Argyrios Kyrtzidis 65ad5691fd Put the mechanism in place to track modifications in an AST entity that were committed after
its initial creation/deserialization and store the changes in a chained PCH.

The idea is that the AST entities call methods on the ASTMutationListener to give notifications
of changes; the PCHWriter implements the ASTMutationListener interface and stores the incremental changes
of the updated entity. WIP

llvm-svn: 117235
2010-10-24 17:26:36 +00:00
Argyrios Kyrtzidis ad5f95cc4b Simplify and "robust-ify" the way that CXXRecord references point to the definition data when loaded from PCH.
Temporary disable 'test/PCH/chain-cxx.cpp' until a better way to fix it is in place.

llvm-svn: 117234
2010-10-24 17:26:31 +00:00
Argyrios Kyrtzidis 8b200a5ef1 Minor refactoring; Pull reading/writing DefinitionData out into a function.
llvm-svn: 117233
2010-10-24 17:26:27 +00:00
Marcin Swiderski 772324971d - Fixed subexpressions evaluation order for binary operators to match order in code generated with the compiler,
- Fixed test cases for unreachable code warnings produced by Sema.

llvm-svn: 117220
2010-10-24 08:21:40 +00:00
Douglas Gregor e63d087bcb C++ [basic.scope.hiding] allows an ordinary name to hide a non-tag
name *in the same scope*, but not across scopes. Implement the
highlighted condition.

llvm-svn: 117212
2010-10-23 16:06:17 +00:00
Chandler Carruth c3ce5840af Update remaining attribute macros to new style.
llvm-svn: 117204
2010-10-23 08:44:57 +00:00
Chandler Carruth b7967b91c9 Update to use 'LLVM_*' macro names for attributes.
llvm-svn: 117201
2010-10-23 08:21:37 +00:00
Anders Carlsson 73067a02db Warn if a variable marked with the "unused" attribute is used. Patch by Darin Adler!
llvm-svn: 117184
2010-10-22 23:37:08 +00:00
John McCall 811a0f5578 Parse attributes on enumerators and instantiate attributes on enum decls.
llvm-svn: 117182
2010-10-22 23:36:17 +00:00
Douglas Gregor c0d2490ac4 In the presence of using declarations, we can find the same class
members in class subobjects of different types. So long as the
underlying declaration sets are the same, and the declaration sets
involve non-instance members, this is not an ambiguity.

llvm-svn: 117163
2010-10-22 22:08:47 +00:00
Ted Kremenek 7043fba7fa Fix '-analyzer-display-progress' for Objective-C methods. Also remove obsolete code.
llvm-svn: 117161
2010-10-22 22:08:29 +00:00
Fariborz Jahanian c123623d28 After discussion with Doug and John, I am reverting
the patch. 

llvm-svn: 117159
2010-10-22 22:05:03 +00:00
Dale Johannesen 70f564e0e8 Change handling of inline asm 'p' constraint to match llvm-gcc.
llvm-svn: 117149
2010-10-22 21:07:10 +00:00
John McCall 457a04e3ce Substantially revise how clang computes the visibility of a declaration to
more closely parallel the computation of linkage.  This gets us to a state
much closer to what gcc emits, modulo bugs, which will undoubtedly arise in
abundance.

llvm-svn: 117147
2010-10-22 21:05:15 +00:00
Fariborz Jahanian 0196aa28ec Patch fixes miscompile with non-trivial copy constructors and
statement expressions, //rdar: //8540501

llvm-svn: 117146
2010-10-22 21:01:02 +00:00
Devang Patel 401c916c8a Delay record type's debug info emission, in -flimit-debug-info mode, if member expression's base is call expr.
llvm-svn: 117127
2010-10-22 18:56:27 +00:00
Devang Patel db3910000a Revert unintentional check-in.
llvm-svn: 117120
2010-10-22 18:31:12 +00:00
Oscar Fuentes ac1a614079 Don't try to guess svn version when current path is a symlink.
See PR 8473.

llvm-svn: 117110
2010-10-22 17:16:39 +00:00
Devang Patel f79199d140 Tidy up MIPS_linkage name. Provide it only if it does not match regular name, otherwise it confuses debugger.
This is tested by local.C in llvmgcc testsuite.

llvm-svn: 117107
2010-10-22 17:11:50 +00:00
Benjamin Kramer fb5e584151 More class anonymization.
llvm-svn: 117106
2010-10-22 16:48:22 +00:00
Benjamin Kramer 2fc373e155 Move classes into anonymous namespaces.
llvm-svn: 117104
2010-10-22 16:33:16 +00:00
Douglas Gregor 412c362d9e When performing name lookup for a namespace definition, only look into
the current context's redeclaration context, ignoring using
directives. Fixes PR8430.

llvm-svn: 117097
2010-10-22 15:24:46 +00:00
Douglas Gregor 06e41ae5c7 Teach the C++ simple-type-specifier parser and tentative parses about
protocol-qualified types such as id<Protocol>.

llvm-svn: 117081
2010-10-21 23:17:00 +00:00
Dan Gohman 2bb62c3d2b Rename clang's TBAA tree root from "experimental" to "simple".
llvm-svn: 117046
2010-10-21 18:50:04 +00:00
Ted Kremenek 5ef9ad9907 Tweak diagnostics for redeclaration of a @property in a class extension where the redelcaration and original
declaration have the 'readwrite' attribute.  This is a common case, and we can issue a more lucid diagnostic.

Fixes <rdar://problem/7629420>.

llvm-svn: 117045
2010-10-21 18:49:42 +00:00
Ted Kremenek 22813f4077 Tidy up comment (remove extraneous text).
llvm-svn: 117044
2010-10-21 18:49:36 +00:00
Dan Gohman 5419ce6827 Add some more comments.
llvm-svn: 117043
2010-10-21 18:49:12 +00:00
Douglas Gregor cd1d0b4f98 Implement the integral promotion rules for the C++0x char16_t and
char32_t character types and enable built-in overloaded operator
candidates for these types. Fixes PR8432.

llvm-svn: 117038
2010-10-21 18:04:08 +00:00
Douglas Gregor a02bb37a8c Diagnose the declaration of template template parameters that
themselves have no template parameters. This is actually a restriction
due to the grammar of template template parameters, but we choose to
diagnose it in Sema to provide better recovery.

llvm-svn: 117032
2010-10-21 17:26:49 +00:00
Douglas Gregor bff6203152 Always treat 'main' as an extern "C" function, so that we detect
redeclarations of main appropriately rather than allowing it to be
overloaded. Also, disallowing declaring main as a template.

Fixes GCC DejaGNU g++.old-deja/g++.other/main1.C.

llvm-svn: 117029
2010-10-21 16:57:46 +00:00
Douglas Gregor 270b2ef0e7 When checking whether a return statement returns a stack-local
variable, handle conditional operators involving a
throw-expression. Fixes GCC DejaGNU's g++.dg/template/cond4.C.

llvm-svn: 117027
2010-10-21 16:21:08 +00:00
Francois Pichet ebdb43d54d Revert r117005, WIN32 is not predefined after all.
llvm-svn: 117026
2010-10-21 16:14:56 +00:00
Ted Kremenek c5644e1b97 Tweak the ObjCAtSyncChecker to assume that a mutex is non-nil after checking that it is
nil.  Otherwise we can get false paths where a second @synchronized using the mutex
can have a bogus warning.  Fixes <rdar://problem/8578650>.

llvm-svn: 117016
2010-10-21 15:38:55 +00:00
Francois Pichet 1ef4eb196d MSVC defines WIN32 as a predefined macro.
llvm-svn: 117005
2010-10-21 09:39:28 +00:00
Michael J. Spencer 54bf3c3cfb Targets: Fix MinGW and VisualStudio predefined macros.
llvm-svn: 117003
2010-10-21 08:22:51 +00:00
Michael J. Spencer 4992ca4b17 Reorganize predefined macros for all Windows targets.
This adds an option to set the _MSC_VER macro without
recompiling. This is very useful when testing compatibility
with the Windows SDK and c++stdlib headers.

-fmsc-version=<version> (defaults to VS2003 (1300))

llvm-svn: 116999
2010-10-21 05:21:48 +00:00
Ted Kremenek 12a37de003 Previously, the printf warnings would say your arguments type was 'int' when it was really a 'char'
or a 'short'. This fixes that and allows the hints to suggest 'h' modifiers for small ints.

Patch by Justin Bogner!

llvm-svn: 116996
2010-10-21 04:00:58 +00:00
Ted Kremenek 6377965efb Remove unused variable.
llvm-svn: 116995
2010-10-21 04:00:51 +00:00
Michael J. Spencer 4c0ffa823f Fix Whitespace.
llvm-svn: 116990
2010-10-21 03:16:25 +00:00
Michael J. Spencer 7b726c3fc8 Revert "Cleanup and fix predefined macros for windows."
Didn't realize this was on my branch ;/.

llvm-svn: 116989
2010-10-21 03:14:35 +00:00
Michael J. Spencer 2fb548cc05 Cleanup and fix predefined macros for windows.
llvm-svn: 116988
2010-10-21 03:13:04 +00:00
Craig Silverstein af8808dd28 Pass TInfo to CXXDestructorDecl::Create(), just like we do for other
function decls.

Reviewed by rjmccall and nlewycky.

llvm-svn: 116979
2010-10-21 00:44:50 +00:00
Argyrios Kyrtzidis 00f5266dbf When implicit members are added to a C++ record, notify the serializer so that a chained PCH writes the definition again.
Thanks to Doug for the hint!

llvm-svn: 116975
2010-10-20 23:48:42 +00:00
Argyrios Kyrtzidis 54b88e72d0 Modify the assumptions of an assert; the updated latest redeclaration can have the same location
if it's a template specialization pointing at the template.

llvm-svn: 116974
2010-10-20 23:48:40 +00:00
Ted Kremenek 982b32b1b6 Remove obsolete GRAuditor and GRSimpleAPICheck, which have been completely subsumed by the Checker interface.
llvm-svn: 116973
2010-10-20 23:48:34 +00:00
Ted Kremenek bd2c800882 Convert GRSimpleAPIChecks in BasicObjCFoundationChecks to be Checkers.
llvm-svn: 116971
2010-10-20 23:38:56 +00:00
Douglas Gregor 796d76a663 Extend the preprocessing record and libclang with support for
inclusion directives, keeping track of every #include, #import,
etc. in the translation unit. We keep track of the source location and
kind of the inclusion, how the file name was spelled, and the
underlying file to which the inclusion resolved.

llvm-svn: 116952
2010-10-20 22:00:55 +00:00
Argyrios Kyrtzidis 3317d985fe Fix chained PCH issue; make sure all visible decls that will be put into a UPDATE_VISIBLE block were recorded beforehand.
llvm-svn: 116931
2010-10-20 16:22:56 +00:00
Argyrios Kyrtzidis afd639501d Minor optimization; Try to iterator over redeclarations only when necessary.
llvm-svn: 116930
2010-10-20 16:22:49 +00:00
Fariborz Jahanian bb40ea42e3 Fixes a potential crash in rewriter when sending message
to 'super'.

llvm-svn: 116928
2010-10-20 16:07:20 +00:00
Duncan Sands 3a02f3eeff GCC 4.4 warns that Receiver may be used uninitialized in this function.
As far as I can see, gcc is right to think this!  The following change
will cause a nice segfault rather than undefined behaviour if this case
occurs.  Someone who understands what this code is supposed to do should
probably take a proper look.

llvm-svn: 116917
2010-10-20 08:21:16 +00:00
John McCall f551acaaf5 Access control polish: drop the note on the original declaration and
say 'implicitly' when it was implicit.  Resolves PR 7930 and my peace of mind.

llvm-svn: 116916
2010-10-20 08:15:06 +00:00
Chandler Carruth 24e17e175d Add support for the '--sysroot' flag, and an accompanying test of its
interactions with -isysroot and other driver commands.

llvm-svn: 116912
2010-10-20 07:00:47 +00:00
John McCall a020a0159f When matching template parameter lists to template-ids in a scope specifier
on a friend declaration, skip template-ids which do not depend on the
current parameter list.

llvm-svn: 116911
2010-10-20 05:44:58 +00:00
Douglas Gregor d507d77432 Fix handling of property and ivar lookup in typo correction; the two
kinds of lookup into Objective-C classes were tangled together, a
situation that was compounded by automatically synthesized ivars.

llvm-svn: 116907
2010-10-20 03:06:34 +00:00
Anders Carlsson 274a70ed7f Add a __has_attribute macro that works much like __has_feature and __has_builtin.
llvm-svn: 116906
2010-10-20 02:31:43 +00:00
Douglas Gregor 87074f19e8 Introduce a simple cache for unqualified typo corrections, so that we
don't repeatedly loop through identifiers, correcting the same typo'd
identifier over and over again. 

We still bail out after 20 typo corrections, but this should help
improve performance in the common case where we're typo-correcting
because the user forgot to include a header.

llvm-svn: 116901
2010-10-20 01:32:02 +00:00
Douglas Gregor 1f32ebe892 Eliminate another ordering dependency in typo correction. Re-enable typo.m, which seems to be working properly.
llvm-svn: 116894
2010-10-20 01:01:57 +00:00
Craig Silverstein 3b9936f0b7 Had the wrong type for ArgType. :-( Fixed.
llvm-svn: 116893
2010-10-20 00:56:01 +00:00
Craig Silverstein 20f7ab72b1 The type-to-delete may not be a pointer if it's a dependent type.
Here's example code:
---
template<class T> class MyClass {
  struct S { };
  S* NewS() { return new S; }
  void DeleteS() { delete NewS(); }
};
---
CXXDeleteExpr::getDestroyedType() on the 'delete NewS()' expression
would crash before this change.  Now it returns a dependent type
object.  Solution suggested by dgregor.

llvm-svn: 116891
2010-10-20 00:38:15 +00:00
Argyrios Kyrtzidis a41f66064f Fix issue with chained PCH where forward references did not pick up later definition in the chained PCH.
llvm-svn: 116887
2010-10-20 00:11:15 +00:00
Fariborz Jahanian 7c299bc6fa Do not rewrite new accessor if user has defined accessors.
Fixes //rdar: // 8570020.

llvm-svn: 116882
2010-10-19 23:47:54 +00:00
Ted Kremenek c81155eef7 Silence uninitialized value warning.
llvm-svn: 116877
2010-10-19 23:10:22 +00:00