Akira Hatanaka [Tue, 14 Feb 2017 06:46:55 +0000 (06:46 +0000)]
[CodeGen][ObjC] Use the type of the captured field of the enclosing
block or lambda.
This is a follow-up to r281682, which fixed a bug in computeBlockInfo
where the captured VarDecl's type, rather than the captured field type
of the enclosing lambda or block, was used to compute the layout of a
block.
This commit makes similar changes to enterBlockScope. This is necessary
to correctly determine whether a block capture requires cleanup.
It looks like the only use of AddDeallocation is to indirectly call the
destructors of objects. In one case I found
(TypeAliasTemplateDecl::Common), the destructor is a nop, so registering
it to run later seems pointless.
All of the other *::Common types have non-trivial dtors, so deleting the
useless AddDeallocation felt somewhat fragile. Happy to kill it + turn
the is_trivial_dtor check into a static_assert if people think that'd be
better.
Richard Smith [Tue, 14 Feb 2017 01:49:59 +0000 (01:49 +0000)]
Canonicalize implicit deduction guide parameter types when forming a deduction
guide from a constructor.
The purpose of this change is to avoid triggering instantiation of the class
when substituting back into the deduction guide if it uses a typedef member.
We will still instantiate the class if the constructor (explicitly or
implicitly, directly or indirectly) uses the current instantiation in a way
that we can't canonicalize out, but that seems unavoidable.
David Majnemer [Tue, 14 Feb 2017 00:54:11 +0000 (00:54 +0000)]
[MS ABI] Correctly mangling vbase destructors
They are a little bit of a special case in the mangling. They are always
mangled without taking into account their virtual-ness of the
destructor. They are also mangled to return void, unlike the actual
destructor.
Richard Smith [Tue, 14 Feb 2017 00:25:28 +0000 (00:25 +0000)]
[c++1z] Synthesize implicit deduction guides from constructors on demand. Rank
such guides below explicit ones, and ensure that references to the class's
template parameters are not treated as forwarding references.
We make a few tweaks to the wording in the current standard:
1) The constructor parameter list is copied faithfully to the deduction guide,
without losing default arguments or a varargs ellipsis (which the standard
wording loses by omission).
2) If the class template declares no constructors, we add a T() -> T<...> guide
(which will only ever work if T has default arguments for all non-pack
template parameters).
3) If the class template declares nothing that looks like a copy or move
constructor, we add a T(T<...>) -> T<...> guide.
#2 and #3 follow from the "pretend we had a class type with these constructors"
philosophy for deduction guides.
Nick Lewycky [Mon, 13 Feb 2017 23:49:55 +0000 (23:49 +0000)]
When the new expr's array size is an ICE, emit it as a constant expression.
This bypasses integer sanitization checks which are redundant on the expression since it's been checked by Sema. Fixes a clang codegen assertion on "void test() { new int[0+1]{0}; }" when building with -fsanitize=signed-integer-overflow.
Benjamin Kramer [Mon, 13 Feb 2017 16:16:43 +0000 (16:16 +0000)]
[ASTUnit] Clear out diagnostic state after creating the preamble.
If the preamble had diagnostic state this would leave behind invalid
state in the DiagnosticsEngine and crash later. The test case runs into
an assertion in DiagnosticsEngine::setSourceManager.
Summary:
Sema::CheckCompletedCoroutineBody was growing unwieldy with building all of the substatements. Also, constructors for CoroutineBodyStmt had way too many parameters.
Instead, CoroutineBodyStmt now defines CtorArgs structure with all of the required construction parameters.
CheckCompleteCoroutineBody delegates construction of individual substatements to short functions one per each substatement.
Also, added a drive-by fix of initializing CoroutinePromise to nullptr in ScopeInfo.h.
And addressed the FIXME that wanted to tail allocate extra room at the end of the CoroutineBodyStmt to hold parameter move expressions. (The comment was longer that the code that implemented tail allocation).
Renato Golin [Sun, 12 Feb 2017 19:08:02 +0000 (19:08 +0000)]
Revert "Attributes on K&R C functions should not cause incompatible..."
...function type with a redeclaration having the same attribute. Fixing this
introduced a secondary problem where we were assuming that K&R functions
could not be attributed types when reporting old-style function definitions
that are not preceded by a prototype."
Also Revert "Hopefully fixes a compile error introduced by r294861."
This reverts commit r294862, r294861, as they bork the ARM builds and
haven't fix it back.
Also, please, short commit titles, long commit decsriptions...
Davide Italiano [Sat, 11 Feb 2017 23:44:37 +0000 (23:44 +0000)]
[Driver] Use stem() and not filename().
On Windows the filename might have an extension, namely
`.exe`, so the search will fail. Sorry, I don't have a
good way to test this as it seems to fail only in some
weird configurations. r284430 has the same modification
for Fuchsia.
CodeGen: use # as the comment leader for ARC marker
Use # as the comment leader for AArch64 auto-release elision marker.
This is to keep it in sync with the value used in swift. When building
libdispatch for Linux AArch64, the auto-release elision marker was
emitted. However, ELF uses # as the comment leader while MachO accepts
both ; and #. Use the common marker for it instead.
CodeGen: annotate ObjC ARC functions with ABI constraints
Certain ARC runtime functions have an ABI contract of being forwarding.
Annotate the functions with the appropriate `returned` attribute on the
arguments. This hoists some of the runtime ABI contract information
into the frontend rather than the backend transformations.
The test adjustments are to mark the returned function parameter as
such. The minor change to the IR output is due to the fact that the
returned reference of the object causes it to extend the lifetime of the
object by returning an autoreleased return value. The result is that
the explicit objc_autorelease call is no longer formed, as autorelease
elision is now possible on the return.
Dylan McKay [Sat, 11 Feb 2017 21:06:07 +0000 (21:06 +0000)]
[AVR] Fix __AVR_xxx macro definitions; authored by Peter Wu
Summary:
The -mmcu option for GCC sets macros like __AVR_ATmega328P__ (with the trailing
underscores), be sure to include these underscores for Clangs -mcpu option.
See "AVR Built-in Macros" in https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
Aaron Ballman [Sat, 11 Feb 2017 17:49:53 +0000 (17:49 +0000)]
Attributes on K&R C functions should not cause incompatible function type with a redeclaration having the same attribute. Fixing this introduced a secondary problem where we were assuming that K&R functions could not be attributed types when reporting old-style function definitions that are not preceded by a prototype.
Don't let EvaluationModes dictate whether an invalid base is OK
What we want to actually control this behavior is something more local
than an EvalutationMode. Please see the linked revision for more
discussion on why/etc.
Richard Smith [Fri, 10 Feb 2017 21:40:29 +0000 (21:40 +0000)]
[c++1z] Require an initializer for deduced class template specialization types.
It's actually meaningful and useful to allow such variables to have no
initializer, but we are strictly following the standard here until the C++
committee reaches consensus on allowing this.
Tim Shen [Fri, 10 Feb 2017 21:03:24 +0000 (21:03 +0000)]
[XRay] Implement powerpc64le xray.
Summary:
powerpc64 big-endian is not supported, but I believe that most logic can
be shared, except for xray_powerpc64.cc.
Also add a function InvalidateInstructionCache to xray_util.h, which is
copied from llvm/Support/Memory.cpp. I'm not sure if I need to add a unittest,
and I don't know how.
Eric Christopher [Fri, 10 Feb 2017 04:35:21 +0000 (04:35 +0000)]
Temporarily revert "For X86-64 linux and PPC64 linux align int128 to 16 bytes."
until we can get better TargetMachine::isCompatibleDataLayout to compare - otherwise
we can't code generate existing bitcode without a string equality data layout.
Eric Christopher [Fri, 10 Feb 2017 03:32:34 +0000 (03:32 +0000)]
For X86-64 linux and PPC64 linux align int128 to 16 bytes.
For other platforms we should find out what they need and likely
make the same change, however, a smaller additional change is easier
for platforms we know have it specified in the ABI.
Richard Smith [Fri, 10 Feb 2017 01:32:04 +0000 (01:32 +0000)]
Sink IsExplicitSpecified flag from CXXConstructorDecl and CXXConversionDecl
into FunctionDecl. Makes CXXConversionDecl 8 bytes smaller. No functionality
change intended.
Amjad Aboud [Thu, 9 Feb 2017 22:07:24 +0000 (22:07 +0000)]
[DebugInfo] Added support to Clang FE for generating debug info for preprocessor macros.
Added "-fdebug-macro" flag (and "-fno-debug-macro" flag) to enable (and to disable) emitting macro debug info.
Added CC1 "-debug-info-macro" flag that enables emitting macro debug info.
Richard Smith [Thu, 9 Feb 2017 21:04:43 +0000 (21:04 +0000)]
Rename IsExplicitSpecialization -> IsMemberSpecialization when we're talking
about member specializations to avoid ambiguous and confusing terminology.
Marcos Pividori [Thu, 9 Feb 2017 18:22:35 +0000 (18:22 +0000)]
[windows] [asan] Add wholearchive flag when including asan_cxx lib.
We need -wholearchive for asan_cxx, the same than for asan.
Clang Driver will add asan_cxx at the beginning of the arg list that we pass to
the linker. To ensure that all the static libraries are linked to asan_cxx, we
force the linker to include the object files in asan_cxx.
This fixes some linker errors when compiling with address sanitizer for MT and
passing the static library libFuzzer.
Craig Topper [Thu, 9 Feb 2017 06:10:14 +0000 (06:10 +0000)]
[X86] Clzero flag addition and inclusion under znver1
1. Adds the command line flag for clzero.
2. Includes the clzero flag under znver1.
3. Defines the macro for clzero.
4. Adds a new file which has the intrinsic definition for clzero instruction.
Patch by Ganesh Gopalasubramanian with some additional tests from me.
Richard Smith [Wed, 8 Feb 2017 19:58:48 +0000 (19:58 +0000)]
Don't crash on 'decltype(auto)::'. Rather than treating it as a meaningless
nested-name-specifier (as the standard appears to require), treat it as the
type specifier 'decltype(auto)' followed by a nested-name-specifier starting
with '::'.
Reid Kleckner [Wed, 8 Feb 2017 16:09:32 +0000 (16:09 +0000)]
[MS] Fix C++ destructor thunk line info for a declaration
Sometimes the MS ABI needs to emit thunks for declarations that don't
have bodies. Destructor thunks make calls to inlinable functions, so
they need line info or LLVM will complain.
[clang-format] Break before a sequence of line comments aligned with the next line.
Summary:
Make the comment alignment respect sections of line comments originally alinged
with the next token. Until now the decision how to break a continuous sequence
of line comments into sections was taken without reference to the next token.
source:
```
class A {
public: // comment about public
// comment about a
int a;
}
```
format before:
```
class A {
public: // comment about public
// comment about a
int a;
}
```
format after:
```
class A {
public: // comment about public
// comment about a
int a;
}
```
Craig Topper [Wed, 8 Feb 2017 07:13:22 +0000 (07:13 +0000)]
[X86] Remove 'umip' feature flag.
This feature flag indicates that the processor has support for removing certain instructions from user mode software. But the feature flag by itself doesn't indicate if the support is enabled in the OS. The affected instructions aren't even instructions the compiler would emit. So I don't think think this feature flag should be in the compiler.
Sema: add warning for c++ member variable shadowing
Add a warning for shadowed variables across records. Referencing a
shadow'ed variable may not give the desired variable. Add an optional
warning for the shadowing.
Richard Smith [Wed, 8 Feb 2017 01:16:55 +0000 (01:16 +0000)]
Fix constructor declarator detection for the case when the name is followed by
an attribute-specifier-seq. (Also fixes the same problem for deduction-guides.)