John McCall [Tue, 26 Oct 2010 00:53:53 +0000 (00:53 +0000)]
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.
Douglas Gregor [Tue, 26 Oct 2010 00:51:02 +0000 (00:51 +0000)]
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.
Ted Kremenek [Tue, 26 Oct 2010 00:06:17 +0000 (00:06 +0000)]
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.
Douglas Gregor [Mon, 25 Oct 2010 20:39:23 +0000 (20:39 +0000)]
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.
David Chisnall [Mon, 25 Oct 2010 17:23:52 +0000 (17:23 +0000)]
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.
Chandler Carruth [Mon, 25 Oct 2010 08:47:36 +0000 (08:47 +0000)]
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.
Marcin Swiderski [Mon, 25 Oct 2010 07:05:54 +0000 (07:05 +0000)]
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).
Marcin Swiderski [Mon, 25 Oct 2010 07:00:40 +0000 (07:00 +0000)]
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).
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
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.
Refactoring.
- Pass around RecordDataImpl instead of the concrete RecordData so that any SmallVector can be used.
- Move ASTDeclWriter::WriteCXXDefinitionData to ASTWriter::AddCXXDefinitionData.
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
Marcin Swiderski [Sun, 24 Oct 2010 08:21:40 +0000 (08:21 +0000)]
- 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.
Douglas Gregor [Sat, 23 Oct 2010 16:06:17 +0000 (16:06 +0000)]
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.
Douglas Gregor [Fri, 22 Oct 2010 22:08:47 +0000 (22:08 +0000)]
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.
Ted Kremenek [Fri, 22 Oct 2010 22:08:32 +0000 (22:08 +0000)]
Fix a horrible bug in all dataflow analyses that use CFGRecStmtVisitor (including live variables analysis).
We shouldn't recurse into CompoundStmts since they are already inlined in the CFG. This could result in
bogus dead stores warnings (among other things).
John McCall [Fri, 22 Oct 2010 21:05:15 +0000 (21:05 +0000)]
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.
Douglas Gregor [Fri, 22 Oct 2010 17:36:51 +0000 (17:36 +0000)]
When we perform name lookup for a template, we may end up finding an
ambiguous name where none of the declarations found are actually
templates. In this case, make sure we clear out the ambiguous-path
data when recomputing the lookup result kind. Fixes PR8439.
Devang Patel [Fri, 22 Oct 2010 17:11:50 +0000 (17:11 +0000)]
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.
Douglas Gregor [Fri, 22 Oct 2010 15:24:46 +0000 (15:24 +0000)]
When performing name lookup for a namespace definition, only look into
the current context's redeclaration context, ignoring using
directives. Fixes PR8430.
Ted Kremenek [Thu, 21 Oct 2010 18:49:42 +0000 (18:49 +0000)]
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.
Douglas Gregor [Thu, 21 Oct 2010 18:04:08 +0000 (18:04 +0000)]
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.
Douglas Gregor [Thu, 21 Oct 2010 17:26:49 +0000 (17:26 +0000)]
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.
Douglas Gregor [Thu, 21 Oct 2010 16:57:46 +0000 (16:57 +0000)]
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.
Douglas Gregor [Thu, 21 Oct 2010 16:21:08 +0000 (16:21 +0000)]
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.
Ted Kremenek [Thu, 21 Oct 2010 15:38:55 +0000 (15:38 +0000)]
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>.
Douglas Gregor [Thu, 21 Oct 2010 06:10:04 +0000 (06:10 +0000)]
Improve the implementation of libclang's token-annotation logic for
entities in the preprocessing record. Previously, we would only end up
getting the first token of a preprocessing record annotated
correctly. For example, given
#include "foo.h"
we would only get the '#' annotated as an inclusion directive; the
'include' and '"foo.h"' tokens would be given the general 'processing
directive' annotation.
Now, we get proper annotations for entities in the preprocessing
record.
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))
Ted Kremenek [Thu, 21 Oct 2010 04:00:58 +0000 (04:00 +0000)]
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.
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.
Douglas Gregor [Wed, 20 Oct 2010 22:00:55 +0000 (22:00 +0000)]
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.
Get FunctionDecl to recurse on FunctionTypeLoc rather than
FunctionType! I didn't realize it was available, until rjmccall
pointed out that DeclaratorDecl made the typeloc available. This
makes FunctionDecl recursion *much* easier, because the typeloc can
take care of default parameters, so we no longer have to do that
separately, which means we can just do a normal type traversal instead
of this special-case WalkUp stuff we did before.
The only downside -- and it's minor -- is that because the TypeLoc
handles both the return type and the argument types, we can't recurse
on the explicit template args in the right place (which would be
between them). I do it beforehand instead. So for
int MyFunc<float>(char x);
we get callbacks in the order: float, int, char.
Duncan Sands [Wed, 20 Oct 2010 08:21:16 +0000 (08:21 +0000)]
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.
John McCall [Wed, 20 Oct 2010 05:44:58 +0000 (05:44 +0000)]
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.
Douglas Gregor [Wed, 20 Oct 2010 03:06:34 +0000 (03:06 +0000)]
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.
Douglas Gregor [Wed, 20 Oct 2010 01:32:02 +0000 (01:32 +0000)]
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.