Chandler Carruth [Thu, 17 Feb 2011 08:37:06 +0000 (08:37 +0000)]
Implement -Wenum-compare, which warns when comparing two enums of
different types. We omit the warning when the enum types are anonymous.
Unlike GCC, this warning does not distinguish between C++ and C/ObjC for
controling whether it is on by default, it is always on by default.
Original patch contributed by Richard Trieu (@ Google), I fixed some
style issues, and cleaned it up for submission.
Chris Lattner [Thu, 17 Feb 2011 07:39:24 +0000 (07:39 +0000)]
Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt. There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself. This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.
This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.
This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.
Review appreciated, particularly for the cindex and template bits.
Douglas Gregor [Thu, 17 Feb 2011 06:52:25 +0000 (06:52 +0000)]
When printing a qualified type, look through a substituted template
parameter type to see what's behind it, so that we don't end up
printing silly things like "float const *" when "const float *" would
make more sense. Also, replace the pile of "isa" tests with a simple
switch enumerating all of the cases, making a few more obvious cases
use prefix qualifiers.
Douglas Gregor [Thu, 17 Feb 2011 03:19:26 +0000 (03:19 +0000)]
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
Douglas Gregor [Thu, 17 Feb 2011 03:09:23 +0000 (03:09 +0000)]
When Parser::ParseExpressionList isn't given a completer, fall back to
normal "expression" completion. Fixes the most annoying
code-completion bug I've found.
Fix PR9025 and add a diagnostic (and sometimes a fixit) for an overloaded
function name used as the base of a member expression. Early feedback from
Chandler Carruth, and code review from Nick Lewycky.
Ted Kremenek [Thu, 17 Feb 2011 02:28:30 +0000 (02:28 +0000)]
Begin overhaul of scan-build/ccc-analyzer's handling of checker options.
We now rely on 'clang --analyze' to provide the default set of checkers. We're
still working on the new '-analyzer-checker <checker>' interface, and once
that's ready we'll wire it up to scan-build.
Douglas Gregor [Wed, 16 Feb 2011 19:08:06 +0000 (19:08 +0000)]
Teach the CXCodeCompleteResults results structure, which stores
code-completion results accessed via libclang, to extend the lifetime
of the allocator used for cached global code-completion results at
least until these completion results are destroyed. Fixes
<rdar://problem/8997369>.
Douglas Gregor [Wed, 16 Feb 2011 18:16:54 +0000 (18:16 +0000)]
Improve the invalidation logic for the cache of global code
completions. We now compute a hash of the names of all top-level
declarations and macro definitions, and invalidate the cache when the
hash value changes.
Zhanyong Wan [Wed, 16 Feb 2011 05:19:17 +0000 (05:19 +0000)]
Improves CMakeLists.txt for Clang's unit tests: make "linked
components" and "used libs" arguments of add_clang_unittest().
Reviewed by jyasskin and chapuni.
Douglas Gregor [Wed, 16 Feb 2011 01:39:26 +0000 (01:39 +0000)]
When searching for visible declarations (e.g., for code completion),
be sure to look at all of the Objective-C class declarations within a
@class. Fixes <rdar://problem/8876207>.
Douglas Gregor [Wed, 16 Feb 2011 00:51:18 +0000 (00:51 +0000)]
When trying to provide a code completion item for a call to "super" in
Objective-C, also look in the categories and class extensions of our
superclasses. Fixes <rdar://problem/8853540>.
John McCall [Wed, 16 Feb 2011 00:49:34 +0000 (00:49 +0000)]
Don't call objc_read_weak as part of emitting a block literal.
Nobody ever gave me a clear reason for why we were doing this, and
now it's apparently causing serious problems, so if *not* having this
causes problems, we get to solve them the right way this time.
Devang Patel [Tue, 15 Feb 2011 23:36:28 +0000 (23:36 +0000)]
Only c++ class arguments with non trivial constructor or destructor needs a reference.
C struct arguments do not need this adjustment.
This fixes 7 failures in callfuncs.exp from gdb testsuite.
Rafael Espindola [Tue, 15 Feb 2011 22:23:51 +0000 (22:23 +0000)]
Add a hack to avoid adding '\01' to asm names when possible. It would be
better for clang to always compute the right name, but for now this hack
fixes PR9177 and lets us build firefox with LTO :-)
Douglas Gregor [Tue, 15 Feb 2011 20:33:25 +0000 (20:33 +0000)]
When code-completing within a list of declaration specifiers,
separately handle the case of a local declaration-specifier list,
including all types in the set of options. Fixes
<rdar://problem/8790735> and <rdar://problem/8662831>.
Douglas Gregor [Tue, 15 Feb 2011 19:17:31 +0000 (19:17 +0000)]
When we encounter an Objective-C class name in an expression, followed
by the code completion token, treat this as a class message send where
the opening square bracket is missing. Fixes <rdar://problem/6970911>.
Allow resolving headers from a PCH even after headers+PCH were moved to another path.
Store in PCH the directory that the PCH was originally created in.
If a header file is not found at the path that we expect it to be and the PCH file
was moved from its original location, try to resolve the file by assuming that
header+PCH were moved together and the header is in the same place relative to the PCH.
John McCall [Tue, 15 Feb 2011 09:22:45 +0000 (09:22 +0000)]
Assorted cleanup:
- Have CGM precompute a number of commonly-used types
- Have CGF copy that during initialization instead of recomputing them
- Use TBAA info when initializing a parameter variable
- Refactor the scalar ++/-- code
[analyzer] Reflect changes for tablegen'ing the checkers.
-Update tablegen files for checkers, use the tablegen class name for the checker class name.
-Update ClangSACheckersProvider to not look into hidden checker packages.
John McCall [Tue, 15 Feb 2011 07:12:36 +0000 (07:12 +0000)]
Return a declaration to the parser when creating a field in C++ so that
the parser will complete the declarator with a valid decl and thus trigger
delayed diagnostics for it. It certainly looks like we were intentionally
returning null here, but I couldn't find any good reason for it, and there
wasn't a comment, so farewell to all that.
John McCall [Tue, 15 Feb 2011 06:40:56 +0000 (06:40 +0000)]
Perform zero-initialization of virtual base classes when emitting
a zero constant for a complete class. rdar://problem/8424975
To make this happen, track the field indexes for virtual bases
in the complete object. I'm curious whether we might be better
off making CGRecordLayoutBuilder *much* more reliant on
ASTRecordLayout; we're currently duplicating an awful lot of the ABI
layout logic.
Warn if method for a deprecated method is implemented.
Warn if class for a deprecated class is implemented.
Warn if category for a deprecated class is implemented.
All under control of -Wdeprecated-implementations.
// rdar://8973810.