Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ the configuration (without a prefix: ``Auto``).
Use C++03-compatible syntax.

* ``LS_Cpp11`` (in configuration: ``Cpp11``)
Use features of C++11 (e.g. ``A<A<int>>`` instead of ``A<A<int> >``).
Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of
``A<A<int> >``).

* ``LS_Auto`` (in configuration: ``Auto``)
Automatic detection based on the input.
Expand Down
14 changes: 7 additions & 7 deletions include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class Driver {
llvm::opt::DerivedArgList *
TranslateInputArgs(const llvm::opt::InputArgList &Args) const;

// getFinalPhase - Determine which compilation mode we are in and record
// getFinalPhase - Determine which compilation mode we are in and record
// which option we used to determine the final phase.
phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
llvm::opt::Arg **FinalPhaseArg = nullptr) const;
Expand Down Expand Up @@ -347,12 +347,12 @@ class Driver {
/// ArgList.
llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args);

/// BuildInputs - Construct the list of inputs and their types from
/// BuildInputs - Construct the list of inputs and their types from
/// the given arguments.
///
/// \param TC - The default host tool chain.
/// \param Args - The input arguments.
/// \param Inputs - The list to store the resulting compilation
/// \param Inputs - The list to store the resulting compilation
/// inputs onto.
void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args,
InputList &Inputs) const;
Expand Down Expand Up @@ -389,9 +389,9 @@ class Driver {
int ExecuteCompilation(Compilation &C,
SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands);

/// generateCompilationDiagnostics - Generate diagnostics information
/// generateCompilationDiagnostics - Generate diagnostics information
/// including preprocessed source file(s).
///
///
void generateCompilationDiagnostics(Compilation &C,
const Command &FailingCommand);

Expand Down Expand Up @@ -461,7 +461,7 @@ class Driver {
/// \param JA - The action of interest.
/// \param BaseInput - The original input file that this action was
/// triggered by.
/// \param BoundArch - The bound architecture.
/// \param BoundArch - The bound architecture.
/// \param AtTopLevel - Whether this is a "top-level" action.
/// \param MultipleArchs - Whether multiple -arch options were supplied.
/// \param NormalizedTriple - The normalized triple of the relevant target.
Expand All @@ -470,7 +470,7 @@ class Driver {
bool AtTopLevel, bool MultipleArchs,
StringRef NormalizedTriple) const;

/// GetTemporaryPath - Return the pathname of a temporary file to use
/// GetTemporaryPath - Return the pathname of a temporary file to use
/// as part of compilation; the file will have the given prefix and suffix.
///
/// GCC goes to extra lengths here to be a bit more robust.
Expand Down
3 changes: 2 additions & 1 deletion include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ struct FormatStyle {
enum LanguageStandard {
/// Use C++03-compatible syntax.
LS_Cpp03,
/// Use features of C++11 (e.g. ``A<A<int>>`` instead of ``A<A<int> >``).
/// Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of
/// ``A<A<int> >``).
LS_Cpp11,
/// Automatic detection based on the input.
LS_Auto
Expand Down
21 changes: 16 additions & 5 deletions lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,18 +545,20 @@ class OpenBSDTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("__ELF__");
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
if (this->HasFloat128)
Builder.defineMacro("__FLOAT128__");
}
public:
OpenBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: OSTargetInfo<Target>(Triple, Opts) {
this->TLSSupported = false;

switch (Triple.getArch()) {
default:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
case llvm::Triple::arm:
case llvm::Triple::sparc:
this->HasFloat128 = true;
// FALLTHROUGH
default:
this->MCountName = "__mcount";
break;
case llvm::Triple::mips64:
Expand Down Expand Up @@ -5144,6 +5146,8 @@ class ARMTargetInfo : public TargetInfo {
default:
if (Triple.getOS() == llvm::Triple::NetBSD)
setABI("apcs-gnu");
else if (Triple.getOS() == llvm::Triple::OpenBSD)
setABI("aapcs-linux");
else
setABI("aapcs");
break;
Expand Down Expand Up @@ -5925,7 +5929,8 @@ class AArch64TargetInfo : public TargetInfo {
public:
AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: TargetInfo(Triple), ABI("aapcs") {
if (getTriple().getOS() == llvm::Triple::NetBSD) {
if (getTriple().getOS() == llvm::Triple::NetBSD ||
getTriple().getOS() == llvm::Triple::OpenBSD) {
WCharType = SignedInt;

// NetBSD apparently prefers consistency across ARM targets to consistency
Expand Down Expand Up @@ -7535,7 +7540,11 @@ class MipsTargetInfo : public TargetInfo {

void setN64ABITypes() {
setN32N64ABITypes();
Int64Type = SignedLong;
if (getTriple().getOS() == llvm::Triple::OpenBSD) {
Int64Type = SignedLongLong;
} else {
Int64Type = SignedLong;
}
IntMaxType = Int64Type;
LongWidth = LongAlign = 64;
PointerWidth = PointerAlign = 64;
Expand Down Expand Up @@ -8574,6 +8583,8 @@ static TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new LinuxTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::OpenBSD:
return new OpenBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
default:
return new AArch64leTargetInfo(Triple, Opts);
}
Expand Down
20 changes: 14 additions & 6 deletions lib/CodeGen/CGExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,20 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType,
currentElement->addIncoming(element, entryBB);

// Emit the actual filler expression.
LValue elementLV =
CGF.MakeAddrLValue(Address(currentElement, elementAlign), elementType);
if (filler)
EmitInitializationToLValue(filler, elementLV);
else
EmitNullInitializationToLValue(elementLV);
{
// C++1z [class.temporary]p5:
// when a default constructor is called to initialize an element of
// an array with no corresponding initializer [...] the destruction of
// every temporary created in a default argument is sequenced before
// the construction of the next array element, if any
CodeGenFunction::RunCleanupsScope CleanupsScope(CGF);
LValue elementLV =
CGF.MakeAddrLValue(Address(currentElement, elementAlign), elementType);
if (filler)
EmitInitializationToLValue(filler, elementLV);
else
EmitNullInitializationToLValue(elementLV);
}

// Move on to the next element.
llvm::Value *nextElement =
Expand Down
1 change: 1 addition & 0 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void Driver::setDriverModeFromOption(StringRef Opt) {
if (!Opt.startswith(OptName))
return;
StringRef Value = Opt.drop_front(OptName.size());

const unsigned M = llvm::StringSwitch<unsigned>(Value)
.Case("gcc", GCCMode)
.Case("g++", GXXMode)
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args,
StringRef Suffix =
tools::arm::getLLVMArchSuffixForARM(CPU, MArch, Triple);
bool IsMProfile = ARM::parseArchProfile(Suffix) == ARM::PK_M;
bool ThumbDefault = IsMProfile || (ARM::parseArchVersion(Suffix) == 7 &&
bool ThumbDefault = IsMProfile || (ARM::parseArchVersion(Suffix) == 7 &&
getTriple().isOSBinFormatMachO());
// FIXME: this is invalid for WindowsCE
if (getTriple().isOSWindows())
Expand Down
12 changes: 10 additions & 2 deletions lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,10 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
}
break;

case llvm::Triple::OpenBSD:
ABI = FloatABI::Soft;
break;

default:
switch (Triple.getEnvironment()) {
case llvm::Triple::GNUEABIHF:
Expand Down Expand Up @@ -1285,6 +1289,8 @@ void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
default:
if (Triple.getOS() == llvm::Triple::NetBSD)
ABIName = "apcs-gnu";
else if (Triple.getOS() == llvm::Triple::OpenBSD)
ABIName = "aapcs-linux";
else
ABIName = "aapcs";
break;
Expand Down Expand Up @@ -3879,16 +3885,18 @@ ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) {
// OpenBSD-specific defaults for PIE
if (Triple.getOS() == llvm::Triple::OpenBSD) {
switch (ToolChain.getArch()) {
case llvm::Triple::arm:
case llvm::Triple::aarch64:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::sparcel:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
IsPICLevelTwo = false; // "-fpie"
break;

case llvm::Triple::ppc:
case llvm::Triple::sparc:
case llvm::Triple::sparcel:
case llvm::Triple::sparcv9:
IsPICLevelTwo = true; // "-fPIE"
break;
Expand Down Expand Up @@ -9690,12 +9698,12 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("__start");
}

CmdArgs.push_back("--eh-frame-hdr");
if (Args.hasArg(options::OPT_static)) {
CmdArgs.push_back("-Bstatic");
} else {
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
CmdArgs.push_back("--eh-frame-hdr");
CmdArgs.push_back("-Bdynamic");
if (Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back("-shared");
Expand Down
1 change: 1 addition & 0 deletions lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) {
LangOpts.CPlusPlus = 1;
LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
LangOpts.CPlusPlus1z = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
LangOpts.LineComment = 1;
bool AlternativeOperators = Style.Language == FormatStyle::LK_Cpp;
LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;
Expand Down
12 changes: 6 additions & 6 deletions lib/Headers/avx512fintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7860,12 +7860,12 @@ _mm512_mask_cvtepi64_storeu_epi16 (void *__P, __mmask8 __M, __m512i __A)
3 + ((imm) & 0x3) * 4); })

#define _mm512_mask_extracti32x4_epi32(W, U, A, imm) __extension__ ({ \
(__m128i)__builtin_ia32_selectd_128((__mmask8)__U, \
(__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \
(__v4si)_mm512_extracti32x4_epi32((A), (imm)), \
(__v4si)__W); })
(__v4si)(W)); })

#define _mm512_maskz_extracti32x4_epi32(U, A, imm) __extension__ ({ \
(__m128i)__builtin_ia32_selectd_128((__mmask8)__U, \
(__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \
(__v4si)_mm512_extracti32x4_epi32((A), (imm)), \
(__v4si)_mm_setzero_si128()); })

Expand All @@ -7878,12 +7878,12 @@ _mm512_mask_cvtepi64_storeu_epi16 (void *__P, __mmask8 __M, __m512i __A)
((imm) & 1) ? 7 : 3); })

#define _mm512_mask_extracti64x4_epi64(W, U, A, imm) __extension__ ({ \
(__m256i)__builtin_ia32_selectq_256((__mmask8)__U, \
(__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \
(__v4di)_mm512_extracti64x4_epi64((A), (imm)), \
(__v4di)__W); })
(__v4di)(W)); })

#define _mm512_maskz_extracti64x4_epi64(U, A, imm) __extension__ ({ \
(__m256i)__builtin_ia32_selectq_256((__mmask8)__U, \
(__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \
(__v4di)_mm512_extracti64x4_epi64((A), (imm)), \
(__v4di)_mm256_setzero_si256()); })

Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11659,7 +11659,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
Context.getLangOpts().OpenCLVersion < 120) {
// OpenCL v1.1 6.3.h: The logical operator not (!) does not
// operate on scalar float types.
if (!resultType->isIntegerType())
if (!resultType->isIntegerType() && !resultType->isPointerType())
return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
<< resultType << Input.get()->getSourceRange());
}
Expand Down
36 changes: 36 additions & 0 deletions test/CodeGenCXX/array-default-argument.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// RUN: %clang_cc1 -emit-llvm -o - %s -triple %itanium_abi_triple | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -o - %s -triple %itanium_abi_triple -std=c++98 -fexceptions -fcxx-exceptions | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-EH

struct A {
A();
~A();
};

struct B {
B(A = A());
~B();
};

void f();
// CHECK-LABEL: define void @_Z1gv()
void g() {
// CHECK: br label %[[LOOP:.*]]

// [[LOOP]]:
// CHECK: {{call|invoke}} {{.*}} @_ZN1AC1Ev([[TEMPORARY:.*]])
// CHECK-EH: unwind label %[[PARTIAL_ARRAY_LPAD:.*]]
// CHECK: {{call|invoke}} {{.*}} @_ZN1BC1E1A({{.*}}, [[TEMPORARY]])
// CHECK-EH: unwind label %[[A_AND_PARTIAL_ARRAY_LPAD:.*]]
// CHECK: {{call|invoke}} {{.*}} @_ZN1AD1Ev([[TEMPORARY]])
// CHECK-EH: unwind label %[[PARTIAL_ARRAY_LPAD]]
// CHECK: getelementptr {{.*}}, i{{[0-9]*}} 1
// CHECK: icmp eq
// CHECK: br i1 {{.*}} label %[[LOOP]]
B b[5];

// CHECK: {{call|invoke}} void @_Z1fv()
f();

// CHECK-NOT: @_ZN1AD1Ev(
// CHECK: {{call|invoke}} {{.*}} @_ZN1BD1Ev(
}
4 changes: 4 additions & 0 deletions test/CodeGenCXX/float128-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple systemz-unknown-linux-gnu -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-SYSZ
// RUN: %clang_cc1 -emit-llvm -triple i686-pc-openbsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
//
/* Various contexts where type __float128 can appear. The different check
prefixes are due to different mangling on X86 and different calling
Expand Down
4 changes: 4 additions & 0 deletions test/Driver/arm-abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
// RUN: %clang -target arm--netbsd-eabihf %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-AAPCS %s

// OpenBSD defaults to aapcs-linux
// RUN: %clang -target arm--openbsd- %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s

// Otherwise, ABI is selected based on environment
// RUN: %clang -target arm---android %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
Expand Down
11 changes: 11 additions & 0 deletions test/Driver/openbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
// CHECK-LD: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
// CHECK-LD: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"

// Check for --eh-frame-hdr being passed with static linking
// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LD-STATIC-EH %s
// CHECK-LD-STATIC-EH: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
// CHECK-LD-STATIC-EH: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bstatic" "-o" "a.out" "{{.*}}rcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"

// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pg -pthread %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-PG %s
// CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
Expand Down Expand Up @@ -90,3 +96,8 @@
// CHECK-STATIC-PIE: "{{.*}}rcrt0.o"
// CHECK-STATIC-PIE-NOT: "-nopie"
// CHECK-NOPIE: "-nopie" "{{.*}}crt0.o"

// Check ARM float ABI
// RUN: %clang -target arm-unknown-openbsd -### -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ARM-FLOAT-ABI %s
// CHECK-ARM-FLOAT-ABI: "-mfloat-abi" "soft"
4 changes: 4 additions & 0 deletions test/Driver/pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@
// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
// RUN: %clang -c %s -target i386-pc-openbsd -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
// RUN: %clang -c %s -target aarch64-unknown-openbsd -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
// RUN: %clang -c %s -target arm-unknown-openbsd -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
// RUN: %clang -c %s -target mips64-unknown-openbsd -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
// RUN: %clang -c %s -target mips64el-unknown-openbsd -### 2>&1 \
Expand Down
2 changes: 1 addition & 1 deletion test/Frontend/gnu-mcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int f() {
// CHECK-ARM-EABI-NETBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
// CHECK-ARM-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
// CHECK-ARM-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
// CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
// CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
// CHECK-ARM64-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
// CHECK-ARM-EABI-MEABI-GNU-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
// CHECK-ARM-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
Expand Down
Loading