Douglas Gregor [Thu, 2 Jun 2011 04:02:27 +0000 (04:02 +0000)]
Tweak code completions for Objective-C Key-Value Observing. The
+keyPathsForValuesAffecting<Key> completion was mislabeled as an
instance method, and +automaticallyNotifiesObserversOf<Key> was
missing entirely. Fixes <rdar://problem/9516762>.
Add the necessary -L option for finding libprofile_rt.a. It might be a good
idea at some point to split out the directories where we install our runtime
libraries.
Manuel Klimek [Wed, 1 Jun 2011 03:59:13 +0000 (03:59 +0000)]
Fix broken test on windows. To get operator new working, we need size_t, for which we need to figure out a way to resolve standard include paths in the test.
Manuel Klimek [Tue, 31 May 2011 23:49:32 +0000 (23:49 +0000)]
This patch implements an AST matching framework that allows to write
tools that match on the C++ ASTs. The main interface is in ASTMatchers.h,
an example implementation of a tool that removes redundant .c_str() calls
is in the example RemoveCStrCalls.cpp.
Various contributions:
Zhanyong Wan, Chandler Carruth, Marcin Kowalczyk, Wei Xu, James Dennett.
Francois Pichet [Tue, 31 May 2011 11:44:00 +0000 (11:44 +0000)]
For compatibility with MSVC, a friend declaration also act as a forward declaration if the tag name is not already declared. The tag name is declared in the next outermost non record scope.
Example:
Chandler Carruth [Sun, 29 May 2011 07:32:14 +0000 (07:32 +0000)]
Fix a regression in the source locations for unary trait expressions.
I tried to use an assert to prove that I could remove each of the
arguments I did, but ended up writing my assert with inverted logic.
Doh! Reported by Xi Wang on cfe-dev. I have manually verified the source
locations and ranges for these using -ast-dump. I tried writing a test
case that would catch these, but these expressions aren't exposed in the
c-index-test's token annotation utility.
Add a couple of helper methods in the SourceManager API, isAtStartOfMacroInstantiation/isAtEndOfMacroInstantiation
useful only for source locations that point at a macro token.
Eli Friedman [Fri, 27 May 2011 22:13:20 +0000 (22:13 +0000)]
Match llvm-gcc's string literals alignment by forcing alignment on string literals to 1. This can significantly impact the size of the string data, and as far as I know, the alignment doesn't help performance. rdar://9078969 .
Douglas Gregor [Fri, 27 May 2011 21:28:00 +0000 (21:28 +0000)]
Clean up my changes to jump-diagnostic handling for local variables of
class type (or array thereof), eliminating some redundant checks
(thanks Eli!) and adding some tests where the behavior differs in
C++98/03 vs. C++0x.
John McCall [Fri, 27 May 2011 20:01:14 +0000 (20:01 +0000)]
Implement a new, much improved version of the cleanup hack. We just need
to be careful to emit landing pads that are always prepared to handle a
cleanup path. This is correct mostly because of the fix to the LLVM
inliner, r132200.
Douglas Gregor [Fri, 27 May 2011 16:05:29 +0000 (16:05 +0000)]
Update the jump-scope checker for local variables with initializers,
so that it looks at the initializer of a local variable of class type
(or array thereof) to determine whether it's just an implicit
invocation of the trivial default constructor. Fixes PR10034.
Chandler Carruth [Fri, 27 May 2011 01:33:31 +0000 (01:33 +0000)]
Enhance Clang to start instantiating static data member definitions
within class templates when they are necessary to complete the type of
the member. The canonical example is code like:
template <typename T> struct S {
static const int arr[];
static const int x;
static int f();
};
We need to instantiate S<T>::arr's definition to pick up its initializer
and complete the array type. This involves new code to specially handle
completing the type of an expression where the type alone is
insufficient. It also requires *updating* the expression with the newly
completed type. Fortunately, all the other infrastructure is already in
Clang to do the instantiation, do the completion, and prune out the
unused bits of code that result from this instantiation.
This addresses the initial bug in PR10001, and will be a step to
fleshing out other cases where we need to work harder to complete an
expression's type. Who knew we still had missing C++03 "features"?
Douglas Gregor [Fri, 27 May 2011 01:19:52 +0000 (01:19 +0000)]
Objective-C doesn't consider the use of incomplete types as method
parameter types to be ill-formed. However, it relies on the
completeness of method parameter types when producing metadata, e.g.,
for a protocol, leading IR generating to crash in such cases.
Since there's no real way to tighten down the semantics of Objective-C
here without breaking existing code, do something safe but lame:
suppress the generation of metadata when this happens.
Richard Trieu [Thu, 26 May 2011 20:49:16 +0000 (20:49 +0000)]
Change the include stack of "instantiated from" notes to fall under the control of f/fno-diagnostics-show-note-include-stack flags. This should help with reducing diagnostic spew from macros instantiations.
Richard Trieu [Thu, 26 May 2011 20:11:09 +0000 (20:11 +0000)]
Add a fix-it and better error recovery for improperly nested namespaces. This will give a better error message for cases such as "namespace foo::bar::baz {}" and a suggested fix-it of "namespace foo { namespace bar { namespace baz {} } }"
Chandler Carruth [Thu, 26 May 2011 08:53:16 +0000 (08:53 +0000)]
Extract two more methods from the unary type trait checking. These
provide re-usable forms of the rest of the custom validation done here.
Still no functionality changed here.
With this it should be possible to have an expression-centric code path
and a type-centric code path which don't duplicate logic.
Chandler Carruth [Thu, 26 May 2011 08:53:14 +0000 (08:53 +0000)]
Remove a no longer relevant comment. It was just repeating the
information in the previous comment which was preserved and moved with
the vec_step implementation code.
Chandler Carruth [Thu, 26 May 2011 08:53:12 +0000 (08:53 +0000)]
Extract the vec_step trait operand checking to a stand alone function.
It has little overlap with other traits' requirements, so the resulting
code is actually simpler.
Chandler Carruth [Thu, 26 May 2011 08:53:10 +0000 (08:53 +0000)]
Add a convenience interface for checking expression arguments to unary
traits which uses the information embedded in the expression. Use this
to simplify several interfaces which repeated information embedded in
the expression through explicit arguments. I added an assertion that the
only extra piece of data to come in from the parser matches what is
stored in the expression. No functionality change intended here.
Also cleaned up the doxygen comments for some of these methods and some
formatting oddities.
Sean Hunt [Thu, 26 May 2011 01:26:05 +0000 (01:26 +0000)]
Implement a new warning for when adding a default argument to a method
makes it into a special member function. This is very bad and can lead
to all sorts of nastiness including implicit member functions violating
the One Definition Rule. This should probably be made ill-formed in a
later version of the standard, but for now we'll just warn.
Eli Friedman [Thu, 26 May 2011 00:10:27 +0000 (00:10 +0000)]
Skip extra copy from aggregate where it isn't necessary; rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0.
Originally r130717, but was backed out due to an ObjC regression.
Sean Hunt [Wed, 25 May 2011 20:50:04 +0000 (20:50 +0000)]
Implement a little bit of cleanup and a lot more of the base work
behind implicit moves. We now correctly identify move constructors and
assignment operators and update bits on the record correctly. Generation
of implicit moves (declarations or definitions) is not yet supported.
A StringRef-ication of the DiagnosticIDs API and internals.
Patch by Matthieu Monrocq with tweaks by me to avoid StringRefs in the static
diagnostic data structures, which resulted in a huge global-var-init function.
Sean Hunt [Tue, 24 May 2011 22:41:36 +0000 (22:41 +0000)]
Implement a new type node, UnaryTransformType, designed to represent a
type that turns one type into another. This is used as the basis to
implement __underlying_type properly - with TypeSourceInfo and proper
behavior in the face of templates.
Douglas Gregor [Tue, 24 May 2011 16:02:01 +0000 (16:02 +0000)]
Implement the initial part of C++0x [expr.const]p2, which specifies
that the unevaluated subexpressions of &&, ||, and ? : are not
considered when determining whether the expression is a constant
expression. Also, turn the "used in its own initializer" warning into
a runtime-behavior warning, so that it doesn't fire when a variable is
used as part of an unevaluated subexpression of its own initializer.
Chandler Carruth [Tue, 24 May 2011 07:43:19 +0000 (07:43 +0000)]
Fix a bug in -Wundefined-reinterpret-cast where we failed to look
through sugared types when testing for TagTypes. This was the actual
cause of the only false positive in Clang+LLVM.
Next evaluation will be over a much larger selection of code including
large amounts of open source code.