Sean Callanan [Fri, 22 Jul 2011 23:46:03 +0000 (23:46 +0000)]
This patch (thanks to Doug Gregor) fixes a
problem where Clang was setting the
hasExternalVisibleDecls() bit for all
DeclContexts it imported. This caused Clang
to make unnecessary calls to
findExternalVisibleDecls() when an external
AST source was installed.
In fact, Clang sometimes interpreted a failure
by one of these spurious calls to find a
Decl as meaning the Decl didn't exist, even
though findExternalLexicalDecls() did locate
that decl. This produced amusing errors of
the form:
-
error: no member named 'b' in 'A'; did you
mean 'b'?
-
Now, if hasExternalVisibleDecls() or
hasExternalLexicalDecls() should be set, the
external AST source must do so itself.
David Majnemer [Fri, 22 Jul 2011 21:09:04 +0000 (21:09 +0000)]
kill a FIXME in IsIntegralPromotion
IsIntegralPromotion should consider the signedness of FromType when
calculating promotions. This, as of now, cannot be exercised on any
platform so there is no corresponding test.
Douglas Gregor [Fri, 22 Jul 2011 16:00:58 +0000 (16:00 +0000)]
Rename ASTReader::PerFileData to serialization::Module, pulling it out
of ASTReader so it can become its own full-fledged class
(eventually). No functionality change.
Add a missing forward declaration and namespace qualifier to this
header. This showed up in client code that has a different include
ordering after Chris's shuffle of raw_ostream. All of the Clang code
ends up with a header included before this one that provides the needed
type and using declaration.
John McCall [Fri, 22 Jul 2011 08:53:00 +0000 (08:53 +0000)]
Document the existing objc_precise_lifetime attribute.
Introduce and document a new objc_returns_inner_pointer
attribute, and consume it by performing a retain+autorelease
on message receivers when they're not immediately loaded from
an object with precise lifetime.
Douglas Gregor [Fri, 22 Jul 2011 06:10:01 +0000 (06:10 +0000)]
Introduce a global bit-offset continuous range map into the ASTReader,
so that we have one, simple way to map from global bit offsets to
local bit offsets. Eliminates a number of loops over the chain, and
generalizes for more interesting bit remappings.
Also, as an amusing oddity, we were computing global bit offsets
*backwards* for preprocessed entities (e.g., the directly included PCH
file in the chain would start at offset zero, rather than the original
PCH that occurs first in translation unit). Even more amusingly, it
made precompiled preambles work, because we were forgetting to adjust
the local bit offset to a global bit offset when storing preprocessed
entity offsets in the ASTUnit. Two wrongs made a right, and now
they're both right.
Douglas Gregor [Fri, 22 Jul 2011 06:03:18 +0000 (06:03 +0000)]
Fix an embarrassing bug in relocatable PCH support, where we were
passing a temporary const char* down as the "isysroot" parameter and
then accessing it later. Fixes <rdar://problem/9035180>.
Move duplicate uninitialized warning suppression into the
AnalysisBasedWarnings Sema layer and out of the Analysis library itself.
This returns the uninitialized values analysis to a more pure form,
allowing its original logic to correctly detect some categories of
definitely uninitialized values. Fixes PR10358 (again).
Thanks to Ted for reviewing and updating this patch after his rewrite of
several portions of this analysis.
John McCall [Fri, 22 Jul 2011 05:23:13 +0000 (05:23 +0000)]
In ARC, non-atomic getters do not need to retain and autorelease
their loaded values, although it still worth doing this for __weak
properties to get the autoreleased-return-value optimization.
John McCall [Fri, 22 Jul 2011 02:45:48 +0000 (02:45 +0000)]
In Objective-C, pull arbitrary attributes from overridden
methods, including indirectly overridden methods like those
declared in protocols and categories. There are mismatches
that we would like to diagnose but aren't yet, but this
is fine for now.
I looked at approaches that avoided doing this lookup
unless we needed it, but the infer-related-result-type
checks were doing it anyway, so I left it with the same
fast-path check for no previous declartions of that
selector.
Jordy Rose [Fri, 22 Jul 2011 02:08:32 +0000 (02:08 +0000)]
Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.
This was previously not-const only because it has to lazily construct a chain
of ivars the first time it is called (and after the chain is invalidated).
In practice, all the clients were just const_casting their const Decls;
all those now-unnecessary const_casts have been removed.
objective-c: Any use of @synthesize or @dynamic lexically after a method (or C function) implementation
will be rejected with a compilation error in ARC mode, and a compiler warning otherwise.
This may cause breakage in non-arc (and arc) tests which don't expect warning/error. Feel free
to fix the tests, or reverse the patch, if I am unavailable. // rdar://9818354 - WIP
Douglas Gregor [Fri, 22 Jul 2011 00:38:23 +0000 (00:38 +0000)]
In the AST reader, factor out the mapping of local type IDs to global
type IDs into a single place, and make sure that all of the callers
use the appropriate functions to do the mapping. Since the mapping is
still the identity function, this is essentially a no-op.
Rafael Espindola [Thu, 21 Jul 2011 23:40:37 +0000 (23:40 +0000)]
Avoid warning on "clang -c -Dfoo test.i". Lines like these are created
when using ccache and libtool.m4 assumes that the compiler cannot print
warnings about options it knows about.
Douglas Gregor [Thu, 21 Jul 2011 22:35:25 +0000 (22:35 +0000)]
In the ASTReader, factor out the loading of (local) declaration IDs,
such that every declaration ID loaded from an AST file will go through
a central local -> global mapping function. At present, this change
does nothing, since the local -> global mapping function is the
identity function.
This is the mechanical part of the refactoring; a follow-up patch will
address a few remaining areas where it's not obvious whether we're
dealing with local or global IDs.
Cleaning up more of the ID situation in the AST reader. This patch relaxes and generalizes how CXX base specifiers are identified and loaded by using a ContinuousRangeMap. This also adds a global bit offset (or base) to the PerFileData.
Douglas Gregor [Thu, 21 Jul 2011 18:46:38 +0000 (18:46 +0000)]
In the AST reader, keep track of the total number of source locations
entries incrementally, rather than iterating over the chain when
loading a single AST file.
For some reason I don't fully comprehend, the MSVC debug build will fail with a huge 50+ lines template error message if PreprocessingRecord::iterator has no operator<()
Richard Trieu [Thu, 21 Jul 2011 03:20:52 +0000 (03:20 +0000)]
Fix a test in warn-sign-conversion.cpp. Removed a part of a directory path so that the directory seperator, which may change on different platforms, is no longer part of the string checked for.
Richard Trieu [Thu, 21 Jul 2011 02:46:28 +0000 (02:46 +0000)]
Remove warning for conditional operands of differend signedness from -Wsign-compare. Cases that previously warn on this will have a different warning emitted from -Wsign-conversion.
Douglas Gregor [Thu, 21 Jul 2011 00:47:40 +0000 (00:47 +0000)]
Rework the detailed preprocessing record to separate preprocessing
entities generated directly by the preprocessor from those loaded from
the external source (e.g., the ASTReader). By separating these two
sets of entities into different vectors, we allow both to grow
independently, and eliminate the need for preallocating all of the
loaded preprocessing entities. This is similar to the way the recent
SourceManager refactoring treats FileIDs and the source location
address space.
As part of this, switch over to building a continuous range map to
track preprocessing entities.
Continuing to improve and generalize how IDs are handled in ASTReader. This patch cleans up and generalizes TypeID loading and uses a similar table-lookup to Doug's previous Decl patch.
Chad Rosier [Wed, 20 Jul 2011 20:26:32 +0000 (20:26 +0000)]
When the compiler crashes, the compiler driver now produces diagnostic information
including the fully preprocessed source file(s) and command line arguments. The
developer is asked to attach this diagnostic information to a bug report.
Chad Rosier [Wed, 20 Jul 2011 19:14:30 +0000 (19:14 +0000)]
If -ccc-host-triple i386-pc-win32-macho or -ccc-host-triple
x86_64-pc-win32-macho is used in conjunction with -no-integrated-as go ahead and
use the Darwin system assembler.
rdar://9785470
arc-objc++: Issue an arc specific diagnostic when overload resolution
fails because of lifetime differences of parameter and argument type.
// rdar://9790531
Chris Lattner [Wed, 20 Jul 2011 07:13:40 +0000 (07:13 +0000)]
arrayref should now move in here, and redundant #includes of <cassert> can go
away (since it comes in through Casting.h). This will have to wait for another
day when I'm unmotivated though, or someone else to pick it up :)
Chris Lattner [Wed, 20 Jul 2011 06:58:45 +0000 (06:58 +0000)]
now that we have a centralized place to do so, add some using declarations for
some common llvm types: stringref and smallvector. This cleans up the codebase
quite a bit.
Chris Lattner [Wed, 20 Jul 2011 06:37:11 +0000 (06:37 +0000)]
introduce a centralized place to introduce and inject llvm types into the
clang namespace. There are a number of LLVM types that are used pervasively
and it doesn't make sense to keep qualifying them. Start with casting
operators.
Chris Lattner [Wed, 20 Jul 2011 06:29:00 +0000 (06:29 +0000)]
fix rdar://9780211 - Clang crashes with an assertion failure building WKView.mm from WebKit
This is something of a hack, the problem is as follows:
1. we instantiate both copied of RetainPtr with the two different argument types
(an id and protocol-qualified id).
2. We refer to the ctor of one of the instantiations when introducing global "x",
this causes us to emit an llvm::Function for a prototype whose "this" has type
"RetainPtr<id<bork> >*".
3. We refer to the ctor of the other instantiation when introducing global "y",
however, because it *mangles to the same name as the other ctor* we just use
a bitcasted version of the llvm::Function we previously emitted.
4. We emit deferred declarations, causing us to emit the body of the ctor, however
the body we emit is for RetainPtr<id>, which expects its 'this' to have an IR
type of "RetainPtr<id>*".
Because of the mangling collision, we don't have this case, and explode.
This is really some sort of weird AST invariant violation or something, but hey
a bitcast makes the pain go away.
Chris Lattner [Wed, 20 Jul 2011 04:59:57 +0000 (04:59 +0000)]
as eli points out, we're not doing memory stuff here. While ConvertType
and ConvertTypeForMem are the same for pointers, it is best to just
use ConvertType. Thanks Eli!
Chris Lattner [Wed, 20 Jul 2011 04:31:01 +0000 (04:31 +0000)]
fix PR10395 - array decay can produce an interesting type when
decaying an array of incomplete type (which has type [0 x i8]*) to a
normal pointer (which has incompletetype*).
Douglas Gregor [Wed, 20 Jul 2011 01:29:15 +0000 (01:29 +0000)]
Use a ContinuousRangeMap to map from the global macro definition ID in
the AST reader down to the AST file + local ID, rather than walking
the PCH chain. More cleanup/generalization, although there is more
work to do for preprocessed entities. In particular, the
"preallocation" scheme for preprocessed entities is not going to work
well with late loading of PCH files, and it's likely we'll have to do
something akin to the SourceManager's negative/positive loading.
Douglas Gregor [Wed, 20 Jul 2011 01:10:58 +0000 (01:10 +0000)]
Use a ContinuousRangeMap to map from the global selector ID in the AST
reader down to the AST file + local ID, rather than walking the PCH
chain. No functionality change; this is generalization and cleanup.
Douglas Gregor [Wed, 20 Jul 2011 00:59:32 +0000 (00:59 +0000)]
Use a ContinuousRangeMap to map from the global identifier ID in the
AST reader down to the AST file + local ID, rather than walking the
PCH chain. No functionality change; this is generalization and cleanup.
Douglas Gregor [Wed, 20 Jul 2011 00:27:43 +0000 (00:27 +0000)]
Use a ContinuousRangeMap to map from the global declaration ID in the
AST reader down to the AST file + local ID within that file, rather
than lamely walking the PCH chain. There's no actual functionality
change now, but this is cleaner and more general.
Sean Callanan [Tue, 19 Jul 2011 22:38:25 +0000 (22:38 +0000)]
This fix (thanks to Doug Gregor) corrects a bug
in ImportDefinition when replacing a previously
forward-declared CXXRecordDecl with its full
definition. The forward-declared type's
DefinitionData had not been intialized for the
forward-declared type, so adding fields to the
Decl caused CXXRecordDecl::addedMember() to
crash when accessing the DefinitionData.
Chad Rosier [Tue, 19 Jul 2011 19:36:03 +0000 (19:36 +0000)]
Clang asserts "Invalid environment!" when using -ccc-host-triple
arch-pc-win32-macho (e.g., x86_64-pc-win32-macho), which appears to be a false
positive.
rdar://9786307
[arcmt] Add some additional driver flags to optionally emit or save the pre-migration ARC errors.
-arcmt-migrate-emit-errors : Emits the pre-migration ARC errors but it doesn't affect anything else
-arcmt-migrate-report-output : Writes out the pre-migration ARC errors to the provided plist file