Douglas Gregor [Tue, 13 Oct 2009 14:39:41 +0000 (14:39 +0000)]
Improve the internal representation and semantic analysis of friend
function templates.
This commit ensures that friend function templates are constructed as
FunctionTemplateDecls rather than partial FunctionDecls (as they
previously were). It then implements template instantiation for friend
function templates, injecting the friend function template only when
no previous declaration exists at the time of instantiation.
Oh, and make sure that explicit specialization declarations are not
friends.
Chris Lattner [Tue, 13 Oct 2009 07:14:16 +0000 (07:14 +0000)]
Teach sema and codegen about the difference between address of labels,
which is a common idiom to improve PIC'ness of code using the addr of
label extension. This implementation is a gross hack, but the only other
alternative would be to teach evalutate about this horrid combination.
While GCC allows things like "&&foo - &&bar + 1", people don't use this
in practice. This implements PR5131.
Chris Lattner [Tue, 13 Oct 2009 06:55:33 +0000 (06:55 +0000)]
reimplement codegen for indirect goto with the following advantages:
1. CGF now has fewer bytes of state (one pointer instead of a vector).
2. The generated code is determinstic, instead of getting labels in
'map order' based on pointer addresses.
3. Clang now emits one 'indirect goto switch' for each function, instead
of one for each indirect goto. This fixes an M*N = N^2 IR size issue
when there are lots of address-taken labels and lots of indirect gotos.
4. This also makes the default cause do something useful, reducing the
size of the jump table needed (by one).
Chris Lattner [Tue, 13 Oct 2009 06:04:29 +0000 (06:04 +0000)]
number address-taken labels from 1. This allows 0 to be used as a sentinel
for a null pointer. In other words, "&&foo != NULL" will always work out to
true.
Douglas Gregor [Mon, 12 Oct 2009 23:11:44 +0000 (23:11 +0000)]
When declaring a class template whose name is qualified, make sure
that the scope in which it is being declared is complete. Also, when
instantiating a member class template's ClassTemplateDecl, be sure to
delay type creation so that the resulting type is dependent. Ick.
Douglas Gregor [Mon, 12 Oct 2009 22:27:17 +0000 (22:27 +0000)]
Permit explicit specialization of member functions of class templates
that are declarations (rather than definitions). Also, be sure to set
the access specifiers properly when instantiating the declarations of
member function templates.
John McCall [Mon, 12 Oct 2009 21:59:07 +0000 (21:59 +0000)]
Implement -Wparentheses: warn about using assignments in contexts that require
conditions. Add a fixit to insert the parentheses. Also fix a very minor
possible memory leak in 'for' conditions.
Ted Kremenek [Mon, 12 Oct 2009 20:55:07 +0000 (20:55 +0000)]
Use a BumpPtrAllocator to allocate all aspects of CFG, including CFGBlocks, successor and predecessor vectors, etc.
Speedup: when doing 'clang-cc -analyze -dump-cfg' (without actual printing, just
CFG building) on the amalgamated SQLite source (all of SQLite in one source
file), runtime reduced by 9%.
Douglas Gregor [Mon, 12 Oct 2009 20:18:28 +0000 (20:18 +0000)]
Diagnose the declaration of explicit specializations after an implicit
instantiation has already been required. To do so, keep track of the
point of instantiation for anything that can be instantiated.
If built-in operators could not be selected because of ambiguity in
user-defined type conversions, issue list of ambiguites in addition
to the diagnostic. So, clang now issues the following:
b.cpp:19:19: error: left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'struct C1'
int i = c1->*pmf;
~~^
b.cpp:19:19: note: because of ambiguity in conversion of 'struct C1' to 'struct E *'
b.cpp:5:5: note: candidate function
operator E*();
^
b.cpp:11:5: note: candidate function
operator E*();
^
Axel Naumann [Mon, 12 Oct 2009 16:42:18 +0000 (16:42 +0000)]
Don't install Makefiles nor tablegen input in include/.
Fix exclusion of .tmp, which in turn enables installation of $(PROJ_OBJ_ROOT)/tools/clang/include/*.inc.
Benjamin Kramer [Sun, 11 Oct 2009 12:22:00 +0000 (12:22 +0000)]
CMake mingw build fixes.
- llvm's libs must be linked after clang's
- libLLVMSystem depends on psapi on win32 (get_system_libs has it)
- CIndex builds successfully on mingw now
Zhongxing Xu [Sun, 11 Oct 2009 08:08:02 +0000 (08:08 +0000)]
Introduces a new BindingVal which combines direct and
default binding for regions. This allows us to simply a lot of code. A
further simplification could be done is that many methods of
regionstore can only work on Store instead of GRState.
Sebastian Redl [Sat, 10 Oct 2009 12:04:10 +0000 (12:04 +0000)]
Implement the core checking for compatible exception specifications in assignment and initialization.
The exception specification of the assignee must be the same or a subset of the target. In addition, exception specifications on arguments and return types must be equivalent, but this is not implemented yet.
This currently produces two diagnostics for every invalid assignment/initialization, due to the diagnostic produced outside PerformImplicitConversion, e.g. in CheckSingleInitializer. I don't know how to suppress this; in any case I think it is the wrong place for a diagnostic, since there are other diagnostics produced inside the function. So I'm leaving it as it is for the moment.
John McCall [Sat, 10 Oct 2009 05:48:19 +0000 (05:48 +0000)]
Qualified lookup through using declarations. Diagnose a new type of ambiguity.
Split the various ambiguous result enumerators into their own enum. Tests
for most of C++ [namespace.qual].
Anders Carlsson [Fri, 9 Oct 2009 23:51:55 +0000 (23:51 +0000)]
Add CheckCallReturnType and start using it for regular call expressions. This will improve error messages. For
struct B;
B f();
void g() {
f();
}
We now get
t.cpp:6:3: error: calling 'f' with incomplete return type 'struct B'
f();
^~~
t.cpp:3:3: note: 'f' declared here
B f();
^
t.cpp:1:8: note: forward declaration of 'struct B'
struct B;
^
Douglas Gregor [Fri, 9 Oct 2009 22:16:47 +0000 (22:16 +0000)]
Minor tweaks for code-completion:
- Filter out unnamed declarations
- Filter out declarations whose names are reserved for the
implementation (e.g., __bar, _Foo)
- Place OVERLOAD: or COMPLETION: at the beginning of each
code-completion result, so we can easily separate them from other
compilation results.
John McCall [Fri, 9 Oct 2009 21:13:30 +0000 (21:13 +0000)]
Refactor the LookupResult API to simplify most common operations. Require users to
pass a LookupResult reference to lookup routines. Call out uses which assume a single
result.
Douglas Gregor [Fri, 9 Oct 2009 21:11:42 +0000 (21:11 +0000)]
When declaring a friend class template, we may end up finding an
injected-class-name (e.g., when we're referring to other
specializations of the current class template). Make sure that we see
the template rather than the injected-class-name. Fixes PR4768.
Produce good looking diagnostics on ambiguous built-in operators.
Now we produce things like:
bug1.cpp:21:11: error: use of overloaded operator '->*' is ambiguous
int i = c->*pmf; // expected-error {{use of overloaded operator '->*' is ambiguous}} \
~^ ~~~
bug1.cpp:21:11: note: built-in candidate operator ->* ('struct A volatile *', 'int const struct A::*')
bug1.cpp:21:11: note: built-in candidate operator ->* ('struct A volatile *', 'int restrict struct A::*')
...
Still need to look at an issue (indicated as FIXME in the test case).
Steve Naroff [Thu, 8 Oct 2009 23:45:10 +0000 (23:45 +0000)]
- Fixup SortCodeCompleteResult() to properly sort keywords on Mac OS (compare was system dependent). Worked on Linux, failed on Mac OS (which caused the recently added testcase to fail on Linux).
- Sort results in testcase.
Mike Stump [Thu, 8 Oct 2009 23:00:00 +0000 (23:00 +0000)]
"Someone pointed out that in my previous Targets.cpp patch I didn't
handle the long size difference for one of the Windows targets." Patch
by John Thompson.
Mike Stump [Thu, 8 Oct 2009 22:55:36 +0000 (22:55 +0000)]
This fixes support for complex literals, reworked to avoid a goto, and
to add a flag noting the presence of a Microsoft extension suffix (i8,
i16, i32, i64). Patch by John Thompson.
Mike Stump [Thu, 8 Oct 2009 21:57:41 +0000 (21:57 +0000)]
In VC++, the *printf functions put an extra "0" in the exponent part
of a floating point number. This add regular expressions to account
for this. Patch by John Thompson.