Douglas Gregor [Tue, 27 Oct 2009 06:26:26 +0000 (06:26 +0000)]
Only set the point of instantiation for an implicit or explicit
instantiation once we have committed to performing the
instantiation. As part of this, make our makeshift
template-instantiation location information suck slightly less.
Mike Stump [Tue, 27 Oct 2009 01:59:05 +0000 (01:59 +0000)]
Refine noreturn handling. Fixes -Wmissing-noreturn so that it doesn't
complain that functions that have a return statement should be
declared noreturn. Fixed PR5286.
Mike Stump [Mon, 26 Oct 2009 23:39:48 +0000 (23:39 +0000)]
Prep for future __builtin_object_size refinements. The theory is that
someone will add an llvm intrinsic for us to use, so the optimizer can
figure out the hard cases. WIP.
For those that want to help, double check with Eric before starting.
He has a bit of code this will plug into.
Zhongxing Xu [Mon, 26 Oct 2009 05:18:31 +0000 (05:18 +0000)]
'error' is usually used as a noreturn function. This can suppress some false
warnings. Eventually we need a way to import externally defined functions
summaries.
Chris Lattner [Sun, 25 Oct 2009 22:21:57 +0000 (22:21 +0000)]
When parsing a top level struct declaration, make sure to
process decl attributes instead of dropping them on the floor.
This allows us to diagnose cases like the testcase. Also don't
diagnose deprecated stuff in ActOnTag: not all uses of tags
may be 'uses', and SemaType does this now.
Chris Lattner [Sun, 25 Oct 2009 22:09:09 +0000 (22:09 +0000)]
move calls to DiagnoseUseOfDecl (which warns about deprecated/unavailable
types) out of Sema::getTypeName into ConvertDeclSpecToType. getTypeName
is sometimes used as a predicate in the parser, so it could cause redundant
diags to be emitted. This is also needed by two upcoming enhancements.
Daniel Dunbar [Sun, 25 Oct 2009 20:34:02 +0000 (20:34 +0000)]
Tweak test, with -strict-whitespace $ won't match on Windows because the buffer
will have \r\n.
- Perhaps we should make FileCheck normalize line-endings, even in
strict-whitespace mode?
Chris Lattner [Sun, 25 Oct 2009 18:21:37 +0000 (18:21 +0000)]
simplify interface to ConvertDeclSpecToType, check for inferred
block return types only when a TST isn't specified, not every time
through GetTypeForDeclarator.
Chris Lattner [Sun, 25 Oct 2009 17:47:27 +0000 (17:47 +0000)]
change Sema::ActOnFriendTypeDecl to use GetTypeForDeclarator instead
of ConvertDeclSpecToType, which I'd like to keep private to SemaType.cpp.
We do this by cons'ing up a trivial Declarator for the type.
Chris Lattner [Sun, 25 Oct 2009 17:16:46 +0000 (17:16 +0000)]
simplify Sema::getTypeName a bit: if control gets out of the switch,
IIDecl cannot be null. There is no need to check for both C++ mode and
presence of CXXRecordDecl. ObjC interfaces can't have ScopeSpecs.
Chris Lattner [Sun, 25 Oct 2009 17:04:48 +0000 (17:04 +0000)]
In objc mode, every identifier in a cast expression was using doing a
type looking using getTypeName() and every property access was using
NextToken() to do lookahead to see if the identifier is followed by
a '.'. Rearrange this code to not need lookahead and only do the
type lookup if we have "identifier." in the token stream. Also
improve a diagnostic a bit.
Sebastian Redl [Sun, 25 Oct 2009 17:03:50 +0000 (17:03 +0000)]
Audit the code for places where it is assumed that every base specifier refers to a RecordType. Add assertions or conditions as appropriate. This fixes another crash in the Apache stdlib vector.
John McCall [Fri, 23 Oct 2009 23:03:21 +0000 (23:03 +0000)]
Store the builtin types as CanQualTypes. Expand a bit on the CanQual API,
but also remove some methods that cause ambiguities, and generally
make CanQual<blah> more analogous to QualType.
Douglas Gregor [Fri, 23 Oct 2009 22:18:25 +0000 (22:18 +0000)]
Migrate Sema::ActOnCallExpr to Sema::FixOverloadedFunctionReference,
so that we maintain better source information after template argument
deduction and overloading resolves down to a specific
declaration. Found and dealt with a few more cases that
FixOverloadedFunctionReference didn't cope with.
(Finally) added a test case that puts together this change with the
DeclRefExpr change to (optionally) include nested-name-specifiers and
explicit template argument lists.
John McCall [Fri, 23 Oct 2009 21:48:59 +0000 (21:48 +0000)]
Remove OriginalTypeParmDecl; the original type is the one specified
in the DeclaratorInfo, if one is present.
Preserve source information through template instantiation. This is made
more complicated by the possibility that ParmVarDecls don't have DIs, which
is possibly worth fixing in the future.
Also preserve source information for function parameters in ObjC method
declarations.
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.