Vendor import of clang release_80 branch r353167:

https://llvm.org/svn/llvm-project/cfe/branches/release_80@353167
This commit is contained in:
Dimitry Andric 2019-02-05 18:39:15 +00:00
parent 292698a853
commit d87c9e7da2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/clang/dist-release_80/; revision=343796
svn path=/vendor/clang/clang-release_80-r353167/; revision=343797; tag=vendor/clang/clang-release_80-r353167
48 changed files with 805 additions and 873 deletions

View File

@ -474,44 +474,58 @@ Half-Precision Floating Point
=============================
Clang supports two half-precision (16-bit) floating point types: ``__fp16`` and
``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
<http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053d/IHI0053D_acle_2_1.pdf>`_)
and ``_Float16`` in ISO/IEC TS 18661-3:2015.
``_Float16``. These types are supported in all language modes.
``__fp16`` is a storage and interchange format only. This means that values of
``__fp16`` promote to (at least) float when used in arithmetic operations.
There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
not the ARM alternative format.
``__fp16`` is supported on every target, as it is purely a storage format; see below.
``_Float16`` is currently only supported on the following targets, with further
targets pending ABI standardization:
- 32-bit ARM
- 64-bit ARM (AArch64)
- SPIR
``_Float16`` will be supported on more targets as they define ABIs for it.
ISO/IEC TS 18661-3:2015 defines C support for additional floating point types.
``_FloatN`` is defined as a binary floating type, where the N suffix denotes
the number of bits and is 16, 32, 64, or greater and equal to 128 and a
multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` is
that arithmetic on ``_Float16`` is performed in half-precision, thus it is not
a storage-only format. ``_Float16`` is available as a source language type in
both C and C++ mode.
``__fp16`` is a storage and interchange format only. This means that values of
``__fp16`` are immediately promoted to (at least) ``float`` when used in arithmetic
operations, so that e.g. the result of adding two ``__fp16`` values has type ``float``.
The behavior of ``__fp16`` is specified by the ARM C Language Extensions (`ACLE <http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053d/IHI0053D_acle_2_1.pdf>`_).
Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``, not the ARM
alternative format.
It is recommended that portable code use the ``_Float16`` type because
``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
defined by the C standards committee, so using ``_Float16`` will not prevent
code from being ported to architectures other than Arm. Also, ``_Float16``
arithmetic and operations will directly map on half-precision instructions when
they are available (e.g. Armv8.2-A), avoiding conversions to/from
single-precision, and thus will result in more performant code. If
half-precision instructions are unavailable, values will be promoted to
single-precision, similar to the semantics of ``__fp16`` except that the
results will be stored in single-precision.
``_Float16`` is an extended floating-point type. This means that, just like arithmetic on
``float`` or ``double``, arithmetic on ``_Float16`` operands is formally performed in the
``_Float16`` type, so that e.g. the result of adding two ``_Float16`` values has type
``_Float16``. The behavior of ``_Float16`` is specified by ISO/IEC TS 18661-3:2015
("Floating-point extensions for C"). As with ``__fp16``, Clang uses the ``binary16``
format from IEEE 754-2008 for ``_Float16``.
In an arithmetic operation where one operand is of ``__fp16`` type and the
other is of ``_Float16`` type, the ``_Float16`` type is first converted to
``__fp16`` type and then the operation is completed as if both operands were of
``__fp16`` type.
``_Float16`` arithmetic will be performed using native half-precision support
when available on the target (e.g. on ARMv8.2a); otherwise it will be performed
at a higher precision (currently always ``float``) and then truncated down to
``_Float16``. Note that C and C++ allow intermediate floating-point operands
of an expression to be computed with greater precision than is expressible in
their type, so Clang may avoid intermediate truncations in certain cases; this may
lead to results that are inconsistent with native arithmetic.
To define a ``_Float16`` literal, suffix ``f16`` can be appended to the compile-time
constant declaration. There is no default argument promotion for ``_Float16``; this
applies to the standard floating types only. As a consequence, for example, an
explicit cast is required for printing a ``_Float16`` value (there is no string
format specifier for ``_Float16``).
It is recommended that portable code use ``_Float16`` instead of ``__fp16``,
as it has been defined by the C standards committee and has behavior that is
more familiar to most programmers.
Because ``__fp16`` operands are always immediately promoted to ``float``, the
common real type of ``__fp16`` and ``_Float16`` for the purposes of the usual
arithmetic conversions is ``float``.
A literal can be given ``_Float16`` type using the suffix ``f16``; for example:
```
3.14f16
```
Because default argument promotion only applies to the standard floating-point
types, ``_Float16`` values are not promoted to ``double`` when passed as variadic
or untyped arguments. As a consequence, some caution must be taken when using
certain library facilities with ``_Float16``; for example, there is no ``printf`` format
specifier for ``_Float16``, and (unlike ``float``) it will not be implicitly promoted to
``double`` when passed to ``printf``, so the programmer must explicitly cast it to
``double`` before using it with an ``%f`` or similar specifier.
Messages on ``deprecated`` and ``unavailable`` Attributes
=========================================================

View File

@ -17,60 +17,50 @@
OpenMP Support
==================
Clang supports the following OpenMP 5.0 features
* The `reduction`-based clauses in the `task` and `target`-based directives.
* Support relational-op != (not-equal) as one of the canonical forms of random
access iterator.
* Support for mapping of the lambdas in target regions.
* Parsing/sema analysis for the requires directive.
* Nested declare target directives.
* Make the `this` pointer implicitly mapped as `map(this[:1])`.
* The `close` *map-type-modifier*.
Clang fully supports OpenMP 4.5. Clang supports offloading to X86_64, AArch64,
PPC64[LE] and has `basic support for Cuda devices`_.
Standalone directives
=====================
* #pragma omp [for] simd: :good:`Complete`.
* #pragma omp declare simd: :partial:`Partial`. We support parsing/semantic
analysis + generation of special attributes for X86 target, but still
missing the LLVM pass for vectorization.
* #pragma omp taskloop [simd]: :good:`Complete`.
* #pragma omp target [enter|exit] data: :good:`Complete`.
* #pragma omp target update: :good:`Complete`.
* #pragma omp target: :good:`Complete`.
* #pragma omp declare target: :good:`Complete`.
* #pragma omp teams: :good:`Complete`.
* #pragma omp distribute [simd]: :good:`Complete`.
* #pragma omp distribute parallel for [simd]: :good:`Complete`.
Combined directives
===================
* #pragma omp parallel for simd: :good:`Complete`.
* #pragma omp target parallel: :good:`Complete`.
* #pragma omp target parallel for [simd]: :good:`Complete`.
* #pragma omp target simd: :good:`Complete`.
* #pragma omp target teams: :good:`Complete`.
* #pragma omp teams distribute [simd]: :good:`Complete`.
* #pragma omp target teams distribute [simd]: :good:`Complete`.
* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
* #pragma omp target teams distribute parallel for [simd]: :good:`Complete`.
Clang does not support any constructs/updates from OpenMP 5.0 except
for `reduction`-based clauses in the `task` and `target`-based directives.
In addition, the LLVM OpenMP runtime `libomp` supports the OpenMP Tools
Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS.
Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and macOS.
General improvements
--------------------
- New collapse clause scheme to avoid expensive remainder operations.
Compute loop index variables after collapsing a loop nest via the
collapse clause by replacing the expensive remainder operation with
multiplications and additions.
- The default schedules for the `distribute` and `for` constructs in a
parallel region and in SPMD mode have changed to ensure coalesced
accesses. For the `distribute` construct, a static schedule is used
with a chunk size equal to the number of threads per team (default
value of threads or as specified by the `thread_limit` clause if
present). For the `for` construct, the schedule is static with chunk
size of one.
- Simplified SPMD code generation for `distribute parallel for` when
the new default schedules are applicable.
.. _basic support for Cuda devices:

View File

@ -127,6 +127,10 @@ Non-comprehensive list of changes in this release
manually and rely on the old behaviour you will need to add appropriate
compiler flags for finding the corresponding libc++ include directory.
- The integrated assembler is used now by default for all MIPS targets.
- Improved support for MIPS N32 ABI and MIPS R6 target triples.
New Compiler Flags
------------------
@ -136,6 +140,13 @@ New Compiler Flags
instrumenting for gcov-based profiling.
See the :doc:`UsersManual` for details.
- When using a custom stack alignment, the ``stackrealign`` attribute is now
implicitly set on the main function.
- Emission of ``R_MIPS_JALR`` and ``R_MICROMIPS_JALR`` relocations can now
be controlled by the ``-mrelax-pic-calls`` and ``-mno-relax-pic-calls``
options.
- ...
Deprecated Compiler Flags
@ -179,6 +190,15 @@ Windows Support
`dllexport` and `dllimport` attributes not apply to inline member functions.
This can significantly reduce compile and link times. See the `User's Manual
<UsersManual.html#the-zc-dllexportinlines-option>`_ for more info.
- For MinGW, ``-municode`` now correctly defines ``UNICODE`` during
preprocessing.
- For MinGW, clang now produces vtables and RTTI for dllexported classes
without key functions. This fixes building Qt in debug mode.
- Allow using Address Sanitizer and Undefined Behaviour Sanitizer on MinGW.
- ...
@ -233,12 +253,15 @@ ABI Changes in Clang
OpenMP Support in Clang
----------------------------------
- Support relational-op != (not-equal) as one of the canonical forms of random
access iterator.
- OpenMP 5.0 features
- Added support for mapping of the lambdas in target regions.
- Added parsing/sema analysis for OpenMP 5.0 requires directive.
- Support relational-op != (not-equal) as one of the canonical forms of random
access iterator.
- Added support for mapping of the lambdas in target regions.
- Added parsing/sema analysis for the requires directive.
- Support nested declare target directives.
- Make the `this` pointer implicitly mapped as `map(this[:1])`.
- Added the `close` *map-type-modifier*.
- Various bugfixes and improvements.
@ -250,6 +273,15 @@ New features supported for Cuda devices:
- Fixed support for lastprivate/reduction variables in SPMD constructs.
- New collapse clause scheme to avoid expensive remainder operations.
- New default schedule for distribute and parallel constructs.
- Simplified code generation for distribute and parallel in SPMD mode.
- Flag (``-fopenmp_optimistic_collapse``) for user to limit collapsed
loop counter width when safe to do so.
- General performance improvement.
CUDA Support in Clang

View File

@ -33,7 +33,7 @@ BUILTIN(__builtin_arm_clrex, "v", "")
// Bit manipulation
BUILTIN(__builtin_arm_rbit, "UiUi", "nc")
BUILTIN(__builtin_arm_rbit64, "LUiLUi", "nc")
BUILTIN(__builtin_arm_rbit64, "WUiWUi", "nc")
// HINT
BUILTIN(__builtin_arm_nop, "v", "")
@ -50,8 +50,8 @@ BUILTIN(__builtin_arm_crc32h, "UiUiUs", "nc")
BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc")
BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc")
BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc")
BUILTIN(__builtin_arm_crc32d, "UiUiLUi", "nc")
BUILTIN(__builtin_arm_crc32cd, "UiUiLUi", "nc")
BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc")
BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc")
// Memory barrier
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
@ -63,10 +63,10 @@ BUILTIN(__builtin_arm_prefetch, "vvC*UiUiUiUi", "nc")
// System Registers
BUILTIN(__builtin_arm_rsr, "UicC*", "nc")
BUILTIN(__builtin_arm_rsr64, "LUicC*", "nc")
BUILTIN(__builtin_arm_rsr64, "WUicC*", "nc")
BUILTIN(__builtin_arm_rsrp, "v*cC*", "nc")
BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
BUILTIN(__builtin_arm_wsr64, "vcC*WUi", "nc")
BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
// MSVC

View File

@ -96,7 +96,7 @@ FEATURE(objc_arc, LangOpts.ObjCAutoRefCount)
FEATURE(objc_arc_fields, true)
FEATURE(objc_arc_weak, LangOpts.ObjCWeak)
FEATURE(objc_default_synthesize_properties, LangOpts.ObjC)
FEATURE(objc_fixed_enum, true)
FEATURE(objc_fixed_enum, LangOpts.ObjC)
FEATURE(objc_instancetype, LangOpts.ObjC)
FEATURE(objc_kindof, LangOpts.ObjC)
FEATURE(objc_modules, LangOpts.ObjC && LangOpts.Modules)

View File

@ -70,15 +70,14 @@ class FileEntry {
bool IsNamedPipe;
bool InPCH;
bool IsValid; // Is this \c FileEntry initialized and valid?
bool DeferredOpen; // Created by getFile(OpenFile=0); may open later.
/// The open file, if it is owned by the \p FileEntry.
mutable std::unique_ptr<llvm::vfs::File> File;
public:
FileEntry()
: UniqueID(0, 0), IsNamedPipe(false), InPCH(false), IsValid(false),
DeferredOpen(false) {}
: UniqueID(0, 0), IsNamedPipe(false), InPCH(false), IsValid(false)
{}
FileEntry(const FileEntry &) = delete;
FileEntry &operator=(const FileEntry &) = delete;

View File

@ -64,6 +64,7 @@ class TargetInfo : public RefCountedBase<TargetInfo> {
bool HasLegalHalfType; // True if the backend supports operations on the half
// LLVM IR type.
bool HasFloat128;
bool HasFloat16;
unsigned char PointerWidth, PointerAlign;
unsigned char BoolWidth, BoolAlign;
unsigned char IntWidth, IntAlign;
@ -517,6 +518,9 @@ class TargetInfo : public RefCountedBase<TargetInfo> {
/// Determine whether the __float128 type is supported on this target.
virtual bool hasFloat128Type() const { return HasFloat128; }
/// Determine whether the _Float16 type is supported on this target.
virtual bool hasFloat16Type() const { return HasFloat16; }
/// Return the alignment that is suitable for storing any
/// object with a fundamental alignment requirement.
unsigned getSuitableAlign() const { return SuitableAlign; }

View File

@ -2418,6 +2418,14 @@ def modd_spreg : Flag<["-"], "modd-spreg">, Group<m_mips_Features_Group>,
def mno_odd_spreg : Flag<["-"], "mno-odd-spreg">, Group<m_mips_Features_Group>,
HelpText<"Disable odd single-precision floating point registers">,
Flags<[HelpHidden]>;
def mrelax_pic_calls : Flag<["-"], "mrelax-pic-calls">,
Group<m_mips_Features_Group>,
HelpText<"Try turning PIC calls (j{al}r{c} $25) into direct calls "
"(MIPS only)">, Flags<[HelpHidden]>;
def mno_relax_pic_calls : Flag<["-"], "mno-relax-pic-calls">,
Group<m_mips_Features_Group>,
HelpText<"Do not try turning PIC calls (j{al}r{c} $25) into direct calls "
"(MIPS only)">, Flags<[HelpHidden]>;
def mglibc : Flag<["-"], "mglibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
def muclibc : Flag<["-"], "muclibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
def module_file_info : Flag<["-"], "module-file-info">, Flags<[DriverOption,CC1Option]>, Group<Action_Group>,

View File

@ -61,6 +61,10 @@ ArgumentsAdjuster getInsertArgumentAdjuster(
const char *Extra,
ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
/// Gets an argument adjuster which strips plugin related command line
/// arguments.
ArgumentsAdjuster getStripPluginsAdjuster();
/// Gets an argument adjuster which adjusts the arguments in sequence
/// with the \p First adjuster and then with the \p Second one.
ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,

View File

@ -189,21 +189,15 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
*SeenFileEntries.insert(std::make_pair(Filename, nullptr)).first;
// See if there is already an entry in the map.
if (NamedFileEnt.second) {
if (NamedFileEnt.second == NON_EXISTENT_FILE)
return nullptr;
// Entry exists: return it *unless* it wasn't opened and open is requested.
if (!(NamedFileEnt.second->DeferredOpen && openFile))
return NamedFileEnt.second;
// We previously stat()ed the file, but didn't open it: do that below.
// FIXME: the below does other redundant work too (stats the dir and file).
} else {
// By default, initialize it to invalid.
NamedFileEnt.second = NON_EXISTENT_FILE;
}
if (NamedFileEnt.second)
return NamedFileEnt.second == NON_EXISTENT_FILE ? nullptr
: NamedFileEnt.second;
++NumFileCacheMisses;
// By default, initialize it to invalid.
NamedFileEnt.second = NON_EXISTENT_FILE;
// Get the null-terminated file name as stored as the key of the
// SeenFileEntries map.
StringRef InterndFileName = NamedFileEnt.first();
@ -241,7 +235,6 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
// It exists. See if we have already opened a file with the same inode.
// This occurs when one dir is symlinked to another, for example.
FileEntry &UFE = UniqueRealFiles[Data.UniqueID];
UFE.DeferredOpen = !openFile;
NamedFileEnt.second = &UFE;
@ -258,15 +251,6 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
InterndFileName = NamedFileEnt.first().data();
}
// If we opened the file for the first time, record the resulting info.
// Do this even if the cache entry was valid, maybe we didn't previously open.
if (F && !UFE.File) {
if (auto PathName = F->getName())
fillRealPathName(&UFE, *PathName);
UFE.File = std::move(F);
assert(!UFE.DeferredOpen && "we just opened it!");
}
if (UFE.isValid()) { // Already have an entry with this inode, return it.
// FIXME: this hack ensures that if we look up a file by a virtual path in
@ -297,9 +281,13 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
UFE.UniqueID = Data.UniqueID;
UFE.IsNamedPipe = Data.IsNamedPipe;
UFE.InPCH = Data.InPCH;
UFE.File = std::move(F);
UFE.IsValid = true;
// Note File and DeferredOpen were initialized above.
if (UFE.File) {
if (auto PathName = UFE.File->getName())
fillRealPathName(&UFE, *PathName);
}
return &UFE;
}
@ -371,7 +359,6 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size,
UFE->UID = NextFileUID++;
UFE->IsValid = true;
UFE->File.reset();
UFE->DeferredOpen = false;
return UFE;
}

View File

@ -35,6 +35,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
NoAsmVariants = false;
HasLegalHalfType = false;
HasFloat128 = false;
HasFloat16 = false;
PointerWidth = PointerAlign = 32;
BoolWidth = BoolAlign = 8;
IntWidth = IntAlign = 32;

View File

@ -570,19 +570,27 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
Triple.getVendor() != llvm::Triple::UnknownVendor ||
!Triple.isOSBinFormatWasm())
return nullptr;
if (Triple.getOS() != llvm::Triple::UnknownOS &&
Triple.getOS() != llvm::Triple::WASI)
return nullptr;
return new WebAssemblyOSTargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
switch (Triple.getOS()) {
case llvm::Triple::WASI:
return new WASITargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
case llvm::Triple::UnknownOS:
return new WebAssemblyOSTargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
default:
return nullptr;
}
case llvm::Triple::wasm64:
if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
Triple.getVendor() != llvm::Triple::UnknownVendor ||
!Triple.isOSBinFormatWasm())
return nullptr;
if (Triple.getOS() != llvm::Triple::UnknownOS &&
Triple.getOS() != llvm::Triple::WASI)
return nullptr;
return new WebAssemblyOSTargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
switch (Triple.getOS()) {
case llvm::Triple::WASI:
return new WASITargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
case llvm::Triple::UnknownOS:
return new WebAssemblyOSTargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
default:
return nullptr;
}
case llvm::Triple::renderscript32:
return new LinuxTargetInfo<RenderScript32TargetInfo>(Triple, Opts);

View File

@ -50,6 +50,7 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
// All AArch64 implementations support ARMv8 FP, which makes half a legal type.
HasLegalHalfType = true;
HasFloat16 = true;
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
MaxVectorAlign = 128;

View File

@ -397,6 +397,7 @@ bool ARMTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
SoftFloat = SoftFloatABI = false;
HWDiv = 0;
DotProd = 0;
HasFloat16 = true;
// This does not diagnose illegal cases like having both
// "+vfpv2" and "+vfpv3" or having "+neon" and "+fp-only-sp".

View File

@ -764,8 +764,9 @@ class LLVM_LIBRARY_VISIBILITY FuchsiaTargetInfo : public OSTargetInfo<Target> {
template <typename Target>
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
: public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const final {
MacroBuilder &Builder) const {
// A common platform macro.
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
@ -783,6 +784,21 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
}
};
// WASI target
template <typename Target>
class LLVM_LIBRARY_VISIBILITY WASITargetInfo
: public WebAssemblyOSTargetInfo<Target> {
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const final {
WebAssemblyOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder);
Builder.defineMacro("__wasi__");
}
public:
explicit WASITargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: WebAssemblyOSTargetInfo<Target>(Triple, Opts) {}
};
} // namespace targets
} // namespace clang
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_OSTARGETS_H

View File

@ -48,6 +48,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
AddrSpaceMap = &SPIRAddrSpaceMap;
UseAddrSpaceMapMangling = true;
HasLegalHalfType = true;
HasFloat16 = true;
// Define available target features
// These must be defined in sorted order!
NoAsmVariants = true;

View File

@ -1716,6 +1716,14 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
} else
D.Diag(diag::warn_target_unsupported_compact_branches) << CPUName;
}
if (Arg *A = Args.getLastArg(options::OPT_mrelax_pic_calls,
options::OPT_mno_relax_pic_calls)) {
if (A->getOption().matches(options::OPT_mno_relax_pic_calls)) {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-mips-jalr-reloc=0");
}
}
}
void Clang::AddPPCTargetArgs(const ArgList &Args,

View File

@ -256,6 +256,13 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs();
if (SanArgs.needsSharedRt()) {
CmdArgs.push_back("-rpath");
CmdArgs.push_back(Args.MakeArgString(
ToolChain.getCompilerRTPath().c_str()));
}
unsigned Major, Minor, Micro;
ToolChain.getTriple().getOSVersion(Major, Minor, Micro);
bool useLibgcc = true;

View File

@ -14470,7 +14470,7 @@ half16 __ovld __cnfn shuffle2(half16 x, half16 y, ushort16 mask);
#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
int printf(__constant const char* st, ...);
#endif
// OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions

View File

@ -617,10 +617,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
if (isHalf || isFloat || isLong || isFloat128)
break; // HF, FF, LF, QF invalid.
if (s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
s += 2; // success, eat up 2 characters.
isFloat16 = true;
continue;
if (PP.getTargetInfo().hasFloat16Type() && s + 2 < ThisTokEnd &&
s[1] == '1' && s[2] == '6') {
s += 2; // success, eat up 2 characters.
isFloat16 = true;
continue;
}
isFloat = true;

View File

@ -681,7 +681,8 @@ QualType clang::getDeclUsageType(ASTContext &C, const NamedDecl *ND) {
T = Property->getType();
else if (const auto *Value = dyn_cast<ValueDecl>(ND))
T = Value->getType();
else
if (T.isNull())
return QualType();
// Dig through references, function pointers, and block pointers to

View File

@ -1301,6 +1301,10 @@ static DeclAccessPair findDecomposableBaseClass(Sema &S, SourceLocation Loc,
static bool checkMemberDecomposition(Sema &S, ArrayRef<BindingDecl*> Bindings,
ValueDecl *Src, QualType DecompType,
const CXXRecordDecl *OrigRD) {
if (S.RequireCompleteType(Src->getLocation(), DecompType,
diag::err_incomplete_type))
return true;
CXXCastPath BasePath;
DeclAccessPair BasePair =
findDecomposableBaseClass(S, Src->getLocation(), OrigRD, BasePath);
@ -5886,9 +5890,6 @@ static bool canPassInRegisters(Sema &S, CXXRecordDecl *D,
if (D->isDependentType() || D->isInvalidDecl())
return false;
if (D->hasAttr<TrivialABIAttr>())
return true;
// Clang <= 4 used the pre-C++11 rule, which ignores move operations.
// The PS4 platform ABI follows the behavior of Clang 3.2.
if (CCK == TargetInfo::CCK_ClangABI4OrPS4)

View File

@ -738,33 +738,20 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
return ExprError();
E = Res.get();
QualType ScalarTy = Ty;
unsigned NumElts = 0;
if (const ExtVectorType *VecTy = Ty->getAs<ExtVectorType>()) {
NumElts = VecTy->getNumElements();
ScalarTy = VecTy->getElementType();
}
// If this is a 'float' or '__fp16' (CVR qualified or typedef)
// promote to double.
// Note that default argument promotion applies only to float (and
// half/fp16); it does not apply to _Float16.
const BuiltinType *BTy = ScalarTy->getAs<BuiltinType>();
const BuiltinType *BTy = Ty->getAs<BuiltinType>();
if (BTy && (BTy->getKind() == BuiltinType::Half ||
BTy->getKind() == BuiltinType::Float)) {
if (getLangOpts().OpenCL &&
!getOpenCLOptions().isEnabled("cl_khr_fp64")) {
if (BTy->getKind() == BuiltinType::Half) {
QualType Ty = Context.FloatTy;
if (NumElts != 0)
Ty = Context.getExtVectorType(Ty, NumElts);
E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
}
if (BTy->getKind() == BuiltinType::Half) {
E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
}
} else {
QualType Ty = Context.DoubleTy;
if (NumElts != 0)
Ty = Context.getExtVectorType(Ty, NumElts);
E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
}
}

View File

@ -6309,7 +6309,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
// -- a predefined __func__ variable
if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) {
if (isa<CXXUuidofExpr>(E)) {
Converted = TemplateArgument(ArgResult.get());
Converted = TemplateArgument(ArgResult.get()->IgnoreImpCasts());
break;
}
Diag(Arg->getBeginLoc(), diag::err_template_arg_not_decl_ref)

View File

@ -1442,7 +1442,12 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
else
Result = Context.Int128Ty;
break;
case DeclSpec::TST_float16: Result = Context.Float16Ty; break;
case DeclSpec::TST_float16:
if (!S.Context.getTargetInfo().hasFloat16Type())
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
<< "_Float16";
Result = Context.Float16Ty;
break;
case DeclSpec::TST_half: Result = Context.HalfTy; break;
case DeclSpec::TST_float: Result = Context.FloatTy; break;
case DeclSpec::TST_double:

View File

@ -108,5 +108,27 @@ ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
};
}
ArgumentsAdjuster getStripPluginsAdjuster() {
return [](const CommandLineArguments &Args, StringRef /*unused*/) {
CommandLineArguments AdjustedArgs;
for (size_t I = 0, E = Args.size(); I != E; I++) {
// According to https://clang.llvm.org/docs/ClangPlugins.html
// plugin arguments are in the form:
// -Xclang {-load, -plugin, -plugin-arg-<plugin-name>, -add-plugin}
// -Xclang <arbitrary-argument>
if (I + 4 < E && Args[I] == "-Xclang" &&
(Args[I + 1] == "-load" || Args[I + 1] == "-plugin" ||
llvm::StringRef(Args[I + 1]).startswith("-plugin-arg-") ||
Args[I + 1] == "-add-plugin") &&
Args[I + 2] == "-Xclang") {
I += 3;
continue;
}
AdjustedArgs.push_back(Args[I]);
}
return AdjustedArgs;
};
}
} // end namespace tooling
} // end namespace clang

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace
// RUN: %clang_cc1 -std=c++11 -ast-dump -fnative-half-type %s | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu %s | FileCheck %s --strict-whitespace
// RUN: %clang_cc1 -std=c++11 -ast-dump -triple aarch64-linux-gnu -fnative-half-type %s | FileCheck %s --check-prefix=CHECK-NATIVE --strict-whitespace
/* Various contexts where type _Float16 can appear. */

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++11 -verify %s
// RUN: %clang_cc1 -std=c++11 -verify %s -triple x86_64-linux-gnu
alignas(double) void f(); // expected-error {{'alignas' attribute only applies to variables, data members and tag types}}
alignas(double) unsigned char c[sizeof(double)]; // expected-note {{previous}}

View File

@ -0,0 +1,8 @@
void test() {
for (auto [loopVar] : y) { // y has to be unresolved
loopVa
}
}
// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:11 %s -o - \
// RUN: | FileCheck %s
// CHECK: COMPLETION: loopVar

View File

@ -1,54 +1,57 @@
// REQUIRES: aarch64-registered-target
// RUN: %clang_cc1 -triple arm64-none-linux-gnu \
// RUN: -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
// RUN: %clang_cc1 -triple aarch64-windows \
// RUN: -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
#include <stdint.h>
int crc32b(int a, char b)
uint32_t crc32b(uint32_t a, uint8_t b)
{
return __builtin_arm_crc32b(a,b);
// CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
// CHECK: call i32 @llvm.aarch64.crc32b(i32 %a, i32 [[T0]])
}
int crc32cb(int a, char b)
uint32_t crc32cb(uint32_t a, uint8_t b)
{
return __builtin_arm_crc32cb(a,b);
// CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
// CHECK: call i32 @llvm.aarch64.crc32cb(i32 %a, i32 [[T0]])
}
int crc32h(int a, short b)
uint32_t crc32h(uint32_t a, uint16_t b)
{
return __builtin_arm_crc32h(a,b);
// CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
// CHECK: call i32 @llvm.aarch64.crc32h(i32 %a, i32 [[T0]])
}
int crc32ch(int a, short b)
uint32_t crc32ch(uint32_t a, uint16_t b)
{
return __builtin_arm_crc32ch(a,b);
// CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
// CHECK: call i32 @llvm.aarch64.crc32ch(i32 %a, i32 [[T0]])
}
int crc32w(int a, int b)
uint32_t crc32w(uint32_t a, uint32_t b)
{
return __builtin_arm_crc32w(a,b);
// CHECK: call i32 @llvm.aarch64.crc32w(i32 %a, i32 %b)
}
int crc32cw(int a, int b)
uint32_t crc32cw(uint32_t a, uint32_t b)
{
return __builtin_arm_crc32cw(a,b);
// CHECK: call i32 @llvm.aarch64.crc32cw(i32 %a, i32 %b)
}
int crc32d(int a, long b)
uint32_t crc32d(uint32_t a, uint64_t b)
{
return __builtin_arm_crc32d(a,b);
// CHECK: call i32 @llvm.aarch64.crc32x(i32 %a, i64 %b)
}
int crc32cd(int a, long b)
uint32_t crc32cd(uint32_t a, uint64_t b)
{
return __builtin_arm_crc32cd(a,b);
// CHECK: call i32 @llvm.aarch64.crc32cx(i32 %a, i64 %b)

View File

@ -1,4 +1,6 @@
// RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
// RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LINUX
// RUN: %clang_cc1 -triple aarch64-windows -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-WIN
#include <stdint.h>
void f0(void *a, void *b) {
__clear_cache(a,b);
@ -15,8 +17,15 @@ unsigned rbit(unsigned a) {
return __builtin_arm_rbit(a);
}
// CHECK-WIN: [[A64:%[^ ]+]] = zext i32 %a to i64
// CHECK-WIN: call i64 @llvm.bitreverse.i64(i64 [[A64]])
// CHECK-LINUX: call i64 @llvm.bitreverse.i64(i64 %a)
unsigned long rbitl(unsigned long a) {
return __builtin_arm_rbit64(a);
}
// CHECK: call {{.*}} @llvm.bitreverse.i64(i64 %a)
unsigned long long rbit64(unsigned long long a) {
uint64_t rbit64(uint64_t a) {
return __builtin_arm_rbit64(a);
}
@ -49,13 +58,17 @@ void prefetch() {
// CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
}
unsigned rsr() {
__typeof__(__builtin_arm_rsr("1:2:3:4:5")) rsr(void);
uint32_t rsr() {
// CHECK: [[V0:[%A-Za-z0-9.]+]] = call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
// CHECK-NEXT: trunc i64 [[V0]] to i32
return __builtin_arm_rsr("1:2:3:4:5");
}
unsigned long rsr64() {
__typeof__(__builtin_arm_rsr64("1:2:3:4:5")) rsr64(void);
uint64_t rsr64(void) {
// CHECK: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
return __builtin_arm_rsr64("1:2:3:4:5");
}
@ -66,13 +79,17 @@ void *rsrp() {
return __builtin_arm_rsrp("1:2:3:4:5");
}
__typeof__(__builtin_arm_wsr("1:2:3:4:5", 0)) wsr(unsigned);
void wsr(unsigned v) {
// CHECK: [[V0:[%A-Za-z0-9.]+]] = zext i32 %v to i64
// CHECK-NEXT: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 [[V0]])
__builtin_arm_wsr("1:2:3:4:5", v);
}
void wsr64(unsigned long v) {
__typeof__(__builtin_arm_wsr64("1:2:3:4:5", 0)) wsr64(uint64_t);
void wsr64(uint64_t v) {
// CHECK: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %v)
__builtin_arm_wsr64("1:2:3:4:5", v);
}

View File

@ -1,5 +1,4 @@
// RUN: %clang -std=c++11 --target=aarch64-arm--eabi -S -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AARCH64
// RUN: %clang -std=c++11 --target=x86_64 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X86
/* Various contexts where type _Float16 can appear. */
@ -15,7 +14,6 @@ namespace {
_Float16 arr1n[10];
// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 2
// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 16
_Float16 arr2n[] = { 1.2, 3.0, 3.e4 };
// CHECK-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x half] [half 0xH3CCD, half 0xH4200, half 0xH7753], align 2
@ -30,14 +28,12 @@ namespace {
_Float16 f1f;
// CHECK-AARCH64-DAG: @f1f = dso_local global half 0xH0000, align 2
// CHECK-X86-DAG: @f1f = dso_local global half 0xH0000, align 2
_Float16 f2f = 32.4;
// CHECK-DAG: @f2f = dso_local global half 0xH500D, align 2
_Float16 arr1f[10];
// CHECK-AARCH64-DAG: @arr1f = dso_local global [10 x half] zeroinitializer, align 2
// CHECK-X86-DAG: @arr1f = dso_local global [10 x half] zeroinitializer, align 16
_Float16 arr2f[] = { -1.2, -3.0, -3.e4 };
// CHECK-DAG: @arr2f = dso_local global [3 x half] [half 0xHBCCD, half 0xHC200, half 0xHF753], align 2
@ -137,8 +133,6 @@ int main(void) {
long double cvtld = f2n;
//CHECK-AARCh64-DAG: [[H2LD:%[a-z0-9]+]] = fpext half {{%[0-9]+}} to fp128
//CHECK-AARCh64-DAG: store fp128 [[H2LD]], fp128* %{{.*}}, align 16
//CHECK-X86-DAG: [[H2LD:%[a-z0-9]+]] = fpext half {{%[0-9]+}} to x86_fp80
//CHECK-X86-DAG: store x86_fp80 [[H2LD]], x86_fp80* %{{.*}}, align 16
_Float16 f2h = 42.0f;
//CHECK-DAG: store half 0xH5140, half* %{{.*}}, align 2

View File

@ -1,5 +1,6 @@
// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=i386-pc-win32 -std=c++98 | FileCheck %s
// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=x86_64-pc-win32 -std=c++98| FileCheck -check-prefix X64 %s
// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=aarch64-pc-win32 -std=c++98 -DARM | FileCheck -check-prefixes=X64,ARM %s
int a;
// CHECK-DAG: @"?a@@3HA"
@ -466,10 +467,12 @@ namespace Complex {
// CHECK-DAG: define dso_local void @"?f@Complex@@YAXU?$_Complex@H@__clang@@@Z"(
void f(_Complex int) {}
}
#ifdef ARM
namespace Float16 {
// CHECK-DAG: define dso_local void @"?f@Float16@@YAXU_Float16@__clang@@@Z"(
// ARM-DAG: define dso_local void @"?f@Float16@@YAXU_Float16@__clang@@@Z"(
void f(_Float16) {}
}
#endif // ARM
namespace PR26029 {
template <class>

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
// CHECK: %[[STRUCT_SMALL:.*]] = type { i32* }
// CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
@ -43,13 +43,6 @@ struct HasNonTrivial {
NonTrivial m;
};
struct __attribute__((trivial_abi)) CopyMoveDeleted {
CopyMoveDeleted(int);
CopyMoveDeleted(const CopyMoveDeleted &) = delete;
CopyMoveDeleted(CopyMoveDeleted &&) = delete;
int a;
};
// CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]])
// CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8
// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0
@ -244,11 +237,3 @@ void calleeExceptionLarge(Large, Large);
void testExceptionLarge() {
calleeExceptionLarge(Large(), Large());
}
// A class with deleted copy and move constructors can still be passed or
// returned in registers if the class is annotated with trivial_abi.
// CHECK: define i64 @_Z19testCopyMoveDeletedi(i32 %
CopyMoveDeleted testCopyMoveDeleted(int a) {
return a;
}

View File

@ -12,28 +12,26 @@ int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)))
// ALL-LABEL: @test_printf_float2(
// FP64: %conv = fpext <2 x float> %0 to <2 x double>
// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %conv)
// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
// NOFP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
// NOFP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
kernel void test_printf_float2(float2 arg) {
printf("%v2f", arg);
printf("%v2hlf", arg);
}
// ALL-LABEL: @test_printf_half2(
// FP64: %conv = fpext <2 x half> %0 to <2 x double>
// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %conv) #2
// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.1, i32 0, i32 0), <2 x half> %0)
// NOFP64: %conv = fpext <2 x half> %0 to <2 x float>
// NOFP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %conv) #2
// NOFP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.1, i32 0, i32 0), <2 x half> %0)
kernel void test_printf_half2(half2 arg) {
printf("%v2f", arg);
printf("%v2hf", arg);
}
#ifdef cl_khr_fp64
// FP64-LABEL: @test_printf_double2(
// FP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %0) #2
// FP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.2, i32 0, i32 0), <2 x double> %0)
kernel void test_printf_double2(double2 arg) {
printf("%v2f", arg);
printf("%v2lf", arg);
}
#endif

View File

@ -444,3 +444,15 @@
// RUN: -mginv -mno-ginv 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NO-GINV %s
// CHECK-NO-GINV: "-target-feature" "-ginv"
//
// -mrelax-pic-calls
// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
// RUN: -mno-relax-pic-calls -mrelax-pic-calls 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-RELAX-PIC-CALLS %s
// CHECK-RELAX-PIC-CALLS-NOT: "-mllvm" "-mips-jalr-reloc=0"
//
// -mno-relax-pic-calls
// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
// RUN: -mrelax-pic-calls -mno-relax-pic-calls 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NO-RELAX-PIC-CALLS %s
// CHECK-NO-RELAX-PIC-CALLS: "-mllvm" "-mips-jalr-reloc=0"

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple aarch64-linux-gnu %s
float a = 1.0h; // expected-error{{no matching literal operator for call to 'operator""h' with argument of type 'long double' or 'const char *', and no matching literal operator template}}
float b = 1.0H; // expected-error{{invalid suffix 'H' on floating constant}}

29
test/PCH/leakfiles Normal file
View File

@ -0,0 +1,29 @@
// Test that compiling using a PCH doesn't leak file descriptors.
// https://bugs.chromium.org/p/chromium/issues/detail?id=924225
//
// This test requires bash loops and ulimit.
// REQUIRES: shell
// UNSUPPORTED: win32
//
// Set up source files. lib/lib.h includes lots of lib*.h files in that dir.
// client.c includes lib/lib.h, and also the individual files directly.
//
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: cd %t
// RUN: mkdir lib
// RUN: for i in {1..300}; do touch lib/lib$i.h; done
// RUN: for i in {1..300}; do echo "#include \"lib$i.h\"" >> lib/lib.h; done
// RUN: echo "#include \"lib/lib.h\"" > client.c
// RUN: for i in {1..300}; do echo "#include \"lib/lib$i.h\"" >> client.c; done
//
// We want to verify that we don't hold all the files open at the same time.
// This is important e.g. on mac, which has a low default FD limit.
// RUN: ulimit -n 100
//
// Test without PCH.
// RUN: %clang_cc1 -fsyntax-only -Ilib/ client.c
//
// Test with PCH.
// RUN: %clang_cc1 -emit-pch -o pch -Ilib/ client.c
// RUN: %clang_cc1 -include-pch pch -Ilib/ client.c -fsyntax-only

File diff suppressed because it is too large Load Diff

11
test/Sema/Float16.c Normal file
View File

@ -0,0 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
#ifdef HAVE
// expected-no-diagnostics
#else
// expected-error@+2{{_Float16 is not supported on this target}}
#endif // HAVE
_Float16 f;

18
test/SemaCXX/Float16.cpp Normal file
View File

@ -0,0 +1,18 @@
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
#ifdef HAVE
// expected-no-diagnostics
#endif // HAVE
#ifndef HAVE
// expected-error@+2{{_Float16 is not supported on this target}}
#endif // !HAVE
_Float16 f;
#ifndef HAVE
// expected-error@+2{{invalid suffix 'F16' on floating constant}}
#endif // !HAVE
const auto g = 1.1F16;

16
test/SemaCXX/PR40395.cpp Normal file
View File

@ -0,0 +1,16 @@
// RUN: %clang_cc1 -std=c++17 -fms-extensions -triple=x86_64-pc-win32 -verify %s
// expected-no-diagnostics
// PR40395 - ConstantExpr shouldn't cause the template object to infinitely
// expand.
struct _GUID {};
struct __declspec(uuid("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}")) B {};
template <const _GUID* piid>
struct A {
virtual void baz() { A<piid>(); }
};
void f() {
A<&__uuidof(B)>();
}

View File

@ -81,4 +81,21 @@ struct PR37352 {
void f() { static auto [a] = *this; } // expected-error {{cannot be declared 'static'}}
};
namespace instantiate_template {
template <typename T1, typename T2>
struct pair {
T1 a;
T2 b;
};
const pair<int, int> &f1();
int f2() {
const auto &[a, b] = f1();
return a + b;
}
} // namespace instantiate_template
// FIXME: by-value array copies

View File

@ -1,9 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -xc %s
#ifdef __OBJC__
#if !__has_feature(objc_fixed_enum)
# error Enumerations with a fixed underlying type are not supported
#endif
#endif
#if !__has_extension(cxx_fixed_enum)
# error Enumerations with a fixed underlying type are not supported

View File

@ -1,13 +1,14 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
// Make sure warnings are produced based on printf format strings.
// FIXME: Make sure warnings are produced based on printf format strings.
// expected-no-diagnostics
kernel void format_string_warnings(__constant char* arg) {
printf("%d", arg); // expected-warning {{format specifies type 'int' but the argument has type '__constant char *'}}
printf("%d", arg);
printf("not enough arguments %d %d", 4); // expected-warning {{more '%' conversions than data arguments}}
printf("not enough arguments %d %d", 4);
printf("too many arguments", 4); // expected-warning {{data argument not used by format string}}
printf("too many arguments", 4);
}

View File

@ -13,10 +13,10 @@ int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)))
kernel void format_v4f32(float4 arg)
{
#ifdef cl_khr_fp64
printf("%v4f\n", arg);
printf("%v4f\n", arg); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
// Precision modifier
printf("%.2v4f\n", arg);
printf("%.2v4f\n", arg); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
#else
// FIXME: These should not warn, and the type should be expected to be float.
printf("%v4f\n", arg); // expected-warning {{double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}

View File

@ -222,33 +222,6 @@ TEST_F(FileManagerTest, getFileReturnsNULLForNonexistentFile) {
EXPECT_EQ(nullptr, file);
}
// When calling getFile(OpenFile=false); getFile(OpenFile=true) the file is
// opened for the second call.
TEST_F(FileManagerTest, getFileDefersOpen) {
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
new llvm::vfs::InMemoryFileSystem());
FS->addFile("/tmp/test", 0, llvm::MemoryBuffer::getMemBufferCopy("test"));
FS->addFile("/tmp/testv", 0, llvm::MemoryBuffer::getMemBufferCopy("testv"));
FileManager manager(options, FS);
const FileEntry *file = manager.getFile("/tmp/test", /*OpenFile=*/false);
ASSERT_TRUE(file != nullptr);
ASSERT_TRUE(file->isValid());
// "real path name" reveals whether the file was actually opened.
EXPECT_FALSE(file->isOpenForTests());
file = manager.getFile("/tmp/test", /*OpenFile=*/true);
ASSERT_TRUE(file != nullptr);
ASSERT_TRUE(file->isValid());
EXPECT_TRUE(file->isOpenForTests());
// However we should never try to open a file previously opened as virtual.
ASSERT_TRUE(manager.getVirtualFile("/tmp/testv", 5, 0));
ASSERT_TRUE(manager.getFile("/tmp/testv", /*OpenFile=*/false));
file = manager.getFile("/tmp/testv", /*OpenFile=*/true);
EXPECT_FALSE(file->isOpenForTests());
}
// The following tests apply to Unix-like system only.
#ifndef _WIN32

View File

@ -450,6 +450,37 @@ TEST(ClangToolTest, StripDependencyFileAdjuster) {
EXPECT_TRUE(HasFlag("-w"));
}
// Check getClangStripPluginsAdjuster strips plugin related args.
TEST(ClangToolTest, StripPluginsAdjuster) {
FixedCompilationDatabase Compilations(
"/", {"-Xclang", "-add-plugin", "-Xclang", "random-plugin"});
ClangTool Tool(Compilations, std::vector<std::string>(1, "/a.cc"));
Tool.mapVirtualFile("/a.cc", "void a() {}");
std::unique_ptr<FrontendActionFactory> Action(
newFrontendActionFactory<SyntaxOnlyAction>());
CommandLineArguments FinalArgs;
ArgumentsAdjuster CheckFlagsAdjuster =
[&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
FinalArgs = Args;
return Args;
};
Tool.clearArgumentsAdjusters();
Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
Tool.run(Action.get());
auto HasFlag = [&FinalArgs](const std::string &Flag) {
return std::find(FinalArgs.begin(), FinalArgs.end(), Flag) !=
FinalArgs.end();
};
EXPECT_FALSE(HasFlag("-Xclang"));
EXPECT_FALSE(HasFlag("-add-plugin"));
EXPECT_FALSE(HasFlag("-random-plugin"));
}
namespace {
/// Find a target name such that looking for it in TargetRegistry by that name
/// returns the same target. We expect that there is at least one target