Migrate LLVM and Clang to use the new makeArrayRef(...) functions where previously explicit non-default constructors were used.
Mostly mechanical with some manual reformatting.
[arcmt] When a NSData's 'bytes' family of methods are used on a local var,
add __attribute__((objc_precise_lifetime)) to make sure that the object
(and its data) will not get released before the var goes out-of-scope.
[arcmt] NSInvocation's [get/set]ReturnValue and [get/set]Argument are only safe
with __unsafe_unretained parameters. Emit error for strong/weak ones. rdar://9206226
Revert r135217, which wasn't the correct fix for PR10358. With this
patch, we actually move the state-machine for the value set backwards
one step. This can pretty easily lead to infinite loops where we
continually try to propagate a bit, succeed for one iteration, but then
back up because we find an uninitialized use.
[analyzer] Per discussions with the Cocoa team, extend CF naming conventions to extend to camel case functions instead of just title case functions. Fixes <rdar://problem/9732321>.
[arcmt] It's not safe to remove the -release on "[[someivar delegate] release];" since it's very likely
that, after migration, the object that was passed to 'setDelegate:' will not be properly retained, e.g:
-whatever {
id x = [[MyDoHicky alloc] init];
[someivar setDelegate: x]; // x won't get retained in ARC.
}
-dealloc {
[[someivar delegate] release]; // give migration error here.
}
Douglas Gregor [Fri, 15 Jul 2011 21:46:17 +0000 (21:46 +0000)]
Augment the interface of ExternalASTSource::FindExternalLexicalDecls()
to allow clients to specify that they've already (correctly) loaded
declarations, and that no further action is needed.
Also, make sure that we clear the "has external lexical declarations"
bit before calling FindExternalLexicalDecls(), to avoid infinite
recursion.
John McCall [Fri, 15 Jul 2011 07:47:58 +0000 (07:47 +0000)]
Restore the C-style cast hack for enum template arguments,
which is required given the current setup for template
argument deduction substitution validation, and add a test
case to make sure we don't break it in the future.
John McCall [Fri, 15 Jul 2011 07:00:14 +0000 (07:00 +0000)]
Add serialization support for SubstNonTypeTemplateParmExpr.
Also add the missing serialization support for SEHTryStmt,
SEHFinallyStmt, and SEHExceptStmt, and fix and finish the
serialization support for AsTypeExpr. In addition, change
the code so that it will no longer link if a Stmt subclass
is missing serialization support.
John McCall [Fri, 15 Jul 2011 06:56:33 +0000 (06:56 +0000)]
Fix the definition of AsTypeExpr. I'm still not sure this
is right --- shouldn't there be a TypeLoc in here somewhere? ---
but at least it doesn't have a redundant QualType and a broken
children() method.
Chris Lattner [Fri, 15 Jul 2011 06:41:05 +0000 (06:41 +0000)]
protect some calls to ConvertType when a function info is under construction
to prevent recursive compilation problems. This fixes a failure of CodeGen/decl.c
on x86-32 targets that don't fill in the coerce-to type.
Jordy Rose [Fri, 15 Jul 2011 06:02:19 +0000 (06:02 +0000)]
Clean up MacOSXAPIChecker, including switching its array of BugTypes to a single llvm::OwningPtr<BugType> (the new convention). No functionality change.
Chris Lattner [Fri, 15 Jul 2011 05:16:14 +0000 (05:16 +0000)]
Enhance the IR type lowering code to be much smarter about recursively lowering
types. Fore xample, we used to lower:
struct bar { int a; };
struct foo {
void (*FP)(struct bar);
} G;
to:
%struct.foo = type { {}* }
since the function pointer would cause recursive translation of bar and
we didn't know if that would get us into trouble. We are now smart enough
to know that it is fine, so we get this type instead:
%struct.foo = type { void (i32)* }
Codegen still needs to be prepared for uncooperative types at any place,
which is why I let the maximally uncooperative code sit around for awhile to
help shake out the bugs.
John McCall [Fri, 15 Jul 2011 05:09:51 +0000 (05:09 +0000)]
Create a new expression node, SubstNonTypeTemplateParmExpr,
to represent a fully-substituted non-type template parameter.
This should improve source fidelity, as well as being generically
useful for diagnostics and such.
Richard Trieu [Fri, 15 Jul 2011 00:00:51 +0000 (00:00 +0000)]
Remove warnings of constant operands of logical operators from template instantiations. Upon instantiation of template, value-dependent parameters are replaced by equivalent literals, so code like:
template<unsigned int A, unsigned int B> struct S {
int foo() {
int x = A && B;
}
}
will not warn on A && B on every instantiation. This will still warn on other cases inside templates, which will be caught on checking the template definition.
Douglas Gregor [Thu, 14 Jul 2011 23:42:32 +0000 (23:42 +0000)]
Tweak the CMake build so that building a project just containing Clang
(and linking to an already-build LLVM) works with Xcode. The resulting
Xcode project for Clang is quite a bit smaller and builds/loads faster.
Rafael Espindola [Thu, 14 Jul 2011 22:58:04 +0000 (22:58 +0000)]
Revert 135177 to fix PR10363.
Revert "For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either."
This case now produces a missing ';' diagnostic, since that seems like a much more likely error than an attempt to declare a function or variable in addition to the class template.
[arcmt] Emit an error for unused -autorelease messages.
An unused autorelease is badness. If we remove it the receiver
will likely die immediately while previously it was kept alive
by the autorelease pool. This is bad practice in general, so leave it
and emit an error to force the user to restructure his code.
Sebastian Redl [Thu, 14 Jul 2011 19:08:10 +0000 (19:08 +0000)]
For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either.
This is a first baby step towards supporting generalized initializer lists. This also removes an aggregate
test case that was just plain wrong, assuming that non-aggregates couldn't be initialized with initializer lists
in C++11 mode.
Add extra sanity checking in FormatString::matchesType() that we are comparing integers to integers. This happens not to be an issue now, but the extra check helps future proof in case of future refactorings.
This is switches all the interfaces points (and most of the commenst
/ local variables I saw on my way through) regarding the
NestedMacroInstantiations bit.
The libclang enums corresponding to this state were renamed, but
a legacy enum was added with the old name, and the same value to keep
existing clients working. I've added a documentation blurb for it, but
let me know if there is a canonical way to document legacy elemenst of
the libclang interface.
Update all of the libclang code corresponding to the preprocessor
MacroInstantiation -> MacroExpansion rename. Internally, everything is
switched.
Introduce a new cursor kind enum with the new name, but retain the old
name as an alias so that we don't break backwards compatibility.
Also update the debug printing routine to use 'macro expansions' as its
explicitly not guaranteed to be stable, and mechanically switch the test
cases over to that.
Move the rest of the preprocessor terminology from 'instantiate' and
variants to 'expand'. This changed a couple of public APIs, including
one public type "MacroInstantiation" which is now "MacroExpansion". The
rest of the codebase was updated to reflect this, especially the
libclang code. Two of the C++ (and thus easily changed) libclang APIs
were updated as well because they pertained directly to the old
MacroInstantiation class.
Convert terminology in the Lexer from 'instantiate' and variants to
'expand'. Also update the public API it provides to the new term, and
propagate that update to the various clients.
Switch the TokenLexer's terminology from various forms of 'instantiate'
to 'expand' for macros. Only comments and uses local to the TokenLexer
are updated.
Douglas Gregor [Thu, 14 Jul 2011 04:54:23 +0000 (04:54 +0000)]
Add a hackaround to avoid the crash in PR10355. However, our recovery
is still terrible here because typo correction is not behaving well in
the presence of overloaded functions.
format string checking: long and int have the same widths on 32-bit, so we shouldn't warn about using
an "int" format specifier with a "long" type in 32-bit.
John McCall [Wed, 13 Jul 2011 20:12:57 +0000 (20:12 +0000)]
Enforce access control for the destructor in a new[] expression and mark
it as used. Otherwise, we can fail to instantiate or validate the destructor,
which can lead to crashes in IR gen like PR10351.
[arcmt] For properties rewrite 'assign' -> 'weak or unsafe_unretained', 'retain' -> 'strong', and add
'weak or unsafe_unretained' when 'assign' is missing. rdar://9496219&9602589.
With -Wselector, don't warn about unimplemented optional method
used in @selector expression because, well, their implementation
is optional. // rdar://9545564
John McCall [Wed, 13 Jul 2011 17:56:40 +0000 (17:56 +0000)]
In debugger mode, make ObjC message sends to unknown selectors return
__unknown_anytype, and rewrite such message sends correctly.
I had to bite the bullet and actually add a debugger support mode for this
one, which is a bit unfortunate, but there really isn't anything else
I could imagine doing; this is clearly just debugger-specific behavior.