Vendor import of clang release_50 branch r312293:

https://llvm.org/svn/llvm-project/cfe/branches/release_50@312293
This commit is contained in:
Dimitry Andric 2017-09-01 16:29:06 +00:00
parent a75fa8aaf2
commit ef2abedb8a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/clang/dist/; revision=323090
svn path=/vendor/clang/clang-release_50-r312293/; revision=323091; tag=vendor/clang/clang-release_50-r312293
24 changed files with 331 additions and 131 deletions

View File

@ -656,6 +656,10 @@ Pass <arg> to the assembler
Pass <arg> to the clang compiler
.. option:: -fclang-abi-compat=<version>
Attempt to match the ABI of Clang <version>
.. option:: -fcomment-block-commands=<arg>,<arg2>...
Treat each comma separated argument in <arg> as a documentation comment block command

View File

@ -1,6 +1,6 @@
=======================================
Clang 5.0.0 (In-Progress) Release Notes
=======================================
=========================
Clang 5.0.0 Release Notes
=========================
.. contents::
:local:
@ -8,12 +8,6 @@ Clang 5.0.0 (In-Progress) Release Notes
Written by the `LLVM Team <http://llvm.org/>`_
.. warning::
These are in-progress notes for the upcoming Clang 5 release.
Release notes for previous releases can be found on
`the Download Page <http://releases.llvm.org/download.html>`_.
Introduction
============
@ -26,15 +20,9 @@ documentation <http://llvm.org/docs/ReleaseNotes.html>`_. All LLVM
releases may be downloaded from the `LLVM releases web
site <http://llvm.org/releases/>`_.
For more information about Clang or LLVM, including information about
the latest release, please check out the main please see the `Clang Web
Site <http://clang.llvm.org>`_ or the `LLVM Web
Site <http://llvm.org>`_.
Note that if you are reading this file from a Subversion checkout or the
main Clang web page, this document applies to the *next* release, not
the current one. To see the release notes for a specific release, please
see the `releases page <http://llvm.org/releases/>`_.
For more information about Clang or LLVM, including information about the
latest release, please see the `Clang Web Site <http://clang.llvm.org>`_ or the
`LLVM Web Site <http://llvm.org>`_.
What's New in Clang 5.0.0?
==========================
@ -47,8 +35,6 @@ sections with improvements to Clang's support for those languages.
Major New Features
------------------
- ...
C++ coroutines
^^^^^^^^^^^^^^
`C++ coroutines TS
@ -61,25 +47,25 @@ coroutine support. Here is `an example
Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- -Wcast-qual was implemented for C++. C-style casts are now properly
- ``-Wcast-qual`` was implemented for C++. C-style casts are now properly
diagnosed.
- -Wunused-lambda-capture warns when a variable explicitly captured
- ``-Wunused-lambda-capture`` warns when a variable explicitly captured
by a lambda is not used in the body of the lambda.
- -Wstrict-prototypes is a new warning that warns about non-prototype
- ``-Wstrict-prototypes`` is a new warning that warns about non-prototype
function and block declarations and types in C and Objective-C.
- -Wunguarded-availability is a new warning that warns about uses of new
- ``-Wunguarded-availability`` is a new warning that warns about uses of new
APIs that were introduced in a system whose version is newer than the
deployment target version. A new Objective-C expression ``@available`` has
been introduced to perform system version checking at runtime. This warning
is off by default to prevent unexpected warnings in existing projects.
However, its less strict sibling -Wunguarded-availability-new is on by
However, its less strict sibling ``-Wunguarded-availability-new`` is on by
default. It warns about unguarded uses of APIs only when they were introduced
in or after macOS 10.13, iOS 11, tvOS 11 or watchOS 4.
- The -Wdocumentation warning now allows the use of ``\param`` and
- The ``-Wdocumentation`` warning now allows the use of ``\param`` and
``\returns`` documentation directives in the documentation comments for
declarations with a function or a block pointer type.
@ -89,7 +75,8 @@ Improvements to Clang's diagnostics
New Compiler Flags
------------------
- --autocomplete was implemented to obtain a list of flags and its arguments. This is used for shell autocompletion.
- ``--autocomplete`` was implemented to obtain a list of flags and its arguments.
This is used for shell autocompletion.
Deprecated Compiler Flags
-------------------------
@ -97,9 +84,9 @@ Deprecated Compiler Flags
The following options are deprecated and ignored. They will be removed in
future versions of Clang.
- -fslp-vectorize-aggressive used to enable the BB vectorizing pass. They have been superseeded
- ``-fslp-vectorize-aggressive`` used to enable the BB vectorizing pass. They have been superseeded
by the normal SLP vectorizer.
- -fno-slp-vectorize-aggressive used to be the default behavior of clang.
- ``-fno-slp-vectorize-aggressive`` used to be the default behavior of clang.
New Pragmas in Clang
-----------------------
@ -117,15 +104,9 @@ Attribute Changes in Clang
- The ``overloadable`` attribute now allows at most one function with a given
name to lack the ``overloadable`` attribute. This unmarked function will not
have its name mangled.
- The ```ms_abi`` attribute and the ``__builtin_ms_va_list`` types and builtins
- The ``ms_abi`` attribute and the ``__builtin_ms_va_list`` types and builtins
are now supported on AArch64.
Windows Support
---------------
Clang's support for building native Windows programs ...
C Language Changes in Clang
---------------------------
@ -154,37 +135,42 @@ a vector expression--occurs when:
vector's elements.
- For compile time constant values, the above rule is weakened to consider the
value of the scalar constant rather than the constant's type.
- Floating point constants with precise integral representations are not
implicitly converted to integer values, this is for compatability with GCC.
value of the scalar constant rather than the constant's type. However,
for compatibility with GCC, floating point constants with precise integral
representations are not implicitly converted to integer values.
Currently the basic integer and floating point types with the following
operators are supported: ``+``, ``/``, ``-``, ``*``, ``%``, ``>``, ``<``,
``>=``, ``<=``, ``==``, ``!=``, ``&``, ``|``, ``^`` and the corresponding
assignment operators where applicable.
...
C11 Feature Support
^^^^^^^^^^^^^^^^^^^
...
C++ Language Changes in Clang
-----------------------------
- We expect this to be the last Clang release that defaults to ``-std=gnu++98``
when using the GCC-compatible ``clang++`` driver. From Clang 6 onwards we
expect to use ``-std=gnu++14`` or a later standard by default, to match the
behavior of recent GCC releases. Users are encouraged to change their build
files to explicitly specify their desired C++ standard.
- Support for the C++17 standard has been completed. This mode can be enabled
using ``-std=c++17`` (the old flag ``-std=c++1z`` is still supported for
compatibility).
- When targeting a platform that uses the Itanium C++ ABI, Clang implements a
`recent change to the ABI`__ that passes objects of class type indirectly if they
have a non-trivial move constructor. Previous versions of Clang only
considered the copy constructor, resulting in an ABI change in rare cases,
but GCC has already implemented this change for several releases.
This affects all targets other than Windows and PS4. You can opt out of this
ABI change with ``-fclang-abi-compat=4.0``.
- As mentioned in `C Language Changes in Clang`_, Clang's support for
implicit scalar to vector conversions also applies to C++. Additionally
the following operators are also supported: ``&&`` and ``||``.
...
C++1z Feature Support
^^^^^^^^^^^^^^^^^^^^^
...
.. __: https://github.com/itanium-cxx-abi/cxx-abi/commit/7099637aba11fed6bdad7ee65bf4fd3f97fbf076
Objective-C Language Changes in Clang
-------------------------------------
@ -240,25 +226,6 @@ The following new functionalities have been added:
- Added OpenCL types to ``CIndex``.
OpenMP Support in Clang
----------------------------------
...
Internal API Changes
--------------------
These are major API changes that have happened since the 4.0.0 release of
Clang. If upgrading an external codebase that uses Clang as a library,
this section should help get you past the largest hurdles of upgrading.
- ...
AST Matchers
------------
...
clang-format
------------
@ -301,7 +268,7 @@ clang-format
| namespace A { | namespace A { |
| int i; | int i; |
| int j; | int j; |
| } | } |
| } | } // namespace A |
+---------------------+---------------------+
* Comment reflow support added. Overly long comment lines will now be reflown with the rest of
@ -351,7 +318,7 @@ Undefined Behavior Sanitizer (UBSan)
- The Undefined Behavior Sanitizer has a new check for pointer overflow. This
check is on by default. The flag to control this functionality is
-fsanitize=pointer-overflow.
``-fsanitize=pointer-overflow``.
Pointer overflow is an indicator of undefined behavior: when a pointer
indexing expression wraps around the address space, or produces other
@ -359,10 +326,10 @@ Undefined Behavior Sanitizer (UBSan)
- UBSan has several new checks which detect violations of nullability
annotations. These checks are off by default. The flag to control this group
of checks is -fsanitize=nullability. The checks can be individially enabled
by -fsanitize=nullability-arg (which checks calls),
-fsanitize=nullability-assign (which checks assignments), and
-fsanitize=nullability-return (which checks return statements).
of checks is ``-fsanitize=nullability``. The checks can be individially enabled
by ``-fsanitize=nullability-arg`` (which checks calls),
``-fsanitize=nullability-assign`` (which checks assignments), and
``-fsanitize=nullability-return`` (which checks return statements).
- UBSan can now detect invalid loads from bitfields and from ObjC BOOLs.
@ -371,20 +338,11 @@ Undefined Behavior Sanitizer (UBSan)
also avoid emitting unnecessary overflow checks in arithmetic expressions
with promoted integer operands.
Core Analysis Improvements
==========================
- ...
New Issues Found
================
- ...
Python Binding Changes
----------------------
Python bindings now support both Python 2 and Python 3.
Python bindings now support both Python 2 and Python 3.
The following methods have been added:
@ -398,10 +356,6 @@ The following methods have been added:
- ``get_exception_specification_kind`` has been added to ``Type``.
- ...
Significant Known Problems
==========================
Additional Information
======================

View File

@ -2028,7 +2028,10 @@ class CXXMethodDecl : public FunctionDecl {
/// \brief Returns the type of the \c this pointer.
///
/// Should only be called for instance (i.e., non-static) methods.
/// Should only be called for instance (i.e., non-static) methods. Note
/// that for the call operator of a lambda closure type, this returns the
/// desugared 'this' type (a pointer to the closure type), not the captured
/// 'this' type.
QualType getThisType(ASTContext &C) const;
unsigned getTypeQualifiers() const {

View File

@ -694,6 +694,9 @@ def fbuiltin : Flag<["-"], "fbuiltin">, Group<f_Group>;
def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group<f_Group>,
Flags<[DriverOption]>, HelpText<"Load the clang builtins module map file.">;
def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group<f_Group>;
def fclang_abi_compat_EQ : Joined<["-"], "fclang-abi-compat=">, Group<f_clang_Group>,
Flags<[CC1Option]>, MetaVarName<"<version>">, Values<"<major>.<minor>,latest">,
HelpText<"Attempt to match the ABI of Clang <version>">;
def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>;
def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">, Group<f_Group>,
Flags<[CoreOption, CC1Option]>, HelpText<"Use colors in diagnostics">;

View File

@ -120,6 +120,10 @@ CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss.
ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is
///< enabled.
/// A version of Clang that we should attempt to be ABI-compatible with.
ENUM_CODEGENOPT(ClangABICompat, ClangABI, 4, ClangABI::Latest)
VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.

View File

@ -69,6 +69,23 @@ class CodeGenOptions : public CodeGenOptionsBase {
LocalExecTLSModel
};
/// Clang versions with different platform ABI conformance.
enum class ClangABI {
/// Attempt to be ABI-compatible with code generated by Clang 3.8.x
/// (SVN r257626). This causes <1 x long long> to be passed in an
/// integer register instead of an SSE register on x64_64.
Ver3_8,
/// Attempt to be ABI-compatible with code generated by Clang 4.0.x
/// (SVN r291814). This causes move operations to be ignored when
/// determining whether a class type can be passed or returned directly.
Ver4,
/// Conform to the underlying platform's C and C++ ABIs as closely
/// as we can.
Latest
};
enum StructReturnConventionKind {
SRCK_Default, // No special option was passed.
SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).

View File

@ -24,6 +24,7 @@ namespace llvm {
namespace clang {
class ASTContext;
class CodeGenOptions;
class TargetInfo;
namespace CodeGen {
@ -68,6 +69,7 @@ namespace swiftcall {
llvm::LLVMContext &getVMContext() const;
const llvm::DataLayout &getDataLayout() const;
const TargetInfo &getTarget() const;
const CodeGenOptions &getCodeGenOpts() const;
/// Return the calling convention to use for system runtime
/// functions.

View File

@ -3260,7 +3260,7 @@ void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) {
llvm::DISubprogram *SP = nullptr;
if (FI != SPCache.end())
SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second);
if (!SP)
if (!SP || !SP->isDefinition())
SP = getFunctionStub(GD);
FnBeginRegionCount.push_back(LexicalBlockStack.size());
LexicalBlockStack.emplace_back(SP);

View File

@ -22,6 +22,7 @@
#include "CodeGenPGO.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/StmtCXX.h"
@ -983,11 +984,22 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
}
// Check the 'this' pointer once per function, if it's available.
if (CXXThisValue) {
if (CXXABIThisValue) {
SanitizerSet SkippedChecks;
SkippedChecks.set(SanitizerKind::ObjectSize, true);
QualType ThisTy = MD->getThisType(getContext());
EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
// If this is the call operator of a lambda with no capture-default, it
// may have a static invoker function, which may call this operator with
// a null 'this' pointer.
if (isLambdaCallOperator(MD) &&
cast<CXXRecordDecl>(MD->getParent())->getLambdaCaptureDefault() ==
LCD_None)
SkippedChecks.set(SanitizerKind::Null, true);
EmitTypeCheck(isa<CXXConstructorDecl>(MD) ? TCK_ConstructorCall
: TCK_MemberCall,
Loc, CXXABIThisValue, ThisTy,
getContext().getTypeAlignInChars(ThisTy->getPointeeType()),
SkippedChecks);
}

View File

@ -44,6 +44,10 @@ CodeGenTypes::~CodeGenTypes() {
delete &*I++;
}
const CodeGenOptions &CodeGenTypes::getCodeGenOpts() const {
return CGM.getCodeGenOpts();
}
void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,
llvm::StructType *Ty,
StringRef suffix) {

View File

@ -178,6 +178,7 @@ class CodeGenTypes {
const TargetInfo &getTarget() const { return Target; }
CGCXXABI &getCXXABI() const { return TheCXXABI; }
llvm::LLVMContext &getLLVMContext() { return TheModule.getContext(); }
const CodeGenOptions &getCodeGenOpts() const;
/// ConvertType - Convert type T into a llvm::Type.
llvm::Type *ConvertType(QualType T);

View File

@ -62,9 +62,20 @@ class ItaniumCXXABI : public CodeGen::CGCXXABI {
bool classifyReturnType(CGFunctionInfo &FI) const override;
bool passClassIndirect(const CXXRecordDecl *RD) const {
// Clang <= 4 used the pre-C++11 rule, which ignores move operations.
// The PS4 platform ABI follows the behavior of Clang 3.2.
if (CGM.getCodeGenOpts().getClangABICompat() <=
CodeGenOptions::ClangABI::Ver4 ||
CGM.getTriple().getOS() == llvm::Triple::PS4)
return RD->hasNonTrivialDestructor() ||
RD->hasNonTrivialCopyConstructor();
return !canCopyArgument(RD);
}
RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override {
// If C++ prohibits us from making a copy, pass by address.
if (!canCopyArgument(RD))
if (passClassIndirect(RD))
return RAA_Indirect;
return RAA_Default;
}
@ -996,7 +1007,7 @@ bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const {
return false;
// If C++ prohibits us from making a copy, return by address.
if (!canCopyArgument(RD)) {
if (passClassIndirect(RD)) {
auto Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
return true;

View File

@ -183,7 +183,11 @@ const TargetInfo &ABIInfo::getTarget() const {
return CGT.getTarget();
}
bool ABIInfo:: isAndroid() const { return getTarget().getTriple().isAndroid(); }
const CodeGenOptions &ABIInfo::getCodeGenOpts() const {
return CGT.getCodeGenOpts();
}
bool ABIInfo::isAndroid() const { return getTarget().getTriple().isAndroid(); }
bool ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
return false;
@ -2095,9 +2099,14 @@ class X86_64ABIInfo : public SwiftABIInfo {
return !getTarget().getTriple().isOSDarwin();
}
/// GCC classifies <1 x long long> as SSE but compatibility with older clang
// compilers require us to classify it as INTEGER.
/// GCC classifies <1 x long long> as SSE but some platform ABIs choose to
/// classify it as INTEGER (for compatibility with older clang compilers).
bool classifyIntegerMMXAsSSE() const {
// Clang <= 3.8 did not do this.
if (getCodeGenOpts().getClangABICompat() <=
CodeGenOptions::ClangABI::Ver3_8)
return false;
const llvm::Triple &Triple = getTarget().getTriple();
if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::PS4)
return false;

View File

@ -2855,6 +2855,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
ABICompatArg->render(Args, CmdArgs);
// Add runtime flag for PS4 when PGO or Coverage are enabled.
if (getToolChain().getTriple().isPS4CPU())
PS4cpu::addProfileRTArgs(getToolChain(), Args, CmdArgs);

View File

@ -246,12 +246,12 @@ AlignTokenSequence(unsigned Start, unsigned End, unsigned Column, F &&Matches,
for (unsigned i = Start; i != End; ++i) {
if (ScopeStack.size() != 0 &&
Changes[i].nestingAndIndentLevel() <
Changes[ScopeStack.back()].nestingAndIndentLevel())
Changes[i].indentAndNestingLevel() <
Changes[ScopeStack.back()].indentAndNestingLevel())
ScopeStack.pop_back();
if (i != Start && Changes[i].nestingAndIndentLevel() >
Changes[i - 1].nestingAndIndentLevel())
if (i != Start && Changes[i].indentAndNestingLevel() >
Changes[i - 1].indentAndNestingLevel())
ScopeStack.push_back(i);
bool InsideNestedScope = ScopeStack.size() != 0;
@ -327,8 +327,8 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
// Measure the scope level (i.e. depth of (), [], {}) of the first token, and
// abort when we hit any token in a higher scope than the starting one.
auto NestingAndIndentLevel = StartAt < Changes.size()
? Changes[StartAt].nestingAndIndentLevel()
auto IndentAndNestingLevel = StartAt < Changes.size()
? Changes[StartAt].indentAndNestingLevel()
: std::pair<unsigned, unsigned>(0, 0);
// Keep track of the number of commas before the matching tokens, we will only
@ -359,7 +359,7 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
unsigned i = StartAt;
for (unsigned e = Changes.size(); i != e; ++i) {
if (Changes[i].nestingAndIndentLevel() < NestingAndIndentLevel)
if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel)
break;
if (Changes[i].NewlinesBefore != 0) {
@ -375,7 +375,7 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
if (Changes[i].Tok->is(tok::comma)) {
++CommasBeforeMatch;
} else if (Changes[i].nestingAndIndentLevel() > NestingAndIndentLevel) {
} else if (Changes[i].indentAndNestingLevel() > IndentAndNestingLevel) {
// Call AlignTokens recursively, skipping over this scope block.
unsigned StoppedAt = AlignTokens(Style, Matches, Changes, i);
i = StoppedAt - 1;

View File

@ -154,12 +154,11 @@ class WhitespaceManager {
const Change *StartOfBlockComment;
int IndentationOffset;
// A combination of nesting level and indent level, which are used in
// A combination of indent level and nesting level, which are used in
// tandem to compute lexical scope, for the purposes of deciding
// when to stop consecutive alignment runs.
std::pair<unsigned, unsigned>
nestingAndIndentLevel() const {
return std::make_pair(Tok->NestingLevel, Tok->IndentLevel);
std::pair<unsigned, unsigned> indentAndNestingLevel() const {
return std::make_pair(Tok->IndentLevel, Tok->NestingLevel);
}
};

View File

@ -573,6 +573,33 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
if (!Opts.ProfileInstrumentUsePath.empty())
setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath);
if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
Opts.setClangABICompat(CodeGenOptions::ClangABI::Latest);
StringRef Ver = A->getValue();
std::pair<StringRef, StringRef> VerParts = Ver.split('.');
unsigned Major, Minor = 0;
// Check the version number is valid: either 3.x (0 <= x <= 9) or
// y or y.0 (4 <= y <= current version).
if (!VerParts.first.startswith("0") &&
!VerParts.first.getAsInteger(10, Major) &&
3 <= Major && Major <= CLANG_VERSION_MAJOR &&
(Major == 3 ? VerParts.second.size() == 1 &&
!VerParts.second.getAsInteger(10, Minor)
: VerParts.first.size() == Ver.size() ||
VerParts.second == "0")) {
// Got a valid version number.
if (Major == 3 && Minor <= 8)
Opts.setClangABICompat(CodeGenOptions::ClangABI::Ver3_8);
else if (Major <= 4)
Opts.setClangABICompat(CodeGenOptions::ClangABI::Ver4);
} else if (Ver != "latest") {
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();
}
}
Opts.CoverageMapping =
Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);

View File

@ -449,6 +449,28 @@ void upcast_to_vbase() {
}
}
struct ThisAlign {
void this_align_lambda();
void this_align_lambda_2();
};
void ThisAlign::this_align_lambda() {
// CHECK-LABEL: define {{.*}}@"_ZZN9ThisAlign17this_align_lambdaEvENK3$_0clEv"
// CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
// CHECK: %[[this_addr:.*]] = alloca
// CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
// CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
// CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}}, %{{.*}}* %[[this_inner]], i32 0, i32 0
// CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}** %[[this_outer_addr]],
//
// CHECK: %[[this_inner_isnonnull:.*]] = icmp ne %{{.*}}* %[[this_inner]], null
// CHECK: %[[this_inner_asint:.*]] = ptrtoint %{{.*}}* %[[this_inner]] to i
// CHECK: %[[this_inner_misalignment:.*]] = and i{{32|64}} %[[this_inner_asint]], {{3|7}},
// CHECK: %[[this_inner_isaligned:.*]] = icmp eq i{{32|64}} %[[this_inner_misalignment]], 0
// CHECK: %[[this_inner_valid:.*]] = and i1 %[[this_inner_isnonnull]], %[[this_inner_isaligned]],
// CHECK: br i1 %[[this_inner_valid:.*]]
[&] { return this; } ();
}
namespace CopyValueRepresentation {
// CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S3aSERKS0_
// CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value
@ -532,4 +554,18 @@ namespace CopyValueRepresentation {
}
}
void ThisAlign::this_align_lambda_2() {
// CHECK-LABEL: define {{.*}}@"_ZZN9ThisAlign19this_align_lambda_2EvENK3$_1clEv"
// CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
// CHECK: %[[this_addr:.*]] = alloca
// CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
// CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
//
// Do not perform a null check on the 'this' pointer if the function might be
// called from a static invoker.
// CHECK-NOT: icmp ne %{{.*}}* %[[this_inner]], null
auto *p = +[] {};
p();
}
// CHECK: attributes [[NR_NUW]] = { noreturn nounwind }

View File

@ -0,0 +1,19 @@
// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fclang-abi-compat=3.0 %s -emit-llvm -o - | FileCheck --check-prefix=PRE39 --check-prefix=PRE5 %s
// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fclang-abi-compat=3.8 %s -emit-llvm -o - | FileCheck --check-prefix=PRE39 --check-prefix=PRE5 %s
// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fclang-abi-compat=3.9 %s -emit-llvm -o - | FileCheck --check-prefix=V39 --check-prefix=PRE5 %s
// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fclang-abi-compat=4.0 %s -emit-llvm -o - | FileCheck --check-prefix=V39 --check-prefix=PRE5 %s
// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fclang-abi-compat=5 %s -emit-llvm -o - | FileCheck --check-prefix=V39 --check-prefix=V5 %s
// RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fclang-abi-compat=latest %s -emit-llvm -o - | FileCheck --check-prefix=V39 --check-prefix=V5 %s
typedef __attribute__((vector_size(8))) long long v1xi64;
void clang39(v1xi64) {}
// PRE39: @_Z7clang39Dv1_x(i64
// V39: @_Z7clang39Dv1_x(double
struct A {
A(const A&) = default;
A(A&&);
};
void clang5(A) {}
// PRE5: @_Z6clang51A()
// V5: @_Z6clang51A(%{{.*}}*

View File

@ -0,0 +1,45 @@
// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213 -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
// PR33997.
struct already_AddRefed {
~already_AddRefed();
};
struct RefPtr {
operator int *();
};
struct ServoCssRulesStrong {
already_AddRefed Consume();
};
struct GroupRule {
GroupRule(already_AddRefed);
};
class ConditionRule : GroupRule {
using GroupRule::GroupRule;
};
class CSSMediaRule : ConditionRule {
using ConditionRule::ConditionRule;
};
class CSSMozDocumentRule : ConditionRule {
using ConditionRule::ConditionRule;
};
class ServoDocumentRule : CSSMozDocumentRule {
ServoDocumentRule(RefPtr);
};
class ServoMediaRule : CSSMediaRule {
ServoMediaRule(RefPtr);
};
ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
: CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {}
ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
// CHECK: define{{.*}}ServoMediaRule
// CHECK-NOT: {{ ret }}
// CHECK: store %class.ConditionRule* %
// CHECK-SAME: %class.ConditionRule** %
// CHECK-SAME: !dbg ![[INL:[0-9]+]]
// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]], inlinedAt:
// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule", {{.*}}isDefinition: true

View File

@ -1,4 +1,6 @@
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=NEWABI
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=OLDABI
// RUN: %clang_cc1 -std=c++11 -triple x86_64-scei-ps4 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=OLDABI
// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=18 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-18
// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=19 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-19
@ -56,8 +58,10 @@ void bar() {
// CHECK-LABEL: define void @_ZN9move_ctor3barEv()
// CHECK: call void @_Z{{.*}}C1Ev(
// CHECK-NOT: call
// CHECK: call void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"* %{{.*}})
// CHECK-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"*)
// NEWABI: call void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"* %{{.*}})
// OLDABI: call void @_ZN9move_ctor3fooENS_1AE(i8* %{{.*}})
// NEWABI-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"*)
// OLDABI-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(i8*)
// WIN64-LABEL: declare void @"\01?foo@move_ctor@@YAXUA@1@@Z"(%"struct.move_ctor::A"*)
}
@ -76,8 +80,10 @@ void bar() {
// CHECK-LABEL: define void @_ZN11all_deleted3barEv()
// CHECK: call void @_Z{{.*}}C1Ev(
// CHECK-NOT: call
// CHECK: call void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"* %{{.*}})
// CHECK-LABEL: declare void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"*)
// NEWABI: call void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"* %{{.*}})
// OLDABI: call void @_ZN11all_deleted3fooENS_1AE(i8* %{{.*}})
// NEWABI-LABEL: declare void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"*)
// OLDABI-LABEL: declare void @_ZN11all_deleted3fooENS_1AE(i8*)
// WIN64-LABEL: declare void @"\01?foo@all_deleted@@YAXUA@1@@Z"(%"struct.all_deleted::A"*)
}
@ -95,8 +101,10 @@ void bar() {
// CHECK-LABEL: define void @_ZN18implicitly_deleted3barEv()
// CHECK: call void @_Z{{.*}}C1Ev(
// CHECK-NOT: call
// CHECK: call void @_ZN18implicitly_deleted3fooENS_1AE(%"struct.implicitly_deleted::A"* %{{.*}})
// CHECK-LABEL: declare void @_ZN18implicitly_deleted3fooENS_1AE(%"struct.implicitly_deleted::A"*)
// NEWABI: call void @_ZN18implicitly_deleted3fooENS_1AE(%"struct.implicitly_deleted::A"* %{{.*}})
// OLDABI: call void @_ZN18implicitly_deleted3fooENS_1AE(i8* %{{.*}})
// NEWABI-LABEL: declare void @_ZN18implicitly_deleted3fooENS_1AE(%"struct.implicitly_deleted::A"*)
// OLDABI-LABEL: declare void @_ZN18implicitly_deleted3fooENS_1AE(i8*)
// In MSVC 2013, the copy ctor is not deleted by a move assignment. In MSVC 2015, it is.
// WIN64-18-LABEL: declare void @"\01?foo@implicitly_deleted@@YAXUA@1@@Z"(i64
@ -116,8 +124,10 @@ void bar() {
// CHECK-LABEL: define void @_ZN11one_deleted3barEv()
// CHECK: call void @_Z{{.*}}C1Ev(
// CHECK-NOT: call
// CHECK: call void @_ZN11one_deleted3fooENS_1AE(%"struct.one_deleted::A"* %{{.*}})
// CHECK-LABEL: declare void @_ZN11one_deleted3fooENS_1AE(%"struct.one_deleted::A"*)
// NEWABI: call void @_ZN11one_deleted3fooENS_1AE(%"struct.one_deleted::A"* %{{.*}})
// OLDABI: call void @_ZN11one_deleted3fooENS_1AE(i8* %{{.*}})
// NEWABI-LABEL: declare void @_ZN11one_deleted3fooENS_1AE(%"struct.one_deleted::A"*)
// OLDABI-LABEL: declare void @_ZN11one_deleted3fooENS_1AE(i8*)
// WIN64-LABEL: declare void @"\01?foo@one_deleted@@YAXUA@1@@Z"(%"struct.one_deleted::A"*)
}
@ -196,8 +206,10 @@ void bar() {
}
// CHECK-LABEL: define void @_ZN14two_copy_ctors3barEv()
// CHECK: call void @_Z{{.*}}C1Ev(
// CHECK: call void @_ZN14two_copy_ctors3fooENS_1BE(%"struct.two_copy_ctors::B"* %{{.*}})
// CHECK-LABEL: declare void @_ZN14two_copy_ctors3fooENS_1BE(%"struct.two_copy_ctors::B"*)
// NEWABI: call void @_ZN14two_copy_ctors3fooENS_1BE(%"struct.two_copy_ctors::B"* %{{.*}})
// OLDABI: call void @_ZN14two_copy_ctors3fooENS_1BE(%"struct.two_copy_ctors::B"* byval
// NEWABI-LABEL: declare void @_ZN14two_copy_ctors3fooENS_1BE(%"struct.two_copy_ctors::B"*)
// OLDABI-LABEL: declare void @_ZN14two_copy_ctors3fooENS_1BE(%"struct.two_copy_ctors::B"* byval
// WIN64-LABEL: declare void @"\01?foo@two_copy_ctors@@YAXUB@1@@Z"(%"struct.two_copy_ctors::B"*)
}
@ -209,7 +221,8 @@ struct A {
void *p;
};
void *foo(A a) { return a.p; }
// CHECK-LABEL: define i8* @_ZN15definition_only3fooENS_1AE(%"struct.definition_only::A"*
// NEWABI-LABEL: define i8* @_ZN15definition_only3fooENS_1AE(%"struct.definition_only::A"*
// OLDABI-LABEL: define i8* @_ZN15definition_only3fooENS_1AE(i8*
// WIN64-LABEL: define i8* @"\01?foo@definition_only@@YAPEAXUA@1@@Z"(%"struct.definition_only::A"*
}
@ -224,7 +237,8 @@ struct A {
B b;
};
void *foo(A a) { return a.b.p; }
// CHECK-LABEL: define i8* @_ZN17deleted_by_member3fooENS_1AE(%"struct.deleted_by_member::A"*
// NEWABI-LABEL: define i8* @_ZN17deleted_by_member3fooENS_1AE(%"struct.deleted_by_member::A"*
// OLDABI-LABEL: define i8* @_ZN17deleted_by_member3fooENS_1AE(i8*
// WIN64-LABEL: define i8* @"\01?foo@deleted_by_member@@YAPEAXUA@1@@Z"(%"struct.deleted_by_member::A"*
}
@ -238,7 +252,8 @@ struct A : B {
A();
};
void *foo(A a) { return a.p; }
// CHECK-LABEL: define i8* @_ZN15deleted_by_base3fooENS_1AE(%"struct.deleted_by_base::A"*
// NEWABI-LABEL: define i8* @_ZN15deleted_by_base3fooENS_1AE(%"struct.deleted_by_base::A"*
// OLDABI-LABEL: define i8* @_ZN15deleted_by_base3fooENS_1AE(i8*
// WIN64-LABEL: define i8* @"\01?foo@deleted_by_base@@YAPEAXUA@1@@Z"(%"struct.deleted_by_base::A"*
}
@ -253,7 +268,8 @@ struct A {
B b;
};
void *foo(A a) { return a.b.p; }
// CHECK-LABEL: define i8* @_ZN22deleted_by_member_copy3fooENS_1AE(%"struct.deleted_by_member_copy::A"*
// NEWABI-LABEL: define i8* @_ZN22deleted_by_member_copy3fooENS_1AE(%"struct.deleted_by_member_copy::A"*
// OLDABI-LABEL: define i8* @_ZN22deleted_by_member_copy3fooENS_1AE(i8*
// WIN64-LABEL: define i8* @"\01?foo@deleted_by_member_copy@@YAPEAXUA@1@@Z"(%"struct.deleted_by_member_copy::A"*
}
@ -267,7 +283,8 @@ struct A : B {
A();
};
void *foo(A a) { return a.p; }
// CHECK-LABEL: define i8* @_ZN20deleted_by_base_copy3fooENS_1AE(%"struct.deleted_by_base_copy::A"*
// NEWABI-LABEL: define i8* @_ZN20deleted_by_base_copy3fooENS_1AE(%"struct.deleted_by_base_copy::A"*
// OLDABI-LABEL: define i8* @_ZN20deleted_by_base_copy3fooENS_1AE(i8*
// WIN64-LABEL: define i8* @"\01?foo@deleted_by_base_copy@@YAPEAXUA@1@@Z"(%"struct.deleted_by_base_copy::A"*
}
@ -277,7 +294,8 @@ struct A {
A(const A &o) = delete;
void *p;
};
// CHECK-LABEL: define i8* @_ZN15explicit_delete3fooENS_1AE(%"struct.explicit_delete::A"*
// NEWABI-LABEL: define i8* @_ZN15explicit_delete3fooENS_1AE(%"struct.explicit_delete::A"*
// OLDABI-LABEL: define i8* @_ZN15explicit_delete3fooENS_1AE(i8*
// WIN64-LABEL: define i8* @"\01?foo@explicit_delete@@YAPEAXUA@1@@Z"(%"struct.explicit_delete::A"*
void *foo(A a) { return a.p; }
}
@ -289,7 +307,8 @@ struct A {
// Deleted copy ctor due to rvalue ref member.
int &&ref;
};
// CHECK-LABEL: define {{.*}} @_ZN28implicitly_deleted_copy_ctor3fooENS_1AE(%"struct.implicitly_deleted_copy_ctor::A"*
// NEWABI-LABEL: define {{.*}} @_ZN28implicitly_deleted_copy_ctor3fooENS_1AE(%"struct.implicitly_deleted_copy_ctor::A"*
// OLDABI-LABEL: define {{.*}} @_ZN28implicitly_deleted_copy_ctor3fooENS_1AE(i32*
// WIN64-LABEL: define {{.*}} @"\01?foo@implicitly_deleted_copy_ctor@@YAAEAHUA@1@@Z"(%"struct.implicitly_deleted_copy_ctor::A"*
int &foo(A a) { return a.ref; }

View File

@ -24,3 +24,6 @@
// RUN: %clang -target armv7-apple-darwin10 -### -S -mno-implicit-float -mimplicit-float %s 2>&1 | FileCheck -check-prefix=TEST8 %s
// TEST8-NOT: "-no-implicit-float"
// RUN: %clang -target x86_64-linux-gnu -### -c -fclang-abi-compat=3.2 %s 2>&1 | FileCheck -check-prefix=TEST9 %s
// TEST9: "-fclang-abi-compat=3.2"

View File

@ -0,0 +1,15 @@
// RUN: not %clang_cc1 -fclang-abi-compat=banana %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang_cc1 -fclang-abi-compat=2.9 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang_cc1 -fclang-abi-compat=8 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang_cc1 -fclang-abi-compat=3.10 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang_cc1 -fclang-abi-compat=4.1 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang_cc1 -fclang-abi-compat=04 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang_cc1 -fclang-abi-compat=4. %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// RUN: not %clang_cc1 -fclang-abi-compat=4.00 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
// INVALID: error: invalid value '{{.*}}' in '-fclang-abi-compat={{.*}}'
//
// RUN: %clang_cc1 -fclang-abi-compat=3.0 %s -fsyntax-only
// RUN: %clang_cc1 -fclang-abi-compat=3.9 %s -fsyntax-only
// RUN: %clang_cc1 -fclang-abi-compat=4 %s -fsyntax-only
// RUN: %clang_cc1 -fclang-abi-compat=4.0 %s -fsyntax-only
// RUN: %clang_cc1 -fclang-abi-compat=latest %s -fsyntax-only

View File

@ -8860,6 +8860,16 @@ TEST_F(FormatTest, AlignConsecutiveDeclarations) {
Alignment);
Alignment.BinPackParameters = true;
Alignment.ColumnLimit = 80;
// Bug 33507
Alignment.PointerAlignment = FormatStyle::PAS_Middle;
verifyFormat(
"auto found = range::find_if(vsProducts, [&](auto * aProduct) {\n"
" static const Version verVs2017;\n"
" return true;\n"
"});\n",
Alignment);
Alignment.PointerAlignment = FormatStyle::PAS_Right;
}
TEST_F(FormatTest, LinuxBraceBreaking) {