namespace Namespace
Namespaces
Records
Functions
@@ -196,14 +196,14 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
Records
Functions
diff --git a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
index 67217393444648..006fde08c5c4c8 100644
--- a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@ TEST(MDGeneratorTest, emitNamespaceMD) {
## Namespaces
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
## Records
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
## Functions
@@ -106,7 +104,7 @@ TEST(MDGeneratorTest, emitRecordMD) {
assert(!Err);
std::string Expected = R"raw(# class r
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
Inherits from F, G
@@ -171,7 +169,7 @@ TEST(MDGeneratorTest, emitFunctionMD) {
*void f(int P)*
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
)raw";
@@ -202,7 +200,7 @@ TEST(MDGeneratorTest, emitEnumMD) {
| X |
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
)raw";
@@ -331,7 +329,7 @@ TEST(MDGeneratorTest, emitCommentMD) {
*void f(int I, int J)*
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index dca7aa5c2cf783..f0faed7f0f8f76 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2157,7 +2157,21 @@
Narrowing Matchers
Example 2: matches s1 = s2
(matcher = cxxOperatorCallExpr(isAssignmentOperator()))
struct S { S& operator=(const S&); };
- void x() { S s1, s2; s1 = s2; })
+ void x() { S s1, s2; s1 = s2; }
+
+
+
+
Matcher<BinaryOperator> | isComparisonOperator | |
+
Matches comparison operators.
+
+Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
+ if (a == b)
+ a += b;
+
+Example 2: matches s1 < s2
+ (matcher = cxxOperatorCallExpr(isComparisonOperator()))
+ struct S { bool operator<(const S& other); };
+ void x(S s1, S s2) { bool b1 = s1 < s2; }
|
@@ -2616,7 +2630,21 @@
Narrowing Matchers
Example 2: matches s1 = s2
(matcher = cxxOperatorCallExpr(isAssignmentOperator()))
struct S { S& operator=(const S&); };
- void x() { S s1, s2; s1 = s2; })
+ void x() { S s1, s2; s1 = s2; }
+
+
+
+
Matcher<CXXOperatorCallExpr> | isComparisonOperator | |
+
Matches comparison operators.
+
+Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
+ if (a == b)
+ a += b;
+
+Example 2: matches s1 < s2
+ (matcher = cxxOperatorCallExpr(isComparisonOperator()))
+ struct S { bool operator<(const S& other); };
+ void x(S s1, S s2) { bool b1 = s1 < s2; }
|
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index cea360d12e91ee..2bd68eec175ac3 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -118,6 +118,22 @@ class CXXOperatorCallExpr final : public CallExpr {
}
bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
+ static bool isComparisonOp(OverloadedOperatorKind Opc) {
+ switch (Opc) {
+ case OO_EqualEqual:
+ case OO_ExclaimEqual:
+ case OO_Greater:
+ case OO_GreaterEqual:
+ case OO_Less:
+ case OO_LessEqual:
+ case OO_Spaceship:
+ return true;
+ default:
+ return false;
+ }
+ }
+ bool isComparisonOp() const { return isComparisonOp(getOperator()); }
+
/// Is this written as an infix binary operator?
bool isInfixBinaryOp() const;
diff --git a/clang/include/clang/AST/GlobalDecl.h b/clang/include/clang/AST/GlobalDecl.h
index 145e961a23a389..0945ebb56a489b 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -35,10 +35,18 @@ enum class DynamicInitKind : unsigned {
/// GlobalDecl - represents a global declaration. This can either be a
/// CXXConstructorDecl and the constructor type (Base, Complete).
-/// a CXXDestructorDecl and the destructor type (Base, Complete) or
+/// a CXXDestructorDecl and the destructor type (Base, Complete),
+/// a FunctionDecl and the kernel reference type (Kernel, Stub), or
/// a VarDecl, a FunctionDecl or a BlockDecl.
+///
+/// When a new type of GlobalDecl is added, the following places should
+/// be updated to convert a Decl* to a GlobalDecl:
+/// PredefinedExpr::ComputeName() in lib/AST/Expr.cpp.
+/// getParentOfLocalEntity() in lib/AST/ItaniumMangle.cpp
+/// ASTNameGenerator::Implementation::writeFuncOrVarName in lib/AST/Mangle.cpp
+///
class GlobalDecl {
- llvm::PointerIntPair
Value;
+ llvm::PointerIntPair Value;
unsigned MultiVersionIndex = 0;
void Init(const Decl *D) {
@@ -55,6 +63,7 @@ class GlobalDecl {
: MultiVersionIndex(MVIndex) {
Init(D);
}
+ GlobalDecl(const NamedDecl *D) { Init(D); }
GlobalDecl(const BlockDecl *D) { Init(D); }
GlobalDecl(const CapturedDecl *D) { Init(D); }
GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
@@ -108,6 +117,8 @@ class GlobalDecl {
void *getAsOpaquePtr() const { return Value.getOpaqueValue(); }
+ explicit operator bool() const { return getAsOpaquePtr(); }
+
static GlobalDecl getFromOpaquePtr(void *P) {
GlobalDecl GD;
GD.Value.setFromOpaqueValue(P);
diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h
index 5db5c5b977da56..39e4f2335deb2b 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -14,6 +14,7 @@
#define LLVM_CLANG_AST_MANGLE_H
#include "clang/AST/Decl.h"
+#include "clang/AST/GlobalDecl.h"
#include "clang/AST/Type.h"
#include "clang/Basic/ABI.h"
#include "llvm/ADT/DenseMap.h"
@@ -96,8 +97,8 @@ class MangleContext {
virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0;
// FIXME: consider replacing raw_ostream & with something like SmallString &.
- void mangleName(const NamedDecl *D, raw_ostream &);
- virtual void mangleCXXName(const NamedDecl *D, raw_ostream &) = 0;
+ void mangleName(GlobalDecl GD, raw_ostream &);
+ virtual void mangleCXXName(GlobalDecl GD, raw_ostream &) = 0;
virtual void mangleThunk(const CXXMethodDecl *MD,
const ThunkInfo &Thunk,
raw_ostream &) = 0;
@@ -109,10 +110,6 @@ class MangleContext {
raw_ostream &) = 0;
virtual void mangleCXXRTTI(QualType T, raw_ostream &) = 0;
virtual void mangleCXXRTTIName(QualType T, raw_ostream &) = 0;
- virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
- raw_ostream &) = 0;
- virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
- raw_ostream &) = 0;
virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &) = 0;
void mangleGlobalBlock(const BlockDecl *BD,
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index da7e23052b288a..31138e47750c57 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4783,7 +4783,7 @@ extern const internal::VariadicFunction<
/// (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
/// \code
/// struct S { S& operator=(const S&); };
-/// void x() { S s1, s2; s1 = s2; })
+/// void x() { S s1, s2; s1 = s2; }
/// \endcode
AST_POLYMORPHIC_MATCHER(isAssignmentOperator,
AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator,
@@ -4791,6 +4791,26 @@ AST_POLYMORPHIC_MATCHER(isAssignmentOperator,
return Node.isAssignmentOp();
}
+/// Matches comparison operators.
+///
+/// Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
+/// \code
+/// if (a == b)
+/// a += b;
+/// \endcode
+///
+/// Example 2: matches s1 < s2
+/// (matcher = cxxOperatorCallExpr(isComparisonOperator()))
+/// \code
+/// struct S { bool operator<(const S& other); };
+/// void x(S s1, S s2) { bool b1 = s1 < s2; }
+/// \endcode
+AST_POLYMORPHIC_MATCHER(isComparisonOperator,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator,
+ CXXOperatorCallExpr)) {
+ return Node.isComparisonOp();
+}
+
/// Matches the left hand side of binary operator expressions.
///
/// Example matches a (matcher = binaryOperator(hasLHS()))
diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 0574af395f7b1d..b544e3b42137bc 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -98,6 +98,19 @@ TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i8x16, "V16cV16cV16c", "nc", "simd1
TARGET_BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_s_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_u_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_s_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_u_i8x16, "V16cV16cV16c", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_s_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_u_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_s_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_u_i16x8, "V8sV8sV8s", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_s_i32x4, "V4iV4iV4i", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_min_u_i32x4, "V4iV4iV4i", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_s_i32x4, "V4iV4iV4i", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_max_u_i32x4, "V4iV4iV4i", "nc", "simd128")
+
TARGET_BUILTIN(__builtin_wasm_avgr_u_i8x16, "V16cV16cV16c", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_avgr_u_i16x8, "V8sV8sV8s", "nc", "simd128")
diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h
index 0a28edefa1e657..d435bebcdcf97d 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -164,10 +164,10 @@ class CodeGenOptions : public CodeGenOptionsBase {
std::string FloatABI;
/// The floating-point denormal mode to use.
- llvm::DenormalMode FPDenormalMode;
+ llvm::DenormalMode FPDenormalMode = llvm::DenormalMode::getIEEE();
- /// The floating-point subnormal mode to use, for float.
- llvm::DenormalMode FP32DenormalMode;
+ /// The floating-point denormal mode to use, for float.
+ llvm::DenormalMode FP32DenormalMode = llvm::DenormalMode::getIEEE();
/// The float precision limit to use, if non-empty.
std::string LimitFloatPrecision;
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 6c79ea59173449..ae3f882dd91055 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -838,9 +838,13 @@ def IncompatibleExceptionSpec : DiagGroup<"incompatible-exception-spec">;
def IntToVoidPointerCast : DiagGroup<"int-to-void-pointer-cast">;
def IntToPointerCast : DiagGroup<"int-to-pointer-cast",
[IntToVoidPointerCast]>;
-def VoidPointerToIntCast : DiagGroup<"void-pointer-to-int-cast">;
+def VoidPointerToEnumCast : DiagGroup<"void-pointer-to-enum-cast">;
+def VoidPointerToIntCast : DiagGroup<"void-pointer-to-int-cast",
+ [VoidPointerToEnumCast]>;
+def PointerToEnumCast : DiagGroup<"pointer-to-enum-cast",
+ [VoidPointerToEnumCast]>;
def PointerToIntCast : DiagGroup<"pointer-to-int-cast",
- [VoidPointerToIntCast]>;
+ [PointerToEnumCast, VoidPointerToIntCast]>;
def Move : DiagGroup<"move", [
PessimizingMove,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e6155d5d0e1018..b0338c44cca96c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2424,20 +2424,19 @@ def note_for_range_invalid_iterator : Note <
"in implicit call to 'operator%select{!=|*|++}0' for iterator of type %1">;
def note_for_range_begin_end : Note<
"selected '%select{begin|end}0' %select{function|template }1%2 with iterator type %3">;
-def warn_for_range_const_reference_copy : Warning<
+def warn_for_range_const_ref_binds_temp_built_from_ref : Warning<
"loop variable %0 "
- "%diff{has type $ but is initialized with type $"
- "|is initialized with a value of a different type}1,2 resulting in a copy">,
+ "%diff{of type $ binds to a temporary constructed from type $"
+ "|binds to a temporary constructed from a different type}1,2">,
InGroup, DefaultIgnore;
def note_use_type_or_non_reference : Note<
- "use non-reference type %0 to keep the copy or type %1 to prevent copying">;
-def warn_for_range_variable_always_copy : Warning<
- "loop variable %0 is always a copy because the range of type %1 does not "
- "return a reference">,
+ "use non-reference type %0 to make construction explicit or type %1 to prevent copying">;
+def warn_for_range_ref_binds_ret_temp : Warning<
+ "loop variable %0 binds to a temporary value produced by a range of type %1">,
InGroup, DefaultIgnore;
def note_use_non_reference_type : Note<"use non-reference type %0">;
def warn_for_range_copy : Warning<
- "loop variable %0 of type %1 creates a copy from type %2">,
+ "loop variable %0 creates a copy from type %1">,
InGroup, DefaultIgnore;
def note_use_reference_type : Note<"use reference type %0 to prevent copying">;
def err_objc_for_range_init_stmt : Error<
@@ -3669,9 +3668,15 @@ def warn_int_to_void_pointer_cast : Warning<
def warn_pointer_to_int_cast : Warning<
"cast to smaller integer type %1 from %0">,
InGroup;
+def warn_pointer_to_enum_cast : Warning<
+ warn_pointer_to_int_cast.Text>,
+ InGroup;
def warn_void_pointer_to_int_cast : Warning<
"cast to smaller integer type %1 from %0">,
InGroup;
+def warn_void_pointer_to_enum_cast : Warning<
+ warn_void_pointer_to_int_cast.Text>,
+ InGroup;
def ext_ms_pointer_to_int_cast : ExtWarn<
"cast to smaller integer type %1 from %0 is a Microsoft extension">,
InGroup;
@@ -9634,7 +9639,7 @@ def err_omp_expected_var_name_member_expr : Error<
def err_omp_expected_var_name_member_expr_or_array_item : Error<
"expected variable name%select{|, data member of current class}0, array element or array section">;
def err_omp_expected_addressable_lvalue_or_array_item : Error<
- "expected addressable lvalue expression, array element or array section">;
+ "expected addressable lvalue expression, array element or array section%select{| of non 'omp_depend_t' type}0">;
def err_omp_expected_named_var_member_or_array_expression: Error<
"expected expression containing only member accesses and/or array sections based on named variables">;
def err_omp_bit_fields_forbidden_in_clause : Error<
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index 3cc7c384ac1066..53b87b73756894 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -230,7 +230,9 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions for HIP")
LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for kernel launch bounds for HIP")
+LANGOPT(SYCL , 1, 0, "SYCL")
LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device")
+LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used")
LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
diff --git a/clang/include/clang/Basic/OpenMPKinds.def b/clang/include/clang/Basic/OpenMPKinds.def
index dbc0d1cec2c75b..70f962427e36c0 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -384,6 +384,7 @@ OPENMP_DEPEND_KIND(in)
OPENMP_DEPEND_KIND(out)
OPENMP_DEPEND_KIND(inout)
OPENMP_DEPEND_KIND(mutexinoutset)
+OPENMP_DEPEND_KIND(depobj)
OPENMP_DEPEND_KIND(source)
OPENMP_DEPEND_KIND(sink)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 2aaf85434214fa..0d5cba8d682aea 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3422,10 +3422,12 @@ defm underscoring : BooleanFFlag<"underscoring">, Group;
defm whole_file : BooleanFFlag<"whole-file">, Group;
// C++ SYCL options
-def fsycl : Flag<["-"], "fsycl">, Group,
+def fsycl : Flag<["-"], "fsycl">, Group, Flags<[CC1Option, CoreOption]>,
HelpText<"Enable SYCL kernels compilation for device">;
-def fno_sycl : Flag<["-"], "fno-sycl">, Group,
+def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>,
HelpText<"Disable SYCL kernels compilation for device">;
+def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
+ HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 1.2.1, sycl-1.2.1">;
include "CC1Options.td"
diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h
index 400ff9d86664bd..88ce205228fd9d 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -623,8 +623,7 @@ class ToolChain {
const llvm::opt::ArgList &DriverArgs,
Action::OffloadKind DeviceOffloadKind,
const llvm::fltSemantics *FPType = nullptr) const {
- // FIXME: This should be IEEE when default handling is fixed.
- return llvm::DenormalMode::getInvalid();
+ return llvm::DenormalMode::getIEEE();
}
};
diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h
index f1a8b98e5efdcc..6944b0b5756e0c 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -908,7 +908,7 @@ class Sema;
private:
friend class OverloadCandidateSet;
OverloadCandidate()
- : IsADLCandidate(CallExpr::NotADL), RewriteKind(CRK_None) {}
+ : IsSurrogate(false), IsADLCandidate(CallExpr::NotADL), RewriteKind(CRK_None) {}
};
/// OverloadCandidateSet - A set of overload candidates, used in C++
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 79f9f42224d083..3377afccb5e6e5 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -650,12 +650,14 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {
if (MC->shouldMangleDeclName(ND)) {
SmallString<256> Buffer;
llvm::raw_svector_ostream Out(Buffer);
+ GlobalDecl GD;
if (const CXXConstructorDecl *CD = dyn_cast(ND))
- MC->mangleCXXCtor(CD, Ctor_Base, Out);
+ GD = GlobalDecl(CD, Ctor_Base);
else if (const CXXDestructorDecl *DD = dyn_cast(ND))
- MC->mangleCXXDtor(DD, Dtor_Base, Out);
+ GD = GlobalDecl(DD, Dtor_Base);
else
- MC->mangleName(ND, Out);
+ GD = GlobalDecl(ND);
+ MC->mangleName(GD, Out);
if (!Buffer.empty() && Buffer.front() == '\01')
return std::string(Buffer.substr(1));
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 6d21869e2f1196..63e34653637ed9 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -135,7 +135,7 @@ class ItaniumMangleContextImpl : public ItaniumMangleContext {
bool shouldMangleStringLiteral(const StringLiteral *) override {
return false;
}
- void mangleCXXName(const NamedDecl *D, raw_ostream &) override;
+ void mangleCXXName(GlobalDecl GD, raw_ostream &) override;
void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk,
raw_ostream &) override;
void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type,
@@ -150,10 +150,6 @@ class ItaniumMangleContextImpl : public ItaniumMangleContext {
void mangleCXXRTTI(QualType T, raw_ostream &) override;
void mangleCXXRTTIName(QualType T, raw_ostream &) override;
void mangleTypeName(QualType T, raw_ostream &) override;
- void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
- raw_ostream &) override;
- void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
- raw_ostream &) override;
void mangleCXXCtorComdat(const CXXConstructorDecl *D, raw_ostream &) override;
void mangleCXXDtorComdat(const CXXDestructorDecl *D, raw_ostream &) override;
@@ -417,14 +413,14 @@ class CXXNameMangler {
void disableDerivedAbiTags() { DisableDerivedAbiTags = true; }
static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C, const VarDecl *VD);
- void mangle(const NamedDecl *D);
+ void mangle(GlobalDecl GD);
void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
void mangleNumber(const llvm::APSInt &I);
void mangleNumber(int64_t Number);
void mangleFloat(const llvm::APFloat &F);
- void mangleFunctionEncoding(const FunctionDecl *FD);
+ void mangleFunctionEncoding(GlobalDecl GD);
void mangleSeqID(unsigned SeqID);
- void mangleName(const NamedDecl *ND);
+ void mangleName(GlobalDecl GD);
void mangleType(QualType T);
void mangleNameOrStandardSubstitution(const NamedDecl *ND);
void mangleLambdaSig(const CXXRecordDecl *Lambda);
@@ -461,24 +457,24 @@ class CXXNameMangler {
void mangleFunctionEncodingBareType(const FunctionDecl *FD);
- void mangleNameWithAbiTags(const NamedDecl *ND,
+ void mangleNameWithAbiTags(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags);
void mangleModuleName(const Module *M);
void mangleModuleNamePrefix(StringRef Name);
void mangleTemplateName(const TemplateDecl *TD,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs);
- void mangleUnqualifiedName(const NamedDecl *ND,
+ void mangleUnqualifiedName(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags) {
- mangleUnqualifiedName(ND, ND->getDeclName(), UnknownArity,
+ mangleUnqualifiedName(GD, cast(GD.getDecl())->getDeclName(), UnknownArity,
AdditionalAbiTags);
}
- void mangleUnqualifiedName(const NamedDecl *ND, DeclarationName Name,
+ void mangleUnqualifiedName(GlobalDecl GD, DeclarationName Name,
unsigned KnownArity,
const AbiTagList *AdditionalAbiTags);
- void mangleUnscopedName(const NamedDecl *ND,
+ void mangleUnscopedName(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags);
- void mangleUnscopedTemplateName(const TemplateDecl *ND,
+ void mangleUnscopedTemplateName(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags);
void mangleUnscopedTemplateName(TemplateName,
const AbiTagList *AdditionalAbiTags);
@@ -486,13 +482,13 @@ class CXXNameMangler {
void mangleRegCallName(const IdentifierInfo *II);
void mangleSourceNameWithAbiTags(
const NamedDecl *ND, const AbiTagList *AdditionalAbiTags = nullptr);
- void mangleLocalName(const Decl *D,
+ void mangleLocalName(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags);
void mangleBlockForPrefix(const BlockDecl *Block);
void mangleUnqualifiedBlock(const BlockDecl *Block);
void mangleTemplateParamDecl(const NamedDecl *Decl);
void mangleLambda(const CXXRecordDecl *Lambda);
- void mangleNestedName(const NamedDecl *ND, const DeclContext *DC,
+ void mangleNestedName(GlobalDecl GD, const DeclContext *DC,
const AbiTagList *AdditionalAbiTags,
bool NoFunction=false);
void mangleNestedName(const TemplateDecl *TD,
@@ -501,7 +497,7 @@ class CXXNameMangler {
void manglePrefix(NestedNameSpecifier *qualifier);
void manglePrefix(const DeclContext *DC, bool NoFunction=false);
void manglePrefix(QualType type);
- void mangleTemplatePrefix(const TemplateDecl *ND, bool NoFunction=false);
+ void mangleTemplatePrefix(GlobalDecl GD, bool NoFunction=false);
void mangleTemplatePrefix(TemplateName Template);
bool mangleUnresolvedTypeOrSimpleId(QualType DestroyedType,
StringRef Prefix = "");
@@ -640,34 +636,36 @@ void CXXNameMangler::mangleSourceNameWithAbiTags(
writeAbiTags(ND, AdditionalAbiTags);
}
-void CXXNameMangler::mangle(const NamedDecl *D) {
+void CXXNameMangler::mangle(GlobalDecl GD) {
// ::= _Z
// ::=
// ::=
Out << "_Z";
- if (const FunctionDecl *FD = dyn_cast(D))
- mangleFunctionEncoding(FD);
- else if (const VarDecl *VD = dyn_cast(D))
+ if (isa(GD.getDecl()))
+ mangleFunctionEncoding(GD);
+ else if (const VarDecl *VD = dyn_cast(GD.getDecl()))
mangleName(VD);
- else if (const IndirectFieldDecl *IFD = dyn_cast(D))
+ else if (const IndirectFieldDecl *IFD =
+ dyn_cast(GD.getDecl()))
mangleName(IFD->getAnonField());
else
- mangleName(cast(D));
+ mangleName(cast(GD.getDecl()));
}
-void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
+void CXXNameMangler::mangleFunctionEncoding(GlobalDecl GD) {
+ const FunctionDecl *FD = cast(GD.getDecl());
// ::=
// Don't mangle in the type if this isn't a decl we should typically mangle.
if (!Context.shouldMangleDeclName(FD)) {
- mangleName(FD);
+ mangleName(GD);
return;
}
AbiTagList ReturnTypeAbiTags = makeFunctionReturnTypeTags(FD);
if (ReturnTypeAbiTags.empty()) {
// There are no tags for return type, the simplest case.
- mangleName(FD);
+ mangleName(GD);
mangleFunctionEncodingBareType(FD);
return;
}
@@ -787,13 +785,14 @@ static bool isStdNamespace(const DeclContext *DC) {
return isStd(cast(DC));
}
-static const TemplateDecl *
-isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs) {
+static const GlobalDecl
+isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs) {
+ const NamedDecl *ND = cast(GD.getDecl());
// Check if we have a function template.
if (const FunctionDecl *FD = dyn_cast(ND)) {
if (const TemplateDecl *TD = FD->getPrimaryTemplate()) {
TemplateArgs = FD->getTemplateSpecializationArgs();
- return TD;
+ return GD.getWithDecl(TD);
}
}
@@ -801,20 +800,21 @@ isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs) {
if (const ClassTemplateSpecializationDecl *Spec =
dyn_cast(ND)) {
TemplateArgs = &Spec->getTemplateArgs();
- return Spec->getSpecializedTemplate();
+ return GD.getWithDecl(Spec->getSpecializedTemplate());
}
// Check if we have a variable template.
if (const VarTemplateSpecializationDecl *Spec =
dyn_cast(ND)) {
TemplateArgs = &Spec->getTemplateArgs();
- return Spec->getSpecializedTemplate();
+ return GD.getWithDecl(Spec->getSpecializedTemplate());
}
- return nullptr;
+ return GlobalDecl();
}
-void CXXNameMangler::mangleName(const NamedDecl *ND) {
+void CXXNameMangler::mangleName(GlobalDecl GD) {
+ const NamedDecl *ND = cast(GD.getDecl());
if (const VarDecl *VD = dyn_cast(ND)) {
// Variables should have implicit tags from its type.
AbiTagList VariableTypeAbiTags = makeVariableTypeTags(VD);
@@ -843,12 +843,13 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) {
// Output name with implicit tags.
mangleNameWithAbiTags(VD, &AdditionalAbiTags);
} else {
- mangleNameWithAbiTags(ND, nullptr);
+ mangleNameWithAbiTags(GD, nullptr);
}
}
-void CXXNameMangler::mangleNameWithAbiTags(const NamedDecl *ND,
+void CXXNameMangler::mangleNameWithAbiTags(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags) {
+ const NamedDecl *ND = cast(GD.getDecl());
// ::= []
// ::= []
// ::= []
@@ -864,14 +865,14 @@ void CXXNameMangler::mangleNameWithAbiTags(const NamedDecl *ND,
while (!DC->isNamespace() && !DC->isTranslationUnit())
DC = getEffectiveParentContext(DC);
else if (GetLocalClassDecl(ND)) {
- mangleLocalName(ND, AdditionalAbiTags);
+ mangleLocalName(GD, AdditionalAbiTags);
return;
}
DC = IgnoreLinkageSpecDecls(DC);
if (isLocalContainerContext(DC)) {
- mangleLocalName(ND, AdditionalAbiTags);
+ mangleLocalName(GD, AdditionalAbiTags);
return;
}
@@ -886,17 +887,17 @@ void CXXNameMangler::mangleNameWithAbiTags(const NamedDecl *ND,
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
// Check if we have a template.
const TemplateArgumentList *TemplateArgs = nullptr;
- if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
+ if (GlobalDecl TD = isTemplate(GD, TemplateArgs)) {
mangleUnscopedTemplateName(TD, AdditionalAbiTags);
mangleTemplateArgs(*TemplateArgs);
return;
}
- mangleUnscopedName(ND, AdditionalAbiTags);
+ mangleUnscopedName(GD, AdditionalAbiTags);
return;
}
- mangleNestedName(ND, DC, AdditionalAbiTags);
+ mangleNestedName(GD, DC, AdditionalAbiTags);
}
void CXXNameMangler::mangleModuleName(const Module *M) {
@@ -947,19 +948,21 @@ void CXXNameMangler::mangleTemplateName(const TemplateDecl *TD,
}
}
-void CXXNameMangler::mangleUnscopedName(const NamedDecl *ND,
+void CXXNameMangler::mangleUnscopedName(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags) {
+ const NamedDecl *ND = cast(GD.getDecl());
// ::=
// ::= St # ::std::
if (isStdNamespace(IgnoreLinkageSpecDecls(getEffectiveDeclContext(ND))))
Out << "St";
- mangleUnqualifiedName(ND, AdditionalAbiTags);
+ mangleUnqualifiedName(GD, AdditionalAbiTags);
}
void CXXNameMangler::mangleUnscopedTemplateName(
- const TemplateDecl *ND, const AbiTagList *AdditionalAbiTags) {
+ GlobalDecl GD, const AbiTagList *AdditionalAbiTags) {
+ const TemplateDecl *ND = cast(GD.getDecl());
// ::=
// ::=
if (mangleSubstitution(ND))
@@ -971,9 +974,9 @@ void CXXNameMangler::mangleUnscopedTemplateName(
"template template param cannot have abi tags");
mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
} else if (isa(ND) || isa(ND)) {
- mangleUnscopedName(ND, AdditionalAbiTags);
+ mangleUnscopedName(GD, AdditionalAbiTags);
} else {
- mangleUnscopedName(ND->getTemplatedDecl(), AdditionalAbiTags);
+ mangleUnscopedName(GD.getWithDecl(ND->getTemplatedDecl()), AdditionalAbiTags);
}
addSubstitution(ND);
@@ -1250,10 +1253,11 @@ void CXXNameMangler::mangleUnresolvedName(
mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
}
-void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
+void CXXNameMangler::mangleUnqualifiedName(GlobalDecl GD,
DeclarationName Name,
unsigned KnownArity,
const AbiTagList *AdditionalAbiTags) {
+ const NamedDecl *ND = cast_or_null(GD.getDecl());
unsigned Arity = KnownArity;
// ::=
// ::=
@@ -1499,10 +1503,11 @@ void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
Out << II->getLength() << II->getName();
}
-void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
+void CXXNameMangler::mangleNestedName(GlobalDecl GD,
const DeclContext *DC,
const AbiTagList *AdditionalAbiTags,
bool NoFunction) {
+ const NamedDecl *ND = cast(GD.getDecl());
//
// ::= N [] [] E
// ::= N [] []
@@ -1520,13 +1525,13 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
// Check if we have a template.
const TemplateArgumentList *TemplateArgs = nullptr;
- if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
+ if (GlobalDecl TD = isTemplate(GD, TemplateArgs)) {
mangleTemplatePrefix(TD, NoFunction);
mangleTemplateArgs(*TemplateArgs);
}
else {
manglePrefix(DC, NoFunction);
- mangleUnqualifiedName(ND, AdditionalAbiTags);
+ mangleUnqualifiedName(GD, AdditionalAbiTags);
}
Out << 'E';
@@ -1544,8 +1549,24 @@ void CXXNameMangler::mangleNestedName(const TemplateDecl *TD,
Out << 'E';
}
-void CXXNameMangler::mangleLocalName(const Decl *D,
+static GlobalDecl getParentOfLocalEntity(const DeclContext *DC) {
+ GlobalDecl GD;
+ // The Itanium spec says:
+ // For entities in constructors and destructors, the mangling of the
+ // complete object constructor or destructor is used as the base function
+ // name, i.e. the C1 or D1 version.
+ if (auto *CD = dyn_cast(DC))
+ GD = GlobalDecl(CD, Ctor_Complete);
+ else if (auto *DD = dyn_cast(DC))
+ GD = GlobalDecl(DD, Dtor_Complete);
+ else
+ GD = GlobalDecl(cast(DC));
+ return GD;
+}
+
+void CXXNameMangler::mangleLocalName(GlobalDecl GD,
const AbiTagList *AdditionalAbiTags) {
+ const Decl *D = GD.getDecl();
// := Z E []
// := Z E s []
// := Z E d [ ]
@@ -1565,7 +1586,7 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
else if (const BlockDecl *BD = dyn_cast(DC))
mangleBlockForPrefix(BD);
else
- mangleFunctionEncoding(cast(DC));
+ mangleFunctionEncoding(getParentOfLocalEntity(DC));
// Implicit ABI tags (from namespace) are not available in the following
// entity; reset to actually emitted tags, which are available.
@@ -1608,7 +1629,7 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
mangleUnqualifiedBlock(BD);
} else {
const NamedDecl *ND = cast(D);
- mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
+ mangleNestedName(GD, getEffectiveDeclContext(ND), AdditionalAbiTags,
true /*NoFunction*/);
}
} else if (const BlockDecl *BD = dyn_cast(D)) {
@@ -1629,7 +1650,7 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
assert(!AdditionalAbiTags && "Block cannot have additional abi tags");
mangleUnqualifiedBlock(BD);
} else {
- mangleUnqualifiedName(cast(D), AdditionalAbiTags);
+ mangleUnqualifiedName(GD, AdditionalAbiTags);
}
if (const NamedDecl *ND = dyn_cast(RD ? RD : D)) {
@@ -1840,7 +1861,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
// Check if we have a template.
const TemplateArgumentList *TemplateArgs = nullptr;
- if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
+ if (GlobalDecl TD = isTemplate(ND, TemplateArgs)) {
mangleTemplatePrefix(TD);
mangleTemplateArgs(*TemplateArgs);
} else {
@@ -1863,7 +1884,7 @@ void CXXNameMangler::mangleTemplatePrefix(TemplateName Template) {
if (OverloadedTemplateStorage *Overloaded
= Template.getAsOverloadedTemplate()) {
- mangleUnqualifiedName(nullptr, (*Overloaded->begin())->getDeclName(),
+ mangleUnqualifiedName(GlobalDecl(), (*Overloaded->begin())->getDeclName(),
UnknownArity, nullptr);
return;
}
@@ -1875,8 +1896,9 @@ void CXXNameMangler::mangleTemplatePrefix(TemplateName Template) {
mangleUnscopedTemplateName(Template, /* AdditionalAbiTags */ nullptr);
}
-void CXXNameMangler::mangleTemplatePrefix(const TemplateDecl *ND,
+void CXXNameMangler::mangleTemplatePrefix(GlobalDecl GD,
bool NoFunction) {
+ const TemplateDecl *ND = cast(GD.getDecl());
// ::=
// ::=
// ::=
@@ -1892,9 +1914,9 @@ void CXXNameMangler::mangleTemplatePrefix(const TemplateDecl *ND,
} else {
manglePrefix(getEffectiveDeclContext(ND), NoFunction);
if (isa(ND) || isa(ND))
- mangleUnqualifiedName(ND, nullptr);
+ mangleUnqualifiedName(GD, nullptr);
else
- mangleUnqualifiedName(ND->getTemplatedDecl(), nullptr);
+ mangleUnqualifiedName(GD.getWithDecl(ND->getTemplatedDecl()), nullptr);
}
addSubstitution(ND);
@@ -4943,45 +4965,42 @@ bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &C,
/// and this routine will return false. In this case, the caller should just
/// emit the identifier of the declaration (\c D->getIdentifier()) as its
/// name.
-void ItaniumMangleContextImpl::mangleCXXName(const NamedDecl *D,
+void ItaniumMangleContextImpl::mangleCXXName(GlobalDecl GD,
raw_ostream &Out) {
+ const NamedDecl *D = cast(GD.getDecl());
assert((isa(D) || isa(D)) &&
"Invalid mangleName() call, argument is not a variable or function!");
- assert(!isa(D) && !isa(D) &&
- "Invalid mangleName() call on 'structor decl!");
PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
getASTContext().getSourceManager(),
"Mangling declaration");
- CXXNameMangler Mangler(*this, Out, D);
- Mangler.mangle(D);
-}
+ if (auto *CD = dyn_cast(D)) {
+ auto Type = GD.getCtorType();
+ CXXNameMangler Mangler(*this, Out, CD, Type);
+ return Mangler.mangle(GlobalDecl(CD, Type));
+ }
-void ItaniumMangleContextImpl::mangleCXXCtor(const CXXConstructorDecl *D,
- CXXCtorType Type,
- raw_ostream &Out) {
- CXXNameMangler Mangler(*this, Out, D, Type);
- Mangler.mangle(D);
-}
+ if (auto *DD = dyn_cast(D)) {
+ auto Type = GD.getDtorType();
+ CXXNameMangler Mangler(*this, Out, DD, Type);
+ return Mangler.mangle(GlobalDecl(DD, Type));
+ }
-void ItaniumMangleContextImpl::mangleCXXDtor(const CXXDestructorDecl *D,
- CXXDtorType Type,
- raw_ostream &Out) {
- CXXNameMangler Mangler(*this, Out, D, Type);
- Mangler.mangle(D);
+ CXXNameMangler Mangler(*this, Out, D);
+ Mangler.mangle(GD);
}
void ItaniumMangleContextImpl::mangleCXXCtorComdat(const CXXConstructorDecl *D,
raw_ostream &Out) {
CXXNameMangler Mangler(*this, Out, D, Ctor_Comdat);
- Mangler.mangle(D);
+ Mangler.mangle(GlobalDecl(D, Ctor_Comdat));
}
void ItaniumMangleContextImpl::mangleCXXDtorComdat(const CXXDestructorDecl *D,
raw_ostream &Out) {
CXXNameMangler Mangler(*this, Out, D, Dtor_Comdat);
- Mangler.mangle(D);
+ Mangler.mangle(GlobalDecl(D, Dtor_Comdat));
}
void ItaniumMangleContextImpl::mangleThunk(const CXXMethodDecl *MD,
@@ -5025,7 +5044,7 @@ void ItaniumMangleContextImpl::mangleCXXDtorThunk(
Mangler.mangleCallOffset(ThisAdjustment.NonVirtual,
ThisAdjustment.Virtual.Itanium.VCallOffsetOffset);
- Mangler.mangleFunctionEncoding(DD);
+ Mangler.mangleFunctionEncoding(GlobalDecl(DD, Type));
}
/// Returns the mangled name for a guard variable for the passed in VarDecl.
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 1a2cb29f0ec77f..d096fac3e3bcca 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -125,7 +125,8 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) {
return shouldMangleCXXName(D);
}
-void MangleContext::mangleName(const NamedDecl *D, raw_ostream &Out) {
+void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
+ const NamedDecl *D = cast(GD.getDecl());
// Any decl can be declared with __asm("foo") on it, and this takes precedence
// over all other naming in the .o file.
if (const AsmLabelAttr *ALA = D->getAttr()) {
@@ -166,7 +167,7 @@ void MangleContext::mangleName(const NamedDecl *D, raw_ostream &Out) {
if (const ObjCMethodDecl *OMD = dyn_cast(D))
mangleObjCMethodName(OMD, Out);
else
- mangleCXXName(D, Out);
+ mangleCXXName(GD, Out);
return;
}
@@ -183,7 +184,7 @@ void MangleContext::mangleName(const NamedDecl *D, raw_ostream &Out) {
else if (const ObjCMethodDecl *OMD = dyn_cast(D))
mangleObjCMethodName(OMD, Out);
else
- mangleCXXName(D, Out);
+ mangleCXXName(GD, Out);
const FunctionDecl *FD = cast(D);
const FunctionType *FT = FD->getType()->castAs();
@@ -230,7 +231,7 @@ void MangleContext::mangleCtorBlock(const CXXConstructorDecl *CD,
raw_ostream &ResStream) {
SmallString<64> Buffer;
llvm::raw_svector_ostream Out(Buffer);
- mangleCXXCtor(CD, CT, Out);
+ mangleName(GlobalDecl(CD, CT), Out);
mangleFunctionBlock(*this, Buffer, BD, ResStream);
}
@@ -239,7 +240,7 @@ void MangleContext::mangleDtorBlock(const CXXDestructorDecl *DD,
raw_ostream &ResStream) {
SmallString<64> Buffer;
llvm::raw_svector_ostream Out(Buffer);
- mangleCXXDtor(DD, DT, Out);
+ mangleName(GlobalDecl(DD, DT), Out);
mangleFunctionBlock(*this, Buffer, BD, ResStream);
}
@@ -437,12 +438,14 @@ class ASTNameGenerator::Implementation {
private:
bool writeFuncOrVarName(const NamedDecl *D, raw_ostream &OS) {
if (MC->shouldMangleDeclName(D)) {
+ GlobalDecl GD;
if (const auto *CtorD = dyn_cast(D))
- MC->mangleCXXCtor(CtorD, Ctor_Complete, OS);
+ GD = GlobalDecl(CtorD, Ctor_Complete);
else if (const auto *DtorD = dyn_cast(D))
- MC->mangleCXXDtor(DtorD, Dtor_Complete, OS);
+ GD = GlobalDecl(DtorD, Dtor_Complete);
else
- MC->mangleName(D, OS);
+ GD = GlobalDecl(D);
+ MC->mangleName(GD, OS);
return false;
} else {
IdentifierInfo *II = D->getIdentifier();
@@ -462,10 +465,12 @@ class ASTNameGenerator::Implementation {
std::string FrontendBuf;
llvm::raw_string_ostream FOS(FrontendBuf);
+ GlobalDecl GD;
if (const auto *CD = dyn_cast_or_null(ND))
- MC->mangleCXXCtor(CD, static_cast(StructorType), FOS);
+ GD = GlobalDecl(CD, static_cast(StructorType));
else if (const auto *DD = dyn_cast_or_null(ND))
- MC->mangleCXXDtor(DD, static_cast(StructorType), FOS);
+ GD = GlobalDecl(DD, static_cast(StructorType));
+ MC->mangleName(GD, FOS);
std::string BackendBuf;
llvm::raw_string_ostream BOS(BackendBuf);
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 5ed25867b4a6ea..8b7c5a2b5c94d2 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -136,7 +136,7 @@ class MicrosoftMangleContextImpl : public MicrosoftMangleContext {
MicrosoftMangleContextImpl(ASTContext &Context, DiagnosticsEngine &Diags);
bool shouldMangleCXXName(const NamedDecl *D) override;
bool shouldMangleStringLiteral(const StringLiteral *SL) override;
- void mangleCXXName(const NamedDecl *D, raw_ostream &Out) override;
+ void mangleCXXName(GlobalDecl GD, raw_ostream &Out) override;
void mangleVirtualMemPtrThunk(const CXXMethodDecl *MD,
const MethodVFTableLocation &ML,
raw_ostream &Out) override;
@@ -178,10 +178,6 @@ class MicrosoftMangleContextImpl : public MicrosoftMangleContext {
ArrayRef BasePath,
raw_ostream &Out) override;
void mangleTypeName(QualType T, raw_ostream &) override;
- void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
- raw_ostream &) override;
- void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
- raw_ostream &) override;
void mangleReferenceTemporary(const VarDecl *, unsigned ManglingNumber,
raw_ostream &) override;
void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &Out) override;
@@ -2950,18 +2946,27 @@ void MicrosoftCXXNameMangler::mangleType(const PipeType *T, Qualifiers,
<< Range;
}
-void MicrosoftMangleContextImpl::mangleCXXName(const NamedDecl *D,
+void MicrosoftMangleContextImpl::mangleCXXName(GlobalDecl GD,
raw_ostream &Out) {
- assert((isa(D) || isa(D)) &&
- "Invalid mangleName() call, argument is not a variable or function!");
- assert(!isa(D) && !isa(D) &&
- "Invalid mangleName() call on 'structor decl!");
-
+ const NamedDecl *D = cast(GD.getDecl());
PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
getASTContext().getSourceManager(),
"Mangling declaration");
msvc_hashing_ostream MHO(Out);
+
+ if (auto *CD = dyn_cast(D)) {
+ auto Type = GD.getCtorType();
+ MicrosoftCXXNameMangler mangler(*this, MHO, CD, Type);
+ return mangler.mangle(D);
+ }
+
+ if (auto *DD = dyn_cast(D)) {
+ auto Type = GD.getDtorType();
+ MicrosoftCXXNameMangler mangler(*this, MHO, DD, Type);
+ return mangler.mangle(D);
+ }
+
MicrosoftCXXNameMangler Mangler(*this, MHO);
return Mangler.mangle(D);
}
@@ -3219,7 +3224,7 @@ void MicrosoftMangleContextImpl::mangleCXXCatchableType(
if (!OmitCopyCtor && CD) {
llvm::raw_svector_ostream Stream(CopyCtorMangling);
msvc_hashing_ostream MHO(Stream);
- mangleCXXCtor(CD, CT, MHO);
+ mangleCXXName(GlobalDecl(CD, CT), MHO);
}
Mangler.getStream() << CopyCtorMangling;
@@ -3322,22 +3327,6 @@ void MicrosoftMangleContextImpl::mangleTypeName(QualType T, raw_ostream &Out) {
Mangler.mangleType(T, SourceRange());
}
-void MicrosoftMangleContextImpl::mangleCXXCtor(const CXXConstructorDecl *D,
- CXXCtorType Type,
- raw_ostream &Out) {
- msvc_hashing_ostream MHO(Out);
- MicrosoftCXXNameMangler mangler(*this, MHO, D, Type);
- mangler.mangle(D);
-}
-
-void MicrosoftMangleContextImpl::mangleCXXDtor(const CXXDestructorDecl *D,
- CXXDtorType Type,
- raw_ostream &Out) {
- msvc_hashing_ostream MHO(Out);
- MicrosoftCXXNameMangler mangler(*this, MHO, D, Type);
- mangler.mangle(D);
-}
-
void MicrosoftMangleContextImpl::mangleReferenceTemporary(
const VarDecl *VD, unsigned ManglingNumber, raw_ostream &Out) {
msvc_hashing_ostream MHO(Out);
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 5452b408a817fd..fd2b6b253c5329 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -358,6 +358,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(isClass);
REGISTER_MATCHER(isClassMessage);
REGISTER_MATCHER(isClassMethod);
+ REGISTER_MATCHER(isComparisonOperator);
REGISTER_MATCHER(isConst);
REGISTER_MATCHER(isConstQualified);
REGISTER_MATCHER(isConstexpr);
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fbb397ba3cfefa..952cc3f0c9b8c3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1320,14 +1320,30 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const CallExpr &E) {
} else if (const Expr *TheExpr = Item.getExpr()) {
ArgVal = EmitScalarExpr(TheExpr, /*Ignore*/ false);
- // Check if this is a retainable type.
+ // If this is a retainable type, push a lifetime-extended cleanup to
+ // ensure the lifetime of the argument is extended to the end of the
+ // enclosing block scope.
+ // FIXME: We only have to do this if the argument is a temporary, which
+ // gets released after the full expression.
if (TheExpr->getType()->isObjCRetainableType()) {
assert(getEvaluationKind(TheExpr->getType()) == TEK_Scalar &&
"Only scalar can be a ObjC retainable type");
- // Check if the object is constant, if not, save it in
- // RetainableOperands.
- if (!isa(ArgVal))
- RetainableOperands.push_back(ArgVal);
+ if (!isa(ArgVal)) {
+ CleanupKind Cleanup = getARCCleanupKind();
+ QualType Ty = TheExpr->getType();
+ Address Alloca = Address::invalid();
+ Address Addr = CreateMemTemp(Ty, "os.log.arg", &Alloca);
+ ArgVal = EmitARCRetain(Ty, ArgVal);
+ Builder.CreateStore(ArgVal, Addr);
+ pushLifetimeExtendedDestroy(Cleanup, Alloca, Ty,
+ CodeGenFunction::destroyARCStrongPrecise,
+ Cleanup & EHCleanup);
+
+ // Push a clang.arc.use call to ensure ARC optimizer knows that the
+ // argument has to be alive.
+ if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+ pushCleanupAfterFullExpr(Cleanup, ArgVal);
+ }
}
} else {
ArgVal = Builder.getInt32(Item.getConstValue().getQuantity());
@@ -1349,18 +1365,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const CallExpr &E) {
llvm::Function *F = CodeGenFunction(CGM).generateBuiltinOSLogHelperFunction(
Layout, BufAddr.getAlignment());
EmitCall(FI, CGCallee::forDirect(F), ReturnValueSlot(), Args);
-
- // Push a clang.arc.use cleanup for each object in RetainableOperands. The
- // cleanup will cause the use to appear after the final log call, keeping
- // the object valid while it’s held in the log buffer. Note that if there’s
- // a release cleanup on the object, it will already be active; since
- // cleanups are emitted in reverse order, the use will occur before the
- // object is released.
- if (!RetainableOperands.empty() && getLangOpts().ObjCAutoRefCount &&
- CGM.getCodeGenOpts().OptimizationLevel != 0)
- for (llvm::Value *Object : RetainableOperands)
- pushFullExprCleanup(getARCCleanupKind(), Object);
-
return RValue::get(BufAddr.getPointer());
}
@@ -14900,6 +14904,47 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
return Builder.CreateCall(Callee, {LHS, RHS});
}
+ case WebAssembly::BI__builtin_wasm_min_s_i8x16:
+ case WebAssembly::BI__builtin_wasm_min_u_i8x16:
+ case WebAssembly::BI__builtin_wasm_max_s_i8x16:
+ case WebAssembly::BI__builtin_wasm_max_u_i8x16:
+ case WebAssembly::BI__builtin_wasm_min_s_i16x8:
+ case WebAssembly::BI__builtin_wasm_min_u_i16x8:
+ case WebAssembly::BI__builtin_wasm_max_s_i16x8:
+ case WebAssembly::BI__builtin_wasm_max_u_i16x8:
+ case WebAssembly::BI__builtin_wasm_min_s_i32x4:
+ case WebAssembly::BI__builtin_wasm_min_u_i32x4:
+ case WebAssembly::BI__builtin_wasm_max_s_i32x4:
+ case WebAssembly::BI__builtin_wasm_max_u_i32x4: {
+ Value *LHS = EmitScalarExpr(E->getArg(0));
+ Value *RHS = EmitScalarExpr(E->getArg(1));
+ Value *ICmp;
+ switch (BuiltinID) {
+ case WebAssembly::BI__builtin_wasm_min_s_i8x16:
+ case WebAssembly::BI__builtin_wasm_min_s_i16x8:
+ case WebAssembly::BI__builtin_wasm_min_s_i32x4:
+ ICmp = Builder.CreateICmpSLT(LHS, RHS);
+ break;
+ case WebAssembly::BI__builtin_wasm_min_u_i8x16:
+ case WebAssembly::BI__builtin_wasm_min_u_i16x8:
+ case WebAssembly::BI__builtin_wasm_min_u_i32x4:
+ ICmp = Builder.CreateICmpULT(LHS, RHS);
+ break;
+ case WebAssembly::BI__builtin_wasm_max_s_i8x16:
+ case WebAssembly::BI__builtin_wasm_max_s_i16x8:
+ case WebAssembly::BI__builtin_wasm_max_s_i32x4:
+ ICmp = Builder.CreateICmpSGT(LHS, RHS);
+ break;
+ case WebAssembly::BI__builtin_wasm_max_u_i8x16:
+ case WebAssembly::BI__builtin_wasm_max_u_i16x8:
+ case WebAssembly::BI__builtin_wasm_max_u_i32x4:
+ ICmp = Builder.CreateICmpUGT(LHS, RHS);
+ break;
+ default:
+ llvm_unreachable("unexpected builtin ID");
+ }
+ return Builder.CreateSelect(ICmp, LHS, RHS);
+ }
case WebAssembly::BI__builtin_wasm_avgr_u_i8x16:
case WebAssembly::BI__builtin_wasm_avgr_u_i16x8: {
Value *LHS = EmitScalarExpr(E->getArg(0));
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 42d5467c63dcab..1188ea39ba2c90 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1748,11 +1748,10 @@ void CodeGenModule::ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
if (CodeGenOpts.NullPointerIsValid)
FuncAttrs.addAttribute("null-pointer-is-valid", "true");
- // TODO: Omit attribute when the default is IEEE.
- if (CodeGenOpts.FPDenormalMode.isValid())
+ if (CodeGenOpts.FPDenormalMode != llvm::DenormalMode::getIEEE())
FuncAttrs.addAttribute("denormal-fp-math",
CodeGenOpts.FPDenormalMode.str());
- if (CodeGenOpts.FP32DenormalMode.isValid()) {
+ if (CodeGenOpts.FP32DenormalMode != CodeGenOpts.FPDenormalMode) {
FuncAttrs.addAttribute(
"denormal-fp-math-f32",
CodeGenOpts.FP32DenormalMode.str());
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 2d16766f76ce6e..342217ae28239b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2413,13 +2413,14 @@ static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
}
static llvm::Constant *EmitFunctionDeclPointer(CodeGenModule &CGM,
- const FunctionDecl *FD) {
+ GlobalDecl GD) {
+ const FunctionDecl *FD = cast(GD.getDecl());
if (FD->hasAttr()) {
ConstantAddress aliasee = CGM.GetWeakRefReference(FD);
return aliasee.getPointer();
}
- llvm::Constant *V = CGM.GetAddrOfFunction(FD);
+ llvm::Constant *V = CGM.GetAddrOfFunction(GD);
if (!FD->hasPrototype()) {
if (const FunctionProtoType *Proto =
FD->getType()->getAs()) {
@@ -2436,9 +2437,10 @@ static llvm::Constant *EmitFunctionDeclPointer(CodeGenModule &CGM,
return V;
}
-static LValue EmitFunctionDeclLValue(CodeGenFunction &CGF,
- const Expr *E, const FunctionDecl *FD) {
- llvm::Value *V = EmitFunctionDeclPointer(CGF.CGM, FD);
+static LValue EmitFunctionDeclLValue(CodeGenFunction &CGF, const Expr *E,
+ GlobalDecl GD) {
+ const FunctionDecl *FD = cast(GD.getDecl());
+ llvm::Value *V = EmitFunctionDeclPointer(CGF.CGM, GD);
CharUnits Alignment = CGF.getContext().getDeclAlign(FD);
return CGF.MakeAddrLValue(V, E->getType(), Alignment,
AlignmentSource::Decl);
@@ -4638,7 +4640,8 @@ RValue CodeGenFunction::EmitSimpleCallExpr(const CallExpr *E,
return EmitCall(E->getCallee()->getType(), Callee, E, ReturnValue);
}
-static CGCallee EmitDirectCallee(CodeGenFunction &CGF, const FunctionDecl *FD) {
+static CGCallee EmitDirectCallee(CodeGenFunction &CGF, GlobalDecl GD) {
+ const FunctionDecl *FD = cast(GD.getDecl());
if (auto builtinID = FD->getBuiltinID()) {
// Replaceable builtin provide their own implementation of a builtin. Unless
@@ -4650,8 +4653,8 @@ static CGCallee EmitDirectCallee(CodeGenFunction &CGF, const FunctionDecl *FD) {
return CGCallee::forBuiltin(builtinID, FD);
}
- llvm::Constant *calleePtr = EmitFunctionDeclPointer(CGF.CGM, FD);
- return CGCallee::forDirect(calleePtr, GlobalDecl(FD));
+ llvm::Constant *calleePtr = EmitFunctionDeclPointer(CGF.CGM, GD);
+ return CGCallee::forDirect(calleePtr, GD);
}
CGCallee CodeGenFunction::EmitCallee(const Expr *E) {
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 620f6ea3e654b0..e16dfbcddbe252 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5214,6 +5214,7 @@ static RTLDependenceKindTy translateDependencyKind(OpenMPDependClauseKind K) {
break;
case OMPC_DEPEND_source:
case OMPC_DEPEND_sink:
+ case OMPC_DEPEND_depobj:
case OMPC_DEPEND_unknown:
llvm_unreachable("Unknown task dependence type");
}
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 719cb05d9ec8ed..0ee315776d333f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1023,22 +1023,15 @@ static std::string getMangledNameImpl(const CodeGenModule &CGM, GlobalDecl GD,
SmallString<256> Buffer;
llvm::raw_svector_ostream Out(Buffer);
MangleContext &MC = CGM.getCXXABI().getMangleContext();
- if (MC.shouldMangleDeclName(ND)) {
- llvm::raw_svector_ostream Out(Buffer);
- if (const auto *D = dyn_cast(ND))
- MC.mangleCXXCtor(D, GD.getCtorType(), Out);
- else if (const auto *D = dyn_cast(ND))
- MC.mangleCXXDtor(D, GD.getDtorType(), Out);
- else
- MC.mangleName(ND, Out);
- } else {
+ if (MC.shouldMangleDeclName(ND))
+ MC.mangleName(GD.getWithDecl(ND), Out);
+ else {
IdentifierInfo *II = ND->getIdentifier();
assert(II && "Attempt to mangle unnamed decl.");
const auto *FD = dyn_cast(ND);
if (FD &&
FD->getType()->castAs()->getCallConv() == CC_X86RegCall) {
- llvm::raw_svector_ostream Out(Buffer);
Out << "__regcall3__" << II->getName();
} else {
Out << II->getName();
@@ -4485,7 +4478,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
maybeSetTrivialComdat(*D, *Fn);
- CodeGenFunction(*this).GenerateCode(D, Fn, FI);
+ CodeGenFunction(*this).GenerateCode(GD, Fn, FI);
setNonAliasAttributes(GD, Fn);
SetLLVMFunctionAttributesForDefinition(D, Fn);
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index b083a5893cf79c..4a5d4997fe4315 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3922,7 +3922,7 @@ MicrosoftCXXABI::getAddrOfCXXCtorClosure(const CXXConstructorDecl *CD,
// Calculate the mangled name.
SmallString<256> ThunkName;
llvm::raw_svector_ostream Out(ThunkName);
- getMangleContext().mangleCXXCtor(CD, CT, Out);
+ getMangleContext().mangleName(GlobalDecl(CD, CT), Out);
// If the thunk has been generated previously, just return it.
if (llvm::GlobalValue *GV = CGM.getModule().getNamedValue(ThunkName))
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index d387a1dc20791a..99faae396be3ba 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2548,8 +2548,13 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
ReciprocalMath = false;
SignedZeros = true;
// -fno_fast_math restores default denormal and fpcontract handling
- DenormalFPMath = DefaultDenormalFPMath;
FPContract = "";
+ DenormalFPMath = llvm::DenormalMode::getIEEE();
+
+ // FIXME: The target may have picked a non-IEEE default mode here based on
+ // -cl-denorms-are-zero. Should the target consider -fp-model interaction?
+ DenormalFP32Math = llvm::DenormalMode::getIEEE();
+
StringRef Val = A->getValue();
if (OFastEnabled && !Val.equals("fast")) {
// Only -ffp-model=fast is compatible with OFast, ignore.
@@ -2724,9 +2729,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
SignedZeros = true;
TrappingMath = true;
FPExceptionBehavior = "strict";
- // -fno_unsafe_math_optimizations restores default denormal handling
- DenormalFPMath = DefaultDenormalFPMath;
- DenormalFP32Math = DefaultDenormalFP32Math;
+
+ // The target may have opted to flush by default, so force IEEE.
+ DenormalFPMath = llvm::DenormalMode::getIEEE();
+ DenormalFP32Math = llvm::DenormalMode::getIEEE();
break;
case options::OPT_Ofast:
@@ -2760,18 +2766,19 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
RoundingFPMath = false;
// -fno_fast_math restores default denormal and fpcontract handling
DenormalFPMath = DefaultDenormalFPMath;
- DenormalFP32Math = DefaultDenormalFP32Math;
+ DenormalFP32Math = llvm::DenormalMode::getIEEE();
FPContract = "";
break;
}
if (StrictFPModel) {
// If -ffp-model=strict has been specified on command line but
// subsequent options conflict then emit warning diagnostic.
- // TODO: How should this interact with DenormalFP32Math?
if (HonorINFs && HonorNaNs &&
!AssociativeMath && !ReciprocalMath &&
SignedZeros && TrappingMath && RoundingFPMath &&
- (FPContract.equals("off") || FPContract.empty()))
+ (FPContract.equals("off") || FPContract.empty()) &&
+ DenormalFPMath == llvm::DenormalMode::getIEEE() &&
+ DenormalFP32Math == llvm::DenormalMode::getIEEE())
// OK: Current Arg doesn't conflict with -ffp-model=strict
;
else {
@@ -2817,15 +2824,16 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
} else if (TrappingMathPresent)
CmdArgs.push_back("-fno-trapping-math");
- // TODO: Omit flag for the default IEEE instead
- if (DenormalFPMath.isValid()) {
+ // The default is IEEE.
+ if (DenormalFPMath != llvm::DenormalMode::getIEEE()) {
llvm::SmallString<64> DenormFlag;
llvm::raw_svector_ostream ArgStr(DenormFlag);
ArgStr << "-fdenormal-fp-math=" << DenormalFPMath;
CmdArgs.push_back(Args.MakeArgString(ArgStr.str()));
}
- if (DenormalFP32Math.isValid()) {
+ // Add f32 specific denormal mode flag if it's different.
+ if (DenormalFP32Math != DenormalFPMath) {
llvm::SmallString<64> DenormFlag;
llvm::raw_svector_ostream ArgStr(DenormFlag);
ArgStr << "-fdenormal-fp-math-f32=" << DenormalFP32Math;
@@ -4040,9 +4048,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
}
- if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false))
+ if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) {
+ CmdArgs.push_back("-fsycl");
CmdArgs.push_back("-fsycl-is-device");
+ if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) {
+ A->render(Args, CmdArgs);
+ } else {
+ // Ensure the default version in SYCL mode is 1.2.1 (aka 2017)
+ CmdArgs.push_back("-sycl-std=2017");
+ }
+ }
+
if (IsOpenMPDevice) {
// We have to pass the triple of the host if compiling for an OpenMP device.
std::string NormalizedTriple =
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index da9ee41da71b6f..84ccbec2150d12 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -411,7 +411,7 @@ class LineJoiner {
? tryMergeSimpleControlStatement(I, E, Limit)
: 0;
}
- if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while)) {
+ if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
return Style.AllowShortLoopsOnASingleLine
? tryMergeSimpleControlStatement(I, E, Limit)
: 0;
@@ -514,7 +514,10 @@ class LineJoiner {
return 0;
Limit = limitConsideringMacros(I + 1, E, Limit);
AnnotatedLine &Line = **I;
- if (Line.Last->isNot(tok::r_paren))
+ if (!Line.First->is(tok::kw_do) && Line.Last->isNot(tok::r_paren))
+ return 0;
+ // Only merge do while if do is the only statement on the line.
+ if (Line.First->is(tok::kw_do) && !Line.Last->is(tok::kw_do))
return 0;
if (1 + I[1]->Last->TotalLength > Limit)
return 0;
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 48c65aded817c1..9f3522a3e65453 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2544,6 +2544,24 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
LangStd = OpenCLLangStd;
}
+ Opts.SYCL = Args.hasArg(options::OPT_fsycl);
+ Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
+ if (Opts.SYCL) {
+ // -sycl-std applies to any SYCL source, not only those containing kernels,
+ // but also those using the SYCL API
+ if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
+ Opts.SYCLVersion = llvm::StringSwitch(A->getValue())
+ .Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017)
+ .Default(0U);
+
+ if (Opts.SYCLVersion == 0U) {
+ // User has passed an invalid value to the flag, this is an error
+ Diags.Report(diag::err_drv_invalid_value)
+ << A->getAsString(Args) << A->getValue();
+ }
+ }
+ }
+
Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
@@ -3145,8 +3163,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
<< Opts.OMPHostIRFile;
}
- Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
-
// Set CUDA mode for OpenMP target NVPTX if specified in options
Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
Args.hasArg(options::OPT_fopenmp_cuda_mode);
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index ac3818afecafa5..f781915cf7c012 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -460,6 +460,13 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
if (LangOpts.FastRelaxedMath)
Builder.defineMacro("__FAST_RELAXED_MATH__");
}
+
+ if (LangOpts.SYCL) {
+ // SYCL Version is set to a value when building SYCL applications
+ if (LangOpts.SYCLVersion == 2017)
+ Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
+ }
+
// Not "standard" per se, but available even with the -undef flag.
if (LangOpts.AsmPreprocessor)
Builder.defineMacro("__ASSEMBLER__");
diff --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index 596ea03cff2f4f..de568b4ff9c516 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -22,31 +22,43 @@ extern "C" {
/* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
/* 8.3 Memory barriers */
-#if !defined(_MSC_VER)
+#if !__has_builtin(__dmb)
#define __dmb(i) __builtin_arm_dmb(i)
+#endif
+#if !__has_builtin(__dsb)
#define __dsb(i) __builtin_arm_dsb(i)
+#endif
+#if !__has_builtin(__isb)
#define __isb(i) __builtin_arm_isb(i)
#endif
/* 8.4 Hints */
-#if !defined(_MSC_VER)
+#if !__has_builtin(__wfi)
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfi(void) {
__builtin_arm_wfi();
}
+#endif
+#if !__has_builtin(__wfe)
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfe(void) {
__builtin_arm_wfe();
}
+#endif
+#if !__has_builtin(__sev)
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sev(void) {
__builtin_arm_sev();
}
+#endif
+#if !__has_builtin(__sevl)
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sevl(void) {
__builtin_arm_sevl();
}
+#endif
+#if !__has_builtin(__yield)
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __yield(void) {
__builtin_arm_yield();
}
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index 394daf94c4b2d7..7972d0a047c23d 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -382,6 +382,14 @@ void USRGenerator::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
Out << "@NA@" << D->getName();
}
+static const ObjCCategoryDecl *getCategoryContext(const NamedDecl *D) {
+ if (auto *CD = dyn_cast(D->getDeclContext()))
+ return CD;
+ if (auto *ICD = dyn_cast(D->getDeclContext()))
+ return ICD->getCategoryDecl();
+ return nullptr;
+}
+
void USRGenerator::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
const DeclContext *container = D->getDeclContext();
if (const ObjCProtocolDecl *pd = dyn_cast(container)) {
@@ -395,14 +403,6 @@ void USRGenerator::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
IgnoreResults = true;
return;
}
- auto getCategoryContext = [](const ObjCMethodDecl *D) ->
- const ObjCCategoryDecl * {
- if (auto *CD = dyn_cast(D->getDeclContext()))
- return CD;
- if (auto *ICD = dyn_cast(D->getDeclContext()))
- return ICD->getCategoryDecl();
- return nullptr;
- };
auto *CD = getCategoryContext(D);
VisitObjCContainerDecl(ID, CD);
}
@@ -475,7 +475,7 @@ void USRGenerator::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
// The USR for a property declared in a class extension or category is based
// on the ObjCInterfaceDecl, not the ObjCCategoryDecl.
if (const ObjCInterfaceDecl *ID = Context->getObjContainingInterface(D))
- Visit(ID);
+ VisitObjCContainerDecl(ID, getCategoryContext(D));
else
Visit(cast(D->getDeclContext()));
GenObjCProperty(D->getName(), D->isClassProperty());
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 27b88b33119986..1da884f657a05a 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3198,9 +3198,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
Data.RLoc = Tok.getLocation();
if (!T.consumeClose())
Data.RLoc = T.getCloseLocation();
- return (Kind == OMPC_depend && Data.ExtraModifier != OMPC_DEPEND_unknown &&
- Vars.empty()) ||
- (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) ||
+ return (Kind != OMPC_depend && Kind != OMPC_map && Vars.empty()) ||
(MustHaveTail && !Data.TailExpr) || InvalidReductionId ||
IsInvalidMapperModifier;
}
diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td
index 4ccb6b5fd49d14..8764098482466c 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -742,17 +742,17 @@ let MaxVersion = CL20 in {
def : Builtin, Size, PointerType, AS>]>;
}
foreach name = ["vstore" # VSize] in {
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
- def : Builtin, Size, PointerType, AS>]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
}
foreach name = ["vloada_half" # VSize] in {
def : Builtin, Size, PointerType, AS>]>;
@@ -784,17 +784,17 @@ let MinVersion = CL20 in {
def : Builtin, Size, PointerType, GenericAS>]>;
}
foreach name = ["vstore" # VSize] in {
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
- def : Builtin, Size, PointerType, GenericAS>]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin, Size, PointerType]>;
+ def : Builtin