[llvm-branch-commits] [cfe-branch] r339660 - Merging r338934:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 14 02:10:53 PDT 2018
Author: hans
Date: Tue Aug 14 02:10:53 2018
New Revision: 339660
URL: http://llvm.org/viewvc/llvm-project?rev=339660&view=rev
Log:
Merging r338934:
------------------------------------------------------------------------
r338934 | vsapsai | 2018-08-04 01:12:37 +0200 (Sat, 04 Aug 2018) | 29 lines
[Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.
Libc++ needs to know when aligned allocation is supported by clang, but is
otherwise unavailable at link time. Otherwise, libc++ will incorrectly end up
generating calls to `__builtin_operator_new`/`__builtin_operator_delete` with
alignment arguments.
This patch implements the following changes:
* The `__cpp_aligned_new` feature test macro to no longer be defined when
aligned allocation is otherwise enabled but unavailable.
* The Darwin driver no longer passes `-faligned-alloc-unavailable` when the
user manually specifies `-faligned-allocation` or `-fno-aligned-allocation`.
* Instead of a warning Clang now generates a hard error when an aligned
allocation or deallocation function is referenced but unavailable.
Patch by Eric Fiselier.
Reviewers: rsmith, vsapsai, erik.pilkington, ahatanak, dexonsmith
Reviewed By: rsmith
Subscribers: Quuxplusone, cfe-commits
Differential Revision: https://reviews.llvm.org/D45015
------------------------------------------------------------------------
Added:
cfe/branches/release_70/test/Lexer/aligned-allocation.cpp
- copied unchanged from r338934, cfe/trunk/test/Lexer/aligned-allocation.cpp
Modified:
cfe/branches/release_70/ (props changed)
cfe/branches/release_70/include/clang/Basic/DiagnosticGroups.td
cfe/branches/release_70/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/release_70/lib/Driver/ToolChains/Darwin.cpp
cfe/branches/release_70/lib/Frontend/InitPreprocessor.cpp
cfe/branches/release_70/lib/Sema/SemaExprCXX.cpp
cfe/branches/release_70/test/Driver/unavailable_aligned_allocation.cpp
Propchange: cfe/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 14 02:10:53 2018
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:338552-338553,338602,338627,338749,338942,339074,339128,339170,339210,339264,339281,339317,339428,339494
+/cfe/trunk:338552-338553,338602,338627,338749,338934,338942,339074,339128,339170,339210,339264,339281,339317,339428,339494
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_70/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/include/clang/Basic/DiagnosticGroups.td?rev=339660&r1=339659&r2=339660&view=diff
==============================================================================
--- cfe/branches/release_70/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/branches/release_70/include/clang/Basic/DiagnosticGroups.td Tue Aug 14 02:10:53 2018
@@ -364,7 +364,6 @@ def NonVirtualDtor : DiagGroup<"non-virt
def NullPointerArithmetic : DiagGroup<"null-pointer-arithmetic">;
def : DiagGroup<"effc++", [NonVirtualDtor]>;
def OveralignedType : DiagGroup<"over-aligned">;
-def AlignedAllocationUnavailable : DiagGroup<"aligned-allocation-unavailable">;
def OldStyleCast : DiagGroup<"old-style-cast">;
def : DiagGroup<"old-style-definition">;
def OutOfLineDeclaration : DiagGroup<"out-of-line-declaration">;
Modified: cfe/branches/release_70/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/include/clang/Basic/DiagnosticSemaKinds.td?rev=339660&r1=339659&r2=339660&view=diff
==============================================================================
--- cfe/branches/release_70/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/release_70/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 14 02:10:53 2018
@@ -6465,12 +6465,12 @@ def warn_overaligned_type : Warning<
"type %0 requires %1 bytes of alignment and the default allocator only "
"guarantees %2 bytes">,
InGroup<OveralignedType>, DefaultIgnore;
-def warn_aligned_allocation_unavailable :Warning<
+def err_aligned_allocation_unavailable : Error<
"aligned %select{allocation|deallocation}0 function of type '%1' is only "
- "available on %2 %3 or newer">, InGroup<AlignedAllocationUnavailable>, DefaultError;
+ "available on %2 %3 or newer">;
def note_silence_unligned_allocation_unavailable : Note<
"if you supply your own aligned allocation functions, use "
- "-Wno-aligned-allocation-unavailable to silence this diagnostic">;
+ "-faligned-allocation to silence this diagnostic">;
def err_conditional_void_nonvoid : Error<
"%select{left|right}1 operand to ? is void, but %select{right|left}1 operand "
Modified: cfe/branches/release_70/lib/Driver/ToolChains/Darwin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/Driver/ToolChains/Darwin.cpp?rev=339660&r1=339659&r2=339660&view=diff
==============================================================================
--- cfe/branches/release_70/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/branches/release_70/lib/Driver/ToolChains/Darwin.cpp Tue Aug 14 02:10:53 2018
@@ -2035,7 +2035,11 @@ bool Darwin::isAlignedAllocationUnavaila
void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const {
- if (isAlignedAllocationUnavailable())
+ // Pass "-faligned-alloc-unavailable" only when the user hasn't manually
+ // enabled or disabled aligned allocations.
+ if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation,
+ options::OPT_fno_aligned_allocation) &&
+ isAlignedAllocationUnavailable())
CC1Args.push_back("-faligned-alloc-unavailable");
}
Modified: cfe/branches/release_70/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/Frontend/InitPreprocessor.cpp?rev=339660&r1=339659&r2=339660&view=diff
==============================================================================
--- cfe/branches/release_70/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/branches/release_70/lib/Frontend/InitPreprocessor.cpp Tue Aug 14 02:10:53 2018
@@ -553,7 +553,7 @@ static void InitializeCPlusPlusFeatureTe
Builder.defineMacro("__cpp_guaranteed_copy_elision", "201606L");
Builder.defineMacro("__cpp_nontype_template_parameter_auto", "201606L");
}
- if (LangOpts.AlignedAllocation)
+ if (LangOpts.AlignedAllocation && !LangOpts.AlignedAllocationUnavailable)
Builder.defineMacro("__cpp_aligned_new", "201606L");
if (LangOpts.RelaxedTemplateTemplateArgs)
Builder.defineMacro("__cpp_template_template_args", "201611L");
Modified: cfe/branches/release_70/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/Sema/SemaExprCXX.cpp?rev=339660&r1=339659&r2=339660&view=diff
==============================================================================
--- cfe/branches/release_70/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/release_70/lib/Sema/SemaExprCXX.cpp Tue Aug 14 02:10:53 2018
@@ -1747,9 +1747,9 @@ static void diagnoseUnavailableAlignedAl
StringRef OSName = AvailabilityAttr::getPlatformNameSourceSpelling(
S.getASTContext().getTargetInfo().getPlatformName());
- S.Diag(Loc, diag::warn_aligned_allocation_unavailable)
- << IsDelete << FD.getType().getAsString() << OSName
- << alignedAllocMinVersion(T.getOS()).getAsString();
+ S.Diag(Loc, diag::err_aligned_allocation_unavailable)
+ << IsDelete << FD.getType().getAsString() << OSName
+ << alignedAllocMinVersion(T.getOS()).getAsString();
S.Diag(Loc, diag::note_silence_unligned_allocation_unavailable);
}
}
Modified: cfe/branches/release_70/test/Driver/unavailable_aligned_allocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/test/Driver/unavailable_aligned_allocation.cpp?rev=339660&r1=339659&r2=339660&view=diff
==============================================================================
--- cfe/branches/release_70/test/Driver/unavailable_aligned_allocation.cpp (original)
+++ cfe/branches/release_70/test/Driver/unavailable_aligned_allocation.cpp Tue Aug 14 02:10:53 2018
@@ -51,4 +51,13 @@
// RUN: -c -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix=AVAILABLE
//
+// Check that passing -faligned-allocation or -fno-aligned-allocation stops the
+// driver from passing -faligned-alloc-unavailable to cc1.
+//
+// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=AVAILABLE
+//
+// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=AVAILABLE
+
// AVAILABLE-NOT: "-faligned-alloc-unavailable"
More information about the llvm-branch-commits
mailing list