Fix the MSVC build. 2 problems:
- buildPieces was return a C++ object from inside an extern "C". (MSVC didn't like that)
- clang_getCursorReferenceNameRange was missing a CINDEX_LINKAGE causing a link error.
Refactor of how modules are handled in ASTReader to remove explicit uses of a chain of AST files, instead redirect calls through a module manager. This should help move toward a DAG and the potential of loading multiple, unrelated PCH files. It's still early in development.
Chad Rosier [Mon, 25 Jul 2011 19:39:39 +0000 (19:39 +0000)]
Allow target to specify about using minimum alignment vs preferred. Takes care of
FIXME: Override "preferred align" for double and long long for ARM apcs-gnu ABI.
Also part of rdar://9802874
Axel Naumann [Mon, 25 Jul 2011 19:18:12 +0000 (19:18 +0000)]
Pick up expected diagnostics not only in the main file but also in the file where the first diagnostic occurred.
Useful if the main file is not relevant (like with cling).
By Vassil Vassilev.
Mechanically rename SourceManager::getInstantiationLoc and
FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part
of the API and documentation update from 'instantiation' as the term for
macros to 'expansion'.
objc: clang should warn if redeclaration of methods
declared in protocol in the class qualified by the
protocol have type conflicts. To reduce amount of
noise, this is done when class is implemented.
// rdar://9352731
Douglas Gregor [Sat, 23 Jul 2011 18:59:35 +0000 (18:59 +0000)]
Tests for explicit conversion operators, along with a fix to avoid
considering explicit conversion operators when determining surrogate
functions. Fixes PR10453. Note that there are a few test cases where
Clang is still wrong because it does not implement DR899; see PR10456.
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.