Douglas Gregor [Fri, 23 Oct 2009 18:54:35 +0000 (18:54 +0000)]
Eliminate QualifiedDeclRefExpr, which captured the notion of a
qualified reference to a declaration that is not a non-static data
member or non-static member function, e.g.,
namespace N { int i; }
int j = N::i;
Instead, extend DeclRefExpr to optionally store the qualifier. Most
clients won't see or care about the difference (since
QualifierDeclRefExpr inherited DeclRefExpr). However, this reduces the
number of top-level expression types that clients need to cope with,
brings the implementation of DeclRefExpr into line with MemberExpr,
and simplifies and unifies our handling of declaration references.
Extended DeclRefExpr to (optionally) store explicitly-specified
template arguments. This occurs when naming a declaration via a
template-id (which will be stored in a TemplateIdRefExpr) that,
following template argument deduction and (possibly) overload
resolution, is replaced with a DeclRefExpr that refers to a template
specialization but maintains the template arguments as written.
Ted Kremenek [Fri, 23 Oct 2009 03:57:22 +0000 (03:57 +0000)]
Fix integer overflow in PCHReader when reading the length of an
identifier. This caused a crash when reading PCH files that contained
long identifier names.
The issue is that 'StrLenPtr' was previously a 'const char *', meaning
the byte loaded from it would be interpretted as a signed integer. If
the topmost bit was set, conversion to 'unsigned' would extend that
bit, causing an overflow.
The solution is to make 'StrLenPtr' an 'unsigned char *', always
treating the value as an unsigned integer.
John McCall [Thu, 22 Oct 2009 22:37:11 +0000 (22:37 +0000)]
When building types from declarators, instead of building two types (one for
the DeclaratorInfo, one for semantic analysis), just build a single type whose
canonical type will reflect the semantic analysis (assuming the type is
well-formed, of course).
To make that work, make a few changes to the type system:
* allow the nominal pointee type of a reference type to be a (possibly sugared)
reference type. Also, preserve the original spelling of the reference type.
Both of these can be ignored on canonical reference types.
* Remove ObjCProtocolListType and preserve the associated source information on
the various ObjC TypeLocs. Preserve the spelling of protocol lists except in
the canonical form.
* Preserve some level of source type structure on parameter types, but
canonicalize on the canonical function type. This is still a WIP.
Drops code size, makes strides towards accurate source location representation,
slight (~1.7%) progression on Cocoa.h because of complexity drop.
Ted Kremenek [Thu, 22 Oct 2009 22:19:00 +0000 (22:19 +0000)]
Always emit error diagnostics when an error occurs within clang_createTranslationUnit() and clang_createTranslationUnitFromSource(). These kind of errors are ones that shouldn't be missed.
Douglas Gregor [Thu, 22 Oct 2009 18:02:20 +0000 (18:02 +0000)]
When replacing a template-id expression with a declaration reference expression after overloading completes, make sure to keep the qualifier. Still not ready with that test-case...
Douglas Gregor [Thu, 22 Oct 2009 17:20:55 +0000 (17:20 +0000)]
When building and instantiating a template-id reference expression, such as
N::f<int>
keep track of the full nested-name-specifier. This is mainly QoI and
relatively hard to test; will try to come up with a printing-based
test once we also retain the explicit template arguments past overload
resolution.
Douglas Gregor [Wed, 21 Oct 2009 22:01:30 +0000 (22:01 +0000)]
Don't generate pointer types for void or base classes when finding
conversion types for builtin overloaded operator candidates; I misread
this section in the standard the first time around.
Douglas Gregor [Wed, 21 Oct 2009 15:46:01 +0000 (15:46 +0000)]
Downgrade "function declared 'noreturn' should not return" from an
error (by default) to a warning, per C++0x [dcl.attr.noreturn]. Patch
from Sean Hunt!
Steve Naroff [Wed, 21 Oct 2009 13:56:23 +0000 (13:56 +0000)]
Extend clang_getCursor() to take a 'relativeDecl' argument (so speed up searching). Without a 'relativeDecl', the algorithm is n-squared. For example, running the following command on 'Large.m' takes hours without a 'relatvieDecl'.
snaroff% time ../../Debug/bin/c-index-test Large.ast all > Large.out
snaroff% cat Large.m
#import <Cocoa/Cocoa.h>
#import <QuickTime/QuickTime.h>
#import <OpenGL/OpenGL.h>
Mike Stump [Wed, 21 Oct 2009 03:49:08 +0000 (03:49 +0000)]
Prep work to always preallocate BlockDeclRefExprs so that we can
generate the debug information for the first parameter to the block
invoke functions. WIP.
Anders Carlsson [Tue, 20 Oct 2009 22:53:47 +0000 (22:53 +0000)]
Change ResolveAddressOfOverloadedFunction to support TemplateIdRefExpr. No testcase yet because FixOverloadedFunctionReference needs to be updated too. Doug, plz review.
Ted Kremenek [Tue, 20 Oct 2009 21:39:41 +0000 (21:39 +0000)]
Add destructor and cleanup code to LocationContext (fixing some leaks). Along the way, have
AnalysisManager periodically cleanup its AnalysisContextManager and LocationContextManager objects,
as they don't need to forever retain all the CFGs ever created when analyzing a file.
Changed text of warning in my last patch.
Related to radar:
<rdar://problem/7308503> clang should disallow the trailing semicolon in method definitions
Issue warning if method body starts with a semicolon.
Fixes
<rdar://problem/7308503> clang should disallow the trailing semicolon in method definitions
Steve Naroff [Tue, 20 Oct 2009 14:46:24 +0000 (14:46 +0000)]
- Extend clang_createIndex() to support PCH and diagnostic 'filtering'. This seems cleaner to me without sacrificing much flexibility.
- Remove clang_wantOnlyLocalDeclarations().
- Remove 'displayDiagnostics' arguments to clang_createTranslationUnitFromSourceFile() and clang_createTranslationUnit().
- Have clang_createTranslationUnitFromSourceFile() strip the '-o <outfile>' command line arguments if they exist. Document this semantic in the header. Also verify we have a valid ASTUnit before telling it to 'unlinkTemporaryFile()'.
Eli Friedman [Tue, 20 Oct 2009 08:27:19 +0000 (08:27 +0000)]
Remove default argument for ImpCastExprToType. Add appropriate argument
to all callers. Switch a few other users of CK_Unknown to proper cast
kinds.
Note that there are still some situations where we end up with
CK_Unknown; they're pretty easy to find with grep. There
are still a few missing conversion kinds, specifically
pointer/int/float->bool and the various combinations of real/complex
float/int->real/complex float/int.
Ted Kremenek [Tue, 20 Oct 2009 06:31:34 +0000 (06:31 +0000)]
Call 'clear()' in ~RopePieceBTreeLeaf(), decrementing the reference
counts of the bufffers referened by the RopePieces in
RopePieceBTreeLeaf. This (I believe) corrently fixes the leak I meant
to fix in r84601 (which ended up causing an overrelease).
Douglas Gregor [Tue, 20 Oct 2009 05:58:46 +0000 (05:58 +0000)]
Handle substitutions into the "first qualifier in scope" of a
qualified member access expression (e.g., t->U::member) when that
first qualifier refers to a template parameters.
Ted Kremenek [Tue, 20 Oct 2009 05:49:17 +0000 (05:49 +0000)]
BumpVectorContext: Use 'unsigned' integer type with PointerIntUnion instead of bool to keep it clear that we are reasoning about an unsigned integer with a single bit.
Chris Lattner [Tue, 20 Oct 2009 05:36:05 +0000 (05:36 +0000)]
Implement PR5242: don't desugar a type more than once in a diagnostic. This
implements a framework that allows us to use information about previously
substituted values to simplify subsequent ones. Maybe this would be useful
for C++'y stuff, who knows. We now get:
t.c:4:21: error: invalid operands to binary expression ('size_t' (aka 'unsigned long *') and 'size_t')
return (size_t) 0 + (size_t) 0;
~~~~~~~~~~ ^ ~~~~~~~~~~
on the testcase. Note that size_t is only aka'd once.
Chris Lattner [Tue, 20 Oct 2009 05:25:22 +0000 (05:25 +0000)]
teach FormatDiagnostic to aggregate previously formatted arguments and
pass them down into the ArgToStringFn implementation. This allows
redundancy across operands to a diagnostic to be eliminated.
Ted Kremenek [Tue, 20 Oct 2009 05:25:11 +0000 (05:25 +0000)]
Fix a reference count imbalance in RewriteRope::MakeRopeString().
This was causing a ton of memory to be leaked when using HTML
diagnostics with the static analyzer (on large files with many errors).
Mike Stump [Tue, 20 Oct 2009 02:12:22 +0000 (02:12 +0000)]
Refine the type of the first parameter to block invoke functions.
WIP. I have yet to find the magic incantation to get the structure
type to be defined. If someone has a pointer, love to hear it.