Sebastian Redl [Fri, 9 Jul 2010 21:00:24 +0000 (21:00 +0000)]
When given the -chained-pch option and a previous PCH file, have the PCHWriter emit a CHAINED_METADATA record instead of METADATA, and write a link to the previous file there.
Fix a crashing but trying to print a TemplateTemplateParmDecl
for code like this:
template<template<typename T> class U> class V {};
The problem is that the DeclPrinter assumed all TemplateDecls
have a getTemplatedClass(), but template template params don't
(so we got a NULL dereference). The solution is to detect if
we're a template template param, and construct the template
class name ('class U') specially in this case.
Rip out the floating point return type handling from the atomic builtin. It's
wrong, and we don't handle floating point value type arguments yet anyways.
Will add correct logic for both when I finish the patch.
Fix PR7600, and correctly convert the result of an atomic builtin to the
expected value type. This is necessary as the builtin is internally represented
as only operating on integral types.
Also, add a FIXME to add support for floating point value types.
Douglas Gregor [Fri, 9 Jul 2010 17:35:33 +0000 (17:35 +0000)]
Introduce -f{no-}spell-checking options to enable/disable
spell-checking. By default, spell-checking is enabled for Clang
(obviously) but disabled in CIndex for performance reasons.
Move traverseunqualifiedtypeloc over to the 'main' typeloc tree.
Note that this is a move -- we pretend that we were really looking
at the unqualified typeloc all along -- rather than a recursion, so
we don't follow the normal CRTP plan of going through
getDerived().TraverseTypeLoc. If we did, we'd be traversing twice
for the same type (once as a QualifiedTypeLoc version of the type,
once as an UnqualifiedTypeLoc version of the type), which in effect
means we'd call VisitTypeLoc twice with the 'same' type. This
solves that problem, at the cost of never seeing the qualified
version of the type (unless the client subclasses
TraverseQualifiedTypeLoc themselves). It's not a perfect solution.
A perfect solution probably requires making QualifiedTypeLoc a
wrapper around TypeLoc -- like QualType is a wrapper around Type*
-- rather than being its own class in the type hierarchy.
Sebastian Redl [Fri, 9 Jul 2010 00:00:58 +0000 (00:00 +0000)]
Add a frontend option -chained-pch and don't pass an active PCH reader to the PCH writer if it is not set, preventing creation of chained PCH files. Since the reader is so far unused, effectively no functionality change.
Douglas Gregor [Thu, 8 Jul 2010 23:20:03 +0000 (23:20 +0000)]
Introduce a new code-completion point prior to an identifier in the
selector of an Objective-C method declaration, e.g., given
- (int)first:(int)x second:(int)y;
this code completion point triggers at the location of "second". It
will provide completions that fill out the method declaration for any
known method, anywhere in the translation unit.
Douglas Gregor [Thu, 8 Jul 2010 20:55:51 +0000 (20:55 +0000)]
During code completion, give the "nil" and "NULL" macros the same
priority as other constants. And, if we're in a place where we prefer
a pointer type, consider "nil" and "NULL" to be close matches.
Douglas Gregor [Thu, 8 Jul 2010 18:37:38 +0000 (18:37 +0000)]
When performing substitution of template arguments within the body of
a template, be sure to include the template arguments from the
injected-class-name. Fixes PR7587.
For TagType and TemplateSpecializationType, isDependent calculation may be invalid because some decls that the
calculation is using may still be initializing.
Thus, store the isDependent flag to PCH and restore directly to Type.
Wrap the new ext-warn on extraneous comma on the last entry of an enumerator
list in a diagnostic group so it can be turned on and off. A terrifying amount
of code, including large chunks of open source code, still do this so it's
important to be able to suppress it when necessary.
Doug, is this a reasonable compromise? I'd lean toward making it a normal
extension, but I don't feel strongly as long as we can turn the warnings off.
Add support for differentiating between attributes ignored when handled and
unknown attributes that we discard. Add a diagnostic group for unknown
attribute warnings to allow turning these off when we don't care. Also
consolidates the tests for this case.
Chris Lattner [Thu, 8 Jul 2010 00:07:45 +0000 (00:07 +0000)]
fix the clang side of PR7437: EmitAggregateCopy
was not producing a memcpy with the right address
spaces because of two places in it doing casts of
the arguments to i8, one of which that didn't
preserve the address space.
Sebastian Redl [Wed, 7 Jul 2010 23:17:38 +0000 (23:17 +0000)]
Rip out the C++0x-specific handling of destructor names. The specification is still in flux and unclear, and our interim workaround was broken. Fixes PR7467.
Douglas Gregor [Wed, 7 Jul 2010 23:08:52 +0000 (23:08 +0000)]
A using declaration can redeclare a typedef to the same type. These
typedefs won't have the same canonical declaration (since they are
distinct), so we need to check for this case specifically. Fixes
<rdar://problem/8018262>.
Douglas Gregor [Wed, 7 Jul 2010 22:35:13 +0000 (22:35 +0000)]
Do not use CXXZeroValueInitExpr for class types. Instead, use
CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as
appropriate. Fixes PR7556, and provides a slide codegen improvement
when copy-initializing a POD class type from a value-initialized
temporary. Previously, we weren't eliding the copy.
Zhanyong Wan [Wed, 7 Jul 2010 21:36:58 +0000 (21:36 +0000)]
Changes how the TypeLoc traverser invokes the Type traverser: before,
VisitFooTypeLoc() calls VisitFooType(); now, TraverseFooTypeLoc()
calls WalkUpFromFooType(). This allows clients that override
WalkUpFromFooType() to continue to work. It also preserves the
property that Visit*() in the base visitor class is a no-op (s.t. a
subclass doesn't have to call Base::Visit*() when overriding
Visit*()).
Also fixes some typos in comments.
Also added a missing getDerived() inside
TraverseQualifiedTypeLoc(). The call is needed in case a subclass
overrides TraverseTypeLoc().
This has 2 (slight) advantages:
-Make explicit at getBody()'s callsite that we expect/handle only CompoundStmt and not CXXTryStmt.
-Better tracking of Decl::getBody()'s callsites.
Introduce Decl::hasBody() and FunctionDecl::hasBody() and use them instead of getBody() when we are just checking the existence of a body, to avoid de-serialization of the body from PCH.
Makes de-serialization of the function body even more "lazier".
Jordy Rose [Wed, 7 Jul 2010 08:15:01 +0000 (08:15 +0000)]
Add memcmp() and bcmp() to CStringChecker. These check for valid access to the buffer arguments and have a special-case for when the buffer arguments are known to be the same address, or when the size is zero.
Chris Lattner [Wed, 7 Jul 2010 06:14:23 +0000 (06:14 +0000)]
implement PR7569, warning about assignment to null, which
people seem to write when they want a deterministic trap.
Suggest instead that they use a volatile pointer or
__builtin_trap.
Avoid double-traversing for QualifiedTypeLoc -- we were calling
VisitTypeLoc twice for qualified types, once for the qualified form
and once for the unqualified (though they looked the same by the time
we got to visittypeloc). Now only visit once, which matches previous
behavior.
Silence an annoying GCC warning about use of an uninitialized variable. Even
making the other switch case unreachable, or sinking the 'continue' into it
doesn't silence this.
John McCall [Tue, 6 Jul 2010 23:57:41 +0000 (23:57 +0000)]
Provide a hook for the benefit of clients using clang IR gen as a subroutine:
emit metadata associating allocas and global values with a Decl*. This feature
is controlled by an option that (intentionally) cannot be enabled on the command
line.
To use this feature, simply set
CodeGenOptions.EmitDeclMetadata = true;
and then interpret the completely underspecified metadata. :)
Jordy Rose [Tue, 6 Jul 2010 23:11:01 +0000 (23:11 +0000)]
Add a new path-sensitive checker for functions in <string.h>, for both null-terminated strings and memory blocks. Currently only checks memcpy(), memmove(), and bcopy(), but this is intended to be expanded soon.
Tom Care [Tue, 6 Jul 2010 21:43:29 +0000 (21:43 +0000)]
Added a path-sensitive idempotent operation checker (-analyzer-idempotent-operation). Finds idempotent and/or tautological operations in a path sensitive context, flagging operations that have no effect or a predictable effect.
Example:
{
int a = 1;
int b = 5;
int c = b / a; // a is 1 on all paths
}
- New IdempotentOperationChecker class
- Moved recursive Stmt functions in r107675 to IdempotentOperationChecker
- Minor refactoring of SVal to allow checking for any integer
- Added command line option for check
- Added basic test cases
Douglas Gregor [Tue, 6 Jul 2010 18:42:40 +0000 (18:42 +0000)]
Improve the accuracy of getSourceRange() for DeclaratorDecl and
TagDecl subclasses when out-of-line template declaration information
is available, from Peter Collingbourne!
Douglas Gregor [Tue, 6 Jul 2010 18:29:01 +0000 (18:29 +0000)]
Remove my egregious hack that forced deserialization of visible
declarations when implicitly declaring the default constructor, copy
constructor, destructor, and copy-assignment operators of a
class. Argiris fixed the underlying problem in r107596.
Pacify versions of gcc that think these variables may be used
uninitialized (which doesn't seem to be the case), by giving
them arbitrary initial values.