John McCall [Wed, 2 Dec 2009 08:25:40 +0000 (08:25 +0000)]
Rip out the last remaining implicit use of OverloadedFunctionDecl in Sema:
LookupResult::getAsSingleDecl() is no more. Shift Sema::LookupSingleName to
return null on overloaded results.
Douglas Gregor [Wed, 2 Dec 2009 08:08:39 +0000 (08:08 +0000)]
Introduce a new clang-cc option
-remap-file=from;to
which takes the file "from" and transparently replaces its contents
with the contents of the file "to" from the source manager's
perspective. This is the moral equivalent of
cp from saved
cp to from
<call clang>
cp saved from
rm saved
John McCall [Wed, 2 Dec 2009 08:04:21 +0000 (08:04 +0000)]
Push overloaded function templates through the parser using a totally different
leaked data structure than before. This kills off the last remaining
explicit uses of OverloadedFunctionDecl in Sema.
Mike Stump [Wed, 2 Dec 2009 07:41:41 +0000 (07:41 +0000)]
More exception handling improvements... WIP.
Highlights include:
Add a helper to generate __cxa_free_exception and _ZSt9terminatev.
Add a region to handle EH object deallocation for ctor failures for throw.
Add a terminate handler for __cxa_end_catch.
A framework for adding cleanup actions for the exceptional edges only.
Douglas Gregor [Wed, 2 Dec 2009 06:49:09 +0000 (06:49 +0000)]
Extend the source manager with the ability to override the contents of
files with the contents of an arbitrary memory buffer. Use this new
functionality to drastically clean up the way in which we handle file
truncation for code-completion: all of the truncation/completion logic
is now encapsulated in the preprocessor where it belongs
(<rdar://problem/7434737>).
John McCall [Wed, 2 Dec 2009 03:53:29 +0000 (03:53 +0000)]
Stop trying to analyze class-hierarchies for dependently-scoped id-expressions;
there's nothing interesting we can say now that we're correctly not requiring
the qualifier to name a known base class in dependent contexts.
Require scope specifiers on member access expressions to name complete types
if they're not dependent; delay lookup when they are dependent.
Use more appropriate diagnostics when qualified implicit member access
expressions find declarations from unrelated classes.
Daniel Dunbar [Wed, 2 Dec 2009 03:23:45 +0000 (03:23 +0000)]
Add ASTUnit::LoadFromCommandLine, which creates an ASTUnit out of a list of
(clang/driver) command line arguments (including the source file).
- The arguments are expected to include the source file.
- The idea is that even though this is a somewhat odd API, its the form which
many tools can most easily use (for example, by interposing with the compiler).
Also, switch index-test's -ast-from-source to use this entry point, and provide
a -arg command line argument which can be used to test that the command line
arguments are handled correctly.
Daniel Dunbar [Tue, 1 Dec 2009 23:07:57 +0000 (23:07 +0000)]
In SourceManager::isBeforeInTranslationUnit, if we are trying to compare two source locations with no common ancestor in the include stack, determine order by assuming memory buffers preceed files, and then that FileIDs are created in order.
The later assumption is patently false, but this was already broken -- this situation is conceptually impossible, my feeling is we should fix SourceManager and friends to make it impossible in practice as well. However, we need to fix PR5662 and perhaps some other things involving memory buffers first. In the short term I'm pretty sure this is reliable.
Chris, Argiris, is this going to break anything that wasn't already broken?
John McCall [Tue, 1 Dec 2009 22:10:20 +0000 (22:10 +0000)]
Rework how we support C++ implicit member accesses. If we can resolve an
implicit member access to a specific declaration, go ahead and create
it as a DeclRefExpr or a MemberExpr (with implicit CXXThisExpr base) as
appropriate. Otherwise, create an UnresolvedMemberExpr or
DependentScopeMemberExpr with a null base expression.
By representing implicit accesses directly in the AST, we get the ability
to correctly delay the decision about whether it's actually an instance
member access or not until resolution is complete. This permits us
to correctly avoid diagnosing the 'problem' of 'MyType::foo()'
where the relationship to the type isn't really known until instantiation.
(objc2 nonfragile-abi specific). If the translation unit includes an implementation
of a subclass (direct or indirect) of a weak_import root class, emit a weak reference
for the root class's metaclass (should complete radar 6815425).
Douglas Gregor [Tue, 1 Dec 2009 17:35:23 +0000 (17:35 +0000)]
Funtion templates and function template specializations do not
override virtual functions. Also, eliminate a (now redundant) call to
AddOverriddenMethods.
Douglas Gregor [Tue, 1 Dec 2009 17:24:26 +0000 (17:24 +0000)]
Move the checking of overridden virtual functions into the code path
common to both parsing and template instantiation, so that we'll find
overridden virtuals for member functions of class templates when they
are instantiated.
Additionally, factor out the checking for pure virtual functions, so
that it will be executed both at parsing time and at template
instantiation time.
These changes fix PR5656 (for real), although one more tweak
w.r.t. member function templates will be coming along shortly.
Douglas Gregor [Tue, 1 Dec 2009 16:58:18 +0000 (16:58 +0000)]
Don't automatically assume that an id-expression refers to a
ValueDecl, because that isn't always the case in ill-formed
code. Diagnose a common mistake (forgetting to provide a template
argument list for a class template, PR5655) and dyn_cast so that we
handle the general problem of referring to a non-value declaration
gracefully.
Mike Stump [Tue, 1 Dec 2009 03:41:18 +0000 (03:41 +0000)]
Much work on try/catch statement. WIP.
Highlights include:
Fix __cxa_begin_catch so it now returns a value.
Added getUnwindResumeOrRethrowFn helper to build up calls to
_Unwind_Resume_or_Rethrow.
Broke out object copying code into CopyObject from EmitCXXThrowExpr.
Built up another version of CopyObject that can copy from memory for
use in the catch parameter code.
RTTI generation for type matching for catch.
Code to check for the type match for catch.
Code to generate the catch parameter, WIP, need make sure references
and pointers and copy ctors work.
Daniel Dunbar [Tue, 1 Dec 2009 02:35:37 +0000 (02:35 +0000)]
c-index-test: Split "function scanning" behavior into its own "filter" -- its
quite slow and doesn't really stress the APIs people should really use.
- I'm not even sure if this mode is still useful given the other scanning mode;
Steve?
Ted Kremenek [Tue, 1 Dec 2009 00:07:10 +0000 (00:07 +0000)]
Allocate MultipleDC objects using the allocator associated with
ASTContext instead of malloc. Besides reducing malloc traffic, this
also removes a source of memory leaks when using a BumpPtrAllocator
for the allocator of ASTContext. There are still leaks when using
MallocAllocator because Decl::Destroy() isn't fully finished.
John McCall [Mon, 30 Nov 2009 23:50:49 +0000 (23:50 +0000)]
Fix and test for a problem caught by the clang-on-clang buildbot: qualified
IDs in dependent contexts are not dependent if the context names a namespace.
John McCall [Mon, 30 Nov 2009 22:42:35 +0000 (22:42 +0000)]
Eliminate the use of OverloadedFunctionDecl in member expressions.
Create a new UnresolvedMemberExpr for these lookups. Assorted hackery
around qualified member expressions; this will all go away when we
implement the correct (i.e. extremely delayed) implicit-member semantics.
Daniel Dunbar [Mon, 30 Nov 2009 08:42:10 +0000 (08:42 +0000)]
clang-cc: Add code (currently disabled) for parsing arguments using clang -cc1 functionality instead of LLVM's CommandLine.
- It works and passes test suite, but I want to polish and test a wee bit more before making the switch.
Daniel Dunbar [Mon, 30 Nov 2009 08:42:00 +0000 (08:42 +0000)]
Add CodeGenOptions::{SoftFloat,FloatABI}, and update the all the (far too many) places to use this instead of using the backend -soft-float and -float-abi= options.
Daniel Dunbar [Mon, 30 Nov 2009 07:18:13 +0000 (07:18 +0000)]
Put CompilerInvocation testing code in clang-cc instead of clang for now, I can't bear to link all of clang into 'clang' yet. :)
- Still triggered by a magic leading -cc1 argument, as before.
Chris Lattner [Mon, 30 Nov 2009 04:18:44 +0000 (04:18 +0000)]
Fix PR5633 by making the preprocessor handle the case where we can
stat a file but where mmaping it fails. In this case, we emit an
error like:
t.c:1:10: fatal error: error opening file '../../foo.h'
Daniel Dunbar [Sun, 29 Nov 2009 20:58:50 +0000 (20:58 +0000)]
Change CompilerInvocation::CreateFromArgs to report errors using a proper diagnostic engine.
- Clients that care about having the diagnostics output honor the user-controllable diagnostic options can buffer the diagnostics and issue them later.
Daniel Dunbar [Sun, 29 Nov 2009 20:58:32 +0000 (20:58 +0000)]
Change CompilerInvocation::CreateFromArgs to take Argv0 and the address of main (or something in the main executable) so it can find the builtin compiler files.