Chandler Carruth [Tue, 31 Jan 2012 02:21:20 +0000 (02:21 +0000)]
Revert r149083 which is not the direction we're going in the Clang
driver based on discussions with Doug Gregor. There are several issues:
1) The patch was not reviewed prior to commit and there were review comments.
2) The design of the functionality (triple-prefixed tool invocation)
isn't the design we want for Clang going forward: it focuses on the
"user triple" rather than on the "toolchain triple", and forces that
bit of state into the API of every single toolchain instead of
handling it automatically in the common base classes.
3) The tests provided are not stable. They fail on a few Linux variants
(Gentoo among them) and on mingw32 and some other environments.
I *am* interested in the Clang driver being able to invoke
triple-prefixed tools, but we need to design that feature the right way.
This patch just extends the previous hack without fixing the underlying
problems with it. I'm working on a new design for this that I will mail
for review by tomorrow.
I am aware that this removes functionality that NetBSD relies on, but
this is ToT, not a release. This functionality hasn't been properly
designed, implemented, and tested yet. We can't "regress" until we get
something that really works, both with the immediate use cases and with
long term maintenance of the Clang driver.
For reference, the original commit log:
Keep track of the original target the user specified before
normalization. This used to be captured in DefaultTargetTriple and is
used for the (optional) $triple-$tool lookup for cross-compilation.
Do this properly by making it an attribute of the toolchain and use it
in combination with the computed triple as index for the toolchain
lookup.
Convert ProgramStateRef to a smart pointer for managing the reference counts of ProgramStates. This leads to a slight memory
improvement, and a simplification of the logic for managing ProgramState objects.
Richard Smith [Tue, 31 Jan 2012 01:47:46 +0000 (01:47 +0000)]
constexpr: remove integral conversion overflow checking introduced in r149286.
As Eli points out, this is implementation-defined, and the way we define it
makes this fine.
Ted Kremenek [Tue, 31 Jan 2012 00:57:20 +0000 (00:57 +0000)]
Convert ProgramStateRef to a smart pointer for managing the reference counts of ProgramStates. This leads to a slight memory
improvement, and a simplification of the logic for managing ProgramState objects.
Douglas Gregor [Mon, 30 Jan 2012 22:22:39 +0000 (22:22 +0000)]
Remove tgmath.h from the module map for now, because it currently causes a
cyclic module dependency due to its inclusion of math.h and
complex.h. I'll take another shot at it later.
objc-arc: Perform null check on receiver before sending methods which
consume one or more of their arguments. If not done, this will cause a leak
as method will not consume the argument when receiver is null.
In this patch, the null path releases consumed argument.
// rdar://10444474
Disable "non literal format string" for NSString that result from a macro expansion.
This is to prevent diagnostic when using NSLocalizedString or CFCopyLocalizedString
macros which are usually used in place of NS and CF strings literals.
John McCall [Mon, 30 Jan 2012 18:36:31 +0000 (18:36 +0000)]
Per discussion on cxx-abi-dev, don't drop leading zeroes from the
mangling of floating-point literals. I just went ahead and
reimplemented toString() here; if someone wants to generalize
the library routine to do this, or feels strongly that we should
be post-processing, please feel free.
Chandler Carruth [Mon, 30 Jan 2012 12:25:35 +0000 (12:25 +0000)]
Fix yet another issue introduced when renaming '-ccc-host-triple' to
'-target'. The original flag was part of a flag group that marked it as
driver-only. The new flag didn't ever get equivalent treatment. This
caused the '-target' flag to get passed down to any raw GCC invocation.
Marking it as a driver option fixes this and PR11875.
Update on format attribute handling.
- Remove the printf0 special handling as we treat it as printf anyway.
- Perform basic checks (non-literal, empty) for all formats and not only printf/scanf.
Douglas Gregor [Mon, 30 Jan 2012 06:38:25 +0000 (06:38 +0000)]
Introduce TargetInfo::hasFeature() to query various feature names in
each of the targets. Use this for module requirements, so that we can
pin the availability of certain modules to certain target features,
e.g., provide a module for xmmintrin.h only when SSE support is
available.
Use these feature names to provide a nearly-complete module map for
Clang's built-in headers. Only mm_alloc.h and unwind.h are missing,
and those two are fairly specialized at the moment. Finishes
<rdar://problem/10710060>.
Chris Lattner [Mon, 30 Jan 2012 06:20:36 +0000 (06:20 +0000)]
Simplify code by using the new getAggregateElement method that got added
recently. This also conveniently gets clang ready for a change about to
land in mainline.
Douglas Gregor [Sun, 29 Jan 2012 20:52:14 +0000 (20:52 +0000)]
Introduce a module map for (some of) the compiler-supplied
headers. The remaining headers require more sophisticated
requirements; they'll be handled separately. Part of
<rdar://problem/10710060>.
Douglas Gregor [Sun, 29 Jan 2012 17:08:11 +0000 (17:08 +0000)]
Rework HeaderSearch's interface for getting a module from a name and
for getting the name of the module file, unifying the code for
searching for a module with a given name (into lookupModule()) and
separating out the mapping to a module file (into
getModuleFileName()). No functionality change.
John McCall [Sun, 29 Jan 2012 02:35:02 +0000 (02:35 +0000)]
Get a little bit smarter about killing off the ReturnValue alloca
in the presence of straight-line cleanups. This is a simple but
important case, particularly for ARC.
John McCall [Sun, 29 Jan 2012 01:20:30 +0000 (01:20 +0000)]
Complain about attempts to use 'protected' visibility on targets
like Darwin that don't support it. We should also complain about
invalid -fvisibility=protected, but that information doesn't seem
to exist at the most appropriate time, so I've left a FIXME behind.
objc-arc: Perform null check on receiver before sending methods which
consume one or more of their arguments. If not done, this will cause a leak
as method will not consume the argument when receiver is null.
// rdar://10444474
Douglas Gregor [Sat, 28 Jan 2012 00:53:29 +0000 (00:53 +0000)]
Allow the external AST source to provide a layout without specifying
the alignment (because it's not encoded in DWARF). In this case, make
an educated guess at the alignment.
Douglas Gregor [Fri, 27 Jan 2012 19:52:33 +0000 (19:52 +0000)]
Introduce module attributes into the module map grammar, along with a
single attribute ("system") that allows us to mark a module as being a
"system" module. Each of the headers that makes up a system module is
considered to be a system header, so that we (for example) suppress
warnings there.
If a module is being inferred for a framework, and that framework
directory is within a system frameworks directory, infer it as a
system framework.
Douglas Gregor [Fri, 27 Jan 2012 01:47:08 +0000 (01:47 +0000)]
Reimplement (de-)serialization of Objective-C categories to eliminate
the direct serialization of the linked-list structure. Instead, use a
scheme similar to how we handle redeclarations, with redeclaration
lists on the side. This addresses several issues:
- In cases involving mixing and matching of many categories across
many modules, the linked-list structure would not be consistent
across different modules, and categories would get lost.
- If a module is loaded after the class definition and its other
categories have already been loaded, we wouldn't see any categories
in the newly-loaded module.
Richard Smith [Fri, 27 Jan 2012 01:14:48 +0000 (01:14 +0000)]
constexpr: Implement the [dcl.constexpr]p5 check for whether a constexpr
function definition can produce a constant expression. This also provides the
last few checks for [dcl.constexpr]p3 and [dcl.constexpr]p4.
Eli Friedman [Thu, 26 Jan 2012 23:34:06 +0000 (23:34 +0000)]
Turn off implicit truncation warning for compound assignment to bitfields; it might be reasonable in some cases, but it clearly doesn't make sense in some cases, like the included testcase.
Eli Friedman [Thu, 26 Jan 2012 23:11:39 +0000 (23:11 +0000)]
Make the bitfield implicit truncation warning slightly more aggressive, and make the printed warning a bit more accurate. The new behavior matches gcc's -Wconversion. <rdar://problem/10238797>.
Remove the ToolTriple logic in NetBSD, which was completely broken by
the recent refactoring. All interesting NetBSD release have a GNU as
version on i386 that supports --32, so don't bother with the conditional
setting of it.
Bob Wilson [Thu, 26 Jan 2012 22:14:27 +0000 (22:14 +0000)]
Make clz/ctz builtins defined for zero on ARM targets. rdar://10732455
ARM supports clz and ctz directly and both operations have well-defined
results for zero. There is no disadvantage in performance to using the
defined-at-zero versions of llvm.ctlz/cttz intrinsics. We're running into
ARM-specific code written with the assumption that __builtin_clz(0) == 32,
even though that value is technically undefined. The code is failing now
because of llvm optimizations that are taking advantage of the undef
behavior (specifically svn r147255). There's nothing wrong with that
optimization on x86 where any incorrect assumptions about __builtin_clz(0)
will quickly be exposed. For ARM, though, optimizations based on that undef
behavior are likely to cause subtle bugs. Other targets with defined-at-zero
clz/ctz support may want to override the default behavior as well.
Keep track of the original target the user specified before
normalization. This used to be captured in DefaultTargetTriple and is
used for the (optional) $triple-$tool lookup for cross-compilation.
Do this properly by making it an attribute of the toolchain and use it
in combination with the computed triple as index for the toolchain
lookup.
Ted Kremenek [Thu, 26 Jan 2012 21:29:00 +0000 (21:29 +0000)]
Change references to 'const ProgramState *' to typedef 'ProgramStateRef'.
At this point this is largely cosmetic, but it opens the door to replace
ProgramStateRef with a smart pointer that more eagerly acts in the role
of reclaiming unused ProgramState objects.
objc-arc: introduce -no-finalize-removal which in gc mode,
leaves "finalize' behind and in arc mode, does not
include it. This allows the migrated source to be compiled
in both gc and arc mode. // rdar://10532441
John McCall [Thu, 26 Jan 2012 20:04:03 +0000 (20:04 +0000)]
Don't suppress access-control or invalid-type diagnostics from a
declarator just because we were able to build an invalid decl
for it. The invalid-type diagnostics, in particular, are still useful
to know, and may indicate something about why the decl is invalid.
Also, recover from an illegal pointer/reference-to-unqualified-retainable
type using __strong instead of __autoreleasing; in general, a random
object is much more likely to be __strong, so this avoids unnecessary
cascading errors in the most common case.
Chandler Carruth [Thu, 26 Jan 2012 09:28:50 +0000 (09:28 +0000)]
Suppress any warnings from this test. They aren't interesting, and they
end up in the same output file as the layout stuff. There may even be
a race condition which is causing this output to confuse the FileCheck
in some cases. I actually don't know how on earth the parsing of the
layout file even works given that there are diagnostics in the middle of
it. ;]
Douglas Gregor [Thu, 26 Jan 2012 07:55:45 +0000 (07:55 +0000)]
Extend the ExternalASTSource interface to allow the AST source to
provide the layout of records, rather than letting Clang compute
the layout itself. LLDB provides the motivation for this feature:
because various layout-altering attributes (packed, aligned, etc.)
don't get reliably get placed into DWARF, the record layouts computed
by LLDB from the reconstructed records differ from the actual layouts,
and badness occurs. This interface lets the DWARF data drive layout,
so we don't need the attributes preserved to get the answer write.
The testing methodology for this change is fun. I've introduced a
variant of -fdump-record-layouts called -fdump-record-layouts-simple
that always has the simple C format and provides size/alignment/field
offsets. There is also a -cc1 option -foverride-record-layout=<file>
to take the output of -fdump-record-layouts-simple and parse it to
produce a set of overridden layouts, which is introduced into the AST
via a testing-only ExternalASTSource (called
LayoutOverrideSource). Each test contains a number of records to lay
out, which use various layout-changing attributes, and then dumps the
layouts. We then run the test again, using the preprocessor to
eliminate the layout-changing attributes entirely (which would give us
different layouts for the records), but supplying the
previously-computed record layouts. Finally, we diff the layouts
produced from the two runs to be sure that they are identical.
Note that this code makes the assumption that we don't *have* to
provide the offsets of bases or virtual bases to get the layout right,
because the alignment attributes don't affect it. I believe this
assumption holds, but if it does not, we can extend
LayoutOverrideSource to also provide base offset information.
Fixes the Clang side of <rdar://problem/10169539>.
Eric Christopher [Thu, 26 Jan 2012 07:01:04 +0000 (07:01 +0000)]
Revert previous patch unifying all of the C++ record prep in one area,
the gdb testsuite complains too much about the ordering of items printed,
even if the offsets in the debug info are correct.
Bob Wilson [Thu, 26 Jan 2012 06:22:30 +0000 (06:22 +0000)]
Fix a minor bug in r148582, which made -ccc-host-triple into an alias option.
I'm not adding a testcase because -ccc-host-triple is slated to be removed,
but clang crashes if you try to use -ccc-host-triple without this fix.