[clang] Add clang_elementwise_builtin_alias (PR #86175)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 21 11:53:32 PDT 2024
https://github.com/bob80905 updated https://github.com/llvm/llvm-project/pull/86175
>From 5e10b1e42a20a39c9a3d5ff332591713511832c8 Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbatista at microsoft.com>
Date: Wed, 20 Mar 2024 13:24:07 -0700
Subject: [PATCH 1/5] make elemnetwise alias an alias of builtin alias
---
clang/include/clang/Basic/Attr.td | 9 ++++++++
clang/include/clang/Basic/AttrDocs.td | 22 +++++++++++++++++++
.../clang/Basic/DiagnosticSemaKinds.td | 3 ++-
clang/lib/AST/Decl.cpp | 2 ++
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 2 ++
5 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index fd7970d0451acd..160e8ef730ef92 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -759,6 +759,15 @@ def BuiltinAlias : Attr {
let Documentation = [BuiltinAliasDocs];
}
+def ElementwiseBuiltinAlias : Attr {
+ let Spellings = [CXX11<"clang", "elementwise_builtin_alias">,
+ C23<"clang", "elementwise_builtin_alias">,
+ GNU<"clang_elementwise_builtin_alias">];
+ let Args = [IdentifierArgument<"BuiltinName">];
+ let Subjects = SubjectList<[Function], ErrorDiag>;
+ let Documentation = [ElementwiseBuiltinAliasDocs];
+}
+
def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr<TargetAnyArm> {
let Spellings = [Clang<"__clang_arm_builtin_alias">];
let Args = [IdentifierArgument<"BuiltinName">];
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 2c07cd09b0d5b7..7ce83bc881f064 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5462,6 +5462,28 @@ for clang builtin functions.
}];
}
+def ElementwiseBuiltinAliasDocs : Documentation {
+ let Category = DocCatFunction;
+ let Heading = "clang::elementwise_builtin_alias, clang_elementwise_builtin_alias";
+ let Content = [{
+This attribute is used in the implementation of the C intrinsics.
+It allows the C intrinsic functions to be declared using the names defined
+in target builtins, and still be recognized as clang builtins equivalent to the
+underlying name. It also declares that the given C intrinsic can accept
+vector arguments. For example, ``hlsl_intrinsics.h`` declares the function ``abs``
+with ``__attribute__((clang_elementwise_builtin_alias(__builtin_abs)))``.
+This ensures that both functions are recognized as that clang builtin,
+and in the latter case, the choice of which builtin to identify the
+function as can be deferred until after overload resolution. It also enables
+the ``abs`` function to take vector arguments.
+
+This attribute can only be used to set up the aliases for certain ARM/RISC-V
+C intrinsic functions; it is intended for use only inside ``arm_*.h`` and
+``riscv_*.h`` and is not a general mechanism for declaring arbitrary aliases
+for clang builtin functions.
+ }];
+}
+
def PreferredNameDocs : Documentation {
let Category = DocCatDecl;
let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c54105507753eb..1252d3804131a6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4412,7 +4412,8 @@ def err_attribute_preferred_name_arg_invalid : Error<
"a specialization of %1">;
def err_attribute_builtin_alias : Error<
"%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">;
-
+def err_attribute_elementwise_builtin_alias : Error<
+ "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">;
// called-once attribute diagnostics.
def err_called_once_attribute_wrong_type : Error<
"'called_once' attribute only applies to function-like parameters">;
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 8626f04012f7d4..cb2c5cf6ceaf49 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3598,6 +3598,8 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const {
BuiltinID = ABAA->getBuiltinName()->getBuiltinID();
} else if (const auto *BAA = getAttr<BuiltinAliasAttr>()) {
BuiltinID = BAA->getBuiltinName()->getBuiltinID();
+ } else if (const auto *EBAA = getAttr<ElementwiseBuiltinAliasAttr>()) {
+ BuiltinID = EBAA->getBuiltinName()->getBuiltinID();
} else if (const auto *A = getAttr<BuiltinAttr>()) {
BuiltinID = A->getID();
}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 45f8544392584e..b37c4d13b26e62 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -18,6 +18,8 @@ namespace hlsl {
#define _HLSL_BUILTIN_ALIAS(builtin) \
__attribute__((clang_builtin_alias(builtin)))
+#define _HLSL_ELEMENTWISE_BUILTIN_ALIAS(builtin) \
+ __attribute__((clang_elementwise_builtin_alias(builtin)))
#define _HLSL_AVAILABILITY(environment, version) \
__attribute__((availability(environment, introduced = version)))
>From 4cb34745b6d51e71fed1036009730f92cd4d36e9 Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbatista at microsoft.com>
Date: Wed, 20 Mar 2024 13:54:06 -0700
Subject: [PATCH 2/5] my alias is now a verified alias!
---
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 2 +-
clang/lib/Sema/SemaDeclAttr.cpp | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index b37c4d13b26e62..f646522e35e84c 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -99,7 +99,7 @@ _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
double2 abs(double2);
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
double3 abs(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
+_HLSL_ELEMENTWISE_BUILTIN_ALIAS(__builtin_elementwise_abs)
double4 abs(double4);
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c00120b59d396e..4710bd61a78e14 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -9851,6 +9851,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
case ParsedAttr::AT_BuiltinAlias:
handleBuiltinAliasAttr(S, D, AL);
break;
+ case ParsedAttr::AT_ElementwiseBuiltinAlias:
+ handleBuiltinAliasAttr(S, D, AL);
+ break;
case ParsedAttr::AT_PreferredType:
handlePreferredTypeAttr(S, D, AL);
>From 4c8ba70909906e13b8b997d406d3f4a0e006015b Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbatista at microsoft.com>
Date: Wed, 20 Mar 2024 17:39:43 -0700
Subject: [PATCH 3/5] attempt to implement 1
---
clang/lib/Sema/SemaChecking.cpp | 632 +++++++++++++++++---------------
clang/lib/Sema/SemaDeclAttr.cpp | 31 +-
2 files changed, 364 insertions(+), 299 deletions(-)
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a5f42b630c3fa2..f60a38980549e9 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2240,317 +2240,353 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
ICEArguments &= ~(1 << ArgNo);
}
- FPOptions FPO;
- switch (BuiltinID) {
- case Builtin::BI__builtin_cpu_supports:
- case Builtin::BI__builtin_cpu_is:
- if (SemaBuiltinCpu(*this, Context.getTargetInfo(), TheCall,
- Context.getAuxTargetInfo(), BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_cpu_init:
- if (!Context.getTargetInfo().supportsCpuInit()) {
- Diag(TheCall->getBeginLoc(), diag::err_builtin_target_unsupported)
- << SourceRange(TheCall->getBeginLoc(), TheCall->getEndLoc());
- return ExprError();
+ // if the call has the elementwise attribute, then
+ // make sure that an elementwise expr is emitted.
+ if (FDecl->hasAttr(Attr::AT_ElementwiseBuiltinAlias)) {
+ switch (FDecl->getNumParams()) {
+ case 1: {
+ if (PrepareBuiltinElementwiseMathOneArgCall(TheCall))
+ return ExprError();
+
+ QualType ArgTy = TheCall->getArg(0)->getType();
+ if (checkFPMathBuiltinElementType(
+ *this, TheCall->getArg(0)->getBeginLoc(), ArgTy, 1))
+ return ExprError();
+ break;
}
- break;
- case Builtin::BI__builtin___CFStringMakeConstantString:
- // CFStringMakeConstantString is currently not implemented for GOFF (i.e.,
- // on z/OS) and for XCOFF (i.e., on AIX). Emit unsupported
- if (CheckBuiltinTargetNotInUnsupported(
- *this, BuiltinID, TheCall,
- {llvm::Triple::GOFF, llvm::Triple::XCOFF}))
- return ExprError();
- assert(TheCall->getNumArgs() == 1 &&
- "Wrong # arguments to builtin CFStringMakeConstantString");
- if (CheckObjCString(TheCall->getArg(0)))
- return ExprError();
- break;
- case Builtin::BI__builtin_ms_va_start:
- case Builtin::BI__builtin_stdarg_start:
- case Builtin::BI__builtin_va_start:
- if (SemaBuiltinVAStart(BuiltinID, TheCall))
- return ExprError();
- break;
- case Builtin::BI__va_start: {
- switch (Context.getTargetInfo().getTriple().getArch()) {
- case llvm::Triple::aarch64:
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- if (SemaBuiltinVAStartARMMicrosoft(TheCall))
+ case 2: {
+ if (SemaBuiltinElementwiseMath(TheCall))
+ return ExprError();
+
+ QualType ArgTy = TheCall->getArg(0)->getType();
+ if (checkFPMathBuiltinElementType(
+ *this, TheCall->getArg(0)->getBeginLoc(), ArgTy, 1) ||
+ checkFPMathBuiltinElementType(
+ *this, TheCall->getArg(1)->getBeginLoc(), ArgTy, 2))
return ExprError();
break;
- default:
+ }
+ case 3: {
+ if (SemaBuiltinElementwiseTernaryMath(TheCall))
+ return ExprError();
+ break;
+ }
+ }
+
+ FPOptions FPO;
+ switch (BuiltinID) {
+ case Builtin::BI__builtin_cpu_supports:
+ case Builtin::BI__builtin_cpu_is:
+ if (SemaBuiltinCpu(*this, Context.getTargetInfo(), TheCall,
+ Context.getAuxTargetInfo(), BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_cpu_init:
+ if (!Context.getTargetInfo().supportsCpuInit()) {
+ Diag(TheCall->getBeginLoc(), diag::err_builtin_target_unsupported)
+ << SourceRange(TheCall->getBeginLoc(), TheCall->getEndLoc());
+ return ExprError();
+ }
+ break;
+ case Builtin::BI__builtin___CFStringMakeConstantString:
+ // CFStringMakeConstantString is currently not implemented for GOFF (i.e.,
+ // on z/OS) and for XCOFF (i.e., on AIX). Emit unsupported
+ if (CheckBuiltinTargetNotInUnsupported(
+ *this, BuiltinID, TheCall,
+ {llvm::Triple::GOFF, llvm::Triple::XCOFF}))
+ return ExprError();
+ assert(TheCall->getNumArgs() == 1 &&
+ "Wrong # arguments to builtin CFStringMakeConstantString");
+ if (CheckObjCString(TheCall->getArg(0)))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_ms_va_start:
+ case Builtin::BI__builtin_stdarg_start:
+ case Builtin::BI__builtin_va_start:
if (SemaBuiltinVAStart(BuiltinID, TheCall))
return ExprError();
break;
+ case Builtin::BI__va_start: {
+ switch (Context.getTargetInfo().getTriple().getArch()) {
+ case llvm::Triple::aarch64:
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ if (SemaBuiltinVAStartARMMicrosoft(TheCall))
+ return ExprError();
+ break;
+ default:
+ if (SemaBuiltinVAStart(BuiltinID, TheCall))
+ return ExprError();
+ break;
+ }
+ break;
}
- break;
- }
- // The acquire, release, and no fence variants are ARM and AArch64 only.
- case Builtin::BI_interlockedbittestandset_acq:
- case Builtin::BI_interlockedbittestandset_rel:
- case Builtin::BI_interlockedbittestandset_nf:
- case Builtin::BI_interlockedbittestandreset_acq:
- case Builtin::BI_interlockedbittestandreset_rel:
- case Builtin::BI_interlockedbittestandreset_nf:
- if (CheckBuiltinTargetInSupported(
- *this, BuiltinID, TheCall,
- {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
- return ExprError();
- break;
+ // The acquire, release, and no fence variants are ARM and AArch64 only.
+ case Builtin::BI_interlockedbittestandset_acq:
+ case Builtin::BI_interlockedbittestandset_rel:
+ case Builtin::BI_interlockedbittestandset_nf:
+ case Builtin::BI_interlockedbittestandreset_acq:
+ case Builtin::BI_interlockedbittestandreset_rel:
+ case Builtin::BI_interlockedbittestandreset_nf:
+ if (CheckBuiltinTargetInSupported(
+ *this, BuiltinID, TheCall,
+ {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
+ return ExprError();
+ break;
- // The 64-bit bittest variants are x64, ARM, and AArch64 only.
- case Builtin::BI_bittest64:
- case Builtin::BI_bittestandcomplement64:
- case Builtin::BI_bittestandreset64:
- case Builtin::BI_bittestandset64:
- case Builtin::BI_interlockedbittestandreset64:
- case Builtin::BI_interlockedbittestandset64:
- if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
- {llvm::Triple::x86_64, llvm::Triple::arm,
- llvm::Triple::thumb,
- llvm::Triple::aarch64}))
- return ExprError();
- break;
+ // The 64-bit bittest variants are x64, ARM, and AArch64 only.
+ case Builtin::BI_bittest64:
+ case Builtin::BI_bittestandcomplement64:
+ case Builtin::BI_bittestandreset64:
+ case Builtin::BI_bittestandset64:
+ case Builtin::BI_interlockedbittestandreset64:
+ case Builtin::BI_interlockedbittestandset64:
+ if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
+ {llvm::Triple::x86_64,
+ llvm::Triple::arm, llvm::Triple::thumb,
+ llvm::Triple::aarch64}))
+ return ExprError();
+ break;
- case Builtin::BI__builtin_set_flt_rounds:
- if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
- {llvm::Triple::x86, llvm::Triple::x86_64,
- llvm::Triple::arm, llvm::Triple::thumb,
- llvm::Triple::aarch64}))
- return ExprError();
- break;
+ case Builtin::BI__builtin_set_flt_rounds:
+ if (CheckBuiltinTargetInSupported(
+ *this, BuiltinID, TheCall,
+ {llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
+ llvm::Triple::thumb, llvm::Triple::aarch64}))
+ return ExprError();
+ break;
- case Builtin::BI__builtin_isgreater:
- case Builtin::BI__builtin_isgreaterequal:
- case Builtin::BI__builtin_isless:
- case Builtin::BI__builtin_islessequal:
- case Builtin::BI__builtin_islessgreater:
- case Builtin::BI__builtin_isunordered:
- if (SemaBuiltinUnorderedCompare(TheCall, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_fpclassify:
- if (SemaBuiltinFPClassification(TheCall, 6, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_isfpclass:
- if (SemaBuiltinFPClassification(TheCall, 2, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_isfinite:
- case Builtin::BI__builtin_isinf:
- case Builtin::BI__builtin_isinf_sign:
- case Builtin::BI__builtin_isnan:
- case Builtin::BI__builtin_issignaling:
- case Builtin::BI__builtin_isnormal:
- case Builtin::BI__builtin_issubnormal:
- case Builtin::BI__builtin_iszero:
- case Builtin::BI__builtin_signbit:
- case Builtin::BI__builtin_signbitf:
- case Builtin::BI__builtin_signbitl:
- if (SemaBuiltinFPClassification(TheCall, 1, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_shufflevector:
- return SemaBuiltinShuffleVector(TheCall);
- // TheCall will be freed by the smart pointer here, but that's fine, since
- // SemaBuiltinShuffleVector guts it, but then doesn't release it.
- case Builtin::BI__builtin_prefetch:
- if (SemaBuiltinPrefetch(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_alloca_with_align:
- case Builtin::BI__builtin_alloca_with_align_uninitialized:
- if (SemaBuiltinAllocaWithAlign(TheCall))
- return ExprError();
- [[fallthrough]];
- case Builtin::BI__builtin_alloca:
- case Builtin::BI__builtin_alloca_uninitialized:
- Diag(TheCall->getBeginLoc(), diag::warn_alloca)
- << TheCall->getDirectCallee();
- break;
- case Builtin::BI__arithmetic_fence:
- if (SemaBuiltinArithmeticFence(TheCall))
- return ExprError();
- break;
- case Builtin::BI__assume:
- case Builtin::BI__builtin_assume:
- if (SemaBuiltinAssume(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_assume_aligned:
- if (SemaBuiltinAssumeAligned(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_dynamic_object_size:
- case Builtin::BI__builtin_object_size:
- if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
- return ExprError();
- break;
- case Builtin::BI__builtin_longjmp:
- if (SemaBuiltinLongjmp(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_setjmp:
- if (SemaBuiltinSetjmp(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_classify_type:
- if (checkArgCount(*this, TheCall, 1)) return true;
- TheCall->setType(Context.IntTy);
- break;
- case Builtin::BI__builtin_complex:
- if (SemaBuiltinComplex(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_constant_p: {
- if (checkArgCount(*this, TheCall, 1)) return true;
- ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
- if (Arg.isInvalid()) return true;
- TheCall->setArg(0, Arg.get());
- TheCall->setType(Context.IntTy);
- break;
- }
- case Builtin::BI__builtin_launder:
- return SemaBuiltinLaunder(*this, TheCall);
- case Builtin::BI__sync_fetch_and_add:
- case Builtin::BI__sync_fetch_and_add_1:
- case Builtin::BI__sync_fetch_and_add_2:
- case Builtin::BI__sync_fetch_and_add_4:
- case Builtin::BI__sync_fetch_and_add_8:
- case Builtin::BI__sync_fetch_and_add_16:
- case Builtin::BI__sync_fetch_and_sub:
- case Builtin::BI__sync_fetch_and_sub_1:
- case Builtin::BI__sync_fetch_and_sub_2:
- case Builtin::BI__sync_fetch_and_sub_4:
- case Builtin::BI__sync_fetch_and_sub_8:
- case Builtin::BI__sync_fetch_and_sub_16:
- case Builtin::BI__sync_fetch_and_or:
- case Builtin::BI__sync_fetch_and_or_1:
- case Builtin::BI__sync_fetch_and_or_2:
- case Builtin::BI__sync_fetch_and_or_4:
- case Builtin::BI__sync_fetch_and_or_8:
- case Builtin::BI__sync_fetch_and_or_16:
- case Builtin::BI__sync_fetch_and_and:
- case Builtin::BI__sync_fetch_and_and_1:
- case Builtin::BI__sync_fetch_and_and_2:
- case Builtin::BI__sync_fetch_and_and_4:
- case Builtin::BI__sync_fetch_and_and_8:
- case Builtin::BI__sync_fetch_and_and_16:
- case Builtin::BI__sync_fetch_and_xor:
- case Builtin::BI__sync_fetch_and_xor_1:
- case Builtin::BI__sync_fetch_and_xor_2:
- case Builtin::BI__sync_fetch_and_xor_4:
- case Builtin::BI__sync_fetch_and_xor_8:
- case Builtin::BI__sync_fetch_and_xor_16:
- case Builtin::BI__sync_fetch_and_nand:
- case Builtin::BI__sync_fetch_and_nand_1:
- case Builtin::BI__sync_fetch_and_nand_2:
- case Builtin::BI__sync_fetch_and_nand_4:
- case Builtin::BI__sync_fetch_and_nand_8:
- case Builtin::BI__sync_fetch_and_nand_16:
- case Builtin::BI__sync_add_and_fetch:
- case Builtin::BI__sync_add_and_fetch_1:
- case Builtin::BI__sync_add_and_fetch_2:
- case Builtin::BI__sync_add_and_fetch_4:
- case Builtin::BI__sync_add_and_fetch_8:
- case Builtin::BI__sync_add_and_fetch_16:
- case Builtin::BI__sync_sub_and_fetch:
- case Builtin::BI__sync_sub_and_fetch_1:
- case Builtin::BI__sync_sub_and_fetch_2:
- case Builtin::BI__sync_sub_and_fetch_4:
- case Builtin::BI__sync_sub_and_fetch_8:
- case Builtin::BI__sync_sub_and_fetch_16:
- case Builtin::BI__sync_and_and_fetch:
- case Builtin::BI__sync_and_and_fetch_1:
- case Builtin::BI__sync_and_and_fetch_2:
- case Builtin::BI__sync_and_and_fetch_4:
- case Builtin::BI__sync_and_and_fetch_8:
- case Builtin::BI__sync_and_and_fetch_16:
- case Builtin::BI__sync_or_and_fetch:
- case Builtin::BI__sync_or_and_fetch_1:
- case Builtin::BI__sync_or_and_fetch_2:
- case Builtin::BI__sync_or_and_fetch_4:
- case Builtin::BI__sync_or_and_fetch_8:
- case Builtin::BI__sync_or_and_fetch_16:
- case Builtin::BI__sync_xor_and_fetch:
- case Builtin::BI__sync_xor_and_fetch_1:
- case Builtin::BI__sync_xor_and_fetch_2:
- case Builtin::BI__sync_xor_and_fetch_4:
- case Builtin::BI__sync_xor_and_fetch_8:
- case Builtin::BI__sync_xor_and_fetch_16:
- case Builtin::BI__sync_nand_and_fetch:
- case Builtin::BI__sync_nand_and_fetch_1:
- case Builtin::BI__sync_nand_and_fetch_2:
- case Builtin::BI__sync_nand_and_fetch_4:
- case Builtin::BI__sync_nand_and_fetch_8:
- case Builtin::BI__sync_nand_and_fetch_16:
- case Builtin::BI__sync_val_compare_and_swap:
- case Builtin::BI__sync_val_compare_and_swap_1:
- case Builtin::BI__sync_val_compare_and_swap_2:
- case Builtin::BI__sync_val_compare_and_swap_4:
- case Builtin::BI__sync_val_compare_and_swap_8:
- case Builtin::BI__sync_val_compare_and_swap_16:
- case Builtin::BI__sync_bool_compare_and_swap:
- case Builtin::BI__sync_bool_compare_and_swap_1:
- case Builtin::BI__sync_bool_compare_and_swap_2:
- case Builtin::BI__sync_bool_compare_and_swap_4:
- case Builtin::BI__sync_bool_compare_and_swap_8:
- case Builtin::BI__sync_bool_compare_and_swap_16:
- case Builtin::BI__sync_lock_test_and_set:
- case Builtin::BI__sync_lock_test_and_set_1:
- case Builtin::BI__sync_lock_test_and_set_2:
- case Builtin::BI__sync_lock_test_and_set_4:
- case Builtin::BI__sync_lock_test_and_set_8:
- case Builtin::BI__sync_lock_test_and_set_16:
- case Builtin::BI__sync_lock_release:
- case Builtin::BI__sync_lock_release_1:
- case Builtin::BI__sync_lock_release_2:
- case Builtin::BI__sync_lock_release_4:
- case Builtin::BI__sync_lock_release_8:
- case Builtin::BI__sync_lock_release_16:
- case Builtin::BI__sync_swap:
- case Builtin::BI__sync_swap_1:
- case Builtin::BI__sync_swap_2:
- case Builtin::BI__sync_swap_4:
- case Builtin::BI__sync_swap_8:
- case Builtin::BI__sync_swap_16:
- return SemaBuiltinAtomicOverloaded(TheCallResult);
- case Builtin::BI__sync_synchronize:
- Diag(TheCall->getBeginLoc(), diag::warn_atomic_implicit_seq_cst)
- << TheCall->getCallee()->getSourceRange();
- break;
- case Builtin::BI__builtin_nontemporal_load:
- case Builtin::BI__builtin_nontemporal_store:
- return SemaBuiltinNontemporalOverloaded(TheCallResult);
- case Builtin::BI__builtin_memcpy_inline: {
- clang::Expr *SizeOp = TheCall->getArg(2);
- // We warn about copying to or from `nullptr` pointers when `size` is
- // greater than 0. When `size` is value dependent we cannot evaluate its
- // value so we bail out.
- if (SizeOp->isValueDependent())
+ case Builtin::BI__builtin_isgreater:
+ case Builtin::BI__builtin_isgreaterequal:
+ case Builtin::BI__builtin_isless:
+ case Builtin::BI__builtin_islessequal:
+ case Builtin::BI__builtin_islessgreater:
+ case Builtin::BI__builtin_isunordered:
+ if (SemaBuiltinUnorderedCompare(TheCall, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_fpclassify:
+ if (SemaBuiltinFPClassification(TheCall, 6, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_isfpclass:
+ if (SemaBuiltinFPClassification(TheCall, 2, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_isfinite:
+ case Builtin::BI__builtin_isinf:
+ case Builtin::BI__builtin_isinf_sign:
+ case Builtin::BI__builtin_isnan:
+ case Builtin::BI__builtin_issignaling:
+ case Builtin::BI__builtin_isnormal:
+ case Builtin::BI__builtin_issubnormal:
+ case Builtin::BI__builtin_iszero:
+ case Builtin::BI__builtin_signbit:
+ case Builtin::BI__builtin_signbitf:
+ case Builtin::BI__builtin_signbitl:
+ if (SemaBuiltinFPClassification(TheCall, 1, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_shufflevector:
+ return SemaBuiltinShuffleVector(TheCall);
+ // TheCall will be freed by the smart pointer here, but that's fine, since
+ // SemaBuiltinShuffleVector guts it, but then doesn't release it.
+ case Builtin::BI__builtin_prefetch:
+ if (SemaBuiltinPrefetch(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_alloca_with_align:
+ case Builtin::BI__builtin_alloca_with_align_uninitialized:
+ if (SemaBuiltinAllocaWithAlign(TheCall))
+ return ExprError();
+ [[fallthrough]];
+ case Builtin::BI__builtin_alloca:
+ case Builtin::BI__builtin_alloca_uninitialized:
+ Diag(TheCall->getBeginLoc(), diag::warn_alloca)
+ << TheCall->getDirectCallee();
+ break;
+ case Builtin::BI__arithmetic_fence:
+ if (SemaBuiltinArithmeticFence(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__assume:
+ case Builtin::BI__builtin_assume:
+ if (SemaBuiltinAssume(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_assume_aligned:
+ if (SemaBuiltinAssumeAligned(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_dynamic_object_size:
+ case Builtin::BI__builtin_object_size:
+ if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_longjmp:
+ if (SemaBuiltinLongjmp(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_setjmp:
+ if (SemaBuiltinSetjmp(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_classify_type:
+ if (checkArgCount(*this, TheCall, 1))
+ return true;
+ TheCall->setType(Context.IntTy);
+ break;
+ case Builtin::BI__builtin_complex:
+ if (SemaBuiltinComplex(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_constant_p: {
+ if (checkArgCount(*this, TheCall, 1))
+ return true;
+ ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
+ if (Arg.isInvalid())
+ return true;
+ TheCall->setArg(0, Arg.get());
+ TheCall->setType(Context.IntTy);
break;
- if (!SizeOp->EvaluateKnownConstInt(Context).isZero()) {
- CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
- CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
}
- break;
- }
- case Builtin::BI__builtin_memset_inline: {
- clang::Expr *SizeOp = TheCall->getArg(2);
- // We warn about filling to `nullptr` pointers when `size` is greater than
- // 0. When `size` is value dependent we cannot evaluate its value so we bail
- // out.
- if (SizeOp->isValueDependent())
+ case Builtin::BI__builtin_launder:
+ return SemaBuiltinLaunder(*this, TheCall);
+ case Builtin::BI__sync_fetch_and_add:
+ case Builtin::BI__sync_fetch_and_add_1:
+ case Builtin::BI__sync_fetch_and_add_2:
+ case Builtin::BI__sync_fetch_and_add_4:
+ case Builtin::BI__sync_fetch_and_add_8:
+ case Builtin::BI__sync_fetch_and_add_16:
+ case Builtin::BI__sync_fetch_and_sub:
+ case Builtin::BI__sync_fetch_and_sub_1:
+ case Builtin::BI__sync_fetch_and_sub_2:
+ case Builtin::BI__sync_fetch_and_sub_4:
+ case Builtin::BI__sync_fetch_and_sub_8:
+ case Builtin::BI__sync_fetch_and_sub_16:
+ case Builtin::BI__sync_fetch_and_or:
+ case Builtin::BI__sync_fetch_and_or_1:
+ case Builtin::BI__sync_fetch_and_or_2:
+ case Builtin::BI__sync_fetch_and_or_4:
+ case Builtin::BI__sync_fetch_and_or_8:
+ case Builtin::BI__sync_fetch_and_or_16:
+ case Builtin::BI__sync_fetch_and_and:
+ case Builtin::BI__sync_fetch_and_and_1:
+ case Builtin::BI__sync_fetch_and_and_2:
+ case Builtin::BI__sync_fetch_and_and_4:
+ case Builtin::BI__sync_fetch_and_and_8:
+ case Builtin::BI__sync_fetch_and_and_16:
+ case Builtin::BI__sync_fetch_and_xor:
+ case Builtin::BI__sync_fetch_and_xor_1:
+ case Builtin::BI__sync_fetch_and_xor_2:
+ case Builtin::BI__sync_fetch_and_xor_4:
+ case Builtin::BI__sync_fetch_and_xor_8:
+ case Builtin::BI__sync_fetch_and_xor_16:
+ case Builtin::BI__sync_fetch_and_nand:
+ case Builtin::BI__sync_fetch_and_nand_1:
+ case Builtin::BI__sync_fetch_and_nand_2:
+ case Builtin::BI__sync_fetch_and_nand_4:
+ case Builtin::BI__sync_fetch_and_nand_8:
+ case Builtin::BI__sync_fetch_and_nand_16:
+ case Builtin::BI__sync_add_and_fetch:
+ case Builtin::BI__sync_add_and_fetch_1:
+ case Builtin::BI__sync_add_and_fetch_2:
+ case Builtin::BI__sync_add_and_fetch_4:
+ case Builtin::BI__sync_add_and_fetch_8:
+ case Builtin::BI__sync_add_and_fetch_16:
+ case Builtin::BI__sync_sub_and_fetch:
+ case Builtin::BI__sync_sub_and_fetch_1:
+ case Builtin::BI__sync_sub_and_fetch_2:
+ case Builtin::BI__sync_sub_and_fetch_4:
+ case Builtin::BI__sync_sub_and_fetch_8:
+ case Builtin::BI__sync_sub_and_fetch_16:
+ case Builtin::BI__sync_and_and_fetch:
+ case Builtin::BI__sync_and_and_fetch_1:
+ case Builtin::BI__sync_and_and_fetch_2:
+ case Builtin::BI__sync_and_and_fetch_4:
+ case Builtin::BI__sync_and_and_fetch_8:
+ case Builtin::BI__sync_and_and_fetch_16:
+ case Builtin::BI__sync_or_and_fetch:
+ case Builtin::BI__sync_or_and_fetch_1:
+ case Builtin::BI__sync_or_and_fetch_2:
+ case Builtin::BI__sync_or_and_fetch_4:
+ case Builtin::BI__sync_or_and_fetch_8:
+ case Builtin::BI__sync_or_and_fetch_16:
+ case Builtin::BI__sync_xor_and_fetch:
+ case Builtin::BI__sync_xor_and_fetch_1:
+ case Builtin::BI__sync_xor_and_fetch_2:
+ case Builtin::BI__sync_xor_and_fetch_4:
+ case Builtin::BI__sync_xor_and_fetch_8:
+ case Builtin::BI__sync_xor_and_fetch_16:
+ case Builtin::BI__sync_nand_and_fetch:
+ case Builtin::BI__sync_nand_and_fetch_1:
+ case Builtin::BI__sync_nand_and_fetch_2:
+ case Builtin::BI__sync_nand_and_fetch_4:
+ case Builtin::BI__sync_nand_and_fetch_8:
+ case Builtin::BI__sync_nand_and_fetch_16:
+ case Builtin::BI__sync_val_compare_and_swap:
+ case Builtin::BI__sync_val_compare_and_swap_1:
+ case Builtin::BI__sync_val_compare_and_swap_2:
+ case Builtin::BI__sync_val_compare_and_swap_4:
+ case Builtin::BI__sync_val_compare_and_swap_8:
+ case Builtin::BI__sync_val_compare_and_swap_16:
+ case Builtin::BI__sync_bool_compare_and_swap:
+ case Builtin::BI__sync_bool_compare_and_swap_1:
+ case Builtin::BI__sync_bool_compare_and_swap_2:
+ case Builtin::BI__sync_bool_compare_and_swap_4:
+ case Builtin::BI__sync_bool_compare_and_swap_8:
+ case Builtin::BI__sync_bool_compare_and_swap_16:
+ case Builtin::BI__sync_lock_test_and_set:
+ case Builtin::BI__sync_lock_test_and_set_1:
+ case Builtin::BI__sync_lock_test_and_set_2:
+ case Builtin::BI__sync_lock_test_and_set_4:
+ case Builtin::BI__sync_lock_test_and_set_8:
+ case Builtin::BI__sync_lock_test_and_set_16:
+ case Builtin::BI__sync_lock_release:
+ case Builtin::BI__sync_lock_release_1:
+ case Builtin::BI__sync_lock_release_2:
+ case Builtin::BI__sync_lock_release_4:
+ case Builtin::BI__sync_lock_release_8:
+ case Builtin::BI__sync_lock_release_16:
+ case Builtin::BI__sync_swap:
+ case Builtin::BI__sync_swap_1:
+ case Builtin::BI__sync_swap_2:
+ case Builtin::BI__sync_swap_4:
+ case Builtin::BI__sync_swap_8:
+ case Builtin::BI__sync_swap_16:
+ return SemaBuiltinAtomicOverloaded(TheCallResult);
+ case Builtin::BI__sync_synchronize:
+ Diag(TheCall->getBeginLoc(), diag::warn_atomic_implicit_seq_cst)
+ << TheCall->getCallee()->getSourceRange();
break;
- if (!SizeOp->EvaluateKnownConstInt(Context).isZero())
- CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
- break;
- }
+ case Builtin::BI__builtin_nontemporal_load:
+ case Builtin::BI__builtin_nontemporal_store:
+ return SemaBuiltinNontemporalOverloaded(TheCallResult);
+ case Builtin::BI__builtin_memcpy_inline: {
+ clang::Expr *SizeOp = TheCall->getArg(2);
+ // We warn about copying to or from `nullptr` pointers when `size` is
+ // greater than 0. When `size` is value dependent we cannot evaluate its
+ // value so we bail out.
+ if (SizeOp->isValueDependent())
+ break;
+ if (!SizeOp->EvaluateKnownConstInt(Context).isZero()) {
+ CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+ CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
+ }
+ break;
+ }
+ case Builtin::BI__builtin_memset_inline: {
+ clang::Expr *SizeOp = TheCall->getArg(2);
+ // We warn about filling to `nullptr` pointers when `size` is greater than
+ // 0. When `size` is value dependent we cannot evaluate its value so we
+ // bail out.
+ if (SizeOp->isValueDependent())
+ break;
+ if (!SizeOp->EvaluateKnownConstInt(Context).isZero())
+ CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+ break;
+ }
#define BUILTIN(ID, TYPE, ATTRS)
#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
case Builtin::BI##ID: \
@@ -3014,7 +3050,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
}
return TheCallResult;
-}
+ }
// Get the valid immediate range for the specified NEON type code.
static unsigned RFT(unsigned t, bool shift = false, bool ForceQuad = false) {
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 4710bd61a78e14..8f5ca271242d5b 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5952,6 +5952,35 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
}
+static void handleElementwiseBuiltinAliasAttr(Sema &S, Decl *D,
+ const ParsedAttr &AL) {
+ if (!AL.isArgIdent(0)) {
+ S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+ << AL << 1 << AANT_ArgumentIdentifier;
+ return;
+ }
+
+ IdentifierInfo *Ident = AL.getArgAsIdent(0)->Ident;
+ unsigned BuiltinID = Ident->getBuiltinID();
+ StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
+
+ bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64();
+ bool IsARM = S.Context.getTargetInfo().getTriple().isARM();
+ bool IsRISCV = S.Context.getTargetInfo().getTriple().isRISCV();
+ bool IsHLSL = S.Context.getLangOpts().HLSL;
+ if ((IsAArch64 && !ArmSveAliasValid(S.Context, BuiltinID, AliasName)) ||
+ (IsARM && !ArmMveAliasValid(BuiltinID, AliasName) &&
+ !ArmCdeAliasValid(BuiltinID, AliasName)) ||
+ (IsRISCV && !RISCVAliasValid(BuiltinID, AliasName)) ||
+ (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
+ S.Diag(AL.getLoc(), diag::err_attribute_elementwise_builtin_alias) << AL;
+ return;
+ }
+
+ D->addAttr(::new (S.Context)
+ ElementwiseBuiltinAliasAttr(S.Context, AL, Ident));
+}
+
static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (!AL.hasParsedType()) {
S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
@@ -9852,7 +9881,7 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
handleBuiltinAliasAttr(S, D, AL);
break;
case ParsedAttr::AT_ElementwiseBuiltinAlias:
- handleBuiltinAliasAttr(S, D, AL);
+ handleElementwiseBuiltinAliasAttr(S, D, AL);
break;
case ParsedAttr::AT_PreferredType:
>From 866007083a306bd4785579b691bbf99143bc0548 Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbatista at microsoft.com>
Date: Thu, 21 Mar 2024 11:43:18 -0700
Subject: [PATCH 4/5] IT WORKS ON CEIL!!!
---
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 4 ++--
clang/lib/Sema/SemaChecking.cpp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index f646522e35e84c..1c8e4073026091 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -99,7 +99,7 @@ _HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
double2 abs(double2);
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
double3 abs(double3);
-_HLSL_ELEMENTWISE_BUILTIN_ALIAS(__builtin_elementwise_abs)
+_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
double4 abs(double4);
//===----------------------------------------------------------------------===//
@@ -251,7 +251,7 @@ _HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
double2 ceil(double2);
_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
double3 ceil(double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
+_HLSL_ELEMENTWISE_BUILTIN_ALIAS(__builtin_ceil)
double4 ceil(double4);
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f60a38980549e9..c2621bdd2f9ce9 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2242,7 +2242,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
// if the call has the elementwise attribute, then
// make sure that an elementwise expr is emitted.
- if (FDecl->hasAttr(Attr::AT_ElementwiseBuiltinAlias)) {
+ if (FDecl->hasAttr<ElementwiseBuiltinAliasAttr>()) {
switch (FDecl->getNumParams()) {
case 1: {
if (PrepareBuiltinElementwiseMathOneArgCall(TheCall))
@@ -2272,7 +2272,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
break;
}
}
-
+ }
FPOptions FPO;
switch (BuiltinID) {
case Builtin::BI__builtin_cpu_supports:
>From 8829ffc40310b1f66f1612e413de27d88c650cd3 Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbatista at microsoft.com>
Date: Thu, 21 Mar 2024 11:53:14 -0700
Subject: [PATCH 5/5] clang-format
---
clang/lib/AST/Decl.cpp | 575 ++--
clang/lib/Headers/hlsl/hlsl_intrinsics.h | 2 +-
clang/lib/Sema/SemaChecking.cpp | 3194 ++++++++++++----------
clang/lib/Sema/SemaDeclAttr.cpp | 549 ++--
4 files changed, 2265 insertions(+), 2055 deletions(-)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index cb2c5cf6ceaf49..695a591c3afdbd 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -80,7 +80,8 @@ Decl *clang::getPrimaryMergedDecl(Decl *D) {
void PrettyDeclStackTraceEntry::print(raw_ostream &OS) const {
SourceLocation Loc = this->Loc;
- if (!Loc.isValid() && TheDecl) Loc = TheDecl->getLocation();
+ if (!Loc.isValid() && TheDecl)
+ Loc = TheDecl->getLocation();
if (Loc.isValid()) {
Loc.print(OS, Context.getSourceManager());
OS << ": ";
@@ -163,8 +164,7 @@ static bool hasExplicitVisibilityAlready(LVComputationKind computation) {
/// Given an LVComputationKind, return one of the same type/value sort
/// that records that it already has explicit visibility.
-static LVComputationKind
-withExplicitVisibilityAlready(LVComputationKind Kind) {
+static LVComputationKind withExplicitVisibilityAlready(LVComputationKind Kind) {
Kind.IgnoreExplicitVisibility = true;
return Kind;
}
@@ -179,8 +179,7 @@ static std::optional<Visibility> getExplicitVisibility(const NamedDecl *D,
/// Is the given declaration a "type" or a "value" for the purposes of
/// visibility computation?
static bool usesTypeVisibility(const NamedDecl *D) {
- return isa<TypeDecl>(D) ||
- isa<ClassTemplateDecl>(D) ||
+ return isa<TypeDecl>(D) || isa<ClassTemplateDecl>(D) ||
isa<ObjCInterfaceDecl>(D);
}
@@ -190,7 +189,7 @@ template <class T>
static std::enable_if_t<!std::is_base_of_v<RedeclarableTemplateDecl, T>, bool>
isExplicitMemberSpecialization(const T *D) {
if (const MemberSpecializationInfo *member =
- D->getMemberSpecializationInfo()) {
+ D->getMemberSpecializationInfo()) {
return member->isExplicitSpecialization();
}
return false;
@@ -205,8 +204,7 @@ static bool isExplicitMemberSpecialization(const RedeclarableTemplateDecl *D) {
/// Given a visibility attribute, return the explicit visibility
/// associated with it.
-template <class T>
-static Visibility getVisibilityFromAttr(const T *attr) {
+template <class T> static Visibility getVisibilityFromAttr(const T *attr) {
switch (attr->getVisibility()) {
case T::Default:
return DefaultVisibility;
@@ -290,8 +288,8 @@ LinkageInfo LinkageComputer::getLVForTemplateParameterList(
}
// Look at all expansions in an expanded pack.
- for (unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
- i != n; ++i) {
+ for (unsigned i = 0, n = TTP->getNumExpansionTemplateParameters(); i != n;
+ ++i) {
LV.merge(getLVForTemplateParameterList(
TTP->getExpansionTemplateParameters(i), computation));
}
@@ -370,8 +368,9 @@ LinkageComputer::getLVForTemplateArgumentList(const TemplateArgumentList &TArgs,
return getLVForTemplateArgumentList(TArgs.asArray(), computation);
}
-static bool shouldConsiderTemplateVisibility(const FunctionDecl *fn,
- const FunctionTemplateSpecializationInfo *specInfo) {
+static bool shouldConsiderTemplateVisibility(
+ const FunctionDecl *fn,
+ const FunctionTemplateSpecializationInfo *specInfo) {
// Include visibility from the template parameters and arguments
// only if this is not an explicit instantiation or specialization
// with direct explicit visibility. (Implicit instantiations won't
@@ -393,8 +392,7 @@ void LinkageComputer::mergeTemplateLV(
LinkageInfo &LV, const FunctionDecl *fn,
const FunctionTemplateSpecializationInfo *specInfo,
LVComputationKind computation) {
- bool considerVisibility =
- shouldConsiderTemplateVisibility(fn, specInfo);
+ bool considerVisibility = shouldConsiderTemplateVisibility(fn, specInfo);
FunctionTemplateDecl *temp = specInfo->getTemplate();
// Merge information from the template declaration.
@@ -427,8 +425,8 @@ static bool hasDirectVisibilityAttribute(const NamedDecl *D,
/// Should we consider visibility associated with the template
/// arguments and parameters of the given class template specialization?
-static bool shouldConsiderTemplateVisibility(
- const ClassTemplateSpecializationDecl *spec,
+static bool
+shouldConsiderTemplateVisibility(const ClassTemplateSpecializationDecl *spec,
LVComputationKind computation) {
// Include visibility from the template parameters and arguments
// only if this is not an explicit instantiation or specialization
@@ -478,9 +476,10 @@ void LinkageComputer::mergeTemplateLV(
LV.setLinkage(tempLV.getLinkage());
LinkageInfo paramsLV =
- getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
+ getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
LV.mergeMaybeWithVisibility(paramsLV,
- considerVisibility && !hasExplicitVisibilityAlready(computation));
+ considerVisibility &&
+ !hasExplicitVisibilityAlready(computation));
// Merge information from the template arguments. We ignore
// template-argument visibility if we've got an explicit
@@ -496,8 +495,8 @@ void LinkageComputer::mergeTemplateLV(
/// arguments and parameters of the given variable template
/// specialization? As usual, follow class template specialization
/// logic up to initialization.
-static bool shouldConsiderTemplateVisibility(
- const VarTemplateSpecializationDecl *spec,
+static bool
+shouldConsiderTemplateVisibility(const VarTemplateSpecializationDecl *spec,
LVComputationKind computation) {
// Include visibility from the template parameters and arguments
// only if this is not an explicit instantiation or specialization
@@ -529,9 +528,9 @@ void LinkageComputer::mergeTemplateLV(LinkageInfo &LV,
// visibility if we're only considering template arguments.
VarTemplateDecl *temp = spec->getSpecializedTemplate();
LinkageInfo tempLV =
- getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
- LV.mergeMaybeWithVisibility(tempLV,
- considerVisibility && !hasExplicitVisibilityAlready(computation));
+ getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
+ LV.mergeMaybeWithVisibility(
+ tempLV, considerVisibility && !hasExplicitVisibilityAlready(computation));
// Merge information from the template arguments. We ignore
// template-argument visibility if we've got an explicit
@@ -554,11 +553,11 @@ static bool useInlineVisibilityHidden(const NamedDecl *D) {
return false;
TemplateSpecializationKind TSK = TSK_Undeclared;
- if (FunctionTemplateSpecializationInfo *spec
- = FD->getTemplateSpecializationInfo()) {
+ if (FunctionTemplateSpecializationInfo *spec =
+ FD->getTemplateSpecializationInfo()) {
TSK = spec->getTemplateSpecializationKind();
} else if (MemberSpecializationInfo *MSI =
- FD->getMemberSpecializationInfo()) {
+ FD->getMemberSpecializationInfo()) {
TSK = MSI->getTemplateSpecializationKind();
}
@@ -567,8 +566,8 @@ static bool useInlineVisibilityHidden(const NamedDecl *D) {
// isInlined() only gives meaningful answers on definitions
// anyway.
return TSK != TSK_ExplicitInstantiationDeclaration &&
- TSK != TSK_ExplicitInstantiationDefinition &&
- FD->hasBody(Def) && Def->isInlined() && !Def->hasAttr<GNUInlineAttr>();
+ TSK != TSK_ExplicitInstantiationDefinition && FD->hasBody(Def) &&
+ Def->isInlined() && !Def->hasAttr<GNUInlineAttr>();
}
template <typename T> static bool isFirstInExternCContext(T *D) {
@@ -697,10 +696,10 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
// If we're declared in a namespace with a visibility attribute,
// use that namespace's visibility, and it still counts as explicit.
for (const DeclContext *DC = D->getDeclContext();
- !isa<TranslationUnitDecl>(DC);
- DC = DC->getParent()) {
+ !isa<TranslationUnitDecl>(DC); DC = DC->getParent()) {
const auto *ND = dyn_cast<NamespaceDecl>(DC);
- if (!ND) continue;
+ if (!ND)
+ continue;
if (std::optional<Visibility> Vis =
getExplicitVisibility(ND, computation)) {
LV.mergeVisibility(*Vis, true);
@@ -787,7 +786,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
mergeTemplateLV(LV, spec, computation);
}
- // - a function; or
+ // - a function; or
} else if (const auto *Function = dyn_cast<FunctionDecl>(D)) {
// In theory, we can modify the function's LV by the LV of its
// type unless it has C linkage (see comment above about variables
@@ -828,17 +827,17 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
// Consider LV from the template and the template arguments.
// We're at file scope, so we do not need to worry about nested
// specializations.
- if (FunctionTemplateSpecializationInfo *specInfo
- = Function->getTemplateSpecializationInfo()) {
+ if (FunctionTemplateSpecializationInfo *specInfo =
+ Function->getTemplateSpecializationInfo()) {
mergeTemplateLV(LV, Function, specInfo, computation);
}
- // - a named class (Clause 9), or an unnamed class defined in a
- // typedef declaration in which the class has the typedef name
- // for linkage purposes (7.1.3); or
- // - a named enumeration (7.2), or an unnamed enumeration
- // defined in a typedef declaration in which the enumeration
- // has the typedef name for linkage purposes (7.1.3); or
+ // - a named class (Clause 9), or an unnamed class defined in a
+ // typedef declaration in which the class has the typedef name
+ // for linkage purposes (7.1.3); or
+ // - a named enumeration (7.2), or an unnamed enumeration
+ // defined in a typedef declaration in which the enumeration
+ // has the typedef name for linkage purposes (7.1.3); or
} else if (const auto *Tag = dyn_cast<TagDecl>(D)) {
// Unnamed tags have no linkage.
if (!Tag->hasNameForLinkage())
@@ -851,46 +850,46 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
mergeTemplateLV(LV, spec, computation);
}
- // FIXME: This is not part of the C++ standard any more.
- // - an enumerator belonging to an enumeration with external linkage; or
+ // FIXME: This is not part of the C++ standard any more.
+ // - an enumerator belonging to an enumeration with external linkage; or
} else if (isa<EnumConstantDecl>(D)) {
- LinkageInfo EnumLV = getLVForDecl(cast<NamedDecl>(D->getDeclContext()),
- computation);
+ LinkageInfo EnumLV =
+ getLVForDecl(cast<NamedDecl>(D->getDeclContext()), computation);
if (!isExternalFormalLinkage(EnumLV.getLinkage()))
return LinkageInfo::none();
LV.merge(EnumLV);
- // - a template
+ // - a template
} else if (const auto *temp = dyn_cast<TemplateDecl>(D)) {
bool considerVisibility = !hasExplicitVisibilityAlready(computation);
- LinkageInfo tempLV =
- getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
+ LinkageInfo tempLV = getLVForTemplateParameterList(
+ temp->getTemplateParameters(), computation);
LV.mergeMaybeWithVisibility(tempLV, considerVisibility);
- // An unnamed namespace or a namespace declared directly or indirectly
- // within an unnamed namespace has internal linkage. All other namespaces
- // have external linkage.
- //
- // We handled names in anonymous namespaces above.
+ // An unnamed namespace or a namespace declared directly or indirectly
+ // within an unnamed namespace has internal linkage. All other
+ // namespaces have external linkage.
+ //
+ // We handled names in anonymous namespaces above.
} else if (isa<NamespaceDecl>(D)) {
return LV;
- // By extension, we assign external linkage to Objective-C
- // interfaces.
+ // By extension, we assign external linkage to Objective-C
+ // interfaces.
} else if (isa<ObjCInterfaceDecl>(D)) {
// fallout
} else if (auto *TD = dyn_cast<TypedefNameDecl>(D)) {
// A typedef declaration has linkage if it gives a type a name for
// linkage purposes.
- if (!TD->getAnonDeclWithTypedefName(/*AnyRedecl*/true))
+ if (!TD->getAnonDeclWithTypedefName(/*AnyRedecl*/ true))
return LinkageInfo::none();
} else if (isa<MSGuidDecl>(D)) {
// A GUID behaves like an inline variable with external linkage. Fall
// through.
- // Everything not covered here has no linkage.
+ // Everything not covered here has no linkage.
} else {
return LinkageInfo::none();
}
@@ -903,10 +902,9 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
return LV;
}
-LinkageInfo
-LinkageComputer::getLVForClassMember(const NamedDecl *D,
- LVComputationKind computation,
- bool IgnoreVarTypeLinkage) {
+LinkageInfo LinkageComputer::getLVForClassMember(const NamedDecl *D,
+ LVComputationKind computation,
+ bool IgnoreVarTypeLinkage) {
// Only certain class members have linkage. Note that fields don't
// really have linkage, but it's convenient to say they do for the
// purposes of calculating linkage of pointer-to-data-member
@@ -917,12 +915,8 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
// linkage and visibility of a template specialization, we might hit
// a template template argument that way. If we do, we need to
// consider its linkage.
- if (!(isa<CXXMethodDecl>(D) ||
- isa<VarDecl>(D) ||
- isa<FieldDecl>(D) ||
- isa<IndirectFieldDecl>(D) ||
- isa<TagDecl>(D) ||
- isa<TemplateDecl>(D)))
+ if (!(isa<CXXMethodDecl>(D) || isa<VarDecl>(D) || isa<FieldDecl>(D) ||
+ isa<IndirectFieldDecl>(D) || isa<TagDecl>(D) || isa<TemplateDecl>(D)))
return LinkageInfo::none();
LinkageInfo LV;
@@ -948,14 +942,13 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
classComputation = withExplicitVisibilityAlready(computation);
LinkageInfo classLV =
- getLVForDecl(cast<RecordDecl>(D->getDeclContext()), classComputation);
+ getLVForDecl(cast<RecordDecl>(D->getDeclContext()), classComputation);
// The member has the same linkage as the class. If that's not externally
// visible, we don't need to compute anything about the linkage.
// FIXME: If we're only computing linkage, can we bail out here?
if (!isExternallyVisible(classLV.getLinkage()))
return classLV;
-
// Otherwise, don't merge in classLV yet, because in certain cases
// we need to completely ignore the visibility from it.
@@ -973,8 +966,8 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
// If this is a method template specialization, use the linkage for
// the template parameters and arguments.
- if (FunctionTemplateSpecializationInfo *spec
- = MD->getTemplateSpecializationInfo()) {
+ if (FunctionTemplateSpecializationInfo *spec =
+ MD->getTemplateSpecializationInfo()) {
mergeTemplateLV(LV, MD, spec, computation);
if (spec->isExplicitSpecialization()) {
explicitSpecSuppressor = MD;
@@ -1011,7 +1004,7 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
explicitSpecSuppressor = RD;
}
- // Static data members.
+ // Static data members.
} else if (const auto *VD = dyn_cast<VarDecl>(D)) {
if (const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
mergeTemplateLV(LV, spec, computation);
@@ -1031,14 +1024,13 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
explicitSpecSuppressor = VD;
}
- // Template members.
+ // Template members.
} else if (const auto *temp = dyn_cast<TemplateDecl>(D)) {
bool considerVisibility =
- (!LV.isVisibilityExplicit() &&
- !classLV.isVisibilityExplicit() &&
- !hasExplicitVisibilityAlready(computation));
- LinkageInfo tempLV =
- getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
+ (!LV.isVisibilityExplicit() && !classLV.isVisibilityExplicit() &&
+ !hasExplicitVisibilityAlready(computation));
+ LinkageInfo tempLV = getLVForTemplateParameterList(
+ temp->getTemplateParameters(), computation);
LV.mergeMaybeWithVisibility(tempLV, considerVisibility);
if (const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
@@ -1155,7 +1147,8 @@ NamedDecl::isReserved(const LangOptions &LangOpts) const {
ObjCStringFormatFamily NamedDecl::getObjCFStringFormattingFamily() const {
StringRef name = getName();
- if (name.empty()) return SFF_None;
+ if (name.empty())
+ return SFF_None;
if (name.front() == 'C')
if (name == "CFStringCreateWithFormat" ||
@@ -1279,8 +1272,8 @@ getExplicitVisibilityAux(const NamedDecl *ND,
if (const auto *fn = dyn_cast<FunctionDecl>(ND)) {
// If the function is a specialization of a template with an
// explicit visibility attribute, use that.
- if (FunctionTemplateSpecializationInfo *templateInfo
- = fn->getTemplateSpecializationInfo())
+ if (FunctionTemplateSpecializationInfo *templateInfo =
+ fn->getTemplateSpecializationInfo())
return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
kind);
@@ -1333,7 +1326,7 @@ LinkageInfo LinkageComputer::getLVForClosure(const DeclContext *DC,
auto *VD = dyn_cast<VarDecl>(Owner);
LinkageInfo OwnerLV =
VD && VD->getType()->getContainedDeducedType()
- ? computeLVForDecl(Owner, computation, /*IgnoreVarTypeLinkage*/true)
+ ? computeLVForDecl(Owner, computation, /*IgnoreVarTypeLinkage*/ true)
: getLVForDecl(Owner, computation);
// A lambda never formally has linkage. But if the owner is externally
@@ -1457,78 +1450,77 @@ LinkageInfo LinkageComputer::computeLVForDecl(const NamedDecl *D,
// Objective-C: treat all Objective-C declarations as having external
// linkage.
switch (D->getKind()) {
- default:
- break;
+ default:
+ break;
- // Per C++ [basic.link]p2, only the names of objects, references,
- // functions, types, templates, namespaces, and values ever have linkage.
- //
- // Note that the name of a typedef, namespace alias, using declaration,
- // and so on are not the name of the corresponding type, namespace, or
- // declaration, so they do *not* have linkage.
- case Decl::ImplicitParam:
- case Decl::Label:
- case Decl::NamespaceAlias:
- case Decl::ParmVar:
- case Decl::Using:
- case Decl::UsingEnum:
- case Decl::UsingShadow:
- case Decl::UsingDirective:
- return LinkageInfo::none();
+ // Per C++ [basic.link]p2, only the names of objects, references,
+ // functions, types, templates, namespaces, and values ever have linkage.
+ //
+ // Note that the name of a typedef, namespace alias, using declaration,
+ // and so on are not the name of the corresponding type, namespace, or
+ // declaration, so they do *not* have linkage.
+ case Decl::ImplicitParam:
+ case Decl::Label:
+ case Decl::NamespaceAlias:
+ case Decl::ParmVar:
+ case Decl::Using:
+ case Decl::UsingEnum:
+ case Decl::UsingShadow:
+ case Decl::UsingDirective:
+ return LinkageInfo::none();
- case Decl::EnumConstant:
- // C++ [basic.link]p4: an enumerator has the linkage of its enumeration.
- if (D->getASTContext().getLangOpts().CPlusPlus)
- return getLVForDecl(cast<EnumDecl>(D->getDeclContext()), computation);
- return LinkageInfo::visible_none();
-
- case Decl::Typedef:
- case Decl::TypeAlias:
- // A typedef declaration has linkage if it gives a type a name for
- // linkage purposes.
- if (!cast<TypedefNameDecl>(D)
- ->getAnonDeclWithTypedefName(/*AnyRedecl*/true))
- return LinkageInfo::none();
- break;
+ case Decl::EnumConstant:
+ // C++ [basic.link]p4: an enumerator has the linkage of its enumeration.
+ if (D->getASTContext().getLangOpts().CPlusPlus)
+ return getLVForDecl(cast<EnumDecl>(D->getDeclContext()), computation);
+ return LinkageInfo::visible_none();
- case Decl::TemplateTemplateParm: // count these as external
- case Decl::NonTypeTemplateParm:
- case Decl::ObjCAtDefsField:
- case Decl::ObjCCategory:
- case Decl::ObjCCategoryImpl:
- case Decl::ObjCCompatibleAlias:
- case Decl::ObjCImplementation:
- case Decl::ObjCMethod:
- case Decl::ObjCProperty:
- case Decl::ObjCPropertyImpl:
- case Decl::ObjCProtocol:
- return getExternalLinkageFor(D);
-
- case Decl::CXXRecord: {
- const auto *Record = cast<CXXRecordDecl>(D);
- if (Record->isLambda()) {
- if (Record->hasKnownLambdaInternalLinkage() ||
- !Record->getLambdaManglingNumber()) {
- // This lambda has no mangling number, so it's internal.
- return LinkageInfo::internal();
- }
+ case Decl::Typedef:
+ case Decl::TypeAlias:
+ // A typedef declaration has linkage if it gives a type a name for
+ // linkage purposes.
+ if (!cast<TypedefNameDecl>(D)->getAnonDeclWithTypedefName(
+ /*AnyRedecl*/ true))
+ return LinkageInfo::none();
+ break;
- return getLVForClosure(
- Record->getDeclContext()->getRedeclContext(),
- Record->getLambdaContextDecl(), computation);
+ case Decl::TemplateTemplateParm: // count these as external
+ case Decl::NonTypeTemplateParm:
+ case Decl::ObjCAtDefsField:
+ case Decl::ObjCCategory:
+ case Decl::ObjCCategoryImpl:
+ case Decl::ObjCCompatibleAlias:
+ case Decl::ObjCImplementation:
+ case Decl::ObjCMethod:
+ case Decl::ObjCProperty:
+ case Decl::ObjCPropertyImpl:
+ case Decl::ObjCProtocol:
+ return getExternalLinkageFor(D);
+
+ case Decl::CXXRecord: {
+ const auto *Record = cast<CXXRecordDecl>(D);
+ if (Record->isLambda()) {
+ if (Record->hasKnownLambdaInternalLinkage() ||
+ !Record->getLambdaManglingNumber()) {
+ // This lambda has no mangling number, so it's internal.
+ return LinkageInfo::internal();
}
- break;
+ return getLVForClosure(Record->getDeclContext()->getRedeclContext(),
+ Record->getLambdaContextDecl(), computation);
}
- case Decl::TemplateParamObject: {
- // The template parameter object can be referenced from anywhere its type
- // and value can be referenced.
- auto *TPO = cast<TemplateParamObjectDecl>(D);
- LinkageInfo LV = getLVForType(*TPO->getType(), computation);
- LV.merge(getLVForValue(TPO->getValue(), computation));
- return LV;
- }
+ break;
+ }
+
+ case Decl::TemplateParamObject: {
+ // The template parameter object can be referenced from anywhere its type
+ // and value can be referenced.
+ auto *TPO = cast<TemplateParamObjectDecl>(D);
+ LinkageInfo LV = getLVForType(*TPO->getType(), computation);
+ LV.merge(getLVForValue(TPO->getValue(), computation));
+ return LV;
+ }
}
// Handle linkage for namespace-scope names.
@@ -1775,8 +1767,7 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream &OS,
if (ND->isAnonymousNamespace()) {
OS << (P.MSVCFormatting ? "`anonymous namespace\'"
: "(anonymous namespace)");
- }
- else
+ } else
OS << *ND;
} else if (const auto *RD = dyn_cast<RecordDecl>(DC)) {
if (!RD->getIdentifier())
@@ -1832,14 +1823,14 @@ void NamedDecl::getNameForDiagnostic(raw_ostream &OS,
printName(OS, Policy);
}
-template<typename T> static bool isRedeclarableImpl(Redeclarable<T> *) {
+template <typename T> static bool isRedeclarableImpl(Redeclarable<T> *) {
return true;
}
static bool isRedeclarableImpl(...) { return false; }
static bool isRedeclarable(Decl::Kind K) {
switch (K) {
-#define DECL(Type, Base) \
- case Decl::Type: \
+#define DECL(Type, Base) \
+ case Decl::Type: \
return isRedeclarableImpl((Type##Decl *)nullptr);
#define ABSTRACT_DECL(DECL)
#include "clang/AST/DeclNodes.inc"
@@ -1888,7 +1879,7 @@ bool NamedDecl::declarationReplaces(const NamedDecl *OldD,
ASTContext &Context = getASTContext();
return Context.getCanonicalNestedNameSpecifier(UUVD->getQualifier()) ==
Context.getCanonicalNestedNameSpecifier(
- cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
+ cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
}
if (isRedeclarable(getKind())) {
@@ -1984,13 +1975,15 @@ static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl) {
SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const {
TypeSourceInfo *TSI = getTypeSourceInfo();
- if (TSI) return TSI->getTypeLoc().getBeginLoc();
+ if (TSI)
+ return TSI->getTypeLoc().getBeginLoc();
return SourceLocation();
}
SourceLocation DeclaratorDecl::getTypeSpecEndLoc() const {
TypeSourceInfo *TSI = getTypeSourceInfo();
- if (TSI) return TSI->getTypeLoc().getEndLoc();
+ if (TSI)
+ return TSI->getTypeLoc().getEndLoc();
return SourceLocation();
}
@@ -1999,7 +1992,7 @@ void DeclaratorDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) {
// Make sure the extended decl info is allocated.
if (!hasExtInfo()) {
// Save (non-extended) type source info pointer.
- auto *savedTInfo = DeclInfo.get<TypeSourceInfo*>();
+ auto *savedTInfo = DeclInfo.get<TypeSourceInfo *>();
// Allocate external info struct.
DeclInfo = new (getASTContext()) ExtInfo;
// Restore savedTInfo into (extended) decl info.
@@ -2018,7 +2011,7 @@ void DeclaratorDecl::setTrailingRequiresClause(Expr *TrailingRequiresClause) {
// Make sure the extended decl info is allocated.
if (!hasExtInfo()) {
// Save (non-extended) type source info pointer.
- auto *savedTInfo = DeclInfo.get<TypeSourceInfo*>();
+ auto *savedTInfo = DeclInfo.get<TypeSourceInfo *>();
// Allocate external info struct.
DeclInfo = new (getASTContext()) ExtInfo;
// Restore savedTInfo into (extended) decl info.
@@ -2034,7 +2027,7 @@ void DeclaratorDecl::setTemplateParameterListsInfo(
// Make sure the extended decl info is allocated.
if (!hasExtInfo()) {
// Save (non-extended) type source info pointer.
- auto *savedTInfo = DeclInfo.get<TypeSourceInfo*>();
+ auto *savedTInfo = DeclInfo.get<TypeSourceInfo *>();
// Allocate external info struct.
DeclInfo = new (getASTContext()) ExtInfo;
// Restore savedTInfo into (extended) decl info.
@@ -2052,7 +2045,7 @@ SourceLocation DeclaratorDecl::getOuterLocStart() const {
// having a postfix component.
static bool typeIsPostfix(QualType QT) {
while (true) {
- const Type* T = QT.getTypePtr();
+ const Type *T = QT.getTypePtr();
switch (T->getTypeClass()) {
default:
return false;
@@ -2117,12 +2110,18 @@ void QualifierInfo::setTemplateParameterListsInfo(
const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) {
switch (SC) {
- case SC_None: break;
- case SC_Auto: return "auto";
- case SC_Extern: return "extern";
- case SC_PrivateExtern: return "__private_extern__";
- case SC_Register: return "register";
- case SC_Static: return "static";
+ case SC_None:
+ break;
+ case SC_Auto:
+ return "auto";
+ case SC_Extern:
+ return "extern";
+ case SC_PrivateExtern:
+ return "__private_extern__";
+ case SC_Register:
+ return "register";
+ case SC_Static:
+ return "static";
}
llvm_unreachable("Invalid storage class");
@@ -2195,7 +2194,7 @@ SourceRange VarDecl::getSourceRange() const {
return DeclaratorDecl::getSourceRange();
}
-template<typename T>
+template <typename T>
static LanguageLinkage getDeclLanguageLinkage(const T &D) {
// C++ [dcl.link]p1: All function types, function names with external linkage,
// and variable names with external linkage have a language linkage.
@@ -2222,8 +2221,7 @@ static LanguageLinkage getDeclLanguageLinkage(const T &D) {
return CXXLanguageLinkage;
}
-template<typename T>
-static bool isDeclExternC(const T &D) {
+template <typename T> static bool isDeclExternC(const T &D) {
// Since the context is ignored for class members, they can only have C++
// language linkage or no language linkage.
const DeclContext *DC = D.getDeclContext();
@@ -2239,9 +2237,7 @@ LanguageLinkage VarDecl::getLanguageLinkage() const {
return getDeclLanguageLinkage(*this);
}
-bool VarDecl::isExternC() const {
- return isDeclExternC(*this);
-}
+bool VarDecl::isExternC() const { return isDeclExternC(*this); }
bool VarDecl::isInExternCContext() const {
return getLexicalDeclContext()->isExternCContext();
@@ -2262,8 +2258,8 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const {
// A declaration is a definition unless [...] it contains the 'extern'
// specifier or a linkage-specification and neither an initializer [...],
// it declares a non-inline static data member in a class declaration [...],
- // it declares a static data member outside a class definition and the variable
- // was defined within the class with the constexpr specifier [...],
+ // it declares a static data member outside a class definition and the
+ // variable was defined within the class with the constexpr specifier [...],
// C++1y [temp.expl.spec]p15:
// An explicit specialization of a static data member or an explicit
// specialization of a static data member template is a definition if the
@@ -2661,8 +2657,7 @@ bool VarDecl::isParameterPack() const {
return isa<PackExpansionType>(getType());
}
-template<typename DeclT>
-static DeclT *getDefinitionOrSelf(DeclT *D) {
+template <typename DeclT> static DeclT *getDefinitionOrSelf(DeclT *D) {
assert(D);
if (auto *Def = D->getDefinition())
return Def;
@@ -2740,7 +2735,7 @@ VarDecl *VarDecl::getTemplateInstantiationPattern() const {
if (VD == this)
return nullptr;
- return getDefinitionOrSelf(const_cast<VarDecl*>(VD));
+ return getDefinitionOrSelf(const_cast<VarDecl *>(VD));
}
VarDecl *VarDecl::getInstantiatedFromStaticDataMember() const {
@@ -2782,7 +2777,8 @@ SourceLocation VarDecl::getPointOfInstantiation() const {
}
VarTemplateDecl *VarDecl::getDescribedVarTemplate() const {
- return getASTContext().getTemplateOrSpecializationInfo(this)
+ return getASTContext()
+ .getTemplateOrSpecializationInfo(this)
.dyn_cast<VarTemplateDecl *>();
}
@@ -2865,13 +2861,14 @@ MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
if (isStaticDataMember())
// FIXME: Remove ?
// return getASTContext().getInstantiatedFromStaticDataMember(this);
- return getASTContext().getTemplateOrSpecializationInfo(this)
+ return getASTContext()
+ .getTemplateOrSpecializationInfo(this)
.dyn_cast<MemberSpecializationInfo *>();
return nullptr;
}
-void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
- SourceLocation PointOfInstantiation) {
+void VarDecl::setTemplateSpecializationKind(
+ TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation) {
assert((isa<VarTemplateSpecializationDecl>(this) ||
getMemberSpecializationInfo()) &&
"not a variable or static data member template specialization");
@@ -2879,8 +2876,7 @@ void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
if (VarTemplateSpecializationDecl *Spec =
dyn_cast<VarTemplateSpecializationDecl>(this)) {
Spec->setSpecializationKind(TSK);
- if (TSK != TSK_ExplicitSpecialization &&
- PointOfInstantiation.isValid() &&
+ if (TSK != TSK_ExplicitSpecialization && PointOfInstantiation.isValid() &&
Spec->getPointOfInstantiation().isInvalid()) {
Spec->setPointOfInstantiation(PointOfInstantiation);
if (ASTMutationListener *L = getASTContext().getASTMutationListener())
@@ -2897,9 +2893,8 @@ void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
}
}
-void
-VarDecl::setInstantiationOfStaticDataMember(VarDecl *VD,
- TemplateSpecializationKind TSK) {
+void VarDecl::setInstantiationOfStaticDataMember(
+ VarDecl *VD, TemplateSpecializationKind TSK) {
assert(getASTContext().getTemplateOrSpecializationInfo(this).isNull() &&
"Previous template or instantiation?");
getASTContext().setInstantiatedFromStaticDataMember(this, VD, TSK);
@@ -2910,12 +2905,12 @@ VarDecl::setInstantiationOfStaticDataMember(VarDecl *VD,
//===----------------------------------------------------------------------===//
ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation StartLoc,
- SourceLocation IdLoc, IdentifierInfo *Id,
- QualType T, TypeSourceInfo *TInfo,
- StorageClass S, Expr *DefArg) {
- return new (C, DC) ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo,
- S, DefArg);
+ SourceLocation StartLoc, SourceLocation IdLoc,
+ IdentifierInfo *Id, QualType T,
+ TypeSourceInfo *TInfo, StorageClass S,
+ Expr *DefArg) {
+ return new (C, DC)
+ ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo, S, DefArg);
}
QualType ParmVarDecl::getOriginalType() const {
@@ -3075,8 +3070,9 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC,
setTrailingRequiresClause(TrailingRequiresClause);
}
-void FunctionDecl::getNameForDiagnostic(
- raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
+void FunctionDecl::getNameForDiagnostic(raw_ostream &OS,
+ const PrintingPolicy &Policy,
+ bool Qualified) const {
NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
const TemplateArgumentList *TemplateArgs = getTemplateSpecializationArgs();
if (TemplateArgs)
@@ -3221,7 +3217,7 @@ void FunctionDecl::setIsPureVirtual(bool P) {
Parent->markedVirtualFunctionPure();
}
-template<std::size_t Len>
+template <std::size_t Len>
static bool isNamed(const NamedDecl *ND, const char (&Str)[Len]) {
const IdentifierInfo *II = ND->getIdentifier();
return II && II->isStr(Str);
@@ -3267,9 +3263,8 @@ bool FunctionDecl::isImmediateFunction() const {
bool FunctionDecl::isMain() const {
const TranslationUnitDecl *tunit =
- dyn_cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext());
- return tunit &&
- !tunit->getASTContext().getLangOpts().Freestanding &&
+ dyn_cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext());
+ return tunit && !tunit->getASTContext().getLangOpts().Freestanding &&
isNamed(this, "main");
}
@@ -3372,7 +3367,8 @@ bool FunctionDecl::isReplaceableGlobalAllocationFunction(
// In C++17, the next parameter can be a 'std::align_val_t' for aligned
// new/delete.
- if (Ctx.getLangOpts().AlignedAllocation && !Ty.isNull() && Ty->isAlignValT()) {
+ if (Ctx.getLangOpts().AlignedAllocation && !Ty.isNull() &&
+ Ty->isAlignValT()) {
Consume();
if (AlignmentParam)
*AlignmentParam = Params;
@@ -3451,9 +3447,7 @@ LanguageLinkage FunctionDecl::getLanguageLinkage() const {
return getDeclLanguageLinkage(*this);
}
-bool FunctionDecl::isExternC() const {
- return isDeclExternC(*this);
-}
+bool FunctionDecl::isExternC() const { return isDeclExternC(*this); }
bool FunctionDecl::isInExternCContext() const {
if (hasAttr<OpenCLKernelAttr>())
@@ -3472,8 +3466,7 @@ bool FunctionDecl::isGlobal() const {
if (getCanonicalDecl()->getStorageClass() == SC_Static)
return false;
- for (const DeclContext *DC = getDeclContext();
- DC->isNamespace();
+ for (const DeclContext *DC = getDeclContext(); DC->isNamespace();
DC = DC->getParent()) {
if (const auto *Namespace = cast<NamespaceDecl>(DC)) {
if (!Namespace->getDeclName())
@@ -3561,13 +3554,12 @@ bool FunctionDecl::isTargetVersionMultiVersion() const {
return isMultiVersion() && hasAttr<TargetVersionAttr>();
}
-void
-FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
+void FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
redeclarable_base::setPreviousDecl(PrevDecl);
if (FunctionTemplateDecl *FunTmpl = getDescribedFunctionTemplate()) {
- FunctionTemplateDecl *PrevFunTmpl
- = PrevDecl? PrevDecl->getDescribedFunctionTemplate() : nullptr;
+ FunctionTemplateDecl *PrevFunTmpl =
+ PrevDecl ? PrevDecl->getDescribedFunctionTemplate() : nullptr;
assert((!PrevDecl || PrevFunTmpl) && "Function/function template mismatch");
FunTmpl->setPreviousDecl(PrevFunTmpl);
}
@@ -3665,7 +3657,7 @@ void FunctionDecl::setParams(ASTContext &C,
// Zero params -> null pointer.
if (!NewParamInfo.empty()) {
- ParamInfo = new (C) ParmVarDecl*[NewParamInfo.size()];
+ ParamInfo = new (C) ParmVarDecl *[NewParamInfo.size()];
std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
}
}
@@ -3801,8 +3793,7 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
if (Prev->doesThisDeclarationHaveABody()) {
// If it's not the case that both 'inline' and 'extern' are
// specified on the definition, then it is always externally visible.
- if (!Prev->isInlineSpecified() ||
- Prev->getStorageClass() != SC_Extern)
+ if (!Prev->isInlineSpecified() || Prev->getStorageClass() != SC_Extern)
return false;
} else if (Prev->isInlineSpecified() &&
Prev->getStorageClass() != SC_Extern) {
@@ -3910,8 +3901,7 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
// If any declaration is 'inline' but not 'extern', then this definition
// is externally visible.
for (auto *Redecl : redecls()) {
- if (Redecl->isInlineSpecified() &&
- Redecl->getStorageClass() != SC_Extern)
+ if (Redecl->isInlineSpecified() && Redecl->getStorageClass() != SC_Extern)
return true;
}
@@ -3968,8 +3958,8 @@ FunctionDecl::TemplatedKind FunctionDecl::getTemplatedKind() const {
return TK_MemberSpecialization;
if (TemplateOrSpecialization.is<FunctionTemplateSpecializationInfo *>())
return TK_FunctionTemplateSpecialization;
- if (TemplateOrSpecialization.is
- <DependentFunctionTemplateSpecializationInfo*>())
+ if (TemplateOrSpecialization
+ .is<DependentFunctionTemplateSpecializationInfo *>())
return TK_DependentFunctionTemplateSpecialization;
llvm_unreachable("Did we miss a TemplateOrSpecialization type?");
@@ -3992,14 +3982,11 @@ MemberSpecializationInfo *FunctionDecl::getMemberSpecializationInfo() const {
return nullptr;
}
-void
-FunctionDecl::setInstantiationOfMemberFunction(ASTContext &C,
- FunctionDecl *FD,
- TemplateSpecializationKind TSK) {
+void FunctionDecl::setInstantiationOfMemberFunction(
+ ASTContext &C, FunctionDecl *FD, TemplateSpecializationKind TSK) {
assert(TemplateOrSpecialization.isNull() &&
"Member function is already a specialization");
- MemberSpecializationInfo *Info
- = new (C) MemberSpecializationInfo(FD, TSK);
+ MemberSpecializationInfo *Info = new (C) MemberSpecializationInfo(FD, TSK);
TemplateOrSpecialization = Info;
}
@@ -4124,9 +4111,9 @@ FunctionDecl::getTemplateInstantiationPattern(bool ForDefinition) const {
}
FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() const {
- if (FunctionTemplateSpecializationInfo *Info
- = TemplateOrSpecialization
- .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
+ if (FunctionTemplateSpecializationInfo *Info =
+ TemplateOrSpecialization
+ .dyn_cast<FunctionTemplateSpecializationInfo *>()) {
return Info->getTemplate();
}
return nullptr;
@@ -4140,9 +4127,9 @@ FunctionDecl::getTemplateSpecializationInfo() const {
const TemplateArgumentList *
FunctionDecl::getTemplateSpecializationArgs() const {
- if (FunctionTemplateSpecializationInfo *Info
- = TemplateOrSpecialization
- .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
+ if (FunctionTemplateSpecializationInfo *Info =
+ TemplateOrSpecialization
+ .dyn_cast<FunctionTemplateSpecializationInfo *>()) {
return Info->TemplateArguments;
}
return nullptr;
@@ -4150,9 +4137,9 @@ FunctionDecl::getTemplateSpecializationArgs() const {
const ASTTemplateArgumentListInfo *
FunctionDecl::getTemplateSpecializationArgsAsWritten() const {
- if (FunctionTemplateSpecializationInfo *Info
- = TemplateOrSpecialization
- .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
+ if (FunctionTemplateSpecializationInfo *Info =
+ TemplateOrSpecialization
+ .dyn_cast<FunctionTemplateSpecializationInfo *>()) {
return Info->TemplateArgumentsAsWritten;
}
if (DependentFunctionTemplateSpecializationInfo *Info =
@@ -4163,14 +4150,12 @@ FunctionDecl::getTemplateSpecializationArgsAsWritten() const {
return nullptr;
}
-void
-FunctionDecl::setFunctionTemplateSpecialization(ASTContext &C,
- FunctionTemplateDecl *Template,
- const TemplateArgumentList *TemplateArgs,
- void *InsertPos,
- TemplateSpecializationKind TSK,
- const TemplateArgumentListInfo *TemplateArgsAsWritten,
- SourceLocation PointOfInstantiation) {
+void FunctionDecl::setFunctionTemplateSpecialization(
+ ASTContext &C, FunctionTemplateDecl *Template,
+ const TemplateArgumentList *TemplateArgs, void *InsertPos,
+ TemplateSpecializationKind TSK,
+ const TemplateArgumentListInfo *TemplateArgsAsWritten,
+ SourceLocation PointOfInstantiation) {
assert((TemplateOrSpecialization.isNull() ||
TemplateOrSpecialization.is<MemberSpecializationInfo *>()) &&
"Member function is already a specialization");
@@ -4295,25 +4280,23 @@ FunctionDecl::getTemplateSpecializationKindForInstantiation() const {
return TSK_Undeclared;
}
-void
-FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
- SourceLocation PointOfInstantiation) {
- if (FunctionTemplateSpecializationInfo *FTSInfo
- = TemplateOrSpecialization.dyn_cast<
- FunctionTemplateSpecializationInfo*>()) {
+void FunctionDecl::setTemplateSpecializationKind(
+ TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation) {
+ if (FunctionTemplateSpecializationInfo *FTSInfo =
+ TemplateOrSpecialization
+ .dyn_cast<FunctionTemplateSpecializationInfo *>()) {
FTSInfo->setTemplateSpecializationKind(TSK);
- if (TSK != TSK_ExplicitSpecialization &&
- PointOfInstantiation.isValid() &&
+ if (TSK != TSK_ExplicitSpecialization && PointOfInstantiation.isValid() &&
FTSInfo->getPointOfInstantiation().isInvalid()) {
FTSInfo->setPointOfInstantiation(PointOfInstantiation);
if (ASTMutationListener *L = getASTContext().getASTMutationListener())
L->InstantiationRequested(this);
}
- } else if (MemberSpecializationInfo *MSInfo
- = TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>()) {
+ } else if (MemberSpecializationInfo *MSInfo =
+ TemplateOrSpecialization
+ .dyn_cast<MemberSpecializationInfo *>()) {
MSInfo->setTemplateSpecializationKind(TSK);
- if (TSK != TSK_ExplicitSpecialization &&
- PointOfInstantiation.isValid() &&
+ if (TSK != TSK_ExplicitSpecialization && PointOfInstantiation.isValid() &&
MSInfo->getPointOfInstantiation().isInvalid()) {
MSInfo->setPointOfInstantiation(PointOfInstantiation);
if (ASTMutationListener *L = getASTContext().getASTMutationListener())
@@ -4324,9 +4307,9 @@ FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
}
SourceLocation FunctionDecl::getPointOfInstantiation() const {
- if (FunctionTemplateSpecializationInfo *FTSInfo
- = TemplateOrSpecialization.dyn_cast<
- FunctionTemplateSpecializationInfo*>())
+ if (FunctionTemplateSpecializationInfo *FTSInfo =
+ TemplateOrSpecialization
+ .dyn_cast<FunctionTemplateSpecializationInfo *>())
return FTSInfo->getPointOfInstantiation();
if (MemberSpecializationInfo *MSInfo =
TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo *>())
@@ -4518,9 +4501,9 @@ FieldDecl *FieldDecl::Create(const ASTContext &C, DeclContext *DC,
}
FieldDecl *FieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) FieldDecl(Field, nullptr, SourceLocation(),
- SourceLocation(), nullptr, QualType(), nullptr,
- nullptr, false, ICIS_NoInit);
+ return new (C, ID)
+ FieldDecl(Field, nullptr, SourceLocation(), SourceLocation(), nullptr,
+ QualType(), nullptr, nullptr, false, ICIS_NoInit);
}
bool FieldDecl::isAnonymousStructOrUnion() const {
@@ -4612,7 +4595,8 @@ unsigned FieldDecl::getFieldIndex() const {
if (Canonical != this)
return Canonical->getFieldIndex();
- if (CachedFieldIndex) return CachedFieldIndex - 1;
+ if (CachedFieldIndex)
+ return CachedFieldIndex - 1;
unsigned Index = 0;
const RecordDecl *RD = getParent()->getDefinition();
@@ -4705,7 +4689,7 @@ void TagDecl::startDefinition() {
if (auto *D = dyn_cast<CXXRecordDecl>(this)) {
struct CXXRecordDecl::DefinitionData *Data =
- new (getASTContext()) struct CXXRecordDecl::DefinitionData(D);
+ new (getASTContext()) struct CXXRecordDecl::DefinitionData(D);
for (auto *I : redecls())
cast<CXXRecordDecl>(I)->DefinitionData = Data;
}
@@ -4759,8 +4743,7 @@ void TagDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) {
if (getExtInfo()->NumTemplParamLists == 0) {
getASTContext().Deallocate(getExtInfo());
TypedefNameDeclOrQualifier = (TypedefNameDecl *)nullptr;
- }
- else
+ } else
getExtInfo()->QualifierLoc = QualifierLoc;
}
}
@@ -4817,9 +4800,9 @@ void EnumDecl::anchor() {}
EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
- IdentifierInfo *Id,
- EnumDecl *PrevDecl, bool IsScoped,
- bool IsScopedUsingClassTag, bool IsFixed) {
+ IdentifierInfo *Id, EnumDecl *PrevDecl,
+ bool IsScoped, bool IsScopedUsingClassTag,
+ bool IsFixed) {
auto *Enum = new (C, DC) EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl,
IsScoped, IsScopedUsingClassTag, IsFixed);
Enum->setMayHaveOutOfDateDef(C.getLangOpts().Modules);
@@ -4841,8 +4824,7 @@ SourceRange EnumDecl::getIntegerTypeRange() const {
return SourceRange();
}
-void EnumDecl::completeDefinition(QualType NewType,
- QualType NewPromotionType,
+void EnumDecl::completeDefinition(QualType NewType, QualType NewPromotionType,
unsigned NumPositiveBits,
unsigned NumNegativeBits) {
assert(!isCompleteDefinition() && "Cannot redefine enums!");
@@ -4875,13 +4857,12 @@ TemplateSpecializationKind EnumDecl::getTemplateSpecializationKind() const {
return TSK_Undeclared;
}
-void EnumDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
- SourceLocation PointOfInstantiation) {
+void EnumDecl::setTemplateSpecializationKind(
+ TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation) {
MemberSpecializationInfo *MSI = getMemberSpecializationInfo();
assert(MSI && "Not an instantiated member enumeration?");
MSI->setTemplateSpecializationKind(TSK);
- if (TSK != TSK_ExplicitSpecialization &&
- PointOfInstantiation.isValid() &&
+ if (TSK != TSK_ExplicitSpecialization && PointOfInstantiation.isValid() &&
MSI->getPointOfInstantiation().isInvalid())
MSI->setPointOfInstantiation(PointOfInstantiation);
}
@@ -4980,9 +4961,9 @@ RecordDecl::RecordDecl(Kind DK, TagKind TK, const ASTContext &C,
RecordDecl *RecordDecl::Create(const ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
- IdentifierInfo *Id, RecordDecl* PrevDecl) {
- RecordDecl *R = new (C, DC) RecordDecl(Record, TK, C, DC,
- StartLoc, IdLoc, Id, PrevDecl);
+ IdentifierInfo *Id, RecordDecl *PrevDecl) {
+ RecordDecl *R =
+ new (C, DC) RecordDecl(Record, TK, C, DC, StartLoc, IdLoc, Id, PrevDecl);
R->setMayHaveOutOfDateDef(C.getLangOpts().Modules);
C.getTypeDeclType(R, PrevDecl);
@@ -4999,7 +4980,7 @@ RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) {
bool RecordDecl::isInjectedClassName() const {
return isImplicit() && getDeclName() && getDeclContext()->isRecord() &&
- cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName();
+ cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName();
}
bool RecordDecl::isLambda() const {
@@ -5081,15 +5062,18 @@ void RecordDecl::LoadFieldsFromExternalStorage() const {
// Notify that we have a RecordDecl doing some initialization.
ExternalASTSource::Deserializing TheFields(Source);
- SmallVector<Decl*, 64> Decls;
+ SmallVector<Decl *, 64> Decls;
setHasLoadedFieldsFromExternalStorage(true);
- Source->FindExternalLexicalDecls(this, [](Decl::Kind K) {
- return FieldDecl::classofKind(K) || IndirectFieldDecl::classofKind(K);
- }, Decls);
+ Source->FindExternalLexicalDecls(
+ this,
+ [](Decl::Kind K) {
+ return FieldDecl::classofKind(K) || IndirectFieldDecl::classofKind(K);
+ },
+ Decls);
#ifndef NDEBUG
// Check that all decls we got were FieldDecls.
- for (unsigned i=0, e=Decls.size(); i != e; ++i)
+ for (unsigned i = 0, e = Decls.size(); i != e; ++i)
assert(isa<FieldDecl>(Decls[i]) || isa<IndirectFieldDecl>(Decls[i]));
#endif
@@ -5107,7 +5091,8 @@ void RecordDecl::LoadFieldsFromExternalStorage() const {
bool RecordDecl::mayInsertExtraPadding(bool EmitRemark) const {
ASTContext &Context = getASTContext();
- const SanitizerMask EnabledAsanMask = Context.getLangOpts().Sanitize.Mask &
+ const SanitizerMask EnabledAsanMask =
+ Context.getLangOpts().Sanitize.Mask &
(SanitizerKind::Address | SanitizerKind::KernelAddress);
if (!EnabledAsanMask || !Context.getLangOpts().SanitizeAddressFieldPadding)
return false;
@@ -5116,23 +5101,23 @@ bool RecordDecl::mayInsertExtraPadding(bool EmitRemark) const {
// We may be able to relax some of these requirements.
int ReasonToReject = -1;
if (!CXXRD || CXXRD->isExternCContext())
- ReasonToReject = 0; // is not C++.
+ ReasonToReject = 0; // is not C++.
else if (CXXRD->hasAttr<PackedAttr>())
- ReasonToReject = 1; // is packed.
+ ReasonToReject = 1; // is packed.
else if (CXXRD->isUnion())
- ReasonToReject = 2; // is a union.
+ ReasonToReject = 2; // is a union.
else if (CXXRD->isTriviallyCopyable())
- ReasonToReject = 3; // is trivially copyable.
+ ReasonToReject = 3; // is trivially copyable.
else if (CXXRD->hasTrivialDestructor())
- ReasonToReject = 4; // has trivial destructor.
+ ReasonToReject = 4; // has trivial destructor.
else if (CXXRD->isStandardLayout())
- ReasonToReject = 5; // is standard layout.
+ ReasonToReject = 5; // is standard layout.
else if (NoSanitizeList.containsLocation(EnabledAsanMask, getLocation(),
"field-padding"))
- ReasonToReject = 6; // is in an excluded file.
+ ReasonToReject = 6; // is in an excluded file.
else if (NoSanitizeList.containsType(
EnabledAsanMask, getQualifiedNameAsString(), "field-padding"))
- ReasonToReject = 7; // The type is excluded.
+ ReasonToReject = 7; // The type is excluded.
if (EmitRemark) {
if (ReasonToReject >= 0)
@@ -5197,7 +5182,7 @@ void BlockDecl::setParams(ArrayRef<ParmVarDecl *> NewParamInfo) {
// Zero params -> null pointer.
if (!NewParamInfo.empty()) {
NumParams = NewParamInfo.size();
- ParamInfo = new (getASTContext()) ParmVarDecl*[NewParamInfo.size()];
+ ParamInfo = new (getASTContext()) ParmVarDecl *[NewParamInfo.size()];
std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
}
}
@@ -5307,12 +5292,12 @@ LabelDecl *LabelDecl::Create(ASTContext &C, DeclContext *DC,
}
LabelDecl *LabelDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) LabelDecl(nullptr, SourceLocation(), nullptr, nullptr,
- SourceLocation());
+ return new (C, ID)
+ LabelDecl(nullptr, SourceLocation(), nullptr, nullptr, SourceLocation());
}
void LabelDecl::setMSAsmLabel(StringRef Name) {
-char *Buffer = new (getASTContext(), 1) char[Name.size() + 1];
+ char *Buffer = new (getASTContext(), 1) char[Name.size() + 1];
memcpy(Buffer, Name.data(), Name.size());
Buffer[Name.size()] = '\0';
MSAsmName = Buffer;
@@ -5409,14 +5394,14 @@ EnumConstantDecl::EnumConstantDecl(const ASTContext &C, DeclContext *DC,
}
EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD,
- SourceLocation L,
- IdentifierInfo *Id, QualType T,
- Expr *E, const llvm::APSInt &V) {
+ SourceLocation L, IdentifierInfo *Id,
+ QualType T, Expr *E,
+ const llvm::APSInt &V) {
return new (C, CD) EnumConstantDecl(C, CD, L, Id, T, E, V);
}
-EnumConstantDecl *
-EnumConstantDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
+EnumConstantDecl *EnumConstantDecl::CreateDeserialized(ASTContext &C,
+ unsigned ID) {
return new (C, ID) EnumConstantDecl(C, nullptr, SourceLocation(), nullptr,
QualType(), nullptr, llvm::APSInt());
}
@@ -5547,8 +5532,8 @@ FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC,
FileScopeAsmDecl *FileScopeAsmDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) FileScopeAsmDecl(nullptr, nullptr, SourceLocation(),
- SourceLocation());
+ return new (C, ID)
+ FileScopeAsmDecl(nullptr, nullptr, SourceLocation(), SourceLocation());
}
void TopLevelStmtDecl::anchor() {}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 1c8e4073026091..9ab34cc57ef322 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -18,7 +18,7 @@ namespace hlsl {
#define _HLSL_BUILTIN_ALIAS(builtin) \
__attribute__((clang_builtin_alias(builtin)))
-#define _HLSL_ELEMENTWISE_BUILTIN_ALIAS(builtin) \
+#define _HLSL_ELEMENTWISE_BUILTIN_ALIAS(builtin) \
__attribute__((clang_elementwise_builtin_alias(builtin)))
#define _HLSL_AVAILABILITY(environment, version) \
__attribute__((availability(environment, introduced = version)))
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index c2621bdd2f9ce9..7e6465cab68723 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -371,35 +371,37 @@ static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall,
return true;
std::pair<unsigned, const char *> Builtins[] = {
- { Builtin::BI__builtin_add_overflow, "ckd_add" },
- { Builtin::BI__builtin_sub_overflow, "ckd_sub" },
- { Builtin::BI__builtin_mul_overflow, "ckd_mul" },
+ {Builtin::BI__builtin_add_overflow, "ckd_add"},
+ {Builtin::BI__builtin_sub_overflow, "ckd_sub"},
+ {Builtin::BI__builtin_mul_overflow, "ckd_mul"},
};
- bool CkdOperation = llvm::any_of(Builtins, [&](const std::pair<unsigned,
- const char *> &P) {
- return BuiltinID == P.first && TheCall->getExprLoc().isMacroID() &&
- Lexer::getImmediateMacroName(TheCall->getExprLoc(),
- S.getSourceManager(), S.getLangOpts()) == P.second;
- });
+ bool CkdOperation =
+ llvm::any_of(Builtins, [&](const std::pair<unsigned, const char *> &P) {
+ return BuiltinID == P.first && TheCall->getExprLoc().isMacroID() &&
+ Lexer::getImmediateMacroName(TheCall->getExprLoc(),
+ S.getSourceManager(),
+ S.getLangOpts()) == P.second;
+ });
auto ValidCkdIntType = [](QualType QT) {
// A valid checked integer type is an integer type other than a plain char,
// bool, a bit-precise type, or an enumeration type.
if (const auto *BT = QT.getCanonicalType()->getAs<BuiltinType>())
return (BT->getKind() >= BuiltinType::Short &&
- BT->getKind() <= BuiltinType::Int128) || (
- BT->getKind() >= BuiltinType::UShort &&
- BT->getKind() <= BuiltinType::UInt128) ||
- BT->getKind() == BuiltinType::UChar ||
- BT->getKind() == BuiltinType::SChar;
+ BT->getKind() <= BuiltinType::Int128) ||
+ (BT->getKind() >= BuiltinType::UShort &&
+ BT->getKind() <= BuiltinType::UInt128) ||
+ BT->getKind() == BuiltinType::UChar ||
+ BT->getKind() == BuiltinType::SChar;
return false;
};
// First two arguments should be integers.
for (unsigned I = 0; I < 2; ++I) {
ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(I));
- if (Arg.isInvalid()) return true;
+ if (Arg.isInvalid())
+ return true;
TheCall->setArg(I, Arg.get());
QualType Ty = Arg.get()->getType();
@@ -416,18 +418,18 @@ static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall,
// the other qualifiers aren't possible.
{
ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(2));
- if (Arg.isInvalid()) return true;
+ if (Arg.isInvalid())
+ return true;
TheCall->setArg(2, Arg.get());
QualType Ty = Arg.get()->getType();
const auto *PtrTy = Ty->getAs<PointerType>();
- if (!PtrTy ||
- !PtrTy->getPointeeType()->isIntegerType() ||
+ if (!PtrTy || !PtrTy->getPointeeType()->isIntegerType() ||
(!ValidCkdIntType(PtrTy->getPointeeType()) && CkdOperation) ||
PtrTy->getPointeeType().isConstQualified()) {
S.Diag(Arg.get()->getBeginLoc(),
diag::err_overflow_builtin_must_be_ptr_int)
- << CkdOperation << Ty << Arg.get()->getSourceRange();
+ << CkdOperation << Ty << Arg.get()->getSourceRange();
return true;
}
}
@@ -545,7 +547,8 @@ struct BuiltinDumpStructGenerator {
}
analyze_printf::PrintfSpecifier Specifier;
- if (Specifier.fixType(T, S.getLangOpts(), S.Context, /*IsObjCLiteral=*/false)) {
+ if (Specifier.fixType(T, S.getLangOpts(), S.Context,
+ /*IsObjCLiteral=*/false)) {
// We were able to guess how to format this.
if (Specifier.getConversionSpecifier().getKind() ==
analyze_printf::PrintfConversionSpecifier::sArg) {
@@ -806,7 +809,7 @@ static bool SemaBuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall) {
}
QualType ReturnTy = CE->getCallReturnType(S.Context);
- QualType ArgTys[2] = { ReturnTy, ChainResult.get()->getType() };
+ QualType ArgTys[2] = {ReturnTy, ChainResult.get()->getType()};
QualType BuiltinTy = S.Context.getFunctionType(
ReturnTy, ArgTys, FunctionProtoType::ExtProtoInfo());
QualType BuiltinPtrTy = S.Context.getPointerType(BuiltinTy);
@@ -1551,7 +1554,7 @@ static bool checkOpenCLEnqueueLocalSizeArgs(Sema &S, CallExpr *TheCall,
bool IllegalParams = false;
for (unsigned I = Start; I <= End; ++I)
IllegalParams |= checkOpenCLEnqueueIntType(S, TheCall->getArg(I),
- S.Context.getSizeType());
+ S.Context.getSizeType());
return IllegalParams;
}
@@ -1656,7 +1659,8 @@ static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) {
// we have a block type, check the prototype
const BlockPointerType *BPT =
cast<BlockPointerType>(Arg3->getType().getCanonicalType());
- if (BPT->getPointeeType()->castAs<FunctionProtoType>()->getNumParams() > 0) {
+ if (BPT->getPointeeType()->castAs<FunctionProtoType>()->getNumParams() >
+ 0) {
S.Diag(Arg3->getBeginLoc(),
diag::err_opencl_enqueue_kernel_blocks_no_args);
return true;
@@ -1727,7 +1731,7 @@ static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) {
/// Returns OpenCL access qual.
static OpenCLAccessAttr *getOpenCLArgAccess(const Decl *D) {
- return D->getAttr<OpenCLAccessAttr>();
+ return D->getAttr<OpenCLAccessAttr>();
}
/// Returns true if pipe element type is different from the pointer.
@@ -1936,8 +1940,8 @@ static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID,
return true;
auto RT = Call->getArg(0)->getType();
- if (!RT->isPointerType() || RT->getPointeeType()
- .getAddressSpace() == LangAS::opencl_constant) {
+ if (!RT->isPointerType() ||
+ RT->getPointeeType().getAddressSpace() == LangAS::opencl_constant) {
S.Diag(Call->getBeginLoc(), diag::err_opencl_builtin_to_addr_invalid_arg)
<< Call->getArg(0) << Call->getDirectCallee() << Call->getSourceRange();
return true;
@@ -1965,8 +1969,8 @@ static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID,
default:
llvm_unreachable("Invalid builtin function");
}
- Call->setType(S.Context.getPointerType(S.Context.getQualifiedType(
- RT.getUnqualifiedType(), Qual)));
+ Call->setType(S.Context.getPointerType(
+ S.Context.getQualifiedType(RT.getUnqualifiedType(), Qual)));
return false;
}
@@ -2214,9 +2218,9 @@ static bool SemaBuiltinPopcountg(Sema &S, CallExpr *TheCall) {
return false;
}
-ExprResult
-Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
- CallExpr *TheCall) {
+ExprResult Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl,
+ unsigned BuiltinID,
+ CallExpr *TheCall) {
ExprResult TheCallResult(TheCall);
// Find out if any arguments are required to be integer constant expressions.
@@ -2224,12 +2228,13 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
ASTContext::GetBuiltinTypeError Error;
Context.GetBuiltinType(BuiltinID, Error, &ICEArguments);
if (Error != ASTContext::GE_None)
- ICEArguments = 0; // Don't diagnose previously diagnosed errors.
+ ICEArguments = 0; // Don't diagnose previously diagnosed errors.
// If any arguments are required to be ICE's, check and diagnose.
for (unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
// Skip arguments not required to be ICE's.
- if ((ICEArguments & (1 << ArgNo)) == 0) continue;
+ if ((ICEArguments & (1 << ArgNo)) == 0)
+ continue;
llvm::APSInt Result;
// If we don't have enough arguments, continue so we can issue better
@@ -2273,323 +2278,323 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
}
}
}
- FPOptions FPO;
- switch (BuiltinID) {
- case Builtin::BI__builtin_cpu_supports:
- case Builtin::BI__builtin_cpu_is:
- if (SemaBuiltinCpu(*this, Context.getTargetInfo(), TheCall,
- Context.getAuxTargetInfo(), BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_cpu_init:
- if (!Context.getTargetInfo().supportsCpuInit()) {
- Diag(TheCall->getBeginLoc(), diag::err_builtin_target_unsupported)
- << SourceRange(TheCall->getBeginLoc(), TheCall->getEndLoc());
- return ExprError();
- }
- break;
- case Builtin::BI__builtin___CFStringMakeConstantString:
- // CFStringMakeConstantString is currently not implemented for GOFF (i.e.,
- // on z/OS) and for XCOFF (i.e., on AIX). Emit unsupported
- if (CheckBuiltinTargetNotInUnsupported(
- *this, BuiltinID, TheCall,
- {llvm::Triple::GOFF, llvm::Triple::XCOFF}))
- return ExprError();
- assert(TheCall->getNumArgs() == 1 &&
- "Wrong # arguments to builtin CFStringMakeConstantString");
- if (CheckObjCString(TheCall->getArg(0)))
+ FPOptions FPO;
+ switch (BuiltinID) {
+ case Builtin::BI__builtin_cpu_supports:
+ case Builtin::BI__builtin_cpu_is:
+ if (SemaBuiltinCpu(*this, Context.getTargetInfo(), TheCall,
+ Context.getAuxTargetInfo(), BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_cpu_init:
+ if (!Context.getTargetInfo().supportsCpuInit()) {
+ Diag(TheCall->getBeginLoc(), diag::err_builtin_target_unsupported)
+ << SourceRange(TheCall->getBeginLoc(), TheCall->getEndLoc());
+ return ExprError();
+ }
+ break;
+ case Builtin::BI__builtin___CFStringMakeConstantString:
+ // CFStringMakeConstantString is currently not implemented for GOFF (i.e.,
+ // on z/OS) and for XCOFF (i.e., on AIX). Emit unsupported
+ if (CheckBuiltinTargetNotInUnsupported(
+ *this, BuiltinID, TheCall,
+ {llvm::Triple::GOFF, llvm::Triple::XCOFF}))
+ return ExprError();
+ assert(TheCall->getNumArgs() == 1 &&
+ "Wrong # arguments to builtin CFStringMakeConstantString");
+ if (CheckObjCString(TheCall->getArg(0)))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_ms_va_start:
+ case Builtin::BI__builtin_stdarg_start:
+ case Builtin::BI__builtin_va_start:
+ if (SemaBuiltinVAStart(BuiltinID, TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__va_start: {
+ switch (Context.getTargetInfo().getTriple().getArch()) {
+ case llvm::Triple::aarch64:
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ if (SemaBuiltinVAStartARMMicrosoft(TheCall))
return ExprError();
break;
- case Builtin::BI__builtin_ms_va_start:
- case Builtin::BI__builtin_stdarg_start:
- case Builtin::BI__builtin_va_start:
+ default:
if (SemaBuiltinVAStart(BuiltinID, TheCall))
return ExprError();
break;
- case Builtin::BI__va_start: {
- switch (Context.getTargetInfo().getTriple().getArch()) {
- case llvm::Triple::aarch64:
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- if (SemaBuiltinVAStartARMMicrosoft(TheCall))
- return ExprError();
- break;
- default:
- if (SemaBuiltinVAStart(BuiltinID, TheCall))
- return ExprError();
- break;
- }
- break;
}
+ break;
+ }
- // The acquire, release, and no fence variants are ARM and AArch64 only.
- case Builtin::BI_interlockedbittestandset_acq:
- case Builtin::BI_interlockedbittestandset_rel:
- case Builtin::BI_interlockedbittestandset_nf:
- case Builtin::BI_interlockedbittestandreset_acq:
- case Builtin::BI_interlockedbittestandreset_rel:
- case Builtin::BI_interlockedbittestandreset_nf:
- if (CheckBuiltinTargetInSupported(
- *this, BuiltinID, TheCall,
- {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
- return ExprError();
- break;
+ // The acquire, release, and no fence variants are ARM and AArch64 only.
+ case Builtin::BI_interlockedbittestandset_acq:
+ case Builtin::BI_interlockedbittestandset_rel:
+ case Builtin::BI_interlockedbittestandset_nf:
+ case Builtin::BI_interlockedbittestandreset_acq:
+ case Builtin::BI_interlockedbittestandreset_rel:
+ case Builtin::BI_interlockedbittestandreset_nf:
+ if (CheckBuiltinTargetInSupported(
+ *this, BuiltinID, TheCall,
+ {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
+ return ExprError();
+ break;
- // The 64-bit bittest variants are x64, ARM, and AArch64 only.
- case Builtin::BI_bittest64:
- case Builtin::BI_bittestandcomplement64:
- case Builtin::BI_bittestandreset64:
- case Builtin::BI_bittestandset64:
- case Builtin::BI_interlockedbittestandreset64:
- case Builtin::BI_interlockedbittestandset64:
- if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
- {llvm::Triple::x86_64,
- llvm::Triple::arm, llvm::Triple::thumb,
- llvm::Triple::aarch64}))
- return ExprError();
- break;
+ // The 64-bit bittest variants are x64, ARM, and AArch64 only.
+ case Builtin::BI_bittest64:
+ case Builtin::BI_bittestandcomplement64:
+ case Builtin::BI_bittestandreset64:
+ case Builtin::BI_bittestandset64:
+ case Builtin::BI_interlockedbittestandreset64:
+ case Builtin::BI_interlockedbittestandset64:
+ if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
+ {llvm::Triple::x86_64, llvm::Triple::arm,
+ llvm::Triple::thumb,
+ llvm::Triple::aarch64}))
+ return ExprError();
+ break;
- case Builtin::BI__builtin_set_flt_rounds:
- if (CheckBuiltinTargetInSupported(
- *this, BuiltinID, TheCall,
- {llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
- llvm::Triple::thumb, llvm::Triple::aarch64}))
- return ExprError();
- break;
+ case Builtin::BI__builtin_set_flt_rounds:
+ if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
+ {llvm::Triple::x86, llvm::Triple::x86_64,
+ llvm::Triple::arm, llvm::Triple::thumb,
+ llvm::Triple::aarch64}))
+ return ExprError();
+ break;
- case Builtin::BI__builtin_isgreater:
- case Builtin::BI__builtin_isgreaterequal:
- case Builtin::BI__builtin_isless:
- case Builtin::BI__builtin_islessequal:
- case Builtin::BI__builtin_islessgreater:
- case Builtin::BI__builtin_isunordered:
- if (SemaBuiltinUnorderedCompare(TheCall, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_fpclassify:
- if (SemaBuiltinFPClassification(TheCall, 6, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_isfpclass:
- if (SemaBuiltinFPClassification(TheCall, 2, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_isfinite:
- case Builtin::BI__builtin_isinf:
- case Builtin::BI__builtin_isinf_sign:
- case Builtin::BI__builtin_isnan:
- case Builtin::BI__builtin_issignaling:
- case Builtin::BI__builtin_isnormal:
- case Builtin::BI__builtin_issubnormal:
- case Builtin::BI__builtin_iszero:
- case Builtin::BI__builtin_signbit:
- case Builtin::BI__builtin_signbitf:
- case Builtin::BI__builtin_signbitl:
- if (SemaBuiltinFPClassification(TheCall, 1, BuiltinID))
- return ExprError();
- break;
- case Builtin::BI__builtin_shufflevector:
- return SemaBuiltinShuffleVector(TheCall);
- // TheCall will be freed by the smart pointer here, but that's fine, since
- // SemaBuiltinShuffleVector guts it, but then doesn't release it.
- case Builtin::BI__builtin_prefetch:
- if (SemaBuiltinPrefetch(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_alloca_with_align:
- case Builtin::BI__builtin_alloca_with_align_uninitialized:
- if (SemaBuiltinAllocaWithAlign(TheCall))
- return ExprError();
- [[fallthrough]];
- case Builtin::BI__builtin_alloca:
- case Builtin::BI__builtin_alloca_uninitialized:
- Diag(TheCall->getBeginLoc(), diag::warn_alloca)
- << TheCall->getDirectCallee();
- break;
- case Builtin::BI__arithmetic_fence:
- if (SemaBuiltinArithmeticFence(TheCall))
- return ExprError();
- break;
- case Builtin::BI__assume:
- case Builtin::BI__builtin_assume:
- if (SemaBuiltinAssume(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_assume_aligned:
- if (SemaBuiltinAssumeAligned(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_dynamic_object_size:
- case Builtin::BI__builtin_object_size:
- if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
- return ExprError();
- break;
- case Builtin::BI__builtin_longjmp:
- if (SemaBuiltinLongjmp(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_setjmp:
- if (SemaBuiltinSetjmp(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_classify_type:
- if (checkArgCount(*this, TheCall, 1))
- return true;
- TheCall->setType(Context.IntTy);
- break;
- case Builtin::BI__builtin_complex:
- if (SemaBuiltinComplex(TheCall))
- return ExprError();
- break;
- case Builtin::BI__builtin_constant_p: {
- if (checkArgCount(*this, TheCall, 1))
- return true;
- ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
- if (Arg.isInvalid())
- return true;
- TheCall->setArg(0, Arg.get());
- TheCall->setType(Context.IntTy);
- break;
- }
- case Builtin::BI__builtin_launder:
- return SemaBuiltinLaunder(*this, TheCall);
- case Builtin::BI__sync_fetch_and_add:
- case Builtin::BI__sync_fetch_and_add_1:
- case Builtin::BI__sync_fetch_and_add_2:
- case Builtin::BI__sync_fetch_and_add_4:
- case Builtin::BI__sync_fetch_and_add_8:
- case Builtin::BI__sync_fetch_and_add_16:
- case Builtin::BI__sync_fetch_and_sub:
- case Builtin::BI__sync_fetch_and_sub_1:
- case Builtin::BI__sync_fetch_and_sub_2:
- case Builtin::BI__sync_fetch_and_sub_4:
- case Builtin::BI__sync_fetch_and_sub_8:
- case Builtin::BI__sync_fetch_and_sub_16:
- case Builtin::BI__sync_fetch_and_or:
- case Builtin::BI__sync_fetch_and_or_1:
- case Builtin::BI__sync_fetch_and_or_2:
- case Builtin::BI__sync_fetch_and_or_4:
- case Builtin::BI__sync_fetch_and_or_8:
- case Builtin::BI__sync_fetch_and_or_16:
- case Builtin::BI__sync_fetch_and_and:
- case Builtin::BI__sync_fetch_and_and_1:
- case Builtin::BI__sync_fetch_and_and_2:
- case Builtin::BI__sync_fetch_and_and_4:
- case Builtin::BI__sync_fetch_and_and_8:
- case Builtin::BI__sync_fetch_and_and_16:
- case Builtin::BI__sync_fetch_and_xor:
- case Builtin::BI__sync_fetch_and_xor_1:
- case Builtin::BI__sync_fetch_and_xor_2:
- case Builtin::BI__sync_fetch_and_xor_4:
- case Builtin::BI__sync_fetch_and_xor_8:
- case Builtin::BI__sync_fetch_and_xor_16:
- case Builtin::BI__sync_fetch_and_nand:
- case Builtin::BI__sync_fetch_and_nand_1:
- case Builtin::BI__sync_fetch_and_nand_2:
- case Builtin::BI__sync_fetch_and_nand_4:
- case Builtin::BI__sync_fetch_and_nand_8:
- case Builtin::BI__sync_fetch_and_nand_16:
- case Builtin::BI__sync_add_and_fetch:
- case Builtin::BI__sync_add_and_fetch_1:
- case Builtin::BI__sync_add_and_fetch_2:
- case Builtin::BI__sync_add_and_fetch_4:
- case Builtin::BI__sync_add_and_fetch_8:
- case Builtin::BI__sync_add_and_fetch_16:
- case Builtin::BI__sync_sub_and_fetch:
- case Builtin::BI__sync_sub_and_fetch_1:
- case Builtin::BI__sync_sub_and_fetch_2:
- case Builtin::BI__sync_sub_and_fetch_4:
- case Builtin::BI__sync_sub_and_fetch_8:
- case Builtin::BI__sync_sub_and_fetch_16:
- case Builtin::BI__sync_and_and_fetch:
- case Builtin::BI__sync_and_and_fetch_1:
- case Builtin::BI__sync_and_and_fetch_2:
- case Builtin::BI__sync_and_and_fetch_4:
- case Builtin::BI__sync_and_and_fetch_8:
- case Builtin::BI__sync_and_and_fetch_16:
- case Builtin::BI__sync_or_and_fetch:
- case Builtin::BI__sync_or_and_fetch_1:
- case Builtin::BI__sync_or_and_fetch_2:
- case Builtin::BI__sync_or_and_fetch_4:
- case Builtin::BI__sync_or_and_fetch_8:
- case Builtin::BI__sync_or_and_fetch_16:
- case Builtin::BI__sync_xor_and_fetch:
- case Builtin::BI__sync_xor_and_fetch_1:
- case Builtin::BI__sync_xor_and_fetch_2:
- case Builtin::BI__sync_xor_and_fetch_4:
- case Builtin::BI__sync_xor_and_fetch_8:
- case Builtin::BI__sync_xor_and_fetch_16:
- case Builtin::BI__sync_nand_and_fetch:
- case Builtin::BI__sync_nand_and_fetch_1:
- case Builtin::BI__sync_nand_and_fetch_2:
- case Builtin::BI__sync_nand_and_fetch_4:
- case Builtin::BI__sync_nand_and_fetch_8:
- case Builtin::BI__sync_nand_and_fetch_16:
- case Builtin::BI__sync_val_compare_and_swap:
- case Builtin::BI__sync_val_compare_and_swap_1:
- case Builtin::BI__sync_val_compare_and_swap_2:
- case Builtin::BI__sync_val_compare_and_swap_4:
- case Builtin::BI__sync_val_compare_and_swap_8:
- case Builtin::BI__sync_val_compare_and_swap_16:
- case Builtin::BI__sync_bool_compare_and_swap:
- case Builtin::BI__sync_bool_compare_and_swap_1:
- case Builtin::BI__sync_bool_compare_and_swap_2:
- case Builtin::BI__sync_bool_compare_and_swap_4:
- case Builtin::BI__sync_bool_compare_and_swap_8:
- case Builtin::BI__sync_bool_compare_and_swap_16:
- case Builtin::BI__sync_lock_test_and_set:
- case Builtin::BI__sync_lock_test_and_set_1:
- case Builtin::BI__sync_lock_test_and_set_2:
- case Builtin::BI__sync_lock_test_and_set_4:
- case Builtin::BI__sync_lock_test_and_set_8:
- case Builtin::BI__sync_lock_test_and_set_16:
- case Builtin::BI__sync_lock_release:
- case Builtin::BI__sync_lock_release_1:
- case Builtin::BI__sync_lock_release_2:
- case Builtin::BI__sync_lock_release_4:
- case Builtin::BI__sync_lock_release_8:
- case Builtin::BI__sync_lock_release_16:
- case Builtin::BI__sync_swap:
- case Builtin::BI__sync_swap_1:
- case Builtin::BI__sync_swap_2:
- case Builtin::BI__sync_swap_4:
- case Builtin::BI__sync_swap_8:
- case Builtin::BI__sync_swap_16:
- return SemaBuiltinAtomicOverloaded(TheCallResult);
- case Builtin::BI__sync_synchronize:
- Diag(TheCall->getBeginLoc(), diag::warn_atomic_implicit_seq_cst)
- << TheCall->getCallee()->getSourceRange();
- break;
- case Builtin::BI__builtin_nontemporal_load:
- case Builtin::BI__builtin_nontemporal_store:
- return SemaBuiltinNontemporalOverloaded(TheCallResult);
- case Builtin::BI__builtin_memcpy_inline: {
- clang::Expr *SizeOp = TheCall->getArg(2);
- // We warn about copying to or from `nullptr` pointers when `size` is
- // greater than 0. When `size` is value dependent we cannot evaluate its
- // value so we bail out.
- if (SizeOp->isValueDependent())
- break;
- if (!SizeOp->EvaluateKnownConstInt(Context).isZero()) {
- CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
- CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
- }
+ case Builtin::BI__builtin_isgreater:
+ case Builtin::BI__builtin_isgreaterequal:
+ case Builtin::BI__builtin_isless:
+ case Builtin::BI__builtin_islessequal:
+ case Builtin::BI__builtin_islessgreater:
+ case Builtin::BI__builtin_isunordered:
+ if (SemaBuiltinUnorderedCompare(TheCall, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_fpclassify:
+ if (SemaBuiltinFPClassification(TheCall, 6, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_isfpclass:
+ if (SemaBuiltinFPClassification(TheCall, 2, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_isfinite:
+ case Builtin::BI__builtin_isinf:
+ case Builtin::BI__builtin_isinf_sign:
+ case Builtin::BI__builtin_isnan:
+ case Builtin::BI__builtin_issignaling:
+ case Builtin::BI__builtin_isnormal:
+ case Builtin::BI__builtin_issubnormal:
+ case Builtin::BI__builtin_iszero:
+ case Builtin::BI__builtin_signbit:
+ case Builtin::BI__builtin_signbitf:
+ case Builtin::BI__builtin_signbitl:
+ if (SemaBuiltinFPClassification(TheCall, 1, BuiltinID))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_shufflevector:
+ return SemaBuiltinShuffleVector(TheCall);
+ // TheCall will be freed by the smart pointer here, but that's fine, since
+ // SemaBuiltinShuffleVector guts it, but then doesn't release it.
+ case Builtin::BI__builtin_prefetch:
+ if (SemaBuiltinPrefetch(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_alloca_with_align:
+ case Builtin::BI__builtin_alloca_with_align_uninitialized:
+ if (SemaBuiltinAllocaWithAlign(TheCall))
+ return ExprError();
+ [[fallthrough]];
+ case Builtin::BI__builtin_alloca:
+ case Builtin::BI__builtin_alloca_uninitialized:
+ Diag(TheCall->getBeginLoc(), diag::warn_alloca)
+ << TheCall->getDirectCallee();
+ break;
+ case Builtin::BI__arithmetic_fence:
+ if (SemaBuiltinArithmeticFence(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__assume:
+ case Builtin::BI__builtin_assume:
+ if (SemaBuiltinAssume(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_assume_aligned:
+ if (SemaBuiltinAssumeAligned(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_dynamic_object_size:
+ case Builtin::BI__builtin_object_size:
+ if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 3))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_longjmp:
+ if (SemaBuiltinLongjmp(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_setjmp:
+ if (SemaBuiltinSetjmp(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_classify_type:
+ if (checkArgCount(*this, TheCall, 1))
+ return true;
+ TheCall->setType(Context.IntTy);
+ break;
+ case Builtin::BI__builtin_complex:
+ if (SemaBuiltinComplex(TheCall))
+ return ExprError();
+ break;
+ case Builtin::BI__builtin_constant_p: {
+ if (checkArgCount(*this, TheCall, 1))
+ return true;
+ ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
+ if (Arg.isInvalid())
+ return true;
+ TheCall->setArg(0, Arg.get());
+ TheCall->setType(Context.IntTy);
+ break;
+ }
+ case Builtin::BI__builtin_launder:
+ return SemaBuiltinLaunder(*this, TheCall);
+ case Builtin::BI__sync_fetch_and_add:
+ case Builtin::BI__sync_fetch_and_add_1:
+ case Builtin::BI__sync_fetch_and_add_2:
+ case Builtin::BI__sync_fetch_and_add_4:
+ case Builtin::BI__sync_fetch_and_add_8:
+ case Builtin::BI__sync_fetch_and_add_16:
+ case Builtin::BI__sync_fetch_and_sub:
+ case Builtin::BI__sync_fetch_and_sub_1:
+ case Builtin::BI__sync_fetch_and_sub_2:
+ case Builtin::BI__sync_fetch_and_sub_4:
+ case Builtin::BI__sync_fetch_and_sub_8:
+ case Builtin::BI__sync_fetch_and_sub_16:
+ case Builtin::BI__sync_fetch_and_or:
+ case Builtin::BI__sync_fetch_and_or_1:
+ case Builtin::BI__sync_fetch_and_or_2:
+ case Builtin::BI__sync_fetch_and_or_4:
+ case Builtin::BI__sync_fetch_and_or_8:
+ case Builtin::BI__sync_fetch_and_or_16:
+ case Builtin::BI__sync_fetch_and_and:
+ case Builtin::BI__sync_fetch_and_and_1:
+ case Builtin::BI__sync_fetch_and_and_2:
+ case Builtin::BI__sync_fetch_and_and_4:
+ case Builtin::BI__sync_fetch_and_and_8:
+ case Builtin::BI__sync_fetch_and_and_16:
+ case Builtin::BI__sync_fetch_and_xor:
+ case Builtin::BI__sync_fetch_and_xor_1:
+ case Builtin::BI__sync_fetch_and_xor_2:
+ case Builtin::BI__sync_fetch_and_xor_4:
+ case Builtin::BI__sync_fetch_and_xor_8:
+ case Builtin::BI__sync_fetch_and_xor_16:
+ case Builtin::BI__sync_fetch_and_nand:
+ case Builtin::BI__sync_fetch_and_nand_1:
+ case Builtin::BI__sync_fetch_and_nand_2:
+ case Builtin::BI__sync_fetch_and_nand_4:
+ case Builtin::BI__sync_fetch_and_nand_8:
+ case Builtin::BI__sync_fetch_and_nand_16:
+ case Builtin::BI__sync_add_and_fetch:
+ case Builtin::BI__sync_add_and_fetch_1:
+ case Builtin::BI__sync_add_and_fetch_2:
+ case Builtin::BI__sync_add_and_fetch_4:
+ case Builtin::BI__sync_add_and_fetch_8:
+ case Builtin::BI__sync_add_and_fetch_16:
+ case Builtin::BI__sync_sub_and_fetch:
+ case Builtin::BI__sync_sub_and_fetch_1:
+ case Builtin::BI__sync_sub_and_fetch_2:
+ case Builtin::BI__sync_sub_and_fetch_4:
+ case Builtin::BI__sync_sub_and_fetch_8:
+ case Builtin::BI__sync_sub_and_fetch_16:
+ case Builtin::BI__sync_and_and_fetch:
+ case Builtin::BI__sync_and_and_fetch_1:
+ case Builtin::BI__sync_and_and_fetch_2:
+ case Builtin::BI__sync_and_and_fetch_4:
+ case Builtin::BI__sync_and_and_fetch_8:
+ case Builtin::BI__sync_and_and_fetch_16:
+ case Builtin::BI__sync_or_and_fetch:
+ case Builtin::BI__sync_or_and_fetch_1:
+ case Builtin::BI__sync_or_and_fetch_2:
+ case Builtin::BI__sync_or_and_fetch_4:
+ case Builtin::BI__sync_or_and_fetch_8:
+ case Builtin::BI__sync_or_and_fetch_16:
+ case Builtin::BI__sync_xor_and_fetch:
+ case Builtin::BI__sync_xor_and_fetch_1:
+ case Builtin::BI__sync_xor_and_fetch_2:
+ case Builtin::BI__sync_xor_and_fetch_4:
+ case Builtin::BI__sync_xor_and_fetch_8:
+ case Builtin::BI__sync_xor_and_fetch_16:
+ case Builtin::BI__sync_nand_and_fetch:
+ case Builtin::BI__sync_nand_and_fetch_1:
+ case Builtin::BI__sync_nand_and_fetch_2:
+ case Builtin::BI__sync_nand_and_fetch_4:
+ case Builtin::BI__sync_nand_and_fetch_8:
+ case Builtin::BI__sync_nand_and_fetch_16:
+ case Builtin::BI__sync_val_compare_and_swap:
+ case Builtin::BI__sync_val_compare_and_swap_1:
+ case Builtin::BI__sync_val_compare_and_swap_2:
+ case Builtin::BI__sync_val_compare_and_swap_4:
+ case Builtin::BI__sync_val_compare_and_swap_8:
+ case Builtin::BI__sync_val_compare_and_swap_16:
+ case Builtin::BI__sync_bool_compare_and_swap:
+ case Builtin::BI__sync_bool_compare_and_swap_1:
+ case Builtin::BI__sync_bool_compare_and_swap_2:
+ case Builtin::BI__sync_bool_compare_and_swap_4:
+ case Builtin::BI__sync_bool_compare_and_swap_8:
+ case Builtin::BI__sync_bool_compare_and_swap_16:
+ case Builtin::BI__sync_lock_test_and_set:
+ case Builtin::BI__sync_lock_test_and_set_1:
+ case Builtin::BI__sync_lock_test_and_set_2:
+ case Builtin::BI__sync_lock_test_and_set_4:
+ case Builtin::BI__sync_lock_test_and_set_8:
+ case Builtin::BI__sync_lock_test_and_set_16:
+ case Builtin::BI__sync_lock_release:
+ case Builtin::BI__sync_lock_release_1:
+ case Builtin::BI__sync_lock_release_2:
+ case Builtin::BI__sync_lock_release_4:
+ case Builtin::BI__sync_lock_release_8:
+ case Builtin::BI__sync_lock_release_16:
+ case Builtin::BI__sync_swap:
+ case Builtin::BI__sync_swap_1:
+ case Builtin::BI__sync_swap_2:
+ case Builtin::BI__sync_swap_4:
+ case Builtin::BI__sync_swap_8:
+ case Builtin::BI__sync_swap_16:
+ return SemaBuiltinAtomicOverloaded(TheCallResult);
+ case Builtin::BI__sync_synchronize:
+ Diag(TheCall->getBeginLoc(), diag::warn_atomic_implicit_seq_cst)
+ << TheCall->getCallee()->getSourceRange();
+ break;
+ case Builtin::BI__builtin_nontemporal_load:
+ case Builtin::BI__builtin_nontemporal_store:
+ return SemaBuiltinNontemporalOverloaded(TheCallResult);
+ case Builtin::BI__builtin_memcpy_inline: {
+ clang::Expr *SizeOp = TheCall->getArg(2);
+ // We warn about copying to or from `nullptr` pointers when `size` is
+ // greater than 0. When `size` is value dependent we cannot evaluate its
+ // value so we bail out.
+ if (SizeOp->isValueDependent())
break;
+ if (!SizeOp->EvaluateKnownConstInt(Context).isZero()) {
+ CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+ CheckNonNullArgument(*this, TheCall->getArg(1), TheCall->getExprLoc());
}
- case Builtin::BI__builtin_memset_inline: {
- clang::Expr *SizeOp = TheCall->getArg(2);
- // We warn about filling to `nullptr` pointers when `size` is greater than
- // 0. When `size` is value dependent we cannot evaluate its value so we
- // bail out.
- if (SizeOp->isValueDependent())
- break;
- if (!SizeOp->EvaluateKnownConstInt(Context).isZero())
- CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+ break;
+ }
+ case Builtin::BI__builtin_memset_inline: {
+ clang::Expr *SizeOp = TheCall->getArg(2);
+ // We warn about filling to `nullptr` pointers when `size` is greater than
+ // 0. When `size` is value dependent we cannot evaluate its value so we
+ // bail out.
+ if (SizeOp->isValueDependent())
break;
- }
+ if (!SizeOp->EvaluateKnownConstInt(Context).isZero())
+ CheckNonNullArgument(*this, TheCall->getArg(0), TheCall->getExprLoc());
+ break;
+ }
#define BUILTIN(ID, TYPE, ATTRS)
-#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
- case Builtin::BI##ID: \
+#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
+ case Builtin::BI##ID: \
return SemaAtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID);
#include "clang/Basic/Builtins.inc"
case Builtin::BI__annotation:
@@ -2986,7 +2991,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
const auto *TyA = Arg->getType()->getAs<VectorType>();
if (!TyA || !TyA->getElementType()->isIntegerType()) {
Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
- << 1 << /* vector of integers */ 6 << Arg->getType();
+ << 1 << /* vector of integers */ 6 << Arg->getType();
return ExprError();
}
TheCall->setType(TyA->getElementType());
@@ -3050,7 +3055,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
}
return TheCallResult;
- }
+}
// Get the valid immediate range for the specified NEON type code.
static unsigned RFT(unsigned t, bool shift = false, bool ForceQuad = false) {
@@ -3446,14 +3451,14 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI,
bool HasConstPtr = false;
switch (BuiltinID) {
#define GET_NEON_OVERLOAD_CHECK
-#include "clang/Basic/arm_neon.inc"
#include "clang/Basic/arm_fp16.inc"
+#include "clang/Basic/arm_neon.inc"
#undef GET_NEON_OVERLOAD_CHECK
}
// For NEON intrinsics which are overloaded on vector element type, validate
// the immediate which specifies which variant to emit.
- unsigned ImmArg = TheCall->getNumArgs()-1;
+ unsigned ImmArg = TheCall->getNumArgs() - 1;
if (mask) {
if (SemaBuiltinConstantArg(TheCall, ImmArg, Result))
return true;
@@ -3497,10 +3502,10 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI,
switch (BuiltinID) {
default:
return false;
- #define GET_NEON_IMMEDIATE_CHECK
- #include "clang/Basic/arm_neon.inc"
- #include "clang/Basic/arm_fp16.inc"
- #undef GET_NEON_IMMEDIATE_CHECK
+#define GET_NEON_IMMEDIATE_CHECK
+#include "clang/Basic/arm_fp16.inc"
+#include "clang/Basic/arm_neon.inc"
+#undef GET_NEON_IMMEDIATE_CHECK
}
return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
@@ -3510,7 +3515,7 @@ bool Sema::CheckMVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
switch (BuiltinID) {
default:
return false;
- #include "clang/Basic/arm_mve_builtin_sema.inc"
+#include "clang/Basic/arm_mve_builtin_sema.inc"
}
}
@@ -3568,7 +3573,8 @@ bool Sema::CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall,
BuiltinID == AArch64::BI__builtin_arm_ldrex ||
BuiltinID == AArch64::BI__builtin_arm_ldaex;
- DeclRefExpr *DRE =cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
+ DeclRefExpr *DRE =
+ cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
// Ensure that we have the proper number of arguments.
if (checkArgCount(*this, TheCall, IsLdrex ? 1 : 2))
@@ -3678,7 +3684,7 @@ bool Sema::CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
if (BuiltinID == ARM::BI__builtin_arm_prefetch) {
return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
- SemaBuiltinConstantArgRange(TheCall, 2, 0, 1);
+ SemaBuiltinConstantArgRange(TheCall, 2, 0, 1);
}
if (BuiltinID == ARM::BI__builtin_arm_rsr64 ||
@@ -3702,7 +3708,8 @@ bool Sema::CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
// range check them here.
// FIXME: VFP Intrinsics should error if VFP not present.
switch (BuiltinID) {
- default: return false;
+ default:
+ return false;
case ARM::BI__builtin_arm_ssat:
return SemaBuiltinConstantArgRange(TheCall, 1, 1, 32);
case ARM::BI__builtin_arm_usat:
@@ -3808,11 +3815,18 @@ bool Sema::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI,
// range check them here.
unsigned i = 0, l = 0, u = 0;
switch (BuiltinID) {
- default: return false;
+ default:
+ return false;
case AArch64::BI__builtin_arm_dmb:
case AArch64::BI__builtin_arm_dsb:
- case AArch64::BI__builtin_arm_isb: l = 0; u = 15; break;
- case AArch64::BI__builtin_arm_tcancel: l = 0; u = 65535; break;
+ case AArch64::BI__builtin_arm_isb:
+ l = 0;
+ u = 15;
+ break;
+ case AArch64::BI__builtin_arm_tcancel:
+ l = 0;
+ u = 65535;
+ break;
}
return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
@@ -3902,8 +3916,7 @@ static bool isValidBPFPreserveEnumValueArg(Expr *Arg) {
return llvm::is_contained(ET->getDecl()->enumerators(), Enumerator);
}
-bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID,
- CallExpr *TheCall) {
+bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
assert((BuiltinID == BPF::BI__builtin_preserve_field_info ||
BuiltinID == BPF::BI__builtin_btf_type_id ||
BuiltinID == BPF::BI__builtin_preserve_type_info ||
@@ -3979,223 +3992,209 @@ bool Sema::CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
};
static BuiltinInfo Infos[] = {
- { Hexagon::BI__builtin_circ_ldd, {{ 3, true, 4, 3 }} },
- { Hexagon::BI__builtin_circ_ldw, {{ 3, true, 4, 2 }} },
- { Hexagon::BI__builtin_circ_ldh, {{ 3, true, 4, 1 }} },
- { Hexagon::BI__builtin_circ_lduh, {{ 3, true, 4, 1 }} },
- { Hexagon::BI__builtin_circ_ldb, {{ 3, true, 4, 0 }} },
- { Hexagon::BI__builtin_circ_ldub, {{ 3, true, 4, 0 }} },
- { Hexagon::BI__builtin_circ_std, {{ 3, true, 4, 3 }} },
- { Hexagon::BI__builtin_circ_stw, {{ 3, true, 4, 2 }} },
- { Hexagon::BI__builtin_circ_sth, {{ 3, true, 4, 1 }} },
- { Hexagon::BI__builtin_circ_sthhi, {{ 3, true, 4, 1 }} },
- { Hexagon::BI__builtin_circ_stb, {{ 3, true, 4, 0 }} },
-
- { Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{ 1, true, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1, true, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{ 1, true, 4, 1 }} },
- { Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1, true, 4, 1 }} },
- { Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1, true, 4, 2 }} },
- { Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1, true, 4, 3 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{ 1, true, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{ 1, true, 4, 1 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{ 1, true, 4, 1 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{ 1, true, 4, 2 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{ 1, true, 4, 3 }} },
-
- { Hexagon::BI__builtin_HEXAGON_A2_combineii, {{ 1, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{ 1, false, 16, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A2_tfril, {{ 1, false, 16, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{ 0, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{ 1, false, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{ 1, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{ 1, false, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{ 1, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{ 1, false, 7, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{ 1, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{ 1, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{ 1, false, 7, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{ 1, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{ 1, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{ 1, false, 7, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_C2_muxii, {{ 2, true, 8, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{ 0, false, 10, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{ 0, false, 10, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{ 0, false, 10, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{ 0, false, 10, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{ 1, false, 6, 2 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{ 1, false, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax,
- {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax,
- {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{ 1, false, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_extractu, {{ 1, false, 5, 0 },
- { 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_extractup, {{ 1, false, 6, 0 },
- { 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_insert, {{ 2, false, 5, 0 },
- { 3, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_insertp, {{ 2, false, 6, 0 },
- { 3, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{ 1, false, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax,
- {{ 2, false, 4, 0 },
- { 3, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax,
- {{ 2, false, 4, 0 },
- { 3, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax,
- {{ 2, false, 4, 0 },
- { 3, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax,
- {{ 2, false, 4, 0 },
- { 3, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_valignib, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{ 1, true , 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{ 1, true, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_extract, {{ 1, false, 5, 0 },
- { 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_extractp, {{ 1, false, 6, 0 },
- { 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_lsli, {{ 0, true, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{ 3, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{ 2, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax,
- {{ 1, false, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{ 1, false, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax,
- {{ 1, false, 4, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{ 1, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{ 2, false, 6, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{ 1, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{ 2, false, 5, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{ 2, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{ 2, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{ 3, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B,
- {{ 3, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{ 2, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{ 2, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{ 3, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B,
- {{ 3, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{ 2, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{ 2, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{ 3, false, 1, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B,
- {{ 3, false, 1, 0 }} },
-
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10, {{ 2, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_128B,
- {{ 2, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_vxx,
- {{ 3, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_vxx_128B,
- {{ 3, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10, {{ 2, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_128B,
- {{ 2, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_vxx,
- {{ 3, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B,
- {{ 3, false, 2, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi_128B, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci, {{ 3, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci_128B,
- {{ 3, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi_128B, {{ 2, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci, {{ 3, false, 3, 0 }} },
- { Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci_128B,
- {{ 3, false, 3, 0 }} },
+ {Hexagon::BI__builtin_circ_ldd, {{3, true, 4, 3}}},
+ {Hexagon::BI__builtin_circ_ldw, {{3, true, 4, 2}}},
+ {Hexagon::BI__builtin_circ_ldh, {{3, true, 4, 1}}},
+ {Hexagon::BI__builtin_circ_lduh, {{3, true, 4, 1}}},
+ {Hexagon::BI__builtin_circ_ldb, {{3, true, 4, 0}}},
+ {Hexagon::BI__builtin_circ_ldub, {{3, true, 4, 0}}},
+ {Hexagon::BI__builtin_circ_std, {{3, true, 4, 3}}},
+ {Hexagon::BI__builtin_circ_stw, {{3, true, 4, 2}}},
+ {Hexagon::BI__builtin_circ_sth, {{3, true, 4, 1}}},
+ {Hexagon::BI__builtin_circ_sthhi, {{3, true, 4, 1}}},
+ {Hexagon::BI__builtin_circ_stb, {{3, true, 4, 0}}},
+
+ {Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{1, true, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{1, true, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, {{1, true, 4, 1}}},
+ {Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{1, true, 4, 1}}},
+ {Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{1, true, 4, 2}}},
+ {Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{1, true, 4, 3}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, {{1, true, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, {{1, true, 4, 1}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, {{1, true, 4, 1}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, {{1, true, 4, 2}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, {{1, true, 4, 3}}},
+
+ {Hexagon::BI__builtin_HEXAGON_A2_combineii, {{1, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A2_tfrih, {{1, false, 16, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A2_tfril, {{1, false, 16, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A2_tfrpi, {{0, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_bitspliti, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, {{1, false, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, {{1, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_cround_ri, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_round_ri, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, {{1, false, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, {{1, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, {{1, false, 7, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, {{1, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, {{1, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, {{1, false, 7, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, {{1, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, {{1, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, {{1, false, 7, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_C2_bitsclri, {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_C2_muxii, {{2, true, 8, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_F2_dfclass, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, {{0, false, 10, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, {{0, false, 10, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_F2_sfclass, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, {{0, false, 10, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, {{0, false, 10, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, {{1, false, 6, 2}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, {{1, false, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax,
+ {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax,
+ {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, {{1, false, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_extractu,
+ {{1, false, 5, 0}, {2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_extractup,
+ {{1, false, 6, 0}, {2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_insert,
+ {{2, false, 5, 0}, {3, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_insertp,
+ {{2, false, 6, 0}, {3, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, {{1, false, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_setbit_i, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax,
+ {{2, false, 4, 0}, {3, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax,
+ {{2, false, 4, 0}, {3, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax,
+ {{2, false, 4, 0}, {3, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax,
+ {{2, false, 4, 0}, {3, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_valignib, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S2_vspliceib, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_clbaddi, {{1, true, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, {{1, true, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_extract,
+ {{1, false, 5, 0}, {2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_extractp,
+ {{1, false, 6, 0}, {2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_lsli, {{0, true, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, {{3, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, {{2, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax,
+ {{1, false, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, {{1, false, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, {{1, false, 4, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {{1, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {{2, false, 6, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, {{1, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, {{2, false, 5, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_valignbi, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, {{2, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, {{2, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, {{3, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B, {{3, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, {{2, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, {{2, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, {{3, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B, {{3, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, {{2, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, {{2, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, {{3, false, 1, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B, {{3, false, 1, 0}}},
+
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10, {{2, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_128B, {{2, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_vxx, {{3, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_vxx_128B,
+ {{3, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10, {{2, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_128B, {{2, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_vxx, {{3, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B,
+ {{3, false, 2, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi_128B, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci, {{3, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci_128B, {{3, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi_128B, {{2, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci, {{3, false, 3, 0}}},
+ {Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci_128B, {{3, false, 3, 0}}},
};
// Use a dynamically initialized static to sort the table exactly once on
// first run.
static const bool SortOnce =
(llvm::sort(Infos,
- [](const BuiltinInfo &LHS, const BuiltinInfo &RHS) {
- return LHS.BuiltinID < RHS.BuiltinID;
- }),
+ [](const BuiltinInfo &LHS, const BuiltinInfo &RHS) {
+ return LHS.BuiltinID < RHS.BuiltinID;
+ }),
true);
(void)SortOnce;
@@ -4767,14 +4766,43 @@ bool Sema::CheckMipsBuiltinCpu(const TargetInfo &TI, unsigned BuiltinID,
bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
unsigned i = 0, l = 0, u = 0, m = 0;
switch (BuiltinID) {
- default: return false;
- case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63; break;
- case Mips::BI__builtin_mips_rddsp: i = 0; l = 0; u = 63; break;
- case Mips::BI__builtin_mips_append: i = 2; l = 0; u = 31; break;
- case Mips::BI__builtin_mips_balign: i = 2; l = 0; u = 3; break;
- case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31; break;
- case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31; break;
- case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31; break;
+ default:
+ return false;
+ case Mips::BI__builtin_mips_wrdsp:
+ i = 1;
+ l = 0;
+ u = 63;
+ break;
+ case Mips::BI__builtin_mips_rddsp:
+ i = 0;
+ l = 0;
+ u = 63;
+ break;
+ case Mips::BI__builtin_mips_append:
+ i = 2;
+ l = 0;
+ u = 31;
+ break;
+ case Mips::BI__builtin_mips_balign:
+ i = 2;
+ l = 0;
+ u = 3;
+ break;
+ case Mips::BI__builtin_mips_precr_sra_ph_w:
+ i = 2;
+ l = 0;
+ u = 31;
+ break;
+ case Mips::BI__builtin_mips_precr_sra_r_ph_w:
+ i = 2;
+ l = 0;
+ u = 31;
+ break;
+ case Mips::BI__builtin_mips_prepend:
+ i = 2;
+ l = 0;
+ u = 31;
+ break;
// MSA intrinsics. Instructions (which the intrinsics maps to) which use the
// df/m field.
// These intrinsics take an unsigned 3 bit immediate.
@@ -4787,9 +4815,17 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
case Mips::BI__builtin_msa_srai_b:
case Mips::BI__builtin_msa_srari_b:
case Mips::BI__builtin_msa_srli_b:
- case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7; break;
+ case Mips::BI__builtin_msa_srlri_b:
+ i = 1;
+ l = 0;
+ u = 7;
+ break;
case Mips::BI__builtin_msa_binsli_b:
- case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7; break;
+ case Mips::BI__builtin_msa_binsri_b:
+ i = 2;
+ l = 0;
+ u = 7;
+ break;
// These intrinsics take an unsigned 4 bit immediate.
case Mips::BI__builtin_msa_bclri_h:
case Mips::BI__builtin_msa_bnegi_h:
@@ -4800,14 +4836,26 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
case Mips::BI__builtin_msa_srai_h:
case Mips::BI__builtin_msa_srari_h:
case Mips::BI__builtin_msa_srli_h:
- case Mips::BI__builtin_msa_srlri_h: i = 1; l = 0; u = 15; break;
+ case Mips::BI__builtin_msa_srlri_h:
+ i = 1;
+ l = 0;
+ u = 15;
+ break;
case Mips::BI__builtin_msa_binsli_h:
- case Mips::BI__builtin_msa_binsri_h: i = 2; l = 0; u = 15; break;
+ case Mips::BI__builtin_msa_binsri_h:
+ i = 2;
+ l = 0;
+ u = 15;
+ break;
// These intrinsics take an unsigned 5 bit immediate.
// The first block of intrinsics actually have an unsigned 5 bit field,
// not a df/n field.
case Mips::BI__builtin_msa_cfcmsa:
- case Mips::BI__builtin_msa_ctcmsa: i = 0; l = 0; u = 31; break;
+ case Mips::BI__builtin_msa_ctcmsa:
+ i = 0;
+ l = 0;
+ u = 31;
+ break;
case Mips::BI__builtin_msa_clei_u_b:
case Mips::BI__builtin_msa_clei_u_h:
case Mips::BI__builtin_msa_clei_u_w:
@@ -4841,9 +4889,17 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
case Mips::BI__builtin_msa_subvi_b:
case Mips::BI__builtin_msa_subvi_h:
case Mips::BI__builtin_msa_subvi_w:
- case Mips::BI__builtin_msa_subvi_d: i = 1; l = 0; u = 31; break;
+ case Mips::BI__builtin_msa_subvi_d:
+ i = 1;
+ l = 0;
+ u = 31;
+ break;
case Mips::BI__builtin_msa_binsli_w:
- case Mips::BI__builtin_msa_binsri_w: i = 2; l = 0; u = 31; break;
+ case Mips::BI__builtin_msa_binsri_w:
+ i = 2;
+ l = 0;
+ u = 31;
+ break;
// These intrinsics take an unsigned 6 bit immediate.
case Mips::BI__builtin_msa_bclri_d:
case Mips::BI__builtin_msa_bnegi_d:
@@ -4854,9 +4910,17 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
case Mips::BI__builtin_msa_srai_d:
case Mips::BI__builtin_msa_srari_d:
case Mips::BI__builtin_msa_srli_d:
- case Mips::BI__builtin_msa_srlri_d: i = 1; l = 0; u = 63; break;
+ case Mips::BI__builtin_msa_srlri_d:
+ i = 1;
+ l = 0;
+ u = 63;
+ break;
case Mips::BI__builtin_msa_binsli_d:
- case Mips::BI__builtin_msa_binsri_d: i = 2; l = 0; u = 63; break;
+ case Mips::BI__builtin_msa_binsri_d:
+ i = 2;
+ l = 0;
+ u = 63;
+ break;
// These intrinsics take a signed 5 bit immediate.
case Mips::BI__builtin_msa_ceqi_b:
case Mips::BI__builtin_msa_ceqi_h:
@@ -4877,7 +4941,11 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
case Mips::BI__builtin_msa_mini_s_b:
case Mips::BI__builtin_msa_mini_s_h:
case Mips::BI__builtin_msa_mini_s_w:
- case Mips::BI__builtin_msa_mini_s_d: i = 1; l = -16; u = 15; break;
+ case Mips::BI__builtin_msa_mini_s_d:
+ i = 1;
+ l = -16;
+ u = 15;
+ break;
// These intrinsics take an unsigned 8 bit immediate.
case Mips::BI__builtin_msa_andi_b:
case Mips::BI__builtin_msa_nori_b:
@@ -4885,53 +4953,161 @@ bool Sema::CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall) {
case Mips::BI__builtin_msa_shf_b:
case Mips::BI__builtin_msa_shf_h:
case Mips::BI__builtin_msa_shf_w:
- case Mips::BI__builtin_msa_xori_b: i = 1; l = 0; u = 255; break;
+ case Mips::BI__builtin_msa_xori_b:
+ i = 1;
+ l = 0;
+ u = 255;
+ break;
case Mips::BI__builtin_msa_bseli_b:
case Mips::BI__builtin_msa_bmnzi_b:
- case Mips::BI__builtin_msa_bmzi_b: i = 2; l = 0; u = 255; break;
+ case Mips::BI__builtin_msa_bmzi_b:
+ i = 2;
+ l = 0;
+ u = 255;
+ break;
// df/n format
// These intrinsics take an unsigned 4 bit immediate.
case Mips::BI__builtin_msa_copy_s_b:
case Mips::BI__builtin_msa_copy_u_b:
case Mips::BI__builtin_msa_insve_b:
- case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15; break;
- case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15; break;
+ case Mips::BI__builtin_msa_splati_b:
+ i = 1;
+ l = 0;
+ u = 15;
+ break;
+ case Mips::BI__builtin_msa_sldi_b:
+ i = 2;
+ l = 0;
+ u = 15;
+ break;
// These intrinsics take an unsigned 3 bit immediate.
case Mips::BI__builtin_msa_copy_s_h:
case Mips::BI__builtin_msa_copy_u_h:
case Mips::BI__builtin_msa_insve_h:
- case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7; break;
- case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7; break;
+ case Mips::BI__builtin_msa_splati_h:
+ i = 1;
+ l = 0;
+ u = 7;
+ break;
+ case Mips::BI__builtin_msa_sldi_h:
+ i = 2;
+ l = 0;
+ u = 7;
+ break;
// These intrinsics take an unsigned 2 bit immediate.
case Mips::BI__builtin_msa_copy_s_w:
case Mips::BI__builtin_msa_copy_u_w:
case Mips::BI__builtin_msa_insve_w:
- case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3; break;
- case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3; break;
+ case Mips::BI__builtin_msa_splati_w:
+ i = 1;
+ l = 0;
+ u = 3;
+ break;
+ case Mips::BI__builtin_msa_sldi_w:
+ i = 2;
+ l = 0;
+ u = 3;
+ break;
// These intrinsics take an unsigned 1 bit immediate.
case Mips::BI__builtin_msa_copy_s_d:
case Mips::BI__builtin_msa_copy_u_d:
case Mips::BI__builtin_msa_insve_d:
- case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1; break;
- case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1; break;
+ case Mips::BI__builtin_msa_splati_d:
+ i = 1;
+ l = 0;
+ u = 1;
+ break;
+ case Mips::BI__builtin_msa_sldi_d:
+ i = 2;
+ l = 0;
+ u = 1;
+ break;
// Memory offsets and immediate loads.
// These intrinsics take a signed 10 bit immediate.
- case Mips::BI__builtin_msa_ldi_b: i = 0; l = -128; u = 255; break;
+ case Mips::BI__builtin_msa_ldi_b:
+ i = 0;
+ l = -128;
+ u = 255;
+ break;
case Mips::BI__builtin_msa_ldi_h:
case Mips::BI__builtin_msa_ldi_w:
- case Mips::BI__builtin_msa_ldi_d: i = 0; l = -512; u = 511; break;
- case Mips::BI__builtin_msa_ld_b: i = 1; l = -512; u = 511; m = 1; break;
- case Mips::BI__builtin_msa_ld_h: i = 1; l = -1024; u = 1022; m = 2; break;
- case Mips::BI__builtin_msa_ld_w: i = 1; l = -2048; u = 2044; m = 4; break;
- case Mips::BI__builtin_msa_ld_d: i = 1; l = -4096; u = 4088; m = 8; break;
- case Mips::BI__builtin_msa_ldr_d: i = 1; l = -4096; u = 4088; m = 8; break;
- case Mips::BI__builtin_msa_ldr_w: i = 1; l = -2048; u = 2044; m = 4; break;
- case Mips::BI__builtin_msa_st_b: i = 2; l = -512; u = 511; m = 1; break;
- case Mips::BI__builtin_msa_st_h: i = 2; l = -1024; u = 1022; m = 2; break;
- case Mips::BI__builtin_msa_st_w: i = 2; l = -2048; u = 2044; m = 4; break;
- case Mips::BI__builtin_msa_st_d: i = 2; l = -4096; u = 4088; m = 8; break;
- case Mips::BI__builtin_msa_str_d: i = 2; l = -4096; u = 4088; m = 8; break;
- case Mips::BI__builtin_msa_str_w: i = 2; l = -2048; u = 2044; m = 4; break;
+ case Mips::BI__builtin_msa_ldi_d:
+ i = 0;
+ l = -512;
+ u = 511;
+ break;
+ case Mips::BI__builtin_msa_ld_b:
+ i = 1;
+ l = -512;
+ u = 511;
+ m = 1;
+ break;
+ case Mips::BI__builtin_msa_ld_h:
+ i = 1;
+ l = -1024;
+ u = 1022;
+ m = 2;
+ break;
+ case Mips::BI__builtin_msa_ld_w:
+ i = 1;
+ l = -2048;
+ u = 2044;
+ m = 4;
+ break;
+ case Mips::BI__builtin_msa_ld_d:
+ i = 1;
+ l = -4096;
+ u = 4088;
+ m = 8;
+ break;
+ case Mips::BI__builtin_msa_ldr_d:
+ i = 1;
+ l = -4096;
+ u = 4088;
+ m = 8;
+ break;
+ case Mips::BI__builtin_msa_ldr_w:
+ i = 1;
+ l = -2048;
+ u = 2044;
+ m = 4;
+ break;
+ case Mips::BI__builtin_msa_st_b:
+ i = 2;
+ l = -512;
+ u = 511;
+ m = 1;
+ break;
+ case Mips::BI__builtin_msa_st_h:
+ i = 2;
+ l = -1024;
+ u = 1022;
+ m = 2;
+ break;
+ case Mips::BI__builtin_msa_st_w:
+ i = 2;
+ l = -2048;
+ u = 2044;
+ m = 4;
+ break;
+ case Mips::BI__builtin_msa_st_d:
+ i = 2;
+ l = -4096;
+ u = 4088;
+ m = 8;
+ break;
+ case Mips::BI__builtin_msa_str_d:
+ i = 2;
+ l = -4096;
+ u = 4088;
+ m = 8;
+ break;
+ case Mips::BI__builtin_msa_str_w:
+ i = 2;
+ l = -2048;
+ u = 2044;
+ m = 4;
+ break;
}
if (!m)
@@ -4970,10 +5146,13 @@ static QualType DecodePPCMMATypeFromStr(ASTContext &Context, const char *&Str,
Str = End;
QualType Type;
switch (size) {
- #define PPC_VECTOR_TYPE(typeName, Id, size) \
- case size: Type = Context.Id##Ty; break;
- #include "clang/Basic/PPCTypes.def"
- default: llvm_unreachable("Invalid PowerPC MMA vector type");
+#define PPC_VECTOR_TYPE(typeName, Id, size) \
+ case size: \
+ Type = Context.Id##Ty; \
+ break;
+#include "clang/Basic/PPCTypes.def"
+ default:
+ llvm_unreachable("Invalid PowerPC MMA vector type");
}
bool CheckVectorArgs = false;
while (!CheckVectorArgs) {
@@ -5068,7 +5247,8 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
<< TheCall->getSourceRange();
switch (BuiltinID) {
- default: return false;
+ default:
+ return false;
case PPC::BI__builtin_altivec_crypto_vshasigmaw:
case PPC::BI__builtin_altivec_crypto_vshasigmad:
return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
@@ -5110,15 +5290,15 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case PPC::BI__builtin_unpack_vector_int128:
return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
case PPC::BI__builtin_altivec_vgnb:
- return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7);
+ return SemaBuiltinConstantArgRange(TheCall, 1, 2, 7);
case PPC::BI__builtin_vsx_xxeval:
- return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255);
+ return SemaBuiltinConstantArgRange(TheCall, 3, 0, 255);
case PPC::BI__builtin_altivec_vsldbi:
- return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
+ return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
case PPC::BI__builtin_altivec_vsrdbi:
- return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
+ return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7);
case PPC::BI__builtin_vsx_xxpermx:
- return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7);
+ return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7);
case PPC::BI__builtin_ppc_tw:
case PPC::BI__builtin_ppc_tdw:
return SemaBuiltinConstantArgRange(TheCall, 2, 1, 31);
@@ -5206,7 +5386,7 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
<< TheCall->getArg(I)->getType() << ArgType << 1 << 0 << 0;
return false;
}
-#define CUSTOM_BUILTIN(Name, Intr, Types, Acc, Feature) \
+#define CUSTOM_BUILTIN(Name, Intr, Types, Acc, Feature) \
case PPC::BI__builtin_##Name: \
return SemaBuiltinPPCMMACall(TheCall, BuiltinID, Types);
#include "clang/Basic/BuiltinsPPC.def"
@@ -5224,7 +5404,7 @@ bool Sema::CheckPPCMMAType(QualType Type, SourceLocation TypeLoc) {
#define PPC_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty
if (false
#include "clang/Basic/PPCTypes.def"
- ) {
+ ) {
Diag(TypeLoc, diag::err_ppc_invalid_use_mma_type);
return true;
}
@@ -5460,7 +5640,8 @@ static bool CheckInvalidVLENandLMUL(const TargetInfo &TI, CallExpr *TheCall,
std::string RequiredExt = "zvl" + std::to_string(MinRequiredVLEN) + "b";
if (!TI.hasFeature(RequiredExt))
return S.Diag(TheCall->getBeginLoc(),
- diag::err_riscv_type_requires_extension) << Type << RequiredExt;
+ diag::err_riscv_type_requires_extension)
+ << Type << RequiredExt;
return false;
}
@@ -5511,8 +5692,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo &TI,
// Error message
FeatureMissing = true;
Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_requires_extension)
- << IsExtension
- << TheCall->getSourceRange() << StringRef(FeatureStrs);
+ << IsExtension << TheCall->getSourceRange() << StringRef(FeatureStrs);
}
}
@@ -6342,12 +6522,21 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID,
// range check them here.
unsigned i = 0, l = 0, u = 0;
switch (BuiltinID) {
- default: return false;
- case SystemZ::BI__builtin_s390_lcbb: i = 1; l = 0; u = 15; break;
+ default:
+ return false;
+ case SystemZ::BI__builtin_s390_lcbb:
+ i = 1;
+ l = 0;
+ u = 15;
+ break;
case SystemZ::BI__builtin_s390_verimb:
case SystemZ::BI__builtin_s390_verimh:
case SystemZ::BI__builtin_s390_verimf:
- case SystemZ::BI__builtin_s390_verimg: i = 3; l = 0; u = 255; break;
+ case SystemZ::BI__builtin_s390_verimg:
+ i = 3;
+ l = 0;
+ u = 255;
+ break;
case SystemZ::BI__builtin_s390_vfaeb:
case SystemZ::BI__builtin_s390_vfaeh:
case SystemZ::BI__builtin_s390_vfaef:
@@ -6359,16 +6548,36 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID,
case SystemZ::BI__builtin_s390_vfaezf:
case SystemZ::BI__builtin_s390_vfaezbs:
case SystemZ::BI__builtin_s390_vfaezhs:
- case SystemZ::BI__builtin_s390_vfaezfs: i = 2; l = 0; u = 15; break;
+ case SystemZ::BI__builtin_s390_vfaezfs:
+ i = 2;
+ l = 0;
+ u = 15;
+ break;
case SystemZ::BI__builtin_s390_vfisb:
case SystemZ::BI__builtin_s390_vfidb:
return SemaBuiltinConstantArgRange(TheCall, 1, 0, 15) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
case SystemZ::BI__builtin_s390_vftcisb:
- case SystemZ::BI__builtin_s390_vftcidb: i = 1; l = 0; u = 4095; break;
- case SystemZ::BI__builtin_s390_vlbb: i = 1; l = 0; u = 15; break;
- case SystemZ::BI__builtin_s390_vpdi: i = 2; l = 0; u = 15; break;
- case SystemZ::BI__builtin_s390_vsldb: i = 2; l = 0; u = 15; break;
+ case SystemZ::BI__builtin_s390_vftcidb:
+ i = 1;
+ l = 0;
+ u = 4095;
+ break;
+ case SystemZ::BI__builtin_s390_vlbb:
+ i = 1;
+ l = 0;
+ u = 15;
+ break;
+ case SystemZ::BI__builtin_s390_vpdi:
+ i = 2;
+ l = 0;
+ u = 15;
+ break;
+ case SystemZ::BI__builtin_s390_vsldb:
+ i = 2;
+ l = 0;
+ u = 15;
+ break;
case SystemZ::BI__builtin_s390_vstrcb:
case SystemZ::BI__builtin_s390_vstrch:
case SystemZ::BI__builtin_s390_vstrcf:
@@ -6380,19 +6589,47 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID,
case SystemZ::BI__builtin_s390_vstrcfs:
case SystemZ::BI__builtin_s390_vstrczbs:
case SystemZ::BI__builtin_s390_vstrczhs:
- case SystemZ::BI__builtin_s390_vstrczfs: i = 3; l = 0; u = 15; break;
- case SystemZ::BI__builtin_s390_vmslg: i = 3; l = 0; u = 15; break;
+ case SystemZ::BI__builtin_s390_vstrczfs:
+ i = 3;
+ l = 0;
+ u = 15;
+ break;
+ case SystemZ::BI__builtin_s390_vmslg:
+ i = 3;
+ l = 0;
+ u = 15;
+ break;
case SystemZ::BI__builtin_s390_vfminsb:
case SystemZ::BI__builtin_s390_vfmaxsb:
case SystemZ::BI__builtin_s390_vfmindb:
- case SystemZ::BI__builtin_s390_vfmaxdb: i = 2; l = 0; u = 15; break;
- case SystemZ::BI__builtin_s390_vsld: i = 2; l = 0; u = 7; break;
- case SystemZ::BI__builtin_s390_vsrd: i = 2; l = 0; u = 7; break;
+ case SystemZ::BI__builtin_s390_vfmaxdb:
+ i = 2;
+ l = 0;
+ u = 15;
+ break;
+ case SystemZ::BI__builtin_s390_vsld:
+ i = 2;
+ l = 0;
+ u = 7;
+ break;
+ case SystemZ::BI__builtin_s390_vsrd:
+ i = 2;
+ l = 0;
+ u = 7;
+ break;
case SystemZ::BI__builtin_s390_vclfnhs:
case SystemZ::BI__builtin_s390_vclfnls:
case SystemZ::BI__builtin_s390_vcfn:
- case SystemZ::BI__builtin_s390_vcnf: i = 1; l = 0; u = 15; break;
- case SystemZ::BI__builtin_s390_vcrnfs: i = 2; l = 0; u = 15; break;
+ case SystemZ::BI__builtin_s390_vcnf:
+ i = 1;
+ l = 0;
+ u = 15;
+ break;
+ case SystemZ::BI__builtin_s390_vcrnfs:
+ i = 2;
+ l = 0;
+ u = 15;
+ break;
}
return SemaBuiltinConstantArgRange(TheCall, i, l, u);
}
@@ -6755,9 +6992,8 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall) {
// is set. If the intrinsic has rounding control(bits 1:0), make sure its only
// combined with ROUND_NO_EXC. If the intrinsic does not have rounding
// control, allow ROUND_NO_EXC and ROUND_CUR_DIRECTION together.
- if (Result == 4/*ROUND_CUR_DIRECTION*/ ||
- Result == 8/*ROUND_NO_EXC*/ ||
- (!HasRC && Result == 12/*ROUND_CUR_DIRECTION|ROUND_NO_EXC*/) ||
+ if (Result == 4 /*ROUND_CUR_DIRECTION*/ || Result == 8 /*ROUND_NO_EXC*/ ||
+ (!HasRC && Result == 12 /*ROUND_CUR_DIRECTION|ROUND_NO_EXC*/) ||
(HasRC && Result.getZExtValue() >= 8 && Result.getZExtValue() <= 11))
return false;
@@ -6981,7 +7217,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_extracti64x2_256_mask:
case X86::BI__builtin_ia32_extractf32x4_256_mask:
case X86::BI__builtin_ia32_extracti32x4_256_mask:
- i = 1; l = 0; u = 1;
+ i = 1;
+ l = 0;
+ u = 1;
break;
case X86::BI__builtin_ia32_vec_set_v2di:
case X86::BI__builtin_ia32_vinsertf128_pd256:
@@ -6996,7 +7234,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_inserti64x2_256:
case X86::BI__builtin_ia32_insertf32x4_256:
case X86::BI__builtin_ia32_inserti32x4_256:
- i = 2; l = 0; u = 1;
+ i = 2;
+ l = 0;
+ u = 1;
break;
case X86::BI__builtin_ia32_vpermilpd:
case X86::BI__builtin_ia32_vec_ext_v4hi:
@@ -7007,12 +7247,16 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_extracti32x4_mask:
case X86::BI__builtin_ia32_extractf64x2_512_mask:
case X86::BI__builtin_ia32_extracti64x2_512_mask:
- i = 1; l = 0; u = 3;
+ i = 1;
+ l = 0;
+ u = 3;
break;
case X86::BI_mm_prefetch:
case X86::BI__builtin_ia32_vec_ext_v8hi:
case X86::BI__builtin_ia32_vec_ext_v8si:
- i = 1; l = 0; u = 7;
+ i = 1;
+ l = 0;
+ u = 7;
break;
case X86::BI__builtin_ia32_sha1rnds4:
case X86::BI__builtin_ia32_blendpd:
@@ -7028,13 +7272,17 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_inserti64x2_512:
case X86::BI__builtin_ia32_insertf32x4:
case X86::BI__builtin_ia32_inserti32x4:
- i = 2; l = 0; u = 3;
+ i = 2;
+ l = 0;
+ u = 3;
break;
case X86::BI__builtin_ia32_vpermil2pd:
case X86::BI__builtin_ia32_vpermil2pd256:
case X86::BI__builtin_ia32_vpermil2ps:
case X86::BI__builtin_ia32_vpermil2ps256:
- i = 3; l = 0; u = 3;
+ i = 3;
+ l = 0;
+ u = 3;
break;
case X86::BI__builtin_ia32_cmpb128_mask:
case X86::BI__builtin_ia32_cmpw128_mask:
@@ -7070,7 +7318,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_vpcomq:
case X86::BI__builtin_ia32_vec_set_v8hi:
case X86::BI__builtin_ia32_vec_set_v8si:
- i = 2; l = 0; u = 7;
+ i = 2;
+ l = 0;
+ u = 7;
break;
case X86::BI__builtin_ia32_vpermilpd256:
case X86::BI__builtin_ia32_roundps:
@@ -7088,7 +7338,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_getmantph512_mask:
case X86::BI__builtin_ia32_vec_ext_v16qi:
case X86::BI__builtin_ia32_vec_ext_v16hi:
- i = 1; l = 0; u = 15;
+ i = 1;
+ l = 0;
+ u = 15;
break;
case X86::BI__builtin_ia32_pblendd128:
case X86::BI__builtin_ia32_blendps:
@@ -7107,10 +7359,14 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_getmantsh_round_mask:
case X86::BI__builtin_ia32_vec_set_v16qi:
case X86::BI__builtin_ia32_vec_set_v16hi:
- i = 2; l = 0; u = 15;
+ i = 2;
+ l = 0;
+ u = 15;
break;
case X86::BI__builtin_ia32_vec_ext_v32qi:
- i = 1; l = 0; u = 31;
+ i = 1;
+ l = 0;
+ u = 31;
break;
case X86::BI__builtin_ia32_cmpps:
case X86::BI__builtin_ia32_cmpss:
@@ -7127,7 +7383,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_cmpsd_mask:
case X86::BI__builtin_ia32_cmpss_mask:
case X86::BI__builtin_ia32_vec_set_v32qi:
- i = 2; l = 0; u = 31;
+ i = 2;
+ l = 0;
+ u = 31;
break;
case X86::BI__builtin_ia32_permdf256:
case X86::BI__builtin_ia32_permdi256:
@@ -7205,7 +7463,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_kshiftrihi:
case X86::BI__builtin_ia32_kshiftrisi:
case X86::BI__builtin_ia32_kshiftridi:
- i = 1; l = 0; u = 255;
+ i = 1;
+ l = 0;
+ u = 255;
break;
case X86::BI__builtin_ia32_vperm2f128_pd256:
case X86::BI__builtin_ia32_vperm2f128_ps256:
@@ -7255,7 +7515,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_vpshrdw128:
case X86::BI__builtin_ia32_vpshrdw256:
case X86::BI__builtin_ia32_vpshrdw512:
- i = 2; l = 0; u = 255;
+ i = 2;
+ l = 0;
+ u = 255;
break;
case X86::BI__builtin_ia32_fixupimmpd512_mask:
case X86::BI__builtin_ia32_fixupimmpd512_maskz:
@@ -7286,7 +7548,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_pternlogq256_mask:
case X86::BI__builtin_ia32_pternlogq256_maskz:
case X86::BI__builtin_ia32_vsm3rnds2:
- i = 3; l = 0; u = 255;
+ i = 3;
+ l = 0;
+ u = 255;
break;
case X86::BI__builtin_ia32_gatherpfdpd:
case X86::BI__builtin_ia32_gatherpfdps:
@@ -7296,7 +7560,9 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_scatterpfdps:
case X86::BI__builtin_ia32_scatterpfqpd:
case X86::BI__builtin_ia32_scatterpfqps:
- i = 4; l = 2; u = 3;
+ i = 4;
+ l = 2;
+ u = 3;
break;
case X86::BI__builtin_ia32_reducesd_mask:
case X86::BI__builtin_ia32_reducess_mask:
@@ -7304,11 +7570,15 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case X86::BI__builtin_ia32_rndscaless_round_mask:
case X86::BI__builtin_ia32_rndscalesh_round_mask:
case X86::BI__builtin_ia32_reducesh_mask:
- i = 4; l = 0; u = 255;
+ i = 4;
+ l = 0;
+ u = 255;
break;
case X86::BI__builtin_ia32_cmpccxadd32:
case X86::BI__builtin_ia32_cmpccxadd64:
- i = 3; l = 0; u = 15;
+ i = 3;
+ l = 0;
+ u = 15;
break;
}
@@ -7339,7 +7609,7 @@ bool Sema::getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
// of member functions is counted. However, it doesn't appear in our own
// lists, so decrement format_idx in that case.
if (IsCXXMember) {
- if(FSI->FormatIdx == 0)
+ if (FSI->FormatIdx == 0)
return false;
--FSI->FormatIdx;
if (FSI->FirstDataArg != 0)
@@ -7369,12 +7639,10 @@ static bool CheckNonNullExpr(Sema &S, const Expr *Expr) {
bool Result;
return (!Expr->isValueDependent() &&
- Expr->EvaluateAsBooleanCondition(Result, S.Context) &&
- !Result);
+ Expr->EvaluateAsBooleanCondition(Result, S.Context) && !Result);
}
-static void CheckNonNullArgument(Sema &S,
- const Expr *ArgExpr,
+static void CheckNonNullArgument(Sema &S, const Expr *ArgExpr,
SourceLocation CallSiteLoc) {
if (CheckNonNullExpr(S, ArgExpr))
S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr,
@@ -7394,19 +7662,17 @@ bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {
/// Diagnose use of %s directive in an NSString which is being passed
/// as formatting string to formatting method.
-static void
-DiagnoseCStringFormatDirectiveInCFAPI(Sema &S,
- const NamedDecl *FDecl,
- Expr **Args,
- unsigned NumArgs) {
+static void DiagnoseCStringFormatDirectiveInCFAPI(Sema &S,
+ const NamedDecl *FDecl,
+ Expr **Args,
+ unsigned NumArgs) {
unsigned Idx = 0;
bool Format = false;
ObjCStringFormatFamily SFFamily = FDecl->getObjCFStringFormattingFamily();
if (SFFamily == ObjCStringFormatFamily::SFF_CFString) {
Idx = 2;
Format = true;
- }
- else
+ } else
for (const auto *I : FDecl->specific_attrs<FormatAttr>()) {
if (S.GetFormatNSStringIdx(I, Idx)) {
Format = true;
@@ -7420,7 +7686,7 @@ DiagnoseCStringFormatDirectiveInCFAPI(Sema &S,
FormatExpr = CSCE->getSubExpr();
const StringLiteral *FormatString;
if (const ObjCStringLiteral *OSL =
- dyn_cast<ObjCStringLiteral>(FormatExpr->IgnoreParenImpCasts()))
+ dyn_cast<ObjCStringLiteral>(FormatExpr->IgnoreParenImpCasts()))
FormatString = OSL->getString();
else
FormatString = dyn_cast<StringLiteral>(FormatExpr->IgnoreParenImpCasts());
@@ -7428,9 +7694,9 @@ DiagnoseCStringFormatDirectiveInCFAPI(Sema &S,
return;
if (S.FormatStringHasSArg(FormatString)) {
S.Diag(FormatExpr->getExprLoc(), diag::warn_objc_cdirective_format_string)
- << "%s" << 1 << 1;
+ << "%s" << 1 << 1;
S.Diag(FDecl->getLocation(), diag::note_entity_declared_at)
- << FDecl->getDeclName();
+ << FDecl->getDeclName();
}
}
@@ -7442,8 +7708,7 @@ static bool isNonNullType(QualType type) {
return false;
}
-static void CheckNonNullArguments(Sema &S,
- const NamedDecl *FDecl,
+static void CheckNonNullArguments(Sema &S, const NamedDecl *FDecl,
const FunctionProtoType *Proto,
ArrayRef<const Expr *> Args,
SourceLocation CallSiteLoc) {
@@ -7479,14 +7744,14 @@ static void CheckNonNullArguments(Sema &S,
if (FDecl && (isa<FunctionDecl>(FDecl) || isa<ObjCMethodDecl>(FDecl))) {
// Handle the nonnull attribute on the parameters of the
// function/method.
- ArrayRef<ParmVarDecl*> parms;
+ ArrayRef<ParmVarDecl *> parms;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(FDecl))
parms = FD->parameters();
else
parms = cast<ObjCMethodDecl>(FDecl)->parameters();
unsigned ParamIndex = 0;
- for (ArrayRef<ParmVarDecl*>::iterator I = parms.begin(), E = parms.end();
+ for (ArrayRef<ParmVarDecl *>::iterator I = parms.begin(), E = parms.end();
I != E; ++I, ++ParamIndex) {
const ParmVarDecl *PVD = *I;
if (PVD->hasAttr<NonNullAttr>() || isNonNullType(PVD->getType())) {
@@ -7640,11 +7905,11 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
if (CallType != VariadicDoesNotApply &&
(!FD || FD->getBuiltinID() != Builtin::BI__noop)) {
unsigned NumParams = Proto ? Proto->getNumParams()
- : FDecl && isa<FunctionDecl>(FDecl)
- ? cast<FunctionDecl>(FDecl)->getNumParams()
- : FDecl && isa<ObjCMethodDecl>(FDecl)
- ? cast<ObjCMethodDecl>(FDecl)->param_size()
- : 0;
+ : FDecl && isa<FunctionDecl>(FDecl)
+ ? cast<FunctionDecl>(FDecl)->getNumParams()
+ : FDecl && isa<ObjCMethodDecl>(FDecl)
+ ? cast<ObjCMethodDecl>(FDecl)->param_size()
+ : 0;
for (unsigned ArgIdx = NumParams; ArgIdx < Args.size(); ++ArgIdx) {
// Args[ArgIdx] can be null in malformed code.
@@ -7793,13 +8058,13 @@ void Sema::CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
/// and safety properties not strictly enforced by the C type system.
bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
const FunctionProtoType *Proto) {
- bool IsMemberOperatorCall = isa<CXXOperatorCallExpr>(TheCall) &&
- isa<CXXMethodDecl>(FDecl);
- bool IsMemberFunction = isa<CXXMemberCallExpr>(TheCall) ||
- IsMemberOperatorCall;
- VariadicCallType CallType = getVariadicCallType(FDecl, Proto,
- TheCall->getCallee());
- Expr** Args = TheCall->getArgs();
+ bool IsMemberOperatorCall =
+ isa<CXXOperatorCallExpr>(TheCall) && isa<CXXMethodDecl>(FDecl);
+ bool IsMemberFunction =
+ isa<CXXMemberCallExpr>(TheCall) || IsMemberOperatorCall;
+ VariadicCallType CallType =
+ getVariadicCallType(FDecl, Proto, TheCall->getCallee());
+ Expr **Args = TheCall->getArgs();
unsigned NumArgs = TheCall->getNumArgs();
Expr *ImplicitThis = nullptr;
@@ -7923,8 +8188,8 @@ bool Sema::CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
/// Checks function calls when a FunctionDecl or a NamedDecl is not available,
/// such as function pointers returned from functions.
bool Sema::CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto) {
- VariadicCallType CallType = getVariadicCallType(/*FDecl=*/nullptr, Proto,
- TheCall->getCallee());
+ VariadicCallType CallType =
+ getVariadicCallType(/*FDecl=*/nullptr, Proto, TheCall->getCallee());
checkCall(/*FDecl=*/nullptr, Proto, /*ThisArg=*/nullptr,
llvm::ArrayRef(TheCall->getArgs(), TheCall->getNumArgs()),
/*IsMemberFunction=*/false, TheCall->getRParenLoc(),
@@ -7972,7 +8237,8 @@ static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op) {
ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult,
AtomicExpr::AtomicOp Op) {
CallExpr *TheCall = cast<CallExpr>(TheCallResult.get());
- DeclRefExpr *DRE =cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
+ DeclRefExpr *DRE =
+ cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
MultiExprArg Args{TheCall->getArgs(), TheCall->getNumArgs()};
return BuildAtomicExpr({TheCall->getBeginLoc(), TheCall->getEndLoc()},
DRE->getSourceRange(), TheCall->getRParenLoc(), Args,
@@ -8016,8 +8282,8 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
} Form = Init;
const unsigned NumForm = GNUCmpXchg + 1;
- const unsigned NumArgs[] = { 2, 2, 3, 3, 3, 3, 4, 5, 6 };
- const unsigned NumVals[] = { 1, 0, 1, 1, 1, 1, 2, 2, 3 };
+ const unsigned NumArgs[] = {2, 2, 3, 3, 3, 3, 4, 5, 6};
+ const unsigned NumVals[] = {1, 0, 1, 1, 1, 1, 2, 2, 3};
// where:
// C is an appropriate type,
// A is volatile _Atomic(C) for __c11 builtins and is C for GNU builtins,
@@ -8025,9 +8291,9 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
// M is C if C is an integer, and ptrdiff_t if C is a pointer, and
// the int parameters are for orderings.
- static_assert(sizeof(NumArgs)/sizeof(NumArgs[0]) == NumForm
- && sizeof(NumVals)/sizeof(NumVals[0]) == NumForm,
- "need to update code for modified forms");
+ static_assert(sizeof(NumArgs) / sizeof(NumArgs[0]) == NumForm &&
+ sizeof(NumVals) / sizeof(NumVals[0]) == NumForm,
+ "need to update code for modified forms");
static_assert(AtomicExpr::AO__atomic_add_fetch == 0 &&
AtomicExpr::AO__atomic_xor_fetch + 1 ==
AtomicExpr::AO__c11_atomic_compare_exchange_strong,
@@ -8214,7 +8480,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
// For a __c11 builtin, this should be a pointer to an _Atomic type.
QualType AtomTy = pointerType->getPointeeType(); // 'A'
- QualType ValType = AtomTy; // 'C'
+ QualType ValType = AtomTy; // 'C'
if (IsC11) {
if (!AtomTy->isAtomicType()) {
Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_atomic)
@@ -8313,8 +8579,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
ValType.removeLocalVolatile();
ValType.removeLocalConst();
QualType ResultType = ValType;
- if (Form == Copy || Form == LoadCopy || Form == GNUXchg ||
- Form == Init)
+ if (Form == Copy || Form == LoadCopy || Form == GNUXchg || Form == Init)
ResultType = Context.VoidTy;
else if (Form == C11CmpXchg || Form == GNUCmpXchg)
ResultType = Context.BoolTy;
@@ -8438,7 +8703,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
}
// Permute the arguments into a 'consistent' order.
- SmallVector<Expr*, 5> SubExprs;
+ SmallVector<Expr *, 5> SubExprs;
SubExprs.push_back(Ptr);
switch (Form) {
case Init:
@@ -8552,7 +8817,7 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) {
ParmVarDecl *Param = Fn->getParamDecl(ArgIndex);
InitializedEntity Entity =
- InitializedEntity::InitializeParameter(S.Context, Param);
+ InitializedEntity::InitializeParameter(S.Context, Param);
ExprResult Arg = E->getArg(ArgIndex);
Arg = S.PerformCopyInitialization(Entity, SourceLocation(), Arg);
@@ -8599,8 +8864,7 @@ bool Sema::BuiltinWasmRefNullFunc(CallExpr *TheCall) {
///
/// This function goes through and does final semantic checking for these
/// builtins, as well as generating any warnings.
-ExprResult
-Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
+ExprResult Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
CallExpr *TheCall = static_cast<CallExpr *>(TheCallResult.get());
Expr *Callee = TheCall->getCallee();
DeclRefExpr *DRE = cast<DeclRefExpr>(Callee->IgnoreParenCasts());
@@ -8671,41 +8935,52 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
// We need to figure out which concrete builtin this maps onto. For example,
// __sync_fetch_and_add with a 2 byte object turns into
// __sync_fetch_and_add_2.
-#define BUILTIN_ROW(x) \
- { Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \
- Builtin::BI##x##_8, Builtin::BI##x##_16 }
+#define BUILTIN_ROW(x) \
+ { \
+ Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \
+ Builtin::BI##x##_8, Builtin::BI##x##_16 \
+ }
static const unsigned BuiltinIndices[][5] = {
- BUILTIN_ROW(__sync_fetch_and_add),
- BUILTIN_ROW(__sync_fetch_and_sub),
- BUILTIN_ROW(__sync_fetch_and_or),
- BUILTIN_ROW(__sync_fetch_and_and),
- BUILTIN_ROW(__sync_fetch_and_xor),
- BUILTIN_ROW(__sync_fetch_and_nand),
-
- BUILTIN_ROW(__sync_add_and_fetch),
- BUILTIN_ROW(__sync_sub_and_fetch),
- BUILTIN_ROW(__sync_and_and_fetch),
- BUILTIN_ROW(__sync_or_and_fetch),
- BUILTIN_ROW(__sync_xor_and_fetch),
- BUILTIN_ROW(__sync_nand_and_fetch),
-
- BUILTIN_ROW(__sync_val_compare_and_swap),
- BUILTIN_ROW(__sync_bool_compare_and_swap),
- BUILTIN_ROW(__sync_lock_test_and_set),
- BUILTIN_ROW(__sync_lock_release),
- BUILTIN_ROW(__sync_swap)
- };
+ BUILTIN_ROW(__sync_fetch_and_add),
+ BUILTIN_ROW(__sync_fetch_and_sub),
+ BUILTIN_ROW(__sync_fetch_and_or),
+ BUILTIN_ROW(__sync_fetch_and_and),
+ BUILTIN_ROW(__sync_fetch_and_xor),
+ BUILTIN_ROW(__sync_fetch_and_nand),
+
+ BUILTIN_ROW(__sync_add_and_fetch),
+ BUILTIN_ROW(__sync_sub_and_fetch),
+ BUILTIN_ROW(__sync_and_and_fetch),
+ BUILTIN_ROW(__sync_or_and_fetch),
+ BUILTIN_ROW(__sync_xor_and_fetch),
+ BUILTIN_ROW(__sync_nand_and_fetch),
+
+ BUILTIN_ROW(__sync_val_compare_and_swap),
+ BUILTIN_ROW(__sync_bool_compare_and_swap),
+ BUILTIN_ROW(__sync_lock_test_and_set),
+ BUILTIN_ROW(__sync_lock_release),
+ BUILTIN_ROW(__sync_swap)};
#undef BUILTIN_ROW
// Determine the index of the size.
unsigned SizeIndex;
switch (Context.getTypeSizeInChars(ValType).getQuantity()) {
- case 1: SizeIndex = 0; break;
- case 2: SizeIndex = 1; break;
- case 4: SizeIndex = 2; break;
- case 8: SizeIndex = 3; break;
- case 16: SizeIndex = 4; break;
+ case 1:
+ SizeIndex = 0;
+ break;
+ case 2:
+ SizeIndex = 1;
+ break;
+ case 4:
+ SizeIndex = 2;
+ break;
+ case 8:
+ SizeIndex = 3;
+ break;
+ case 16:
+ SizeIndex = 4;
+ break;
default:
Diag(DRE->getBeginLoc(), diag::err_atomic_builtin_pointer_size)
<< FirstArg->getType() << FirstArg->getSourceRange();
@@ -8720,7 +8995,8 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
unsigned BuiltinIndex, NumFixed = 1;
bool WarnAboutSemanticsChange = false;
switch (BuiltinID) {
- default: llvm_unreachable("Unknown overloaded atomic builtin!");
+ default:
+ llvm_unreachable("Unknown overloaded atomic builtin!");
case Builtin::BI__sync_fetch_and_add:
case Builtin::BI__sync_fetch_and_add_1:
case Builtin::BI__sync_fetch_and_add_2:
@@ -8884,7 +9160,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
// Now that we know how many fixed arguments we expect, first check that we
// have at least that many.
- if (TheCall->getNumArgs() < 1+NumFixed) {
+ if (TheCall->getNumArgs() < 1 + NumFixed) {
Diag(TheCall->getEndLoc(), diag::err_typecheck_call_too_few_args_at_least)
<< 0 << 1 + NumFixed << TheCall->getNumArgs() << /*is non object*/ 0
<< Callee->getSourceRange();
@@ -8921,13 +9197,13 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
// deduce the types of the rest of the arguments accordingly. Walk
// the remaining arguments, converting them to the deduced value type.
for (unsigned i = 0; i != NumFixed; ++i) {
- ExprResult Arg = TheCall->getArg(i+1);
+ ExprResult Arg = TheCall->getArg(i + 1);
// GCC does an implicit conversion to the pointer or integer ValType. This
// can fail in some cases (1i -> int**), check for this error case now.
// Initialize the argument.
- InitializedEntity Entity = InitializedEntity::InitializeParameter(Context,
- ValType, /*consume*/ false);
+ InitializedEntity Entity = InitializedEntity::InitializeParameter(
+ Context, ValType, /*consume*/ false);
Arg = PerformCopyInitialization(Entity, SourceLocation(), Arg);
if (Arg.isInvalid())
return ExprError();
@@ -8938,7 +9214,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
// pass in 42. The 42 gets converted to char. This is even more strange
// for things like 45.123 -> char, etc.
// FIXME: Do this check.
- TheCall->setArg(i+1, Arg.get());
+ TheCall->setArg(i + 1, Arg.get());
}
// Create a new DeclRefExpr to refer to the new decl.
@@ -8950,8 +9226,8 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
// Set the callee in the CallExpr.
// FIXME: This loses syntactic information.
QualType CalleePtrTy = Context.getPointerType(NewBuiltinDecl->getType());
- ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy,
- CK_BuiltinFnToFnPtr);
+ ExprResult PromotedCall =
+ ImpCastExprToType(NewDRE, CalleePtrTy, CK_BuiltinFnToFnPtr);
TheCall->setCallee(PromotedCall.get());
// Change the result type of the call to match the original value type. This
@@ -9123,8 +9399,7 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
// On x64 Windows, don't allow this in System V ABI functions.
// (Yes, that means there's no corresponding way to support variadic
// System V ABI functions on Windows.)
- if ((IsWindows && CC == CC_X86_64SysV) ||
- (!IsWindows && CC == CC_Win64))
+ if ((IsWindows && CC == CC_X86_64SysV) || (!IsWindows && CC == CC_Win64))
return S.Diag(Fn->getBeginLoc(),
diag::err_va_start_used_in_wrong_abi_function)
<< !IsWindows;
@@ -9137,8 +9412,9 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
return false;
}
-static bool checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn,
- ParmVarDecl **LastParam = nullptr) {
+static bool
+checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn,
+ ParmVarDecl **LastParam = nullptr) {
// Determine whether the current function, block, or obj-c method is variadic
// and get its parameter list.
bool IsVariadic = false;
@@ -9243,8 +9519,10 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
Context.typesAreCompatible(ED->getPromotionType(), Type));
}()) {
unsigned Reason = 0;
- if (Type->isReferenceType()) Reason = 1;
- else if (IsCRegister) Reason = 2;
+ if (Type->isReferenceType())
+ Reason = 1;
+ else if (IsCRegister)
+ Reason = 2;
Diag(Arg->getBeginLoc(), diag::warn_va_start_type_is_undefined) << Reason;
Diag(ParamLoc, diag::note_parameter_type) << Type;
}
@@ -9482,8 +9760,8 @@ bool Sema::SemaBuiltinComplex(CallExpr *TheCall) {
if (!Context.hasSameType(Real->getType(), Imag->getType())) {
return Diag(Real->getBeginLoc(),
diag::err_typecheck_call_different_arg_types)
- << Real->getType() << Imag->getType()
- << Real->getSourceRange() << Imag->getSourceRange();
+ << Real->getType() << Imag->getType() << Real->getSourceRange()
+ << Imag->getSourceRange();
}
// We don't allow _Complex _Float16 nor _Complex __fp16 as type specifiers;
@@ -9627,7 +9905,7 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
<< TheCall->getArg(i)->getSourceRange());
}
- SmallVector<Expr*, 32> exprs;
+ SmallVector<Expr *, 32> exprs;
for (unsigned i = 0, e = TheCall->getNumArgs(); i != e; i++) {
exprs.push_back(TheCall->getArg(i));
@@ -9649,8 +9927,7 @@ ExprResult Sema::SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
QualType SrcTy = E->getType();
if (!SrcTy->isVectorType() && !SrcTy->isDependentType())
- return ExprError(Diag(BuiltinLoc,
- diag::err_convertvector_non_vector)
+ return ExprError(Diag(BuiltinLoc, diag::err_convertvector_non_vector)
<< E->getSourceRange());
if (!DstTy->isVectorType() && !DstTy->isDependentType())
return ExprError(Diag(BuiltinLoc, diag::err_builtin_non_vector_type)
@@ -9661,9 +9938,9 @@ ExprResult Sema::SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
unsigned SrcElts = SrcTy->castAs<VectorType>()->getNumElements();
unsigned DstElts = DstTy->castAs<VectorType>()->getNumElements();
if (SrcElts != DstElts)
- return ExprError(Diag(BuiltinLoc,
- diag::err_convertvector_incompatible_vector)
- << E->getSourceRange());
+ return ExprError(
+ Diag(BuiltinLoc, diag::err_convertvector_incompatible_vector)
+ << E->getSourceRange());
}
return new (Context)
@@ -9719,7 +9996,8 @@ bool Sema::SemaBuiltinArithmeticFence(CallExpr *TheCall) {
// has side effects.
bool Sema::SemaBuiltinAssume(CallExpr *TheCall) {
Expr *Arg = TheCall->getArg(0);
- if (Arg->isInstantiationDependent()) return false;
+ if (Arg->isInstantiationDependent())
+ return false;
if (Arg->HasSideEffects(Context))
Diag(Arg->getBeginLoc(), diag::warn_assume_side_effects)
@@ -9773,8 +10051,7 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) {
Expr *FirstArg = TheCall->getArg(0);
{
- ExprResult FirstArgResult =
- DefaultFunctionArrayLvalueConversion(FirstArg);
+ ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg);
if (checkBuiltinArgument(*this, TheCall, 0))
return true;
/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
@@ -9894,10 +10171,12 @@ bool Sema::SemaBuiltinOSLogFormat(CallExpr *TheCall) {
bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
llvm::APSInt &Result) {
Expr *Arg = TheCall->getArg(ArgNum);
- DeclRefExpr *DRE =cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
+ DeclRefExpr *DRE =
+ cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
FunctionDecl *FDecl = cast<FunctionDecl>(DRE->getDecl());
- if (Arg->isTypeDependent() || Arg->isValueDependent()) return false;
+ if (Arg->isTypeDependent() || Arg->isValueDependent())
+ return false;
std::optional<llvm::APSInt> R;
if (!(R = Arg->getIntegerConstantExpr(Context)))
@@ -9909,8 +10188,8 @@ bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
/// SemaBuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
/// TheCall is a constant expression in the range [Low, High].
-bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum,
- int Low, int High, bool RangeIsError) {
+bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low,
+ int High, bool RangeIsError) {
if (isConstantEvaluatedContext())
return false;
llvm::APSInt Result;
@@ -9940,8 +10219,8 @@ bool Sema::SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum,
return false;
}
-/// SemaBuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
-/// TheCall is a constant expression is a multiple of Num..
+/// SemaBuiltinConstantArgMultiple - Handle a check if argument ArgNum of
+/// CallExpr TheCall is a constant expression is a multiple of Num..
bool Sema::SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
unsigned Num) {
llvm::APSInt Result;
@@ -10068,7 +10347,8 @@ bool Sema::SemaBuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall,
}
/// SemaBuiltinARMMemoryTaggingCall - Handle calls of memory tagging extensions
-bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall) {
+bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID,
+ CallExpr *TheCall) {
if (BuiltinID == AArch64::BI__builtin_arm_irg) {
if (checkArgCount(*this, TheCall, 2))
return true;
@@ -10081,7 +10361,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall
QualType FirstArgType = FirstArg.get()->getType();
if (!FirstArgType->isAnyPointerType())
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
- << "first" << FirstArgType << Arg0->getSourceRange();
+ << "first" << FirstArgType << Arg0->getSourceRange();
TheCall->setArg(0, FirstArg.get());
ExprResult SecArg = DefaultLvalueConversion(Arg1);
@@ -10090,7 +10370,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall
QualType SecArgType = SecArg.get()->getType();
if (!SecArgType->isIntegerType())
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_integer)
- << "second" << SecArgType << Arg1->getSourceRange();
+ << "second" << SecArgType << Arg1->getSourceRange();
// Derive the return type from the pointer argument.
TheCall->setType(FirstArgType);
@@ -10108,7 +10388,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall
QualType FirstArgType = FirstArg.get()->getType();
if (!FirstArgType->isAnyPointerType())
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
- << "first" << FirstArgType << Arg0->getSourceRange();
+ << "first" << FirstArgType << Arg0->getSourceRange();
TheCall->setArg(0, FirstArg.get());
// Derive the return type from the pointer argument.
@@ -10130,12 +10410,12 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall
QualType FirstArgType = FirstArg.get()->getType();
if (!FirstArgType->isAnyPointerType())
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
- << "first" << FirstArgType << Arg0->getSourceRange();
+ << "first" << FirstArgType << Arg0->getSourceRange();
QualType SecArgType = Arg1->getType();
if (!SecArgType->isIntegerType())
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_integer)
- << "second" << SecArgType << Arg1->getSourceRange();
+ << "second" << SecArgType << Arg1->getSourceRange();
TheCall->setType(Context.IntTy);
return false;
}
@@ -10152,7 +10432,7 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall
QualType FirstArgType = FirstArg.get()->getType();
if (!FirstArgType->isAnyPointerType())
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer)
- << "first" << FirstArgType << Arg0->getSourceRange();
+ << "first" << FirstArgType << Arg0->getSourceRange();
TheCall->setArg(0, FirstArg.get());
// Derive the return type from the pointer argument.
@@ -10174,18 +10454,19 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall
QualType ArgTypeA = ArgExprA.get()->getType();
QualType ArgTypeB = ArgExprB.get()->getType();
- auto isNull = [&] (Expr *E) -> bool {
- return E->isNullPointerConstant(
- Context, Expr::NPC_ValueDependentIsNotNull); };
+ auto isNull = [&](Expr *E) -> bool {
+ return E->isNullPointerConstant(Context,
+ Expr::NPC_ValueDependentIsNotNull);
+ };
// argument should be either a pointer or null
if (!ArgTypeA->isAnyPointerType() && !isNull(ArgA))
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer)
- << "first" << ArgTypeA << ArgA->getSourceRange();
+ << "first" << ArgTypeA << ArgA->getSourceRange();
if (!ArgTypeB->isAnyPointerType() && !isNull(ArgB))
return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer)
- << "second" << ArgTypeB << ArgB->getSourceRange();
+ << "second" << ArgTypeB << ArgB->getSourceRange();
// Ensure Pointee types are compatible
if (ArgTypeA->isAnyPointerType() && !isNull(ArgA) &&
@@ -10193,18 +10474,19 @@ bool Sema::SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall
QualType pointeeA = ArgTypeA->getPointeeType();
QualType pointeeB = ArgTypeB->getPointeeType();
if (!Context.typesAreCompatible(
- Context.getCanonicalType(pointeeA).getUnqualifiedType(),
- Context.getCanonicalType(pointeeB).getUnqualifiedType())) {
- return Diag(TheCall->getBeginLoc(), diag::err_typecheck_sub_ptr_compatible)
- << ArgTypeA << ArgTypeB << ArgA->getSourceRange()
- << ArgB->getSourceRange();
+ Context.getCanonicalType(pointeeA).getUnqualifiedType(),
+ Context.getCanonicalType(pointeeB).getUnqualifiedType())) {
+ return Diag(TheCall->getBeginLoc(),
+ diag::err_typecheck_sub_ptr_compatible)
+ << ArgTypeA << ArgTypeB << ArgA->getSourceRange()
+ << ArgB->getSourceRange();
}
}
// at least one argument should be pointer type
if (!ArgTypeA->isAnyPointerType() && !ArgTypeB->isAnyPointerType())
return Diag(TheCall->getBeginLoc(), diag::err_memtag_any2arg_pointer)
- << ArgTypeA << ArgTypeB << ArgA->getSourceRange();
+ << ArgTypeA << ArgTypeB << ArgA->getSourceRange();
if (isNull(ArgA)) // adopt type of the other pointer
ArgExprA = ImpCastExprToType(ArgExprA.get(), ArgTypeB, CK_NullToPointer);
@@ -10293,7 +10575,7 @@ bool Sema::SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
else
Ranges.append({15, 7, 15});
- for (unsigned i=0; i<Fields.size(); ++i) {
+ for (unsigned i = 0; i < Fields.size(); ++i) {
int IntField;
ValidString &= !Fields[i].getAsInteger(10, IntField);
ValidString &= (IntField >= 0 && IntField <= Ranges[i]);
@@ -10317,17 +10599,17 @@ bool Sema::SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
// These are the named PSTATE accesses using "MSR (immediate)" instructions,
// along with the upper limit on the immediates allowed.
auto MaxLimit = llvm::StringSwitch<std::optional<unsigned>>(Reg)
- .CaseLower("spsel", 15)
- .CaseLower("daifclr", 15)
- .CaseLower("daifset", 15)
- .CaseLower("pan", 15)
- .CaseLower("uao", 15)
- .CaseLower("dit", 15)
- .CaseLower("ssbs", 15)
- .CaseLower("tco", 15)
- .CaseLower("allint", 1)
- .CaseLower("pm", 1)
- .Default(std::nullopt);
+ .CaseLower("spsel", 15)
+ .CaseLower("daifclr", 15)
+ .CaseLower("daifset", 15)
+ .CaseLower("pan", 15)
+ .CaseLower("uao", 15)
+ .CaseLower("dit", 15)
+ .CaseLower("ssbs", 15)
+ .CaseLower("tco", 15)
+ .CaseLower("allint", 1)
+ .CaseLower("pm", 1)
+ .Default(std::nullopt);
// If this is not a named PSTATE, just continue without validating, as this
// will be lowered to an "MSR (register)" instruction directly
@@ -10413,7 +10695,7 @@ bool Sema::SemaBuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID,
// number of arguments in TheCall and if it is not the case, to display a
// better error message.
while (*TypeStr != '\0') {
- (void) DecodePPCMMATypeFromStr(Context, TypeStr, Mask);
+ (void)DecodePPCMMATypeFromStr(Context, TypeStr, Mask);
ArgNum++;
}
if (checkArgCount(*this, TheCall, ArgNum))
@@ -10464,9 +10746,7 @@ class UncoveredArgHandler {
public:
UncoveredArgHandler() = default;
- bool hasUncoveredArg() const {
- return (FirstUncoveredArg >= 0);
- }
+ bool hasUncoveredArg() const { return (FirstUncoveredArg >= 0); }
unsigned getUncoveredArg() const {
assert(hasUncoveredArg() && "no uncovered argument");
@@ -10510,8 +10790,7 @@ enum StringLiteralCheckType {
} // namespace
static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
- BinaryOperatorKind BinOpKind,
- bool AddendIsRight) {
+ BinaryOperatorKind BinOpKind, bool AddendIsRight) {
unsigned BitWidth = Offset.getBitWidth();
unsigned AddendBitWidth = Addend.getBitWidth();
// There might be negative interim results.
@@ -10559,13 +10838,11 @@ class FormatStringLiteral {
const StringLiteral *FExpr;
int64_t Offset;
- public:
+public:
FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
: FExpr(fexpr), Offset(Offset) {}
- StringRef getString() const {
- return FExpr->getString().drop_front(Offset);
- }
+ StringRef getString() const { return FExpr->getString().drop_front(Offset); }
unsigned getByteLength() const {
return FExpr->getByteLength() - getCharByteWidth() * Offset;
@@ -10585,10 +10862,11 @@ class FormatStringLiteral {
bool isUTF32() const { return FExpr->isUTF32(); }
bool isPascal() const { return FExpr->isPascal(); }
- SourceLocation getLocationOfByte(
- unsigned ByteNo, const SourceManager &SM, const LangOptions &Features,
- const TargetInfo &Target, unsigned *StartToken = nullptr,
- unsigned *StartTokenByteOffset = nullptr) const {
+ SourceLocation
+ getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
+ const LangOptions &Features, const TargetInfo &Target,
+ unsigned *StartToken = nullptr,
+ unsigned *StartTokenByteOffset = nullptr) const {
return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
StartToken, StartTokenByteOffset);
}
@@ -10656,8 +10934,7 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef<const Expr *> Args,
case Stmt::ConditionalOperatorClass: {
// The expression is a literal if both sub-expressions were, and it was
// completely checked only if both sub-expressions were checked.
- const AbstractConditionalOperator *C =
- cast<AbstractConditionalOperator>(E);
+ const AbstractConditionalOperator *C = cast<AbstractConditionalOperator>(E);
// Determine whether it is necessary to check both sub-expressions, for
// example, because the condition expression is a constant that can be
@@ -10833,7 +11110,8 @@ checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef<const Expr *> Args,
case Stmt::CallExprClass:
case Stmt::CXXMemberCallExprClass: {
const CallExpr *CE = cast<CallExpr>(E);
- if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl())) {
+ if (const NamedDecl *ND =
+ dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl())) {
bool IsFirst = true;
StringLiteralCheckType CommonResult;
for (const auto *FA : ND->specific_attrs<FormatArgAttr>()) {
@@ -11061,7 +11339,7 @@ bool Sema::CheckFormatArguments(ArrayRef<const Expr *> Args,
if (UncoveredArg.hasUncoveredArg()) {
unsigned ArgIdx = UncoveredArg.getUncoveredArg() + firstDataArg;
assert(ArgIdx < Args.size() && "ArgIdx outside bounds");
- UncoveredArg.Diagnose(*this, /*IsFunctionCall*/true, Args[ArgIdx]);
+ UncoveredArg.Diagnose(*this, /*IsFunctionCall*/ true, Args[ArgIdx]);
}
if (CT != SLCT_NotALiteral)
@@ -11085,7 +11363,7 @@ bool Sema::CheckFormatArguments(ArrayRef<const Expr *> Args,
// warn only with -Wformat-nonliteral.
if (Args.size() == firstDataArg) {
Diag(FormatLoc, diag::warn_format_nonliteral_noargs)
- << OrigFormatExpr->getSourceRange();
+ << OrigFormatExpr->getSourceRange();
switch (Type) {
default:
break;
@@ -11093,16 +11371,16 @@ bool Sema::CheckFormatArguments(ArrayRef<const Expr *> Args,
case FST_FreeBSDKPrintf:
case FST_Printf:
Diag(FormatLoc, diag::note_format_security_fixit)
- << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
+ << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
break;
case FST_NSString:
Diag(FormatLoc, diag::note_format_security_fixit)
- << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
+ << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
break;
}
} else {
Diag(FormatLoc, diag::warn_format_nonliteral)
- << OrigFormatExpr->getSourceRange();
+ << OrigFormatExpr->getSourceRange();
}
return false;
}
@@ -11154,23 +11432,21 @@ class CheckFormatHandler : public analyze_format_string::FormatStringHandler {
unsigned specifierLen) override;
void HandleInvalidLengthModifier(
- const analyze_format_string::FormatSpecifier &FS,
- const analyze_format_string::ConversionSpecifier &CS,
- const char *startSpecifier, unsigned specifierLen,
- unsigned DiagID);
+ const analyze_format_string::FormatSpecifier &FS,
+ const analyze_format_string::ConversionSpecifier &CS,
+ const char *startSpecifier, unsigned specifierLen, unsigned DiagID);
void HandleNonStandardLengthModifier(
- const analyze_format_string::FormatSpecifier &FS,
- const char *startSpecifier, unsigned specifierLen);
+ const analyze_format_string::FormatSpecifier &FS,
+ const char *startSpecifier, unsigned specifierLen);
void HandleNonStandardConversionSpecifier(
- const analyze_format_string::ConversionSpecifier &CS,
- const char *startSpecifier, unsigned specifierLen);
+ const analyze_format_string::ConversionSpecifier &CS,
+ const char *startSpecifier, unsigned specifierLen);
void HandlePosition(const char *startPos, unsigned posLen) override;
- void HandleInvalidPosition(const char *startSpecifier,
- unsigned specifierLen,
+ void HandleInvalidPosition(const char *startSpecifier, unsigned specifierLen,
analyze_format_string::PositionContext p) override;
void HandleZeroPosition(const char *startPos, unsigned posLen) override;
@@ -11218,10 +11494,11 @@ SourceRange CheckFormatHandler::getFormatStringRange() {
return OrigFormatExpr->getSourceRange();
}
-CharSourceRange CheckFormatHandler::
-getSpecifierRange(const char *startSpecifier, unsigned specifierLen) {
+CharSourceRange
+CheckFormatHandler::getSpecifierRange(const char *startSpecifier,
+ unsigned specifierLen) {
SourceLocation Start = getLocationOfByte(startSpecifier);
- SourceLocation End = getLocationOfByte(startSpecifier + specifierLen - 1);
+ SourceLocation End = getLocationOfByte(startSpecifier + specifierLen - 1);
// Advance the end SourceLocation by one due to half-open ranges.
End = End.getLocWithOffset(1);
@@ -11235,10 +11512,10 @@ SourceLocation CheckFormatHandler::getLocationOfByte(const char *x) {
}
void CheckFormatHandler::HandleIncompleteSpecifier(const char *startSpecifier,
- unsigned specifierLen){
+ unsigned specifierLen) {
EmitFormatDiagnostic(S.PDiag(diag::warn_printf_incomplete_specifier),
getLocationOfByte(startSpecifier),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen));
}
@@ -11256,12 +11533,12 @@ void CheckFormatHandler::HandleInvalidLengthModifier(
if (FixedLM) {
EmitFormatDiagnostic(S.PDiag(DiagID) << LM.toString() << CS.toString(),
getLocationOfByte(LM.getStart()),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen));
S.Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
- << FixedLM->toString()
- << FixItHint::CreateReplacement(LMRange, FixedLM->toString());
+ << FixedLM->toString()
+ << FixItHint::CreateReplacement(LMRange, FixedLM->toString());
} else {
FixItHint Hint;
@@ -11270,9 +11547,8 @@ void CheckFormatHandler::HandleInvalidLengthModifier(
EmitFormatDiagnostic(S.PDiag(DiagID) << LM.toString() << CS.toString(),
getLocationOfByte(LM.getStart()),
- /*IsStringLocation*/true,
- getSpecifierRange(startSpecifier, specifierLen),
- Hint);
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startSpecifier, specifierLen), Hint);
}
}
@@ -11288,20 +11564,20 @@ void CheckFormatHandler::HandleNonStandardLengthModifier(
std::optional<LengthModifier> FixedLM = FS.getCorrectedLengthModifier();
if (FixedLM) {
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard)
- << LM.toString() << 0,
+ << LM.toString() << 0,
getLocationOfByte(LM.getStart()),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen));
S.Diag(getLocationOfByte(LM.getStart()), diag::note_format_fix_specifier)
- << FixedLM->toString()
- << FixItHint::CreateReplacement(LMRange, FixedLM->toString());
+ << FixedLM->toString()
+ << FixItHint::CreateReplacement(LMRange, FixedLM->toString());
} else {
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard)
- << LM.toString() << 0,
+ << LM.toString() << 0,
getLocationOfByte(LM.getStart()),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen));
}
}
@@ -11315,30 +11591,29 @@ void CheckFormatHandler::HandleNonStandardConversionSpecifier(
std::optional<ConversionSpecifier> FixedCS = CS.getStandardSpecifier();
if (FixedCS) {
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard)
- << CS.toString() << /*conversion specifier*/1,
+ << CS.toString() << /*conversion specifier*/ 1,
getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen));
CharSourceRange CSRange = getSpecifierRange(CS.getStart(), CS.getLength());
S.Diag(getLocationOfByte(CS.getStart()), diag::note_format_fix_specifier)
- << FixedCS->toString()
- << FixItHint::CreateReplacement(CSRange, FixedCS->toString());
+ << FixedCS->toString()
+ << FixItHint::CreateReplacement(CSRange, FixedCS->toString());
} else {
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard)
- << CS.toString() << /*conversion specifier*/1,
+ << CS.toString() << /*conversion specifier*/ 1,
getLocationOfByte(CS.getStart()),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen));
}
}
-void CheckFormatHandler::HandlePosition(const char *startPos,
- unsigned posLen) {
+void CheckFormatHandler::HandlePosition(const char *startPos, unsigned posLen) {
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
- getLocationOfByte(startPos),
- /*IsStringLocation*/true,
- getSpecifierRange(startPos, posLen));
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
}
void CheckFormatHandler::HandleInvalidPosition(
@@ -11353,18 +11628,18 @@ void CheckFormatHandler::HandleInvalidPosition(
void CheckFormatHandler::HandleZeroPosition(const char *startPos,
unsigned posLen) {
EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
- getLocationOfByte(startPos),
- /*IsStringLocation*/true,
- getSpecifierRange(startPos, posLen));
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
}
void CheckFormatHandler::HandleNullChar(const char *nullCharacter) {
if (!isa<ObjCStringLiteral>(OrigFormatExpr)) {
// The presence of a null character is likely an error.
EmitFormatDiagnostic(
- S.PDiag(diag::warn_printf_format_string_contains_null_char),
- getLocationOfByte(nullCharacter), /*IsStringLocation*/true,
- getFormatStringRange());
+ S.PDiag(diag::warn_printf_format_string_contains_null_char),
+ getLocationOfByte(nullCharacter), /*IsStringLocation*/ true,
+ getFormatStringRange());
}
}
@@ -11392,8 +11667,7 @@ void CheckFormatHandler::DoneProcessing() {
void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall,
const Expr *ArgExpr) {
- assert(hasUncoveredArg() && !DiagnosticExprs.empty() &&
- "Invalid state");
+ assert(hasUncoveredArg() && !DiagnosticExprs.empty() && "Invalid state");
if (!ArgExpr)
return;
@@ -11408,25 +11682,19 @@ void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall,
PDiag << E->getSourceRange();
CheckFormatHandler::EmitFormatDiagnostic(
- S, IsFunctionCall, DiagnosticExprs[0],
- PDiag, Loc, /*IsStringLocation*/false,
- DiagnosticExprs[0]->getSourceRange());
-}
-
-bool
-CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex,
- SourceLocation Loc,
- const char *startSpec,
- unsigned specifierLen,
- const char *csStart,
- unsigned csLen) {
+ S, IsFunctionCall, DiagnosticExprs[0], PDiag, Loc,
+ /*IsStringLocation*/ false, DiagnosticExprs[0]->getSourceRange());
+}
+
+bool CheckFormatHandler::HandleInvalidConversionSpecifier(
+ unsigned argIndex, SourceLocation Loc, const char *startSpec,
+ unsigned specifierLen, const char *csStart, unsigned csLen) {
bool keepGoing = true;
if (argIndex < NumDataArgs) {
// Consider the argument coverered, even though the specifier doesn't
// make sense.
CoveredArgs.set(argIndex);
- }
- else {
+ } else {
// If argIndex exceeds the number of data arguments we
// don't issue a warning because that is just a cascade of warnings (and
// they may have intended '%%' anyway). We don't want to continue processing
@@ -11444,8 +11712,7 @@ CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex,
if (!llvm::sys::locale::isPrint(*csStart)) {
llvm::UTF32 CodePoint;
const llvm::UTF8 **B = reinterpret_cast<const llvm::UTF8 **>(&csStart);
- const llvm::UTF8 *E =
- reinterpret_cast<const llvm::UTF8 *>(csStart + csLen);
+ const llvm::UTF8 *E = reinterpret_cast<const llvm::UTF8 *>(csStart + csLen);
llvm::ConversionResult Result =
llvm::convertUTF8Sequence(B, E, &CodePoint, llvm::strictConversion);
@@ -11472,29 +11739,27 @@ CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex,
return keepGoing;
}
-void
-CheckFormatHandler::HandlePositionalNonpositionalArgs(SourceLocation Loc,
- const char *startSpec,
- unsigned specifierLen) {
+void CheckFormatHandler::HandlePositionalNonpositionalArgs(
+ SourceLocation Loc, const char *startSpec, unsigned specifierLen) {
EmitFormatDiagnostic(
- S.PDiag(diag::warn_format_mix_positional_nonpositional_args),
- Loc, /*isStringLoc*/true, getSpecifierRange(startSpec, specifierLen));
+ S.PDiag(diag::warn_format_mix_positional_nonpositional_args), Loc,
+ /*isStringLoc*/ true, getSpecifierRange(startSpec, specifierLen));
}
-bool
-CheckFormatHandler::CheckNumArgs(
- const analyze_format_string::FormatSpecifier &FS,
- const analyze_format_string::ConversionSpecifier &CS,
- const char *startSpecifier, unsigned specifierLen, unsigned argIndex) {
+bool CheckFormatHandler::CheckNumArgs(
+ const analyze_format_string::FormatSpecifier &FS,
+ const analyze_format_string::ConversionSpecifier &CS,
+ const char *startSpecifier, unsigned specifierLen, unsigned argIndex) {
if (argIndex >= NumDataArgs) {
- PartialDiagnostic PDiag = FS.usesPositionalArg()
- ? (S.PDiag(diag::warn_printf_positional_arg_exceeds_data_args)
- << (argIndex+1) << NumDataArgs)
- : S.PDiag(diag::warn_printf_insufficient_data_args);
- EmitFormatDiagnostic(
- PDiag, getLocationOfByte(CS.getStart()), /*IsStringLocation*/true,
- getSpecifierRange(startSpecifier, specifierLen));
+ PartialDiagnostic PDiag =
+ FS.usesPositionalArg()
+ ? (S.PDiag(diag::warn_printf_positional_arg_exceeds_data_args)
+ << (argIndex + 1) << NumDataArgs)
+ : S.PDiag(diag::warn_printf_insufficient_data_args);
+ EmitFormatDiagnostic(PDiag, getLocationOfByte(CS.getStart()),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startSpecifier, specifierLen));
// Since more arguments than conversion tokens are given, by extension
// all arguments are covered, so mark this as so.
@@ -11504,14 +11769,14 @@ CheckFormatHandler::CheckNumArgs(
return true;
}
-template<typename Range>
+template <typename Range>
void CheckFormatHandler::EmitFormatDiagnostic(PartialDiagnostic PDiag,
SourceLocation Loc,
bool IsStringLocation,
Range StringRange,
ArrayRef<FixItHint> FixIt) {
- EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag,
- Loc, IsStringLocation, StringRange, FixIt);
+ EmitFormatDiagnostic(S, inFunctionCall, Args[FormatIdx], PDiag, Loc,
+ IsStringLocation, StringRange, FixIt);
}
/// If the format string is not within the function call, emit a note
@@ -11552,11 +11817,11 @@ void CheckFormatHandler::EmitFormatDiagnostic(
D << FixIt;
} else {
S.Diag(IsStringLocation ? ArgumentExpr->getExprLoc() : Loc, PDiag)
- << ArgumentExpr->getSourceRange();
+ << ArgumentExpr->getSourceRange();
const Sema::SemaDiagnosticBuilder &Note =
- S.Diag(IsStringLocation ? Loc : StringRange.getBegin(),
- diag::note_format_string_defined);
+ S.Diag(IsStringLocation ? Loc : StringRange.getBegin(),
+ diag::note_format_string_defined);
Note << StringRange;
Note << FixIt;
@@ -11592,9 +11857,8 @@ class CheckPrintfHandler : public CheckFormatHandler {
}
bool HandleInvalidPrintfConversionSpecifier(
- const analyze_printf::PrintfSpecifier &FS,
- const char *startSpecifier,
- unsigned specifierLen) override;
+ const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier,
+ unsigned specifierLen) override;
void handleInvalidMaskType(StringRef MaskType) override;
@@ -11602,16 +11866,16 @@ class CheckPrintfHandler : public CheckFormatHandler {
const char *startSpecifier, unsigned specifierLen,
const TargetInfo &Target) override;
bool checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
- const char *StartSpecifier,
- unsigned SpecifierLen,
+ const char *StartSpecifier, unsigned SpecifierLen,
const Expr *E);
- bool HandleAmount(const analyze_format_string::OptionalAmount &Amt, unsigned k,
- const char *startSpecifier, unsigned specifierLen);
+ bool HandleAmount(const analyze_format_string::OptionalAmount &Amt,
+ unsigned k, const char *startSpecifier,
+ unsigned specifierLen);
void HandleInvalidAmount(const analyze_printf::PrintfSpecifier &FS,
const analyze_printf::OptionalAmount &Amt,
- unsigned type,
- const char *startSpecifier, unsigned specifierLen);
+ unsigned type, const char *startSpecifier,
+ unsigned specifierLen);
void HandleFlag(const analyze_printf::PrintfSpecifier &FS,
const analyze_printf::OptionalFlag &flag,
const char *startSpecifier, unsigned specifierLen);
@@ -11619,34 +11883,31 @@ class CheckPrintfHandler : public CheckFormatHandler {
const analyze_printf::OptionalFlag &ignoredFlag,
const analyze_printf::OptionalFlag &flag,
const char *startSpecifier, unsigned specifierLen);
- bool checkForCStrMembers(const analyze_printf::ArgType &AT,
- const Expr *E);
+ bool checkForCStrMembers(const analyze_printf::ArgType &AT, const Expr *E);
void HandleEmptyObjCModifierFlag(const char *startFlag,
unsigned flagLen) override;
void HandleInvalidObjCModifierFlag(const char *startFlag,
- unsigned flagLen) override;
+ unsigned flagLen) override;
- void HandleObjCFlagsWithNonObjCConversion(const char *flagsStart,
- const char *flagsEnd,
- const char *conversionPosition)
- override;
+ void
+ HandleObjCFlagsWithNonObjCConversion(const char *flagsStart,
+ const char *flagsEnd,
+ const char *conversionPosition) override;
};
} // namespace
bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier(
- const analyze_printf::PrintfSpecifier &FS,
- const char *startSpecifier,
- unsigned specifierLen) {
+ const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier,
+ unsigned specifierLen) {
const analyze_printf::PrintfConversionSpecifier &CS =
- FS.getConversionSpecifier();
+ FS.getConversionSpecifier();
- return HandleInvalidConversionSpecifier(FS.getArgIndex(),
- getLocationOfByte(CS.getStart()),
- startSpecifier, specifierLen,
- CS.getStart(), CS.getLength());
+ return HandleInvalidConversionSpecifier(
+ FS.getArgIndex(), getLocationOfByte(CS.getStart()), startSpecifier,
+ specifierLen, CS.getStart(), CS.getLength());
}
void CheckPrintfHandler::handleInvalidMaskType(StringRef MaskType) {
@@ -11686,10 +11947,10 @@ bool CheckPrintfHandler::HandleAmount(
if (!AT.matchesType(S.Context, T)) {
EmitFormatDiagnostic(S.PDiag(diag::warn_printf_asterisk_wrong_type)
- << k << AT.getRepresentativeTypeName(S.Context)
- << T << Arg->getSourceRange(),
+ << k << AT.getRepresentativeTypeName(S.Context)
+ << T << Arg->getSourceRange(),
getLocationOfByte(Amt.getStart()),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen));
// Don't do any more checking. We will just emit
// spurious errors.
@@ -11701,26 +11962,23 @@ bool CheckPrintfHandler::HandleAmount(
}
void CheckPrintfHandler::HandleInvalidAmount(
- const analyze_printf::PrintfSpecifier &FS,
- const analyze_printf::OptionalAmount &Amt,
- unsigned type,
- const char *startSpecifier,
- unsigned specifierLen) {
+ const analyze_printf::PrintfSpecifier &FS,
+ const analyze_printf::OptionalAmount &Amt, unsigned type,
+ const char *startSpecifier, unsigned specifierLen) {
const analyze_printf::PrintfConversionSpecifier &CS =
- FS.getConversionSpecifier();
+ FS.getConversionSpecifier();
FixItHint fixit =
- Amt.getHowSpecified() == analyze_printf::OptionalAmount::Constant
- ? FixItHint::CreateRemoval(getSpecifierRange(Amt.getStart(),
- Amt.getConstantLength()))
- : FixItHint();
+ Amt.getHowSpecified() == analyze_printf::OptionalAmount::Constant
+ ? FixItHint::CreateRemoval(
+ getSpecifierRange(Amt.getStart(), Amt.getConstantLength()))
+ : FixItHint();
EmitFormatDiagnostic(S.PDiag(diag::warn_printf_nonsensical_optional_amount)
- << type << CS.toString(),
+ << type << CS.toString(),
getLocationOfByte(Amt.getStart()),
- /*IsStringLocation*/true,
- getSpecifierRange(startSpecifier, specifierLen),
- fixit);
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startSpecifier, specifierLen), fixit);
}
void CheckPrintfHandler::HandleFlag(const analyze_printf::PrintfSpecifier &FS,
@@ -11729,39 +11987,37 @@ void CheckPrintfHandler::HandleFlag(const analyze_printf::PrintfSpecifier &FS,
unsigned specifierLen) {
// Warn about pointless flag with a fixit removal.
const analyze_printf::PrintfConversionSpecifier &CS =
- FS.getConversionSpecifier();
- EmitFormatDiagnostic(S.PDiag(diag::warn_printf_nonsensical_flag)
- << flag.toString() << CS.toString(),
- getLocationOfByte(flag.getPosition()),
- /*IsStringLocation*/true,
- getSpecifierRange(startSpecifier, specifierLen),
- FixItHint::CreateRemoval(
- getSpecifierRange(flag.getPosition(), 1)));
+ FS.getConversionSpecifier();
+ EmitFormatDiagnostic(
+ S.PDiag(diag::warn_printf_nonsensical_flag)
+ << flag.toString() << CS.toString(),
+ getLocationOfByte(flag.getPosition()),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startSpecifier, specifierLen),
+ FixItHint::CreateRemoval(getSpecifierRange(flag.getPosition(), 1)));
}
void CheckPrintfHandler::HandleIgnoredFlag(
- const analyze_printf::PrintfSpecifier &FS,
- const analyze_printf::OptionalFlag &ignoredFlag,
- const analyze_printf::OptionalFlag &flag,
- const char *startSpecifier,
- unsigned specifierLen) {
+ const analyze_printf::PrintfSpecifier &FS,
+ const analyze_printf::OptionalFlag &ignoredFlag,
+ const analyze_printf::OptionalFlag &flag, const char *startSpecifier,
+ unsigned specifierLen) {
// Warn about ignored flag with a fixit removal.
EmitFormatDiagnostic(S.PDiag(diag::warn_printf_ignored_flag)
- << ignoredFlag.toString() << flag.toString(),
+ << ignoredFlag.toString() << flag.toString(),
getLocationOfByte(ignoredFlag.getPosition()),
- /*IsStringLocation*/true,
+ /*IsStringLocation*/ true,
getSpecifierRange(startSpecifier, specifierLen),
FixItHint::CreateRemoval(
- getSpecifierRange(ignoredFlag.getPosition(), 1)));
+ getSpecifierRange(ignoredFlag.getPosition(), 1)));
}
void CheckPrintfHandler::HandleEmptyObjCModifierFlag(const char *startFlag,
unsigned flagLen) {
// Warn about an empty flag.
- EmitFormatDiagnostic(S.PDiag(diag::warn_printf_empty_objc_flag),
- getLocationOfByte(startFlag),
- /*IsStringLocation*/true,
- getSpecifierRange(startFlag, flagLen));
+ EmitFormatDiagnostic(
+ S.PDiag(diag::warn_printf_empty_objc_flag), getLocationOfByte(startFlag),
+ /*IsStringLocation*/ true, getSpecifierRange(startFlag, flagLen));
}
void CheckPrintfHandler::HandleInvalidObjCModifierFlag(const char *startFlag,
@@ -11770,30 +12026,31 @@ void CheckPrintfHandler::HandleInvalidObjCModifierFlag(const char *startFlag,
auto Range = getSpecifierRange(startFlag, flagLen);
StringRef flag(startFlag, flagLen);
EmitFormatDiagnostic(S.PDiag(diag::warn_printf_invalid_objc_flag) << flag,
- getLocationOfByte(startFlag),
- /*IsStringLocation*/true,
- Range, FixItHint::CreateRemoval(Range));
+ getLocationOfByte(startFlag),
+ /*IsStringLocation*/ true, Range,
+ FixItHint::CreateRemoval(Range));
}
void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion(
- const char *flagsStart, const char *flagsEnd, const char *conversionPosition) {
- // Warn about using '[...]' without a '@' conversion.
- auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1);
- auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion;
- EmitFormatDiagnostic(S.PDiag(diag) << StringRef(conversionPosition, 1),
- getLocationOfByte(conversionPosition),
- /*IsStringLocation*/true,
- Range, FixItHint::CreateRemoval(Range));
+ const char *flagsStart, const char *flagsEnd,
+ const char *conversionPosition) {
+ // Warn about using '[...]' without a '@' conversion.
+ auto Range = getSpecifierRange(flagsStart, flagsEnd - flagsStart + 1);
+ auto diag = diag::warn_printf_ObjCflags_without_ObjCConversion;
+ EmitFormatDiagnostic(S.PDiag(diag) << StringRef(conversionPosition, 1),
+ getLocationOfByte(conversionPosition),
+ /*IsStringLocation*/ true, Range,
+ FixItHint::CreateRemoval(Range));
}
// Determines if the specified is a C++ class or struct containing
// a member with the specified name and kind (e.g. a CXXMethodDecl named
// "c_str()").
-template<typename MemberKind>
-static llvm::SmallPtrSet<MemberKind*, 1>
+template <typename MemberKind>
+static llvm::SmallPtrSet<MemberKind *, 1>
CXXRecordMembersNamed(StringRef Name, Sema &S, QualType Ty) {
const RecordType *RT = Ty->getAs<RecordType>();
- llvm::SmallPtrSet<MemberKind*, 1> Results;
+ llvm::SmallPtrSet<MemberKind *, 1> Results;
if (!RT)
return Results;
@@ -11825,8 +12082,8 @@ bool Sema::hasCStrMethod(const Expr *E) {
MethodSet Results =
CXXRecordMembersNamed<CXXMethodDecl>("c_str", *this, E->getType());
- for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
- MI != ME; ++MI)
+ for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); MI != ME;
+ ++MI)
if ((*MI)->getMinRequiredArguments() == 0)
return true;
return false;
@@ -11835,15 +12092,15 @@ bool Sema::hasCStrMethod(const Expr *E) {
// Check if a (w)string was passed when a (w)char* was needed, and offer a
// better diagnostic if so. AT is assumed to be valid.
// Returns true when a c_str() conversion method is found.
-bool CheckPrintfHandler::checkForCStrMembers(
- const analyze_printf::ArgType &AT, const Expr *E) {
+bool CheckPrintfHandler::checkForCStrMembers(const analyze_printf::ArgType &AT,
+ const Expr *E) {
using MethodSet = llvm::SmallPtrSet<CXXMethodDecl *, 1>;
MethodSet Results =
CXXRecordMembersNamed<CXXMethodDecl>("c_str", S, E->getType());
- for (MethodSet::iterator MI = Results.begin(), ME = Results.end();
- MI != ME; ++MI) {
+ for (MethodSet::iterator MI = Results.begin(), ME = Results.end(); MI != ME;
+ ++MI) {
const CXXMethodDecl *Method = *MI;
if (Method->getMinRequiredArguments() == 0 &&
AT.matchesType(S.Context, Method->getReturnType())) {
@@ -11868,10 +12125,9 @@ bool CheckPrintfHandler::HandlePrintfSpecifier(
if (FS.consumesDataArgument()) {
if (atFirstArg) {
- atFirstArg = false;
- usesPositionalArgs = FS.usesPositionalArg();
- }
- else if (usesPositionalArgs != FS.usesPositionalArg()) {
+ atFirstArg = false;
+ usesPositionalArgs = FS.usesPositionalArg();
+ } else if (usesPositionalArgs != FS.usesPositionalArg()) {
HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
startSpecifier, specifierLen);
return false;
@@ -11880,13 +12136,13 @@ bool CheckPrintfHandler::HandlePrintfSpecifier(
// First check if the field width, precision, and conversion specifier
// have matching data arguments.
- if (!HandleAmount(FS.getFieldWidth(), /* field width */ 0,
- startSpecifier, specifierLen)) {
+ if (!HandleAmount(FS.getFieldWidth(), /* field width */ 0, startSpecifier,
+ specifierLen)) {
return false;
}
- if (!HandleAmount(FS.getPrecision(), /* precision */ 1,
- startSpecifier, specifierLen)) {
+ if (!HandleAmount(FS.getPrecision(), /* precision */ 1, startSpecifier,
+ specifierLen)) {
return false;
}
@@ -11918,8 +12174,9 @@ bool CheckPrintfHandler::HandlePrintfSpecifier(
// Type check the first argument (int for %b, pointer for %D)
const Expr *Ex = getDataArg(argIndex);
const analyze_printf::ArgType &AT =
- (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ?
- ArgType(S.Context.IntTy) : ArgType::CPointerTy;
+ (CS.getKind() == ConversionSpecifier::FreeBSDbArg)
+ ? ArgType(S.Context.IntTy)
+ : ArgType::CPointerTy;
if (AT.isValid() && !AT.matchesType(S.Context, Ex->getType()))
EmitFormatDiagnostic(
S.PDiag(diag::warn_format_conversion_argument_type_mismatch)
@@ -11939,7 +12196,7 @@ bool CheckPrintfHandler::HandlePrintfSpecifier(
Ex->getBeginLoc(), /*IsStringLocation*/ false,
getSpecifierRange(startSpecifier, specifierLen));
- return true;
+ return true;
}
// Check for using an Objective-C specific conversion specifier
@@ -12004,13 +12261,13 @@ bool CheckPrintfHandler::HandlePrintfSpecifier(
// Check for invalid use of field width
if (!FS.hasValidFieldWidth()) {
HandleInvalidAmount(FS, FS.getFieldWidth(), /* field width */ 0,
- startSpecifier, specifierLen);
+ startSpecifier, specifierLen);
}
// Check for invalid use of precision
if (!FS.hasValidPrecision()) {
HandleInvalidAmount(FS, FS.getPrecision(), /* precision */ 1,
- startSpecifier, specifierLen);
+ startSpecifier, specifierLen);
}
// Precision is mandatory for %P specifier.
@@ -12039,10 +12296,10 @@ bool CheckPrintfHandler::HandlePrintfSpecifier(
// Check that flags are not ignored by another flag
if (FS.hasSpacePrefix() && FS.hasPlusPrefix()) // ' ' ignored by '+'
HandleIgnoredFlag(FS, FS.hasSpacePrefix(), FS.hasPlusPrefix(),
- startSpecifier, specifierLen);
+ startSpecifier, specifierLen);
if (FS.hasLeadingZeros() && FS.isLeftJustified()) // '0' ignored by '-'
HandleIgnoredFlag(FS, FS.hasLeadingZeros(), FS.isLeftJustified(),
- startSpecifier, specifierLen);
+ startSpecifier, specifierLen);
// Check the length modifier is valid with the given conversion specifier.
if (!FS.hasValidLengthModifier(S.getASTContext().getTargetInfo(),
@@ -12109,20 +12366,19 @@ static bool requiresParensToAddCast(const Expr *E) {
}
static std::pair<QualType, StringRef>
-shouldNotPrintDirectly(const ASTContext &Context,
- QualType IntendedTy,
+shouldNotPrintDirectly(const ASTContext &Context, QualType IntendedTy,
const Expr *E) {
// Use a 'while' to peel off layers of typedefs.
QualType TyTy = IntendedTy;
while (const TypedefType *UserTy = TyTy->getAs<TypedefType>()) {
StringRef Name = UserTy->getDecl()->getName();
QualType CastTy = llvm::StringSwitch<QualType>(Name)
- .Case("CFIndex", Context.getNSIntegerType())
- .Case("NSInteger", Context.getNSIntegerType())
- .Case("NSUInteger", Context.getNSUIntegerType())
- .Case("SInt32", Context.IntTy)
- .Case("UInt32", Context.UnsignedIntTy)
- .Default(QualType());
+ .Case("CFIndex", Context.getNSIntegerType())
+ .Case("NSInteger", Context.getNSIntegerType())
+ .Case("NSUInteger", Context.getNSUIntegerType())
+ .Case("SInt32", Context.IntTy)
+ .Case("UInt32", Context.UnsignedIntTy)
+ .Default(QualType());
if (!CastTy.isNull())
return std::make_pair(CastTy, Name);
@@ -12132,8 +12388,7 @@ shouldNotPrintDirectly(const ASTContext &Context,
// Strip parens if necessary.
if (const ParenExpr *PE = dyn_cast<ParenExpr>(E))
- return shouldNotPrintDirectly(Context,
- PE->getSubExpr()->getType(),
+ return shouldNotPrintDirectly(Context, PE->getSubExpr()->getType(),
PE->getSubExpr());
// If this is a conditional expression, then its result type is constructed
@@ -12144,14 +12399,10 @@ shouldNotPrintDirectly(const ASTContext &Context,
QualType TrueTy, FalseTy;
StringRef TrueName, FalseName;
- std::tie(TrueTy, TrueName) =
- shouldNotPrintDirectly(Context,
- CO->getTrueExpr()->getType(),
- CO->getTrueExpr());
- std::tie(FalseTy, FalseName) =
- shouldNotPrintDirectly(Context,
- CO->getFalseExpr()->getType(),
- CO->getFalseExpr());
+ std::tie(TrueTy, TrueName) = shouldNotPrintDirectly(
+ Context, CO->getTrueExpr()->getType(), CO->getTrueExpr());
+ std::tie(FalseTy, FalseName) = shouldNotPrintDirectly(
+ Context, CO->getFalseExpr()->getType(), CO->getFalseExpr());
if (TrueTy == FalseTy)
return std::make_pair(TrueTy, TrueName);
@@ -12167,8 +12418,8 @@ shouldNotPrintDirectly(const ASTContext &Context,
/// Return true if \p ICE is an implicit argument promotion of an arithmetic
/// type. Bit-field 'promotions' from a higher ranked type to a lower ranked
/// type do not count.
-static bool
-isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE) {
+static bool isArithmeticArgumentPromotion(Sema &S,
+ const ImplicitCastExpr *ICE) {
QualType From = ICE->getSubExpr()->getType();
QualType To = ICE->getType();
// It's an integer promotion if the destination type is the promoted
@@ -12188,11 +12439,9 @@ isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE) {
S.Context.getFloatingTypeOrder(From, To) < 0;
}
-bool
-CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
- const char *StartSpecifier,
- unsigned SpecifierLen,
- const Expr *E) {
+bool CheckPrintfHandler::checkFormatExpr(
+ const analyze_printf::PrintfSpecifier &FS, const char *StartSpecifier,
+ unsigned SpecifierLen, const Expr *E) {
using namespace analyze_format_string;
using namespace analyze_printf;
@@ -12338,10 +12587,12 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
// Special-case some of Darwin's platform-independence types by suggesting
// casts to primitive types that are known to be large enough.
- bool ShouldNotPrintDirectly = false; StringRef CastTyName;
+ bool ShouldNotPrintDirectly = false;
+ StringRef CastTyName;
if (S.Context.getTargetInfo().getTriple().isOSDarwin()) {
QualType CastTy;
- std::tie(CastTy, CastTyName) = shouldNotPrintDirectly(S.Context, IntendedTy, E);
+ std::tie(CastTy, CastTyName) =
+ shouldNotPrintDirectly(S.Context, IntendedTy, E);
if (!CastTy.isNull()) {
// %zi/%zu and %td/%tu are OK to use for NSInteger/NSUInteger of type int
// (long in ASTContext). Only complain to pedants or when they're the
@@ -12409,7 +12660,7 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
CastFix << (S.LangOpts.CPlusPlus ? ">" : ")");
- SmallVector<FixItHint,4> Hints;
+ SmallVector<FixItHint, 4> Hints;
if (AT.matchesType(S.Context, IntendedTy) != ArgType::Match ||
ShouldNotPrintDirectly)
Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str()));
@@ -12466,8 +12717,8 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
}
}
} else {
- const CharSourceRange &CSR = getSpecifierRange(StartSpecifier,
- SpecifierLen);
+ const CharSourceRange &CSR =
+ getSpecifierRange(StartSpecifier, SpecifierLen);
// Since the warning for passing non-POD types to variadic functions
// was deferred until now, we emit a warning for non-POD
// arguments here.
@@ -12576,10 +12827,10 @@ class CheckScanfHandler : public CheckFormatHandler {
const char *startSpecifier,
unsigned specifierLen) override;
- bool HandleInvalidScanfConversionSpecifier(
- const analyze_scanf::ScanfSpecifier &FS,
- const char *startSpecifier,
- unsigned specifierLen) override;
+ bool
+ HandleInvalidScanfConversionSpecifier(const analyze_scanf::ScanfSpecifier &FS,
+ const char *startSpecifier,
+ unsigned specifierLen) override;
void HandleIncompleteScanList(const char *start, const char *end) override;
};
@@ -12589,27 +12840,24 @@ class CheckScanfHandler : public CheckFormatHandler {
void CheckScanfHandler::HandleIncompleteScanList(const char *start,
const char *end) {
EmitFormatDiagnostic(S.PDiag(diag::warn_scanf_scanlist_incomplete),
- getLocationOfByte(end), /*IsStringLocation*/true,
+ getLocationOfByte(end), /*IsStringLocation*/ true,
getSpecifierRange(start, end - start));
}
bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier(
- const analyze_scanf::ScanfSpecifier &FS,
- const char *startSpecifier,
- unsigned specifierLen) {
+ const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier,
+ unsigned specifierLen) {
const analyze_scanf::ScanfConversionSpecifier &CS =
- FS.getConversionSpecifier();
+ FS.getConversionSpecifier();
- return HandleInvalidConversionSpecifier(FS.getArgIndex(),
- getLocationOfByte(CS.getStart()),
- startSpecifier, specifierLen,
- CS.getStart(), CS.getLength());
+ return HandleInvalidConversionSpecifier(
+ FS.getArgIndex(), getLocationOfByte(CS.getStart()), startSpecifier,
+ specifierLen, CS.getStart(), CS.getLength());
}
bool CheckScanfHandler::HandleScanfSpecifier(
- const analyze_scanf::ScanfSpecifier &FS,
- const char *startSpecifier,
- unsigned specifierLen) {
+ const analyze_scanf::ScanfSpecifier &FS, const char *startSpecifier,
+ unsigned specifierLen) {
using namespace analyze_scanf;
using namespace analyze_format_string;
@@ -12621,8 +12869,7 @@ bool CheckScanfHandler::HandleScanfSpecifier(
if (atFirstArg) {
atFirstArg = false;
usesPositionalArgs = FS.usesPositionalArg();
- }
- else if (usesPositionalArgs != FS.usesPositionalArg()) {
+ } else if (usesPositionalArgs != FS.usesPositionalArg()) {
HandlePositionalNonpositionalArgs(getLocationOfByte(CS.getStart()),
startSpecifier, specifierLen);
return false;
@@ -12633,11 +12880,11 @@ bool CheckScanfHandler::HandleScanfSpecifier(
const OptionalAmount &Amt = FS.getFieldWidth();
if (Amt.getHowSpecified() == OptionalAmount::Constant) {
if (Amt.getConstantAmount() == 0) {
- const CharSourceRange &R = getSpecifierRange(Amt.getStart(),
- Amt.getConstantLength());
+ const CharSourceRange &R =
+ getSpecifierRange(Amt.getStart(), Amt.getConstantLength());
EmitFormatDiagnostic(S.PDiag(diag::warn_scanf_nonzero_width),
getLocationOfByte(Amt.getStart()),
- /*IsStringLocation*/true, R,
+ /*IsStringLocation*/ true, R,
FixItHint::CreateRemoval(R));
}
}
@@ -12651,9 +12898,9 @@ bool CheckScanfHandler::HandleScanfSpecifier(
// Consume the argument.
unsigned argIndex = FS.getArgIndex();
if (argIndex < NumDataArgs) {
- // The check to see if the argIndex is valid will come later.
- // We set the bit here because we may exit early from this
- // function if we encounter some other error.
+ // The check to see if the argIndex is valid will come later.
+ // We set the bit here because we may exit early from this
+ // function if we encounter some other error.
CoveredArgs.set(argIndex);
}
@@ -12750,7 +12997,7 @@ static void CheckFormatString(
const char *Str = StrRef.data();
// Account for cases where the string literal is truncated in a declaration.
const ConstantArrayType *T =
- S.Context.getAsConstantArrayType(FExpr->getType());
+ S.Context.getAsConstantArrayType(FExpr->getType());
assert(T && "String literal not of constant array type!");
size_t TypeSize = T->getSize().getZExtValue();
size_t StrLen = std::min(std::max(TypeSize, size_t(1)) - 1, StrRef.size());
@@ -12814,9 +13061,8 @@ bool Sema::FormatStringHasSArg(const StringLiteral *FExpr) {
assert(T && "String literal not of constant array type!");
size_t TypeSize = T->getSize().getZExtValue();
size_t StrLen = std::min(std::max(TypeSize, size_t(1)) - 1, StrRef.size());
- return analyze_format_string::ParseFormatStringHasSArg(Str, Str + StrLen,
- getLangOpts(),
- Context.getTargetInfo());
+ return analyze_format_string::ParseFormatStringHasSArg(
+ Str, Str + StrLen, getLangOpts(), Context.getTargetInfo());
}
//===--- CHECK: Warn on use of wrong absolute value function. -------------===//
@@ -12864,7 +13110,7 @@ static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction) {
return 0;
case Builtin::BIcabsf:
- return Builtin::BIcabs;
+ return Builtin::BIcabs;
case Builtin::BIcabs:
return Builtin::BIcabsl;
case Builtin::BIcabsl:
@@ -12914,11 +13160,7 @@ static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType,
return BestKind;
}
-enum AbsoluteValueKind {
- AVK_Integer,
- AVK_Floating,
- AVK_Complex
-};
+enum AbsoluteValueKind { AVK_Integer, AVK_Floating, AVK_Complex };
static AbsoluteValueKind getAbsoluteValueKind(QualType T) {
if (T->isIntegralOrEnumerationType())
@@ -13108,8 +13350,8 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range,
if (!EmitHeaderHint)
return;
- S.Diag(Loc, diag::note_include_header_or_declare) << HeaderName
- << FunctionName;
+ S.Diag(Loc, diag::note_include_header_or_declare)
+ << HeaderName << FunctionName;
}
template <std::size_t StrLen>
@@ -13224,32 +13466,44 @@ void Sema::CheckAbsoluteValueFunction(const CallExpr *Call,
//===--- CHECK: Warn on use of std::max and unsigned zero. r---------------===//
void Sema::CheckMaxUnsignedZero(const CallExpr *Call,
const FunctionDecl *FDecl) {
- if (!Call || !FDecl) return;
+ if (!Call || !FDecl)
+ return;
// Ignore template specializations and macros.
- if (inTemplateInstantiation()) return;
- if (Call->getExprLoc().isMacroID()) return;
+ if (inTemplateInstantiation())
+ return;
+ if (Call->getExprLoc().isMacroID())
+ return;
// Only care about the one template argument, two function parameter std::max
- if (Call->getNumArgs() != 2) return;
- if (!IsStdFunction(FDecl, "max")) return;
- const auto * ArgList = FDecl->getTemplateSpecializationArgs();
- if (!ArgList) return;
- if (ArgList->size() != 1) return;
+ if (Call->getNumArgs() != 2)
+ return;
+ if (!IsStdFunction(FDecl, "max"))
+ return;
+ const auto *ArgList = FDecl->getTemplateSpecializationArgs();
+ if (!ArgList)
+ return;
+ if (ArgList->size() != 1)
+ return;
// Check that template type argument is unsigned integer.
- const auto& TA = ArgList->get(0);
- if (TA.getKind() != TemplateArgument::Type) return;
+ const auto &TA = ArgList->get(0);
+ if (TA.getKind() != TemplateArgument::Type)
+ return;
QualType ArgType = TA.getAsType();
- if (!ArgType->isUnsignedIntegerType()) return;
+ if (!ArgType->isUnsignedIntegerType())
+ return;
// See if either argument is a literal zero.
- auto IsLiteralZeroArg = [](const Expr* E) -> bool {
+ auto IsLiteralZeroArg = [](const Expr *E) -> bool {
const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E);
- if (!MTE) return false;
+ if (!MTE)
+ return false;
const auto *Num = dyn_cast<IntegerLiteral>(MTE->getSubExpr());
- if (!Num) return false;
- if (Num->getValue() != 0) return false;
+ if (!Num)
+ return false;
+ if (Num->getValue() != 0)
+ return false;
return true;
};
@@ -13259,7 +13513,8 @@ void Sema::CheckMaxUnsignedZero(const CallExpr *Call,
const bool IsSecondArgZero = IsLiteralZeroArg(SecondArg);
// Only warn when exactly one argument is zero.
- if (IsFirstArgZero == IsSecondArgZero) return;
+ if (IsFirstArgZero == IsSecondArgZero)
+ return;
SourceRange FirstRange = FirstArg->getSourceRange();
SourceRange SecondRange = SecondArg->getSourceRange();
@@ -13280,8 +13535,8 @@ void Sema::CheckMaxUnsignedZero(const CallExpr *Call,
}
Diag(Call->getExprLoc(), diag::note_remove_max_call)
- << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange())
- << FixItHint::CreateRemoval(RemovalRange);
+ << FixItHint::CreateRemoval(Call->getCallee()->getSourceRange())
+ << FixItHint::CreateRemoval(RemovalRange);
}
//===--- CHECK: Standard memory functions ---------------------------------===//
@@ -13462,7 +13717,7 @@ struct SearchNonTrivialToCopyField
Sema &S;
};
-}
+} // namespace
/// Detect if \c SizeofExpr is likely to calculate the sizeof an object.
static bool doesExprLikelyComputeSize(const Expr *SizeofExpr) {
@@ -13506,7 +13761,7 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) {
return;
const Expr *SizeArg =
- Call->getArg(BId == Builtin::BImemset ? 2 : 1)->IgnoreImpCasts();
+ Call->getArg(BId == Builtin::BImemset ? 2 : 1)->IgnoreImpCasts();
auto isLiteralZero = [](const Expr *E) {
return (isa<IntegerLiteral>(E) &&
@@ -13540,8 +13795,7 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) {
// If the second argument to a memset is a sizeof expression and the third
// isn't, this is also likely an error. This should catch
// 'memset(buf, sizeof(buf), 0xff)'.
- if (BId == Builtin::BImemset &&
- doesExprLikelyComputeSize(Call->getArg(1)) &&
+ if (BId == Builtin::BImemset && doesExprLikelyComputeSize(Call->getArg(1)) &&
!doesExprLikelyComputeSize(Call->getArg(2))) {
SourceLocation DiagLoc = Call->getArg(1)->getExprLoc();
S.Diag(DiagLoc, diag::warn_suspicious_sizeof_memset) << 1;
@@ -13557,8 +13811,7 @@ static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) {
/// function calls.
///
/// \param Call The call expression to diagnose.
-void Sema::CheckMemaccessArguments(const CallExpr *Call,
- unsigned BId,
+void Sema::CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
IdentifierInfo *FnName) {
assert(BId != 0);
@@ -13570,7 +13823,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
return;
unsigned LastArg = (BId == Builtin::BImemset || BId == Builtin::BIbzero ||
- BId == Builtin::BIstrndup ? 1 : 2);
+ BId == Builtin::BIstrndup
+ ? 1
+ : 2);
unsigned LenArg =
(BId == Builtin::BIbzero || BId == Builtin::BIstrndup ? 1 : 2);
const Expr *LenExpr = Call->getArg(LenArg)->IgnoreParenImpCasts();
@@ -13646,22 +13901,19 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
ReadableName = Lexer::getImmediateMacroName(SL, SM, LangOpts);
SL = SM.getSpellingLoc(SL);
DSR = SourceRange(SM.getSpellingLoc(DSR.getBegin()),
- SM.getSpellingLoc(DSR.getEnd()));
+ SM.getSpellingLoc(DSR.getEnd()));
SSR = SourceRange(SM.getSpellingLoc(SSR.getBegin()),
- SM.getSpellingLoc(SSR.getEnd()));
+ SM.getSpellingLoc(SSR.getEnd()));
}
DiagRuntimeBehavior(SL, SizeOfArg,
PDiag(diag::warn_sizeof_pointer_expr_memaccess)
- << ReadableName
- << PointeeTy
- << DestTy
- << DSR
- << SSR);
- DiagRuntimeBehavior(SL, SizeOfArg,
- PDiag(diag::warn_sizeof_pointer_expr_memaccess_note)
- << ActionIdx
- << SSR);
+ << ReadableName << PointeeTy << DestTy << DSR
+ << SSR);
+ DiagRuntimeBehavior(
+ SL, SizeOfArg,
+ PDiag(diag::warn_sizeof_pointer_expr_memaccess_note)
+ << ActionIdx << SSR);
break;
}
@@ -13675,9 +13927,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
Context.typesAreCompatible(SizeOfArgTy, DestTy)) {
DiagRuntimeBehavior(LenExpr->getExprLoc(), Dest,
PDiag(diag::warn_sizeof_pointer_type_memaccess)
- << FnName << SizeOfArgTy << ArgIdx
- << PointeeTy << Dest->getSourceRange()
- << LenExpr->getSourceRange());
+ << FnName << SizeOfArgTy << ArgIdx
+ << PointeeTy << Dest->getSourceRange()
+ << LenExpr->getSourceRange());
break;
}
}
@@ -13700,7 +13952,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
if (ArgIdx != 0 || IsCmp) {
if (BId == Builtin::BImemcpy)
OperationType = 1;
- else if(BId == Builtin::BImemmove)
+ else if (BId == Builtin::BImemmove)
OperationType = 2;
else if (IsCmp)
OperationType = 3;
@@ -13712,12 +13964,11 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
<< IsContained << ContainedRD << OperationType
<< Call->getCallee()->getSourceRange());
} else if (PointeeTy.hasNonTrivialObjCLifetime() &&
- BId != Builtin::BImemset)
- DiagRuntimeBehavior(
- Dest->getExprLoc(), Dest,
- PDiag(diag::warn_arc_object_memaccess)
- << ArgIdx << FnName << PointeeTy
- << Call->getCallee()->getSourceRange());
+ BId != Builtin::BImemset)
+ DiagRuntimeBehavior(Dest->getExprLoc(), Dest,
+ PDiag(diag::warn_arc_object_memaccess)
+ << ArgIdx << FnName << PointeeTy
+ << Call->getCallee()->getSourceRange());
else if (const auto *RT = PointeeTy->getAs<RecordType>()) {
if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) {
@@ -13738,9 +13989,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
continue;
DiagRuntimeBehavior(
- Dest->getExprLoc(), Dest,
- PDiag(diag::note_bad_memaccess_silence)
- << FixItHint::CreateInsertion(ArgRange.getBegin(), "(void*)"));
+ Dest->getExprLoc(), Dest,
+ PDiag(diag::note_bad_memaccess_silence)
+ << FixItHint::CreateInsertion(ArgRange.getBegin(), "(void*)"));
break;
}
}
@@ -13752,7 +14003,7 @@ static const Expr *ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx) {
Ex = Ex->IgnoreParenCasts();
while (true) {
- const BinaryOperator * BO = dyn_cast<BinaryOperator>(Ex);
+ const BinaryOperator *BO = dyn_cast<BinaryOperator>(Ex);
if (!BO || !BO->isAdditiveOp())
break;
@@ -13873,8 +14124,7 @@ static const Expr *getStrlenExprArg(const Expr *E) {
// Warn on anti-patterns as the 'size' argument to strncat.
// The correct size argument should look like following:
// strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
-void Sema::CheckStrncatArguments(const CallExpr *CE,
- IdentifierInfo *FnName) {
+void Sema::CheckStrncatArguments(const CallExpr *CE, IdentifierInfo *FnName) {
// Don't crash if the user has the wrong number of arguments.
if (CE->getNumArgs() < 3)
return;
@@ -13927,8 +14177,8 @@ void Sema::CheckStrncatArguments(const CallExpr *CE,
// Check if the destination is an array (rather than a pointer to an array).
QualType DstTy = DstArg->getType();
- bool isKnownSizeArray = isConstantSizeArrayWithMoreThanOneElement(DstTy,
- Context);
+ bool isKnownSizeArray =
+ isConstantSizeArrayWithMoreThanOneElement(DstTy, Context);
if (!isKnownSizeArray) {
if (PatternType == 1)
Diag(SL, diag::warn_strncat_wrong_size) << SR;
@@ -13952,7 +14202,7 @@ void Sema::CheckStrncatArguments(const CallExpr *CE,
OS << ") - 1";
Diag(SL, diag::note_strncat_wrong_size)
- << FixItHint::CreateReplacement(SR, OS.str());
+ << FixItHint::CreateReplacement(SR, OS.str());
}
namespace {
@@ -14069,18 +14319,15 @@ void Sema::CheckFreeArguments(const CallExpr *E) {
return CheckFreeArgumentsCast(*this, CalleeName, Cast);
}
-void
-Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
- SourceLocation ReturnLoc,
- bool isObjCMethod,
- const AttrVec *Attrs,
- const FunctionDecl *FD) {
+void Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
+ SourceLocation ReturnLoc, bool isObjCMethod,
+ const AttrVec *Attrs, const FunctionDecl *FD) {
// Check if the return value is null but should not be.
if (((Attrs && hasSpecificAttr<ReturnsNonNullAttr>(*Attrs)) ||
(!isObjCMethod && isNonNullType(lhsType))) &&
CheckNonNullExpr(*this, RetValExp))
Diag(ReturnLoc, diag::warn_null_ret)
- << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange();
+ << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange();
// C++11 [basic.stc.dynamic.allocation]p4:
// If an allocation function declared with a non-throwing
@@ -14090,12 +14337,12 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
if (FD) {
OverloadedOperatorKind Op = FD->getOverloadedOperator();
if (Op == OO_New || Op == OO_Array_New) {
- const FunctionProtoType *Proto
- = FD->getType()->castAs<FunctionProtoType>();
- if (!Proto->isNothrow(/*ResultIfDependent*/true) &&
+ const FunctionProtoType *Proto =
+ FD->getType()->castAs<FunctionProtoType>();
+ if (!Proto->isNothrow(/*ResultIfDependent*/ true) &&
CheckNonNullExpr(*this, RetValExp))
Diag(ReturnLoc, diag::warn_operator_new_returns_null)
- << FD << getLangOpts().CPlusPlus11;
+ << FD << getLangOpts().CPlusPlus11;
}
}
@@ -14146,8 +14393,8 @@ void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
}
// Match a more general floating-point equality comparison (-Wfloat-equal).
- Expr* LeftExprSansParen = LHS->IgnoreParenImpCasts();
- Expr* RightExprSansParen = RHS->IgnoreParenImpCasts();
+ Expr *LeftExprSansParen = LHS->IgnoreParenImpCasts();
+ Expr *RightExprSansParen = RHS->IgnoreParenImpCasts();
// Special case: check for x == x (which is OK).
// Do not emit warnings for such cases.
@@ -14161,26 +14408,26 @@ void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
// is a heuristic: often comparison against such literals are used to
// detect if a value in a variable has not changed. This clearly can
// lead to false negatives.
- if (FloatingLiteral* FLL = dyn_cast<FloatingLiteral>(LeftExprSansParen)) {
+ if (FloatingLiteral *FLL = dyn_cast<FloatingLiteral>(LeftExprSansParen)) {
if (FLL->isExact())
return;
- } else
- if (FloatingLiteral* FLR = dyn_cast<FloatingLiteral>(RightExprSansParen))
- if (FLR->isExact())
- return;
+ } else if (FloatingLiteral *FLR =
+ dyn_cast<FloatingLiteral>(RightExprSansParen))
+ if (FLR->isExact())
+ return;
// Check for comparisons with builtin types.
- if (CallExpr* CL = dyn_cast<CallExpr>(LeftExprSansParen))
+ if (CallExpr *CL = dyn_cast<CallExpr>(LeftExprSansParen))
if (CL->getBuiltinCallee())
return;
- if (CallExpr* CR = dyn_cast<CallExpr>(RightExprSansParen))
+ if (CallExpr *CR = dyn_cast<CallExpr>(RightExprSansParen))
if (CR->getBuiltinCallee())
return;
// Emit the diagnostic.
Diag(Loc, diag::warn_floatingpoint_eq)
- << LHS->getSourceRange() << RHS->getSourceRange();
+ << LHS->getSourceRange() << RHS->getSourceRange();
}
//===--- CHECK: Integer mixed-sign comparisons (-Wsign-compare) --------===//
@@ -14204,19 +14451,15 @@ struct IntRange {
: Width(Width), NonNegative(NonNegative) {}
/// Number of bits excluding the sign bit.
- unsigned valueBits() const {
- return NonNegative ? Width : Width - 1;
- }
+ unsigned valueBits() const { return NonNegative ? Width : Width - 1; }
/// Returns the range of the bool type.
- static IntRange forBoolType() {
- return IntRange(1, true);
- }
+ static IntRange forBoolType() { return IntRange(1, true); }
/// Returns the range of an opaque value of the given integral type.
static IntRange forValueOfType(ASTContext &C, QualType T) {
return forValueOfCanonicalType(C,
- T->getCanonicalTypeInternal().getTypePtr());
+ T->getCanonicalTypeInternal().getTypePtr());
}
/// Returns the range of an opaque value of a canonical integral type.
@@ -14248,10 +14491,10 @@ struct IntRange {
unsigned NumNegative = Enum->getNumNegativeBits();
if (NumNegative == 0)
- return IntRange(NumPositive, true/*NonNegative*/);
+ return IntRange(NumPositive, true /*NonNegative*/);
else
return IntRange(std::max(NumPositive + 1, NumNegative),
- false/*NonNegative*/);
+ false /*NonNegative*/);
}
if (const auto *EIT = dyn_cast<BitIntType>(T))
@@ -14462,13 +14705,15 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth,
// GetExprRange requires an integer expression, but a throw expression
// results in a void type.
Expr *E = CO->getTrueExpr();
- IntRange L = E->getType()->isVoidType()
- ? IntRange{0, true}
- : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate);
+ IntRange L =
+ E->getType()->isVoidType()
+ ? IntRange{0, true}
+ : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate);
E = CO->getFalseExpr();
- IntRange R = E->getType()->isVoidType()
- ? IntRange{0, true}
- : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate);
+ IntRange R =
+ E->getType()->isVoidType()
+ ? IntRange{0, true}
+ : GetExprRange(C, E, MaxWidth, InConstantContext, Approximate);
return IntRange::join(L, R);
}
@@ -14524,8 +14769,8 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth,
case BO_Shl:
// ...except that we want to treat '1 << (blah)' as logically
// positive. It's an important idiom.
- if (IntegerLiteral *I
- = dyn_cast<IntegerLiteral>(BO->getLHS()->IgnoreParenCasts())) {
+ if (IntegerLiteral *I =
+ dyn_cast<IntegerLiteral>(BO->getLHS()->IgnoreParenCasts())) {
if (I->getValue() == 1) {
IntRange R = IntRange::forValueOfType(C, GetExprType(E));
return IntRange(R.Width, /*NonNegative*/ true);
@@ -14707,8 +14952,7 @@ static void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC,
static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) {
// Suppress cases where we are comparing against an enum constant.
- if (const DeclRefExpr *DR =
- dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
+ if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
if (isa<EnumConstantDecl>(DR->getDecl()))
return true;
@@ -14719,8 +14963,8 @@ static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) {
if (BeginLoc.isMacroID()) {
StringRef MacroName = Lexer::getImmediateMacroName(
BeginLoc, S.getSourceManager(), S.getLangOpts());
- return MacroName != "YES" && MacroName != "NO" &&
- MacroName != "true" && MacroName != "false";
+ return MacroName != "YES" && MacroName != "NO" && MacroName != "true" &&
+ MacroName != "false";
}
return false;
@@ -14797,21 +15041,30 @@ struct PromotedRange {
Value.isUnsigned() == PromotedMin.isUnsigned());
if (!isContiguous()) {
assert(Value.isUnsigned() && "discontiguous range for signed compare");
- if (Value.isMinValue()) return Min;
- if (Value.isMaxValue()) return Max;
- if (Value >= PromotedMin) return InRange;
- if (Value <= PromotedMax) return InRange;
+ if (Value.isMinValue())
+ return Min;
+ if (Value.isMaxValue())
+ return Max;
+ if (Value >= PromotedMin)
+ return InRange;
+ if (Value <= PromotedMax)
+ return InRange;
return InHole;
}
switch (llvm::APSInt::compareValues(Value, PromotedMin)) {
- case -1: return Less;
- case 0: return PromotedMin == PromotedMax ? OnlyValue : Min;
+ case -1:
+ return Less;
+ case 0:
+ return PromotedMin == PromotedMax ? OnlyValue : Min;
case 1:
switch (llvm::APSInt::compareValues(Value, PromotedMax)) {
- case -1: return InRange;
- case 0: return Max;
- case 1: return Greater;
+ case -1:
+ return InRange;
+ case 0:
+ return Max;
+ case 1:
+ return Greater;
}
}
@@ -14822,11 +15075,15 @@ struct PromotedRange {
constantValue(BinaryOperatorKind Op, ComparisonResult R, bool ConstantOnRHS) {
if (Op == BO_Cmp) {
ComparisonResult LTFlag = LT, GTFlag = GT;
- if (ConstantOnRHS) std::swap(LTFlag, GTFlag);
-
- if (R & EQ) return StringRef("'std::strong_ordering::equal'");
- if (R & LTFlag) return StringRef("'std::strong_ordering::less'");
- if (R & GTFlag) return StringRef("'std::strong_ordering::greater'");
+ if (ConstantOnRHS)
+ std::swap(LTFlag, GTFlag);
+
+ if (R & EQ)
+ return StringRef("'std::strong_ordering::equal'");
+ if (R & LTFlag)
+ return StringRef("'std::strong_ordering::less'");
+ if (R & GTFlag)
+ return StringRef("'std::strong_ordering::greater'");
return std::nullopt;
}
@@ -14855,13 +15112,12 @@ struct PromotedRange {
return std::nullopt;
}
};
-}
+} // namespace
static bool HasEnumType(Expr *E) {
// Strip off implicit integral promotions.
while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
- if (ICE->getCastKind() != CK_IntegralCast &&
- ICE->getCastKind() != CK_NoOp)
+ if (ICE->getCastKind() != CK_IntegralCast && ICE->getCastKind() != CK_NoOp)
break;
E = ICE->getSubExpr();
}
@@ -14872,11 +15128,7 @@ static bool HasEnumType(Expr *E) {
static int classifyConstantValue(Expr *Constant) {
// The values of this enumeration are used in the diagnostics
// diag::warn_out_of_range_compare and diag::warn_tautological_bool_compare.
- enum ConstantValueKind {
- Miscellaneous = 0,
- LiteralTrue,
- LiteralFalse
- };
+ enum ConstantValueKind { Miscellaneous = 0, LiteralTrue, LiteralFalse };
if (auto *BL = dyn_cast<CXXBoolLiteralExpr>(Constant))
return BL->getValue() ? ConstantValueKind::LiteralTrue
: ConstantValueKind::LiteralFalse;
@@ -14984,7 +15236,7 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E,
if (ED) {
OS << '\'' << *ED << "' (" << Value << ")";
} else if (auto *BL = dyn_cast<ObjCBoolLiteralExpr>(
- Constant->IgnoreParenImpCasts())) {
+ Constant->IgnoreParenImpCasts())) {
OS << (BL->getValue() ? "YES" : "NO");
} else {
OS << Value;
@@ -15023,8 +15275,8 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E,
(isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
? (HasEnumType(OriginalOther)
? diag::warn_unsigned_enum_always_true_comparison
- : IsCharTy ? diag::warn_unsigned_char_always_true_comparison
- : diag::warn_unsigned_always_true_comparison)
+ : IsCharTy ? diag::warn_unsigned_char_always_true_comparison
+ : diag::warn_unsigned_always_true_comparison)
: diag::warn_tautological_constant_compare;
S.Diag(E->getOperatorLoc(), Diag)
@@ -15171,7 +15423,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
// White-list bool bitfields.
QualType BitfieldType = Bitfield->getType();
if (BitfieldType->isBooleanType())
- return false;
+ return false;
if (BitfieldType->isEnumeralType()) {
EnumDecl *BitfieldEnumDecl = BitfieldType->castAs<EnumType>()->getDecl();
@@ -15189,8 +15441,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
// Ignore value- or type-dependent expressions.
if (Bitfield->getBitWidth()->isValueDependent() ||
- Bitfield->getBitWidth()->isTypeDependent() ||
- Init->isValueDependent() ||
+ Bitfield->getBitWidth()->isTypeDependent() || Init->isValueDependent() ||
Init->isTypeDependent())
return false;
@@ -15335,19 +15586,19 @@ static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,
return;
}
S.Diag(E->getExprLoc(), diag)
- << SourceType << T << E->getSourceRange() << SourceRange(CContext);
+ << SourceType << T << E->getSourceRange() << SourceRange(CContext);
}
/// Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
static void DiagnoseImpCast(Sema &S, Expr *E, QualType T,
- SourceLocation CContext,
- unsigned diag, bool pruneControlFlow = false) {
+ SourceLocation CContext, unsigned diag,
+ bool pruneControlFlow = false) {
DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
}
static bool isObjCSignedCharBool(Sema &S, QualType Ty) {
return Ty->isSpecificBuiltinType(BuiltinType::SChar) &&
- S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty);
+ S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty);
}
static void adornObjCBoolConversionDiagWithTernaryFixit(
@@ -15382,7 +15633,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,
llvm::APFloat Value(0.0);
bool IsConstant =
- E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects);
+ E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects);
if (!IsConstant) {
if (isObjCSignedCharBool(S, T)) {
return adornObjCBoolConversionDiagWithTernaryFixit(
@@ -15391,8 +15642,8 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,
<< E->getType());
}
- return DiagnoseImpCast(S, E, T, CContext,
- diag::warn_impcast_float_integer, PruneWarnings);
+ return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
+ PruneWarnings);
}
bool isExact = false;
@@ -15420,7 +15671,8 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,
}
if (Result == llvm::APFloat::opOK && isExact) {
- if (IsLiteral) return;
+ if (IsLiteral)
+ return;
return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
PruneWarnings);
}
@@ -15439,7 +15691,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,
// Warn on floating point literal to integer.
DiagID = diag::warn_impcast_literal_float_to_integer;
} else if (IntegerValue == 0) {
- if (Value.isZero()) { // Skip -0.0 to 0 conversion.
+ if (Value.isZero()) { // Skip -0.0 to 0 conversion.
return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
}
@@ -15451,7 +15703,7 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,
return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
}
- } else { // IntegerValue.isSigned()
+ } else { // IntegerValue.isSigned()
if (!IntegerValue.isMaxSignedValue() &&
!IntegerValue.isMinSignedValue()) {
return DiagnoseImpCast(S, E, T, CContext,
@@ -15500,7 +15752,8 @@ static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
->getAs<BuiltinType>();
// The below checks assume source is floating point.
- if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
+ if (!ResultBT || !RBT || !RBT->isFloatingPoint())
+ return;
// If source is floating point but target is an integer.
if (ResultBT->isInteger())
@@ -15521,7 +15774,8 @@ static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
static std::string PrettyPrintInRange(const llvm::APSInt &Value,
IntRange Range) {
- if (!Range.Width) return "0";
+ if (!Range.Width)
+ return "0";
llvm::APSInt ValueInRange = Value;
ValueInRange.setIsSigned(!Range.NonNegative);
@@ -15536,12 +15790,12 @@ static bool IsImplicitBoolFloatConversion(Sema &S, Expr *Ex, bool ToBool) {
Expr *InnerE = Ex->IgnoreParenImpCasts();
const Type *Target = S.Context.getCanonicalType(Ex->getType()).getTypePtr();
const Type *Source =
- S.Context.getCanonicalType(InnerE->getType()).getTypePtr();
+ S.Context.getCanonicalType(InnerE->getType()).getTypePtr();
if (Target->isDependentType())
return false;
const BuiltinType *FloatCandidateBT =
- dyn_cast<BuiltinType>(ToBool ? Source : Target);
+ dyn_cast<BuiltinType>(ToBool ? Source : Target);
const Type *BoolCandidateType = ToBool ? Target : Source;
return (BoolCandidateType->isSpecificBuiltinType(BuiltinType::Bool) &&
@@ -15556,14 +15810,13 @@ static void CheckImplicitArgumentConversions(Sema &S, CallExpr *TheCall,
if (!IsImplicitBoolFloatConversion(S, CurrA, true))
continue;
- bool IsSwapped = ((i > 0) &&
- IsImplicitBoolFloatConversion(S, TheCall->getArg(i - 1), false));
- IsSwapped |= ((i < (NumArgs - 1)) &&
- IsImplicitBoolFloatConversion(S, TheCall->getArg(i + 1), false));
+ bool IsSwapped = ((i > 0) && IsImplicitBoolFloatConversion(
+ S, TheCall->getArg(i - 1), false));
+ IsSwapped |= ((i < (NumArgs - 1)) && IsImplicitBoolFloatConversion(
+ S, TheCall->getArg(i + 1), false));
if (IsSwapped) {
// Warn on this floating-point to bool conversion.
- DiagnoseImpCast(S, CurrA->IgnoreParenImpCasts(),
- CurrA->getType(), CC,
+ DiagnoseImpCast(S, CurrA->IgnoreParenImpCasts(), CurrA->getType(), CC,
diag::warn_impcast_floating_point_to_bool);
}
}
@@ -15640,10 +15893,8 @@ static void checkObjCCollectionLiteralElement(Sema &S,
QualType ElementType = Element->getType();
ExprResult ElementResult(Element);
if (ElementType->getAs<ObjCObjectPointerType>() &&
- S.CheckSingleAssignmentConstraints(TargetElementType,
- ElementResult,
- false, false)
- != Sema::Compatible) {
+ S.CheckSingleAssignmentConstraints(TargetElementType, ElementResult,
+ false, false) != Sema::Compatible) {
S.Diag(Element->getBeginLoc(), diag::warn_objc_collection_literal_element)
<< ElementType << ElementKind << TargetElementType
<< Element->getSourceRange();
@@ -15667,8 +15918,8 @@ static void checkObjCArrayLiteral(Sema &S, QualType TargetType,
return;
if (TargetObjCPtr->isUnspecialized() ||
- TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
- != S.NSArrayDecl->getCanonicalDecl())
+ TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=
+ S.NSArrayDecl->getCanonicalDecl())
return;
auto TypeArgs = TargetObjCPtr->getTypeArgs();
@@ -15678,8 +15929,7 @@ static void checkObjCArrayLiteral(Sema &S, QualType TargetType,
QualType TargetElementType = TypeArgs[0];
for (unsigned I = 0, N = ArrayLiteral->getNumElements(); I != N; ++I) {
checkObjCCollectionLiteralElement(S, TargetElementType,
- ArrayLiteral->getElement(I),
- 0);
+ ArrayLiteral->getElement(I), 0);
}
}
@@ -15696,8 +15946,8 @@ checkObjCDictionaryLiteral(Sema &S, QualType TargetType,
return;
if (TargetObjCPtr->isUnspecialized() ||
- TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl()
- != S.NSDictionaryDecl->getCanonicalDecl())
+ TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=
+ S.NSDictionaryDecl->getCanonicalDecl())
return;
auto TypeArgs = TargetObjCPtr->getTypeArgs();
@@ -15792,12 +16042,15 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
SourceLocation CC,
bool *ICContext = nullptr,
bool IsListInit = false) {
- if (E->isTypeDependent() || E->isValueDependent()) return;
+ if (E->isTypeDependent() || E->isValueDependent())
+ return;
const Type *Source = S.Context.getCanonicalType(E->getType()).getTypePtr();
const Type *Target = S.Context.getCanonicalType(T).getTypePtr();
- if (Source == Target) return;
- if (Target->isDependentType()) return;
+ if (Source == Target)
+ return;
+ if (Target->isDependentType())
+ return;
// If the conversion context location is invalid don't complain. We also
// don't want to emit a warning if the issue occurs from the expansion of
@@ -15952,9 +16205,10 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
Expr::EvalResult result;
if (E->EvaluateAsRValue(result, S.Context)) {
// Value might be a float, a float vector, or a float complex.
- if (IsSameFloatAfterCast(result.Val,
- S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)),
- S.Context.getFloatTypeSemantics(QualType(SourceBT, 0))))
+ if (IsSameFloatAfterCast(
+ result.Val,
+ S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)),
+ S.Context.getFloatTypeSemantics(QualType(SourceBT, 0))))
return;
}
@@ -16306,7 +16560,8 @@ static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
// If -Wconversion would have warned about either of the candidates
// for a signedness conversion to the context type...
- if (!Suspicious) return;
+ if (!Suspicious)
+ return;
// ...but it's currently ignored...
if (!S.Diags.isIgnored(diag::warn_impcast_integer_sign_conditional, CC))
@@ -16314,11 +16569,12 @@ static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
// ...then check whether it would have warned about either of the
// candidates for a signedness conversion to the condition type.
- if (E->getType() == T) return;
+ if (E->getType() == T)
+ return;
Suspicious = false;
- CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(),
- E->getType(), CC, &Suspicious);
+ CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(), E->getType(), CC,
+ &Suspicious);
if (!Suspicious)
CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(),
E->getType(), CC, &Suspicious);
@@ -16343,7 +16599,7 @@ struct AnalyzeImplicitConversionsWorkItem {
SourceLocation CC;
bool IsListInit;
};
-}
+} // namespace
/// Data recursive variant of AnalyzeImplicitConversions. Subexpressions
/// that should be visited are added to WorkList.
@@ -16449,10 +16705,12 @@ static void AnalyzeImplicitConversions(
// we don't really need to recurse into them, because any internal
// expressions should have been analyzed already when they were
// built into statements.
- if (isa<StmtExpr>(E)) return;
+ if (isa<StmtExpr>(E))
+ return;
// Don't descend into unevaluated contexts.
- if (isa<UnaryExprOrTypeTraitExpr>(E)) return;
+ if (isa<UnaryExprOrTypeTraitExpr>(E))
+ return;
// Now just recurse over the expression's children.
CC = E->getExprLoc();
@@ -16503,7 +16761,7 @@ static void AnalyzeImplicitConversions(
/// implicit conversions in the given expression. There are a couple
/// of competing diagnostics here, -Wconversion and -Wsign-compare.
static void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC,
- bool IsListInit/*= false*/) {
+ bool IsListInit /*= false*/) {
llvm::SmallVector<AnalyzeImplicitConversionsWorkItem, 16> WorkList;
WorkList.push_back({OrigE, CC, IsListInit});
while (!WorkList.empty())
@@ -16616,8 +16874,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
unsigned DiagID = IsCompare
? diag::warn_address_of_reference_null_compare
: diag::warn_address_of_reference_bool_conversion;
- PartialDiagnostic PD = PDiag(DiagID) << E->getSourceRange() << Range
- << IsEqual;
+ PartialDiagnostic PD = PDiag(DiagID)
+ << E->getSourceRange() << Range << IsEqual;
if (CheckForReference(*this, E, PD)) {
return;
}
@@ -16630,8 +16888,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
E->printPretty(S, nullptr, getPrintingPolicy());
unsigned DiagID = IsCompare ? diag::warn_nonnull_expr_compare
: diag::warn_cast_nonnull_to_bool;
- Diag(E->getExprLoc(), DiagID) << IsParam << S.str()
- << E->getSourceRange() << Range << IsEqual;
+ Diag(E->getExprLoc(), DiagID)
+ << IsParam << S.str() << E->getSourceRange() << Range << IsEqual;
Diag(NonnullAttr->getLocation(), diag::note_declared_nonnull) << IsParam;
};
@@ -16672,7 +16930,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
return;
// Check for parameter decl with nonnull attribute
- if (const auto* PV = dyn_cast<ParmVarDecl>(D)) {
+ if (const auto *PV = dyn_cast<ParmVarDecl>(D)) {
if (getCurFunction() &&
!getCurFunction()->ModifiedNonNullParams.count(PV)) {
if (const Attr *A = PV->getAttr<NonNullAttr>()) {
@@ -16690,8 +16948,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
for (const auto *NonNull : FD->specific_attrs<NonNullAttr>()) {
if (!NonNull->args_size()) {
- ComplainAboutNonnullParamOrCall(NonNull);
- return;
+ ComplainAboutNonnullParamOrCall(NonNull);
+ return;
}
for (const ParamIdx &ArgNo : NonNull->args()) {
@@ -16725,11 +16983,7 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
unsigned DiagID = IsCompare ? diag::warn_null_pointer_compare
: diag::warn_impcast_pointer_to_bool;
- enum {
- AddressOf,
- FunctionPointer,
- ArrayPointer
- } DiagType;
+ enum { AddressOf, FunctionPointer, ArrayPointer } DiagType;
if (IsAddressOf)
DiagType = AddressOf;
else if (IsFunction)
@@ -16738,8 +16992,8 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
DiagType = ArrayPointer;
else
llvm_unreachable("Could not determine diagnostic.");
- Diag(E->getExprLoc(), DiagID) << DiagType << S.str() << E->getSourceRange()
- << Range << IsEqual;
+ Diag(E->getExprLoc(), DiagID)
+ << DiagType << S.str() << E->getSourceRange() << Range << IsEqual;
if (!IsFunction)
return;
@@ -16809,9 +17063,9 @@ void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) {
::CheckBoolLikeConversion(*this, E, CC);
}
-/// Diagnose when expression is an integer constant expression and its evaluation
-/// results in integer overflow
-void Sema::CheckForIntOverflow (const Expr *E) {
+/// Diagnose when expression is an integer constant expression and its
+/// evaluation results in integer overflow
+void Sema::CheckForIntOverflow(const Expr *E) {
// Use a work list to deal with nested struct initializers.
SmallVector<const Expr *, 2> Exprs(1, E);
@@ -16840,8 +17094,7 @@ void Sema::CheckForIntOverflow (const Expr *E) {
Exprs.push_back(Array->getIdx());
else if (const auto *Compound = dyn_cast<CompoundLiteralExpr>(E))
Exprs.push_back(Compound->getInitializer());
- else if (const auto *New = dyn_cast<CXXNewExpr>(E);
- New && New->isArray()) {
+ else if (const auto *New = dyn_cast<CXXNewExpr>(E); New && New->isArray()) {
if (auto ArraySize = New->getArraySize())
Exprs.push_back(*ArraySize);
}
@@ -16895,9 +17148,7 @@ class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> {
}
/// Merge a sequence of operations into its parent.
- void merge(Seq S) {
- Values[S.Index].Merged = true;
- }
+ void merge(Seq S) { Values[S.Index].Merged = true; }
/// Determine whether two operations are unsequenced. This operation
/// is asymmetric: \p Cur should be the more recent sequence, and \p Old
@@ -16988,7 +17239,7 @@ class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> {
/// UK_ModAsValue.
struct SequencedSubexpression {
SequencedSubexpression(SequenceChecker &Self)
- : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) {
+ : Self(Self), OldModAsSideEffect(Self.ModAsSideEffect) {
Self.ModAsSideEffect = &ModAsSideEffect;
}
@@ -17741,9 +17992,8 @@ void Sema::CheckCompletedExpr(Expr *E, SourceLocation CheckLoc,
}
void Sema::CheckBitFieldInitialization(SourceLocation InitLoc,
- FieldDecl *BitField,
- Expr *Init) {
- (void) AnalyzeBitFieldAssignment(*this, BitField, Init, InitLoc);
+ FieldDecl *BitField, Expr *Init) {
+ (void)AnalyzeBitFieldAssignment(*this, BitField, Init, InitLoc);
}
static void diagnoseArrayStarInParamType(Sema &S, QualType PType,
@@ -18125,39 +18375,44 @@ void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) {
// Require that the destination be a pointer type.
const PointerType *DestPtr = T->getAs<PointerType>();
- if (!DestPtr) return;
+ if (!DestPtr)
+ return;
// If the destination has alignment 1, we're done.
QualType DestPointee = DestPtr->getPointeeType();
- if (DestPointee->isIncompleteType()) return;
+ if (DestPointee->isIncompleteType())
+ return;
CharUnits DestAlign = Context.getTypeAlignInChars(DestPointee);
- if (DestAlign.isOne()) return;
+ if (DestAlign.isOne())
+ return;
// Require that the source be a pointer type.
const PointerType *SrcPtr = Op->getType()->getAs<PointerType>();
- if (!SrcPtr) return;
+ if (!SrcPtr)
+ return;
QualType SrcPointee = SrcPtr->getPointeeType();
// Explicitly allow casts from cv void*. We already implicitly
// allowed casts to cv void*, since they have alignment 1.
// Also allow casts involving incomplete types, which implicitly
// includes 'void'.
- if (SrcPointee->isIncompleteType()) return;
+ if (SrcPointee->isIncompleteType())
+ return;
CharUnits SrcAlign = getPresumedAlignmentOfPointer(Op, *this);
- if (SrcAlign >= DestAlign) return;
+ if (SrcAlign >= DestAlign)
+ return;
Diag(TRange.getBegin(), diag::warn_cast_align)
- << Op->getType() << T
- << static_cast<unsigned>(SrcAlign.getQuantity())
- << static_cast<unsigned>(DestAlign.getQuantity())
- << TRange << Op->getSourceRange();
+ << Op->getType() << T << static_cast<unsigned>(SrcAlign.getQuantity())
+ << static_cast<unsigned>(DestAlign.getQuantity()) << TRange
+ << Op->getSourceRange();
}
void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
- const ArraySubscriptExpr *ASE,
- bool AllowOnePastEnd, bool IndexNegated) {
+ const ArraySubscriptExpr *ASE, bool AllowOnePastEnd,
+ bool IndexNegated) {
// Already diagnosed by the constant evaluator.
if (isConstantEvaluatedContext())
return;
@@ -18172,8 +18427,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
const ConstantArrayType *ArrayTy =
Context.getAsConstantArrayType(BaseExpr->getType());
- LangOptions::StrictFlexArraysLevelKind
- StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLevel();
+ LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel =
+ getLangOpts().getStrictFlexArraysLevel();
const Type *BaseType =
ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
@@ -18313,8 +18568,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
// ']' location) and the index expression are both from macro expansions
// within a system header.
if (ASE) {
- SourceLocation RBracketLoc = SourceMgr.getSpellingLoc(
- ASE->getRBracketLoc());
+ SourceLocation RBracketLoc =
+ SourceMgr.getSpellingLoc(ASE->getRBracketLoc());
if (SourceMgr.isInSystemHeader(RBracketLoc)) {
SourceLocation IndexLoc =
SourceMgr.getSpellingLoc(IndexExpr->getBeginLoc());
@@ -18336,7 +18591,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
unsigned DiagID = diag::warn_array_index_precedes_bounds;
if (!ASE) {
DiagID = diag::warn_ptr_arith_precedes_bounds;
- if (index.isNegative()) index = -index;
+ if (index.isNegative())
+ index = -index;
}
DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
@@ -18363,56 +18619,55 @@ void Sema::CheckArrayAccess(const Expr *expr) {
while (expr) {
expr = expr->IgnoreParenImpCasts();
switch (expr->getStmtClass()) {
- case Stmt::ArraySubscriptExprClass: {
- const ArraySubscriptExpr *ASE = cast<ArraySubscriptExpr>(expr);
- CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE,
- AllowOnePastEnd > 0);
- expr = ASE->getBase();
- break;
- }
- case Stmt::MemberExprClass: {
- expr = cast<MemberExpr>(expr)->getBase();
+ case Stmt::ArraySubscriptExprClass: {
+ const ArraySubscriptExpr *ASE = cast<ArraySubscriptExpr>(expr);
+ CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, AllowOnePastEnd > 0);
+ expr = ASE->getBase();
+ break;
+ }
+ case Stmt::MemberExprClass: {
+ expr = cast<MemberExpr>(expr)->getBase();
+ break;
+ }
+ case Stmt::OMPArraySectionExprClass: {
+ const OMPArraySectionExpr *ASE = cast<OMPArraySectionExpr>(expr);
+ if (ASE->getLowerBound())
+ CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(),
+ /*ASE=*/nullptr, AllowOnePastEnd > 0);
+ return;
+ }
+ case Stmt::UnaryOperatorClass: {
+ // Only unwrap the * and & unary operators
+ const UnaryOperator *UO = cast<UnaryOperator>(expr);
+ expr = UO->getSubExpr();
+ switch (UO->getOpcode()) {
+ case UO_AddrOf:
+ AllowOnePastEnd++;
break;
- }
- case Stmt::OMPArraySectionExprClass: {
- const OMPArraySectionExpr *ASE = cast<OMPArraySectionExpr>(expr);
- if (ASE->getLowerBound())
- CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(),
- /*ASE=*/nullptr, AllowOnePastEnd > 0);
- return;
- }
- case Stmt::UnaryOperatorClass: {
- // Only unwrap the * and & unary operators
- const UnaryOperator *UO = cast<UnaryOperator>(expr);
- expr = UO->getSubExpr();
- switch (UO->getOpcode()) {
- case UO_AddrOf:
- AllowOnePastEnd++;
- break;
- case UO_Deref:
- AllowOnePastEnd--;
- break;
- default:
- return;
- }
+ case UO_Deref:
+ AllowOnePastEnd--;
break;
- }
- case Stmt::ConditionalOperatorClass: {
- const ConditionalOperator *cond = cast<ConditionalOperator>(expr);
- if (const Expr *lhs = cond->getLHS())
- CheckArrayAccess(lhs);
- if (const Expr *rhs = cond->getRHS())
- CheckArrayAccess(rhs);
- return;
- }
- case Stmt::CXXOperatorCallExprClass: {
- const auto *OCE = cast<CXXOperatorCallExpr>(expr);
- for (const auto *Arg : OCE->arguments())
- CheckArrayAccess(Arg);
- return;
- }
default:
return;
+ }
+ break;
+ }
+ case Stmt::ConditionalOperatorClass: {
+ const ConditionalOperator *cond = cast<ConditionalOperator>(expr);
+ if (const Expr *lhs = cond->getLHS())
+ CheckArrayAccess(lhs);
+ if (const Expr *rhs = cond->getRHS())
+ CheckArrayAccess(rhs);
+ return;
+ }
+ case Stmt::CXXOperatorCallExprClass: {
+ const auto *OCE = cast<CXXOperatorCallExpr>(expr);
+ for (const auto *Arg : OCE->arguments())
+ CheckArrayAccess(Arg);
+ return;
+ }
+ default:
+ return;
}
}
}
@@ -18478,19 +18733,22 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) {
if (!findRetainCycleOwner(S, ref->getBase(), owner))
return false;
- if (ref->isFreeIvar()) owner.setLocsFrom(ref);
+ if (ref->isFreeIvar())
+ owner.setLocsFrom(ref);
owner.Indirect = true;
return true;
}
if (DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e)) {
VarDecl *var = dyn_cast<VarDecl>(ref->getDecl());
- if (!var) return false;
+ if (!var)
+ return false;
return considerVariable(var, ref, owner);
}
if (MemberExpr *member = dyn_cast<MemberExpr>(e)) {
- if (member->isArrow()) return false;
+ if (member->isArrow())
+ return false;
// Don't count this as an indirect ownership.
e = member->getBase();
@@ -18499,17 +18757,18 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) {
if (PseudoObjectExpr *pseudo = dyn_cast<PseudoObjectExpr>(e)) {
// Only pay attention to pseudo-objects on property references.
- ObjCPropertyRefExpr *pre
- = dyn_cast<ObjCPropertyRefExpr>(pseudo->getSyntacticForm()
- ->IgnoreParens());
- if (!pre) return false;
- if (pre->isImplicitProperty()) return false;
+ ObjCPropertyRefExpr *pre = dyn_cast<ObjCPropertyRefExpr>(
+ pseudo->getSyntacticForm()->IgnoreParens());
+ if (!pre)
+ return false;
+ if (pre->isImplicitProperty())
+ return false;
ObjCPropertyDecl *property = pre->getExplicitProperty();
if (!property->isRetaining() &&
!(property->getPropertyIvarDecl() &&
- property->getPropertyIvarDecl()->getType()
- .getObjCLifetime() == Qualifiers::OCL_Strong))
- return false;
+ property->getPropertyIvarDecl()->getType().getObjCLifetime() ==
+ Qualifiers::OCL_Strong))
+ return false;
owner.Indirect = true;
if (pre->isSuperReceiver()) {
@@ -18520,8 +18779,8 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) {
owner.Range = pre->getSourceRange();
return true;
}
- e = const_cast<Expr*>(cast<OpaqueValueExpr>(pre->getBase())
- ->getSourceExpr());
+ e = const_cast<Expr *>(
+ cast<OpaqueValueExpr>(pre->getBase())->getSourceExpr());
continue;
}
@@ -18533,56 +18792,57 @@ static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) {
namespace {
- struct FindCaptureVisitor : EvaluatedExprVisitor<FindCaptureVisitor> {
- VarDecl *Variable;
- Expr *Capturer = nullptr;
- bool VarWillBeReased = false;
+struct FindCaptureVisitor : EvaluatedExprVisitor<FindCaptureVisitor> {
+ VarDecl *Variable;
+ Expr *Capturer = nullptr;
+ bool VarWillBeReased = false;
- FindCaptureVisitor(ASTContext &Context, VarDecl *variable)
- : EvaluatedExprVisitor<FindCaptureVisitor>(Context),
- Variable(variable) {}
+ FindCaptureVisitor(ASTContext &Context, VarDecl *variable)
+ : EvaluatedExprVisitor<FindCaptureVisitor>(Context), Variable(variable) {}
- void VisitDeclRefExpr(DeclRefExpr *ref) {
- if (ref->getDecl() == Variable && !Capturer)
- Capturer = ref;
- }
+ void VisitDeclRefExpr(DeclRefExpr *ref) {
+ if (ref->getDecl() == Variable && !Capturer)
+ Capturer = ref;
+ }
- void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) {
- if (Capturer) return;
- Visit(ref->getBase());
- if (Capturer && ref->isFreeIvar())
- Capturer = ref;
- }
+ void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) {
+ if (Capturer)
+ return;
+ Visit(ref->getBase());
+ if (Capturer && ref->isFreeIvar())
+ Capturer = ref;
+ }
- void VisitBlockExpr(BlockExpr *block) {
- // Look inside nested blocks
- if (block->getBlockDecl()->capturesVariable(Variable))
- Visit(block->getBlockDecl()->getBody());
- }
+ void VisitBlockExpr(BlockExpr *block) {
+ // Look inside nested blocks
+ if (block->getBlockDecl()->capturesVariable(Variable))
+ Visit(block->getBlockDecl()->getBody());
+ }
- void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) {
- if (Capturer) return;
- if (OVE->getSourceExpr())
- Visit(OVE->getSourceExpr());
- }
+ void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) {
+ if (Capturer)
+ return;
+ if (OVE->getSourceExpr())
+ Visit(OVE->getSourceExpr());
+ }
- void VisitBinaryOperator(BinaryOperator *BinOp) {
- if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign)
+ void VisitBinaryOperator(BinaryOperator *BinOp) {
+ if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign)
+ return;
+ Expr *LHS = BinOp->getLHS();
+ if (const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
+ if (DRE->getDecl() != Variable)
return;
- Expr *LHS = BinOp->getLHS();
- if (const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
- if (DRE->getDecl() != Variable)
- return;
- if (Expr *RHS = BinOp->getRHS()) {
- RHS = RHS->IgnoreParenCasts();
- std::optional<llvm::APSInt> Value;
- VarWillBeReased =
- (RHS && (Value = RHS->getIntegerConstantExpr(Context)) &&
- *Value == 0);
- }
+ if (Expr *RHS = BinOp->getRHS()) {
+ RHS = RHS->IgnoreParenCasts();
+ std::optional<llvm::APSInt> Value;
+ VarWillBeReased =
+ (RHS && (Value = RHS->getIntegerConstantExpr(Context)) &&
+ *Value == 0);
}
}
- };
+ }
+};
} // namespace
@@ -18629,15 +18889,16 @@ static void diagnoseRetainCycle(Sema &S, Expr *capturer,
assert(owner.Variable && owner.Loc.isValid());
S.Diag(capturer->getExprLoc(), diag::warn_arc_retain_cycle)
- << owner.Variable << capturer->getSourceRange();
+ << owner.Variable << capturer->getSourceRange();
S.Diag(owner.Loc, diag::note_arc_retain_cycle_owner)
- << owner.Indirect << owner.Range;
+ << owner.Indirect << owner.Range;
}
/// Check for a keyword selector that starts with the word 'add' or
/// 'set'.
static bool isSetterLikeSelector(Selector sel) {
- if (sel.isUnarySelector()) return false;
+ if (sel.isUnarySelector())
+ return false;
StringRef str = sel.getNameForSlot(0);
str = str.ltrim('_');
@@ -18651,15 +18912,15 @@ static bool isSetterLikeSelector(Selector sel) {
} else
return false;
- if (str.empty()) return true;
+ if (str.empty())
+ return true;
return !isLowercase(str.front());
}
static std::optional<int>
GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
bool IsMutableArray = S.NSAPIObj->isSubclassOfNSClass(
- Message->getReceiverInterface(),
- NSAPI::ClassId_NSMutableArray);
+ Message->getReceiverInterface(), NSAPI::ClassId_NSMutableArray);
if (!IsMutableArray) {
return std::nullopt;
}
@@ -18675,15 +18936,15 @@ GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
NSAPI::NSArrayMethodKind MK = *MKOpt;
switch (MK) {
- case NSAPI::NSMutableArr_addObject:
- case NSAPI::NSMutableArr_insertObjectAtIndex:
- case NSAPI::NSMutableArr_setObjectAtIndexedSubscript:
- return 0;
- case NSAPI::NSMutableArr_replaceObjectAtIndex:
- return 1;
+ case NSAPI::NSMutableArr_addObject:
+ case NSAPI::NSMutableArr_insertObjectAtIndex:
+ case NSAPI::NSMutableArr_setObjectAtIndexedSubscript:
+ return 0;
+ case NSAPI::NSMutableArr_replaceObjectAtIndex:
+ return 1;
- default:
- return std::nullopt;
+ default:
+ return std::nullopt;
}
return std::nullopt;
@@ -18692,8 +18953,7 @@ GetNSMutableArrayArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
static std::optional<int>
GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
bool IsMutableDictionary = S.NSAPIObj->isSubclassOfNSClass(
- Message->getReceiverInterface(),
- NSAPI::ClassId_NSMutableDictionary);
+ Message->getReceiverInterface(), NSAPI::ClassId_NSMutableDictionary);
if (!IsMutableDictionary) {
return std::nullopt;
}
@@ -18709,13 +18969,13 @@ GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
NSAPI::NSDictionaryMethodKind MK = *MKOpt;
switch (MK) {
- case NSAPI::NSMutableDict_setObjectForKey:
- case NSAPI::NSMutableDict_setValueForKey:
- case NSAPI::NSMutableDict_setObjectForKeyedSubscript:
- return 0;
+ case NSAPI::NSMutableDict_setObjectForKey:
+ case NSAPI::NSMutableDict_setValueForKey:
+ case NSAPI::NSMutableDict_setObjectForKeyedSubscript:
+ return 0;
- default:
- return std::nullopt;
+ default:
+ return std::nullopt;
}
return std::nullopt;
@@ -18724,12 +18984,10 @@ GetNSMutableDictionaryArgumentIndex(Sema &S, ObjCMessageExpr *Message) {
static std::optional<int> GetNSSetArgumentIndex(Sema &S,
ObjCMessageExpr *Message) {
bool IsMutableSet = S.NSAPIObj->isSubclassOfNSClass(
- Message->getReceiverInterface(),
- NSAPI::ClassId_NSMutableSet);
+ Message->getReceiverInterface(), NSAPI::ClassId_NSMutableSet);
bool IsMutableOrderedSet = S.NSAPIObj->isSubclassOfNSClass(
- Message->getReceiverInterface(),
- NSAPI::ClassId_NSMutableOrderedSet);
+ Message->getReceiverInterface(), NSAPI::ClassId_NSMutableOrderedSet);
if (!IsMutableSet && !IsMutableOrderedSet) {
return std::nullopt;
}
@@ -18745,13 +19003,13 @@ static std::optional<int> GetNSSetArgumentIndex(Sema &S,
NSAPI::NSSetMethodKind MK = *MKOpt;
switch (MK) {
- case NSAPI::NSMutableSet_addObject:
- case NSAPI::NSOrderedSet_setObjectAtIndex:
- case NSAPI::NSOrderedSet_setObjectAtIndexedSubscript:
- case NSAPI::NSOrderedSet_insertObjectAtIndex:
- return 0;
- case NSAPI::NSOrderedSet_replaceObjectAtIndexWithObject:
- return 1;
+ case NSAPI::NSMutableSet_addObject:
+ case NSAPI::NSOrderedSet_setObjectAtIndex:
+ case NSAPI::NSOrderedSet_setObjectAtIndexedSubscript:
+ case NSAPI::NSOrderedSet_insertObjectAtIndex:
+ return 0;
+ case NSAPI::NSOrderedSet_replaceObjectAtIndexWithObject:
+ return 1;
}
return std::nullopt;
@@ -18782,7 +19040,7 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) {
if (ArgRE->isObjCSelfExpr()) {
Diag(Message->getSourceRange().getBegin(),
diag::warn_objc_circular_container)
- << ArgRE->getDecl() << StringRef("'super'");
+ << ArgRE->getDecl() << StringRef("'super'");
}
}
} else {
@@ -18798,11 +19056,11 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) {
ValueDecl *Decl = ReceiverRE->getDecl();
Diag(Message->getSourceRange().getBegin(),
diag::warn_objc_circular_container)
- << Decl << Decl;
+ << Decl << Decl;
if (!ArgRE->isObjCSelfExpr()) {
Diag(Decl->getLocation(),
diag::note_objc_circular_container_declared_here)
- << Decl;
+ << Decl;
}
}
}
@@ -18812,10 +19070,10 @@ void Sema::CheckObjCCircularContainer(ObjCMessageExpr *Message) {
ObjCIvarDecl *Decl = IvarRE->getDecl();
Diag(Message->getSourceRange().getBegin(),
diag::warn_objc_circular_container)
- << Decl << Decl;
+ << Decl << Decl;
Diag(Decl->getLocation(),
diag::note_objc_circular_container_declared_here)
- << Decl;
+ << Decl;
}
}
}
@@ -18876,8 +19134,8 @@ void Sema::checkRetainCycles(VarDecl *Var, Expr *Init) {
diagnoseRetainCycle(*this, Capturer, Owner);
}
-static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc,
- Expr *RHS, bool isProperty) {
+static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc, Expr *RHS,
+ bool isProperty) {
// Check if RHS is an Objective-C object literal, which also can get
// immediately zapped in a weak reference. Note that we explicitly
// allow ObjCStringLiterals, since those are designed to never really die.
@@ -18890,23 +19148,20 @@ static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc,
return false;
S.Diag(Loc, diag::warn_arc_literal_assign)
- << (unsigned) Kind
- << (isProperty ? 0 : 1)
- << RHS->getSourceRange();
+ << (unsigned)Kind << (isProperty ? 0 : 1) << RHS->getSourceRange();
return true;
}
static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc,
- Qualifiers::ObjCLifetime LT,
- Expr *RHS, bool isProperty) {
+ Qualifiers::ObjCLifetime LT, Expr *RHS,
+ bool isProperty) {
// Strip off any implicit cast added to get to the one ARC-specific.
while (ImplicitCastExpr *cast = dyn_cast<ImplicitCastExpr>(RHS)) {
if (cast->getCastKind() == CK_ARCConsumeObject) {
S.Diag(Loc, diag::warn_arc_retained_assign)
- << (LT == Qualifiers::OCL_ExplicitNone)
- << (isProperty ? 0 : 1)
- << RHS->getSourceRange();
+ << (LT == Qualifiers::OCL_ExplicitNone) << (isProperty ? 0 : 1)
+ << RHS->getSourceRange();
return true;
}
RHS = cast->getSubExpr();
@@ -18919,8 +19174,7 @@ static bool checkUnsafeAssignObject(Sema &S, SourceLocation Loc,
return false;
}
-bool Sema::checkUnsafeAssigns(SourceLocation Loc,
- QualType LHS, Expr *RHS) {
+bool Sema::checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS) {
Qualifiers::ObjCLifetime LT = LHS.getObjCLifetime();
if (LT != Qualifiers::OCL_Weak && LT != Qualifiers::OCL_ExplicitNone)
@@ -18932,13 +19186,11 @@ bool Sema::checkUnsafeAssigns(SourceLocation Loc,
return false;
}
-void Sema::checkUnsafeExprAssigns(SourceLocation Loc,
- Expr *LHS, Expr *RHS) {
+void Sema::checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS) {
QualType LHSType;
// PropertyRef on LHS type need be directly obtained from
// its declaration as it has a PseudoType.
- ObjCPropertyRefExpr *PRE
- = dyn_cast<ObjCPropertyRefExpr>(LHS->IgnoreParens());
+ ObjCPropertyRefExpr *PRE = dyn_cast<ObjCPropertyRefExpr>(LHS->IgnoreParens());
if (PRE && !PRE->isImplicitProperty()) {
const ObjCPropertyDecl *PD = PRE->getExplicitProperty();
if (PD)
@@ -18982,7 +19234,7 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc,
while (ImplicitCastExpr *cast = dyn_cast<ImplicitCastExpr>(RHS)) {
if (cast->getCastKind() == CK_ARCConsumeObject) {
Diag(Loc, diag::warn_arc_retained_property_assign)
- << RHS->getSourceRange();
+ << RHS->getSourceRange();
return;
}
RHS = cast->getSubExpr();
@@ -19009,14 +19261,14 @@ static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr,
// Get line numbers of statement and body.
bool StmtLineInvalid;
- unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc,
- &StmtLineInvalid);
+ unsigned StmtLine =
+ SourceMgr.getPresumedLineNumber(StmtLoc, &StmtLineInvalid);
if (StmtLineInvalid)
return false;
bool BodyLineInvalid;
- unsigned BodyLine = SourceMgr.getSpellingLineNumber(Body->getSemiLoc(),
- &BodyLineInvalid);
+ unsigned BodyLine =
+ SourceMgr.getSpellingLineNumber(Body->getSemiLoc(), &BodyLineInvalid);
if (BodyLineInvalid)
return false;
@@ -19027,8 +19279,7 @@ static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr,
return true;
}
-void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc,
- const Stmt *Body,
+void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
unsigned DiagID) {
// Since this is a syntactic check, don't emit diagnostic for template
// instantiations, this just adds noise.
@@ -19048,8 +19299,7 @@ void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc,
Diag(NBody->getSemiLoc(), diag::note_empty_body_on_separate_line);
}
-void Sema::DiagnoseEmptyLoopBody(const Stmt *S,
- const Stmt *PossibleBody) {
+void Sema::DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody) {
assert(!CurrentInstantiationScope); // Ensured by caller
SourceLocation StmtLoc;
@@ -19118,7 +19368,7 @@ void Sema::DiagnoseEmptyLoopBody(const Stmt *S,
/// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
void Sema::DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
- SourceLocation OpLoc) {
+ SourceLocation OpLoc) {
if (Diags.isIgnored(diag::warn_sizeof_pointer_expr_memaccess, OpLoc))
return;
@@ -19278,12 +19528,10 @@ static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1,
return false;
// Check the base classes.
- for (CXXRecordDecl::base_class_const_iterator
- Base1 = D1CXX->bases_begin(),
- BaseEnd1 = D1CXX->bases_end(),
- Base2 = D2CXX->bases_begin();
- Base1 != BaseEnd1;
- ++Base1, ++Base2) {
+ for (CXXRecordDecl::base_class_const_iterator Base1 = D1CXX->bases_begin(),
+ BaseEnd1 = D1CXX->bases_end(),
+ Base2 = D2CXX->bases_begin();
+ Base1 != BaseEnd1; ++Base1, ++Base2) {
if (!isLayoutCompatible(C, Base1->getType(), Base2->getType()))
return false;
}
@@ -19298,7 +19546,7 @@ static bool isLayoutCompatibleStruct(ASTContext &C, RecordDecl *RD1,
Field2End = RD2->field_end(),
Field1 = RD1->field_begin(),
Field1End = RD1->field_end();
- for ( ; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) {
+ for (; Field1 != Field1End && Field2 != Field2End; ++Field1, ++Field2) {
if (!isLayoutCompatible(C, *Field1, *Field2))
return false;
}
@@ -19317,14 +19565,13 @@ static bool isLayoutCompatibleUnion(ASTContext &C, RecordDecl *RD1,
UnmatchedFields.insert(Field2);
for (auto *Field1 : RD1->fields()) {
- llvm::SmallPtrSet<FieldDecl *, 8>::iterator
- I = UnmatchedFields.begin(),
- E = UnmatchedFields.end();
+ llvm::SmallPtrSet<FieldDecl *, 8>::iterator I = UnmatchedFields.begin(),
+ E = UnmatchedFields.end();
- for ( ; I != E; ++I) {
+ for (; I != E; ++I) {
if (isLayoutCompatible(C, Field1, *I, /*IsUnionMember=*/true)) {
bool Result = UnmatchedFields.erase(*I);
- (void) Result;
+ (void)Result;
assert(Result);
break;
}
@@ -19369,15 +19616,13 @@ static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2) {
return false;
if (TC1 == Type::Enum) {
- return isLayoutCompatible(C,
- cast<EnumType>(T1)->getDecl(),
+ return isLayoutCompatible(C, cast<EnumType>(T1)->getDecl(),
cast<EnumType>(T2)->getDecl());
} else if (TC1 == Type::Record) {
if (!T1->isStandardLayoutType() || !T2->isStandardLayoutType())
return false;
- return isLayoutCompatible(C,
- cast<RecordType>(T1)->getDecl(),
+ return isLayoutCompatible(C, cast<RecordType>(T1)->getDecl(),
cast<RecordType>(T2)->getDecl());
}
@@ -19404,7 +19649,7 @@ bool Sema::IsLayoutCompatible(QualType T1, QualType T2) const {
static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx,
const ValueDecl **VD, uint64_t *MagicValue,
bool isConstantEvaluated) {
- while(true) {
+ while (true) {
if (!TypeExpr)
return false;
@@ -19516,8 +19761,7 @@ static bool GetMatchingCType(
if (!MagicValues)
return false;
- llvm::DenseMap<Sema::TypeTagMagicValue,
- Sema::TypeTagData>::const_iterator I =
+ llvm::DenseMap<Sema::TypeTagMagicValue, Sema::TypeTagData>::const_iterator I =
MagicValues->find(std::make_pair(ArgumentKind, MagicValue));
if (I == MagicValues->end())
return false;
@@ -19528,8 +19772,7 @@ static bool GetMatchingCType(
void Sema::RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
uint64_t MagicValue, QualType Type,
- bool LayoutCompatible,
- bool MustBeNull) {
+ bool LayoutCompatible, bool MustBeNull) {
if (!TypeTagForDatatypeMagicValues)
TypeTagForDatatypeMagicValues.reset(
new llvm::DenseMap<TypeTagMagicValue, TypeTagData>);
@@ -19551,8 +19794,8 @@ static bool IsSameCharType(QualType T1, QualType T2) {
BuiltinType::Kind T1Kind = BT1->getKind();
BuiltinType::Kind T2Kind = BT2->getKind();
- return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) ||
- (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) ||
+ return (T1Kind == BuiltinType::SChar && T2Kind == BuiltinType::Char_S) ||
+ (T1Kind == BuiltinType::UChar && T2Kind == BuiltinType::Char_U) ||
(T1Kind == BuiltinType::Char_U && T2Kind == BuiltinType::UChar) ||
(T1Kind == BuiltinType::Char_S && T2Kind == BuiltinType::SChar);
}
@@ -19579,7 +19822,7 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
if (FoundWrongKind)
Diag(TypeTagExpr->getExprLoc(),
diag::warn_type_tag_for_datatype_wrong_kind)
- << TypeTagExpr->getSourceRange();
+ << TypeTagExpr->getSourceRange();
return;
}
@@ -19606,12 +19849,11 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
if (TypeInfo.MustBeNull) {
// Type tag with matching void type requires a null pointer.
- if (!ArgumentExpr->isNullPointerConstant(Context,
- Expr::NPC_ValueDependentIsNotNull)) {
+ if (!ArgumentExpr->isNullPointerConstant(
+ Context, Expr::NPC_ValueDependentIsNotNull)) {
Diag(ArgumentExpr->getExprLoc(),
diag::warn_type_safety_null_pointer_required)
- << ArgumentKind->getName()
- << ArgumentExpr->getSourceRange()
+ << ArgumentKind->getName() << ArgumentExpr->getSourceRange()
<< TypeTagExpr->getSourceRange();
}
return;
@@ -19635,19 +19877,16 @@ void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
RequiredType->getPointeeType())) ||
(!IsPointerAttr && IsSameCharType(ArgumentType, RequiredType)))
mismatch = false;
- } else
- if (IsPointerAttr)
- mismatch = !isLayoutCompatible(Context,
- ArgumentType->getPointeeType(),
- RequiredType->getPointeeType());
- else
- mismatch = !isLayoutCompatible(Context, ArgumentType, RequiredType);
+ } else if (IsPointerAttr)
+ mismatch = !isLayoutCompatible(Context, ArgumentType->getPointeeType(),
+ RequiredType->getPointeeType());
+ else
+ mismatch = !isLayoutCompatible(Context, ArgumentType, RequiredType);
if (mismatch)
Diag(ArgumentExpr->getExprLoc(), diag::warn_type_safety_type_mismatch)
- << ArgumentType << ArgumentKind
- << TypeInfo.LayoutCompatible << RequiredType
- << ArgumentExpr->getSourceRange()
+ << ArgumentType << ArgumentKind << TypeInfo.LayoutCompatible
+ << RequiredType << ArgumentExpr->getSourceRange()
<< TypeTagExpr->getSourceRange();
}
@@ -19740,7 +19979,7 @@ void Sema::RefersToMemberWithReducedAlignment(
// For now, just disregard these cases. This is left for future
// improvement.
if (!DRE && !isa<CXXThisExpr>(TopBase))
- return;
+ return;
// Alignment expected by the whole expression.
CharUnits ExpectedAlignment = Context.getTypeAlignInChars(E->getType());
@@ -19936,7 +20175,8 @@ bool Sema::SemaBuiltinNonDeterministicValue(CallExpr *TheCall) {
QualType TyArg = Arg.get()->getType();
if (!TyArg->isBuiltinType() && !TyArg->isVectorType())
- return Diag(TheCall->getArg(0)->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+ return Diag(TheCall->getArg(0)->getBeginLoc(),
+ diag::err_builtin_invalid_arg_type)
<< 1 << /*vector, integer or floating point ty*/ 0 << TyArg;
TheCall->setType(TyArg);
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 8f5ca271242d5b..21a328bf5acd63 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -53,11 +53,7 @@ using namespace clang;
using namespace sema;
namespace AttributeLangSupport {
- enum LANG {
- C,
- Cpp,
- ObjC
- };
+enum LANG { C, Cpp, ObjC };
} // end namespace AttributeLangSupport
//===----------------------------------------------------------------------===//
@@ -81,8 +77,8 @@ static bool isFunctionOrMethodOrBlock(const Decl *D) {
/// been processed by Sema::GetTypeForDeclarator.
static bool hasDeclarator(const Decl *D) {
// In some sense, TypedefDecl really *ought* to be a DeclaratorDecl.
- return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
- isa<ObjCPropertyDecl>(D);
+ return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) ||
+ isa<TypedefNameDecl>(D) || isa<ObjCPropertyDecl>(D);
}
/// hasFunctionProto - Return true if the given decl has a argument
@@ -169,7 +165,7 @@ static inline bool isNSStringType(QualType T, ASTContext &Ctx,
if (!Cls)
return false;
- IdentifierInfo* ClsName = Cls->getIdentifier();
+ IdentifierInfo *ClsName = Cls->getIdentifier();
if (AllowNSAttributedString &&
ClsName == &Ctx.Idents.get("NSAttributedString"))
@@ -251,8 +247,9 @@ static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr,
/// that the result will fit into a regular (signed) int. All args have the same
/// purpose as they do in checkUInt32Argument.
template <typename AttrInfo>
-static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI, const Expr *Expr,
- int &Val, unsigned Idx = UINT_MAX) {
+static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI,
+ const Expr *Expr, int &Val,
+ unsigned Idx = UINT_MAX) {
uint32_t UVal;
if (!checkUInt32Argument(S, AI, Expr, UVal, Idx))
return false;
@@ -404,15 +401,15 @@ static void handleSimpleAttribute(Sema &S, Decl *D,
}
template <typename... DiagnosticArgs>
-static const Sema::SemaDiagnosticBuilder&
+static const Sema::SemaDiagnosticBuilder &
appendDiagnostics(const Sema::SemaDiagnosticBuilder &Bldr) {
return Bldr;
}
template <typename T, typename... DiagnosticArgs>
-static const Sema::SemaDiagnosticBuilder&
+static const Sema::SemaDiagnosticBuilder &
appendDiagnostics(const Sema::SemaDiagnosticBuilder &Bldr, T &&ExtraArg,
- DiagnosticArgs &&... ExtraArgs) {
+ DiagnosticArgs &&...ExtraArgs) {
return appendDiagnostics(Bldr << std::forward<T>(ExtraArg),
std::forward<DiagnosticArgs>(ExtraArgs)...);
}
@@ -425,7 +422,7 @@ template <typename AttrType, typename... DiagnosticArgs>
static void handleSimpleAttributeOrDiagnose(Sema &S, Decl *D,
const AttributeCommonInfo &CI,
bool PassesCheck, unsigned DiagID,
- DiagnosticArgs &&... ExtraArgs) {
+ DiagnosticArgs &&...ExtraArgs) {
if (!PassesCheck) {
Sema::SemaDiagnosticBuilder DB = S.Diag(D->getBeginLoc(), DiagID);
appendDiagnostics(DB, std::forward<DiagnosticArgs>(ExtraArgs)...);
@@ -440,10 +437,9 @@ static bool isIntOrBool(Expr *Exp) {
return QT->isBooleanType() || QT->isIntegerType();
}
-
// Check to see if the type is a smart pointer of some kind. We assume
// it's a smart pointer if it defines both operator-> and operator*.
-static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType* RT) {
+static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType *RT) {
auto IsOverloadedOperatorPresent = [&S](const RecordDecl *Record,
OverloadedOperatorKind Op) {
DeclContextLookupResult Result =
@@ -663,10 +659,10 @@ static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
const RecordType *RT = getRecordType(ArgTy);
// Now check if we index into a record type function param.
- if(!RT && ParamIdxOk) {
+ if (!RT && ParamIdxOk) {
const auto *FD = dyn_cast<FunctionDecl>(D);
const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
- if(FD && IL) {
+ if (FD && IL) {
unsigned int NumParams = FD->getNumParams();
llvm::APInt ArgValue = IL->getValue();
uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
@@ -890,7 +886,7 @@ static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL,
static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
- SmallVector<Expr*, 2> Args;
+ SmallVector<Expr *, 2> Args;
if (!checkTryLockFunAttrCommon(S, D, AL, Args))
return;
@@ -900,7 +896,7 @@ static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D,
static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
- SmallVector<Expr*, 2> Args;
+ SmallVector<Expr *, 2> Args;
if (!checkTryLockFunAttrCommon(S, D, AL, Args))
return;
@@ -910,7 +906,7 @@ static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D,
static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// check that the argument is lockable object
- SmallVector<Expr*, 1> Args;
+ SmallVector<Expr *, 1> Args;
checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
unsigned Size = Args.size();
if (Size == 0)
@@ -924,7 +920,7 @@ static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
// check that all arguments are lockable objects
- SmallVector<Expr*, 1> Args;
+ SmallVector<Expr *, 1> Args;
checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
unsigned Size = Args.size();
if (Size == 0)
@@ -1024,7 +1020,7 @@ class ArgumentDependenceChecker
return true;
}
};
-}
+} // namespace
static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
@@ -1219,8 +1215,8 @@ static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
IdentifierLoc *IL = AL.getArgAsIdent(0);
if (!ConsumableAttr::ConvertStrToConsumedState(IL->Ident->getName(),
DefaultState)) {
- S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL
- << IL->Ident;
+ S.Diag(IL->Loc, diag::warn_attribute_type_not_supported)
+ << AL << IL->Ident;
return;
}
} else {
@@ -1304,10 +1300,10 @@ static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// FIXME: This check is currently being done in the analysis. It can be
// enabled here only after the parser propagates attributes at
// template specialization definition, not declaration.
- //QualType ReturnType = cast<ParmVarDecl>(D)->getType();
- //const CXXRecordDecl *RD = ReturnType->getAsCXXRecordDecl();
+ // QualType ReturnType = cast<ParmVarDecl>(D)->getType();
+ // const CXXRecordDecl *RD = ReturnType->getAsCXXRecordDecl();
//
- //if (!RD || !RD->hasAttr<ConsumableAttr>()) {
+ // if (!RD || !RD->hasAttr<ConsumableAttr>()) {
// S.Diag(AL.getLoc(), diag::warn_return_state_for_unconsumable_type) <<
// ReturnType.getAsString();
// return;
@@ -1323,8 +1319,8 @@ static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
IdentifierLoc *IL = AL.getArgAsIdent(0);
if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->Ident->getName(),
ReturnState)) {
- S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL
- << IL->Ident;
+ S.Diag(IL->Loc, diag::warn_attribute_type_not_supported)
+ << AL << IL->Ident;
return;
}
} else {
@@ -1370,8 +1366,8 @@ static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
IdentifierLoc *Ident = AL.getArgAsIdent(0);
StringRef Param = Ident->Ident->getName();
if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
- S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL
- << Param;
+ S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported)
+ << AL << Param;
return;
}
} else {
@@ -1392,8 +1388,8 @@ static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
IdentifierLoc *Ident = AL.getArgAsIdent(0);
StringRef Param = Ident->Ident->getName();
if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
- S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL
- << Param;
+ S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported)
+ << AL << Param;
return;
}
} else {
@@ -1414,10 +1410,10 @@ static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (auto *TD = dyn_cast<TagDecl>(D))
TD->addAttr(::new (S.Context) PackedAttr(S.Context, AL));
else if (auto *FD = dyn_cast<FieldDecl>(D)) {
- bool BitfieldByteAligned = (!FD->getType()->isDependentType() &&
- !FD->getType()->isIncompleteType() &&
- FD->isBitField() &&
- S.Context.getTypeAlign(FD->getType()) <= 8);
+ bool BitfieldByteAligned =
+ (!FD->getType()->isDependentType() &&
+ !FD->getType()->isIncompleteType() && FD->isBitField() &&
+ S.Context.getTypeAlign(FD->getType()) <= 8);
if (S.getASTContext().getTargetInfo().getTriple().isPS()) {
if (BitfieldByteAligned)
@@ -1485,15 +1481,13 @@ static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL) {
<< AL << VD->getType() << 0;
return false;
}
- }
- else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
+ } else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
if (!PD->getType()->getAs<ObjCObjectPointerType>()) {
S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type)
<< AL << PD->getType() << 1;
return false;
}
- }
- else {
+ } else {
S.Diag(AL.getLoc(), diag::warn_attribute_iboutlet) << AL;
return false;
}
@@ -1542,9 +1536,10 @@ static void handleIBOutletCollection(Sema &S, Decl *D, const ParsedAttr &AL) {
// attributes. So, __attribute__((iboutletcollection(char))) will be
// treated as __attribute__((iboutletcollection())).
if (!QT->isObjCIdType() && !QT->isObjCObjectType()) {
- S.Diag(AL.getLoc(),
- QT->isBuiltinType() ? diag::err_iboutletcollection_builtintype
- : diag::err_iboutletcollection_type) << QT;
+ S.Diag(AL.getLoc(), QT->isBuiltinType()
+ ? diag::err_iboutletcollection_builtintype
+ : diag::err_iboutletcollection_type)
+ << QT;
return;
}
@@ -1641,7 +1636,7 @@ static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D,
handleNonNullAttr(S, D, AL);
} else {
S.Diag(AL.getLoc(), diag::warn_attribute_nonnull_parm_no_args)
- << D->getSourceRange();
+ << D->getSourceRange();
}
return;
}
@@ -1708,18 +1703,17 @@ void Sema::AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
if (!(I = E->getIntegerConstantExpr(Context))) {
if (OE)
Diag(AttrLoc, diag::err_attribute_argument_n_type)
- << &TmpAttr << 1 << AANT_ArgumentIntegerConstant
- << E->getSourceRange();
+ << &TmpAttr << 1 << AANT_ArgumentIntegerConstant
+ << E->getSourceRange();
else
Diag(AttrLoc, diag::err_attribute_argument_type)
- << &TmpAttr << AANT_ArgumentIntegerConstant
- << E->getSourceRange();
+ << &TmpAttr << AANT_ArgumentIntegerConstant << E->getSourceRange();
return;
}
if (!I->isPowerOf2()) {
Diag(AttrLoc, diag::err_alignment_not_power_of_two)
- << E->getSourceRange();
+ << E->getSourceRange();
return;
}
@@ -1870,21 +1864,21 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// Is the function argument a pointer type?
QualType T = getFunctionOrMethodParamType(D, Idx.getASTIndex());
- int Err = -1; // No error
+ int Err = -1; // No error
switch (K) {
- case OwnershipAttr::Takes:
- case OwnershipAttr::Holds:
- if (!T->isAnyPointerType() && !T->isBlockPointerType())
- Err = 0;
- break;
- case OwnershipAttr::Returns:
- if (!T->isIntegerType())
- Err = 1;
- break;
+ case OwnershipAttr::Takes:
+ case OwnershipAttr::Holds:
+ if (!T->isAnyPointerType() && !T->isBlockPointerType())
+ Err = 0;
+ break;
+ case OwnershipAttr::Returns:
+ if (!T->isIntegerType())
+ Err = 1;
+ break;
}
if (-1 != Err) {
- S.Diag(AL.getLoc(), diag::err_ownership_type) << AL << Err
- << Ex->getSourceRange();
+ S.Diag(AL.getLoc(), diag::err_ownership_type)
+ << AL << Err << Ex->getSourceRange();
return;
}
@@ -1893,11 +1887,11 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// Cannot have two ownership attributes of different kinds for the same
// index.
if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
- S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)
- << AL << I
- << (AL.isRegularKeywordAttribute() ||
- I->isRegularKeywordAttribute());
- return;
+ S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)
+ << AL << I
+ << (AL.isRegularKeywordAttribute() ||
+ I->isRegularKeywordAttribute());
+ return;
} else if (K == OwnershipAttr::Returns &&
I->getOwnKind() == OwnershipAttr::Returns) {
// A returns attribute conflicts with any other returns attribute using
@@ -2048,8 +2042,8 @@ static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
// Check that the value.
- if (Model != "global-dynamic" && Model != "local-dynamic"
- && Model != "initial-exec" && Model != "local-exec") {
+ if (Model != "global-dynamic" && Model != "local-dynamic" &&
+ Model != "initial-exec" && Model != "local-exec") {
S.Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
return;
}
@@ -2189,7 +2183,8 @@ static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
}
static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) {
- if (hasDeclarator(D)) return;
+ if (hasDeclarator(D))
+ return;
if (!isa<ObjCMethodDecl>(D)) {
S.Diag(Attrs.getLoc(), diag::warn_attribute_wrong_decl_type)
@@ -2327,8 +2322,7 @@ static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D,
// [[carries_dependency]] can only be applied to a parameter if it is a
// parameter of a function declaration or lambda.
if (!(Scope->getFlags() & clang::Scope::FunctionDeclarationScope)) {
- S.Diag(AL.getLoc(),
- diag::err_carries_dependency_param_not_function_decl);
+ S.Diag(AL.getLoc(), diag::err_carries_dependency_param_not_function_decl);
return;
}
}
@@ -2395,8 +2389,8 @@ static bool checkAvailabilityAttr(Sema &S, SourceRange Range,
VersionTuple Introduced,
VersionTuple Deprecated,
VersionTuple Obsoleted) {
- StringRef PlatformName
- = AvailabilityAttr::getPrettyPlatformName(Platform->getName());
+ StringRef PlatformName =
+ AvailabilityAttr::getPrettyPlatformName(Platform->getName());
if (PlatformName.empty())
PlatformName = Platform->getName();
@@ -2405,24 +2399,22 @@ static bool checkAvailabilityAttr(Sema &S, SourceRange Range,
if (!Introduced.empty() && !Deprecated.empty() &&
!(Introduced <= Deprecated)) {
S.Diag(Range.getBegin(), diag::warn_availability_version_ordering)
- << 1 << PlatformName << Deprecated.getAsString()
- << 0 << Introduced.getAsString();
+ << 1 << PlatformName << Deprecated.getAsString() << 0
+ << Introduced.getAsString();
return true;
}
- if (!Introduced.empty() && !Obsoleted.empty() &&
- !(Introduced <= Obsoleted)) {
+ if (!Introduced.empty() && !Obsoleted.empty() && !(Introduced <= Obsoleted)) {
S.Diag(Range.getBegin(), diag::warn_availability_version_ordering)
- << 2 << PlatformName << Obsoleted.getAsString()
- << 0 << Introduced.getAsString();
+ << 2 << PlatformName << Obsoleted.getAsString() << 0
+ << Introduced.getAsString();
return true;
}
- if (!Deprecated.empty() && !Obsoleted.empty() &&
- !(Deprecated <= Obsoleted)) {
+ if (!Deprecated.empty() && !Obsoleted.empty() && !(Deprecated <= Obsoleted)) {
S.Diag(Range.getBegin(), diag::warn_availability_version_ordering)
- << 2 << PlatformName << Obsoleted.getAsString()
- << 1 << Deprecated.getAsString();
+ << 2 << PlatformName << Obsoleted.getAsString() << 1
+ << Deprecated.getAsString();
return true;
}
@@ -2520,7 +2512,8 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(
Which = 0;
FirstVersion = OldIntroduced;
SecondVersion = Introduced;
- } else if (!versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
+ } else if (!versionsMatch(Deprecated, OldDeprecated,
+ OverrideOrImpl)) {
Which = 1;
FirstVersion = Deprecated;
SecondVersion = OldDeprecated;
@@ -2533,8 +2526,8 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(
if (Which == -1) {
Diag(OldAA->getLocation(),
diag::warn_mismatched_availability_override_unavail)
- << AvailabilityAttr::getPrettyPlatformName(Platform->getName())
- << (AMK == AMK_Override);
+ << AvailabilityAttr::getPrettyPlatformName(Platform->getName())
+ << (AMK == AMK_Override);
} else if (Which != 1 && AMK == AMK_OptionalProtocolImplementation) {
// Allow different 'introduced' / 'obsoleted' availability versions
// on a method that implements an optional protocol requirement. It
@@ -2546,10 +2539,10 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(
} else {
Diag(OldAA->getLocation(),
diag::warn_mismatched_availability_override)
- << Which
- << AvailabilityAttr::getPrettyPlatformName(Platform->getName())
- << FirstVersion.getAsString() << SecondVersion.getAsString()
- << (AMK == AMK_Override);
+ << Which
+ << AvailabilityAttr::getPrettyPlatformName(Platform->getName())
+ << FirstVersion.getAsString() << SecondVersion.getAsString()
+ << (AMK == AMK_Override);
}
if (AMK == AMK_Override)
Diag(CI.getLoc(), diag::note_overridden_method);
@@ -2591,10 +2584,8 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(
}
}
- if (FoundAny &&
- MergedIntroduced == Introduced &&
- MergedDeprecated == Deprecated &&
- MergedObsoleted == Obsoleted)
+ if (FoundAny && MergedIntroduced == Introduced &&
+ MergedDeprecated == Deprecated && MergedObsoleted == Obsoleted)
return nullptr;
// Only create a new attribute if !OverrideOrImpl, but we want to do
@@ -2626,7 +2617,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
IdentifierInfo *II = Platform->Ident;
if (AvailabilityAttr::getPrettyPlatformName(II->getName()).empty())
S.Diag(Platform->Loc, diag::warn_availability_unknown_platform)
- << Platform->Ident;
+ << Platform->Ident;
auto *ND = dyn_cast<NamedDecl>(D);
if (!ND) // We warned about this already, so just return.
@@ -2924,8 +2915,8 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL,
VisibilityAttr::VisibilityType type;
if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr, type)) {
- S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
- << TypeStr;
+ S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
+ << AL << TypeStr;
return;
}
@@ -3004,15 +2995,13 @@ static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL) {
S.Diag(TD->getLocation(), diag::err_nsobject_attribute);
return;
}
- }
- else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
+ } else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
QualType T = PD->getType();
if (!T->isCARCBridgableType()) {
S.Diag(PD->getLocation(), diag::err_nsobject_attribute);
return;
}
- }
- else {
+ } else {
// It is okay to include this attribute on properties, e.g.:
//
// @property (retain, nonatomic) struct Bork *Q __attribute__((NSObject));
@@ -3068,7 +3057,7 @@ static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (Idx->isSigned() && Idx->isNegative()) {
S.Diag(AL.getLoc(), diag::err_attribute_sentinel_less_than_zero)
- << E->getSourceRange();
+ << E->getSourceRange();
return;
}
@@ -3090,7 +3079,7 @@ static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// FIXME: This error message could be improved, it would be nice
// to say what the bounds actually are.
S.Diag(AL.getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
- << E->getSourceRange();
+ << E->getSourceRange();
return;
}
}
@@ -3203,7 +3192,7 @@ static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (!D->canBeWeakImported(isDef)) {
if (isDef)
S.Diag(AL.getLoc(), diag::warn_attribute_invalid_on_definition)
- << "weak_import";
+ << "weak_import";
else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
(S.Context.getTargetInfo().getTriple().isOSDarwin() &&
(isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
@@ -3235,9 +3224,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
}
WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
- if (Existing && !(Existing->getXDim() == WGSize[0] &&
- Existing->getYDim() == WGSize[1] &&
- Existing->getZDim() == WGSize[2]))
+ if (Existing &&
+ !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] &&
+ Existing->getZDim() == WGSize[2]))
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
D->addAttr(::new (S.Context)
@@ -3305,7 +3294,7 @@ SectionAttr *Sema::mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
if (ExistingAttr->getName() == Name)
return nullptr;
Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
- << 1 /*section*/;
+ << 1 /*section*/;
Diag(CI.getLoc(), diag::note_previous_attribute);
return nullptr;
}
@@ -3405,7 +3394,7 @@ CodeSegAttr *Sema::mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
if (ExistingAttr->getName() == Name)
return nullptr;
Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
- << 0 /*codeseg*/;
+ << 0 /*codeseg*/;
Diag(CI.getLoc(), diag::note_previous_attribute);
return nullptr;
}
@@ -3421,10 +3410,9 @@ static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
if (const auto *ExistingAttr = D->getAttr<CodeSegAttr>()) {
if (!ExistingAttr->isImplicit()) {
- S.Diag(AL.getLoc(),
- ExistingAttr->getName() == Str
- ? diag::warn_duplicate_codeseg_attribute
- : diag::err_conflicting_codeseg_attribute);
+ S.Diag(AL.getLoc(), ExistingAttr->getName() == Str
+ ? diag::warn_duplicate_codeseg_attribute
+ : diag::err_conflicting_codeseg_attribute);
return;
}
D->dropAttr<CodeSegAttr>();
@@ -3750,8 +3738,8 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
FD = dyn_cast<FunctionDecl>(DRE->getDecl());
NI = DRE->getNameInfo();
if (!FD) {
- S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
- << NI.getName();
+ S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function)
+ << 1 << NI.getName();
return;
}
} else if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
@@ -3760,8 +3748,8 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
FD = S.ResolveSingleFunctionTemplateSpecialization(ULE, true);
NI = ULE->getNameInfo();
if (!FD) {
- S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
- << NI.getName();
+ S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function)
+ << 2 << NI.getName();
if (ULE->getType() == S.Context.OverloadTy)
S.NoteAllOverloadCandidates(ULE);
return;
@@ -3773,7 +3761,7 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (FD->getNumParams() != 1) {
S.Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
- << NI.getName();
+ << NI.getName();
return;
}
@@ -3781,10 +3769,10 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// If this ever proves to be a problem it should be easy to fix.
QualType Ty = S.Context.getPointerType(cast<VarDecl>(D)->getType());
QualType ParamTy = FD->getParamDecl(0)->getType();
- if (S.CheckAssignmentConstraints(FD->getParamDecl(0)->getLocation(),
- ParamTy, Ty) != Sema::Compatible) {
+ if (S.CheckAssignmentConstraints(FD->getParamDecl(0)->getLocation(), ParamTy,
+ Ty) != Sema::Compatible) {
S.Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
- << NI.getName() << ParamTy << Ty;
+ << NI.getName() << ParamTy << Ty;
return;
}
@@ -3823,8 +3811,7 @@ static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
bool NotNSStringTy = !isNSStringType(Ty, S.Context);
- if (NotNSStringTy &&
- !isCFStringType(Ty, S.Context) &&
+ if (NotNSStringTy && !isCFStringType(Ty, S.Context) &&
(!Ty->isPointerType() ||
!Ty->castAs<PointerType>()->getPointeeType()->isCharType())) {
S.Diag(AL.getLoc(), diag::err_format_attribute_not)
@@ -3959,8 +3946,7 @@ FormatAttr *Sema::mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
int FirstArg) {
// Check whether we already have an equivalent format attribute.
for (auto *F : D->specific_attrs<FormatAttr>()) {
- if (F->getType() == Format &&
- F->getFormatIdx() == FormatIdx &&
+ if (F->getType() == Format && F->getFormatIdx() == FormatIdx &&
F->getFirstArg() == FirstArg) {
// If we don't have a valid location for this attribute, adopt the
// location.
@@ -4026,7 +4012,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (ArgIdx == 0) {
S.Diag(AL.getLoc(),
diag::err_format_attribute_implicit_this_format_string)
- << IdxExpr->getSourceRange();
+ << IdxExpr->getSourceRange();
return;
}
ArgIdx--;
@@ -4035,12 +4021,12 @@ static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// make sure the format string is really a string
QualType Ty = getFunctionOrMethodParamType(D, ArgIdx);
- if (!isNSStringType(Ty, S.Context, true) &&
- !isCFStringType(Ty, S.Context) &&
+ if (!isNSStringType(Ty, S.Context, true) && !isCFStringType(Ty, S.Context) &&
(!Ty->isPointerType() ||
!Ty->castAs<PointerType>()->getPointeeType()->isCharType())) {
S.Diag(AL.getLoc(), diag::err_format_attribute_not)
- << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, ArgIdx);
+ << IdxExpr->getSourceRange()
+ << getFunctionOrMethodParamRange(D, ArgIdx);
return;
}
@@ -4271,7 +4257,7 @@ static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
}
RecordDecl::field_iterator Field = RD->field_begin(),
- FieldEnd = RD->field_end();
+ FieldEnd = RD->field_end();
if (Field == FieldEnd) {
S.Diag(AL.getLoc(), diag::warn_transparent_union_attribute_zero_fields);
return;
@@ -4282,7 +4268,7 @@ static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (FirstType->hasFloatingRepresentation() || FirstType->isVectorType()) {
S.Diag(FirstField->getLocation(),
diag::warn_transparent_union_attribute_floating)
- << FirstType->isVectorType() << FirstType;
+ << FirstType->isVectorType() << FirstType;
return;
}
@@ -4364,7 +4350,7 @@ void Sema::AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E) {
if (!T->isDependentType() && !T->isAnyPointerType() &&
!T->isReferenceType() && !T->isMemberPointerType()) {
Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
- << &TmpAttr << T << D->getSourceRange();
+ << &TmpAttr << T << D->getSourceRange();
return;
}
@@ -4377,7 +4363,7 @@ void Sema::AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E) {
if (!Alignment.isPowerOf2()) {
Diag(AttrLoc, diag::err_alignment_not_power_of_two)
- << E->getSourceRange();
+ << E->getSourceRange();
return;
}
@@ -4535,7 +4521,7 @@ void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
if (!(TmpAttr.isAlignas() && !Alignment)) {
if (!llvm::isPowerOf2_64(AlignVal)) {
Diag(AttrLoc, diag::err_alignment_not_power_of_two)
- << E->getSourceRange();
+ << E->getSourceRange();
return;
}
}
@@ -4657,7 +4643,7 @@ void Sema::CheckAlignasUnderalignment(Decl *D) {
CharUnits NaturalAlign = Context.getTypeAlignInChars(UnderlyingTy);
if (NaturalAlign > RequestedAlign)
Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
- << DiagTy << (unsigned)NaturalAlign.getQuantity();
+ << DiagTy << (unsigned)NaturalAlign.getQuantity();
}
}
@@ -5158,7 +5144,8 @@ static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
}
static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
- if (hasDeclarator(D)) return;
+ if (hasDeclarator(D))
+ return;
// Diagnostic is emitted elsewhere: here we store the (valid) AL
// in the Decl node for syntactic reasoning, e.g., pretty-printing.
@@ -5362,7 +5349,7 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
return true;
if (Attrs.hasProcessingCache()) {
- CC = (CallingConv) Attrs.getProcessingCache();
+ CC = (CallingConv)Attrs.getProcessingCache();
return false;
}
@@ -5411,12 +5398,11 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
CC = CC_X86RegCall;
break;
case ParsedAttr::AT_MSABI:
- CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_C :
- CC_Win64;
+ CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_C : CC_Win64;
break;
case ParsedAttr::AT_SysVABI:
- CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_X86_64SysV :
- CC_C;
+ CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_X86_64SysV
+ : CC_C;
break;
case ParsedAttr::AT_Pcs: {
StringRef StrRef;
@@ -5451,7 +5437,8 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
case ParsedAttr::AT_PreserveNone:
CC = CC_PreserveNone;
break;
- default: llvm_unreachable("unexpected attribute kind");
+ default:
+ llvm_unreachable("unexpected attribute kind");
}
TargetInfo::CallingConvCheckResult A = TargetInfo::CCCR_OK;
@@ -5523,7 +5510,7 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC,
}
}
- Attrs.setProcessingCache((unsigned) CC);
+ Attrs.setProcessingCache((unsigned)CC);
return false;
}
@@ -5635,7 +5622,7 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) {
if (Context.getTargetInfo().getRegParmMax() == 0) {
Diag(AL.getLoc(), diag::err_attribute_regparm_wrong_platform)
- << NumParamsExpr->getSourceRange();
+ << NumParamsExpr->getSourceRange();
AL.setInvalid();
return true;
}
@@ -5643,7 +5630,8 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) {
numParams = NP;
if (numParams > Context.getTargetInfo().getRegParmMax()) {
Diag(AL.getLoc(), diag::err_attribute_regparm_invalid_number)
- << Context.getTargetInfo().getRegParmMax() << NumParamsExpr->getSourceRange();
+ << Context.getTargetInfo().getRegParmMax()
+ << NumParamsExpr->getSourceRange();
AL.setInvalid();
return true;
}
@@ -5924,8 +5912,7 @@ static bool RISCVAliasValid(unsigned BuiltinID, StringRef AliasName) {
BuiltinID <= RISCV::LastRVVBuiltin;
}
-static void handleBuiltinAliasAttr(Sema &S, Decl *D,
- const ParsedAttr &AL) {
+static void handleBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
if (!AL.isArgIdent(0)) {
S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
<< AL << 1 << AANT_ArgumentIdentifier;
@@ -6115,8 +6102,8 @@ static void handleXReturnsXRetainedAttr(Sema &S, Decl *D,
// Attributes on parameters are used for out-parameters,
// passed as pointers-to-pointers.
unsigned DiagID = K == Sema::RetainOwnershipKind::CF
- ? /*pointer-to-CF-pointer*/2
- : /*pointer-to-OSObject-pointer*/3;
+ ? /*pointer-to-CF-pointer*/ 2
+ : /*pointer-to-OSObject-pointer*/ 3;
ReturnType = Param->getType()->getPointeeType();
if (ReturnType.isNull()) {
S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
@@ -6128,7 +6115,8 @@ static void handleXReturnsXRetainedAttr(Sema &S, Decl *D,
} else {
AttributeDeclKind ExpectedDeclKind;
switch (AL.getKind()) {
- default: llvm_unreachable("invalid ownership attribute");
+ default:
+ llvm_unreachable("invalid ownership attribute");
case ParsedAttr::AT_NSReturnsRetained:
case ParsedAttr::AT_NSReturnsAutoreleased:
case ParsedAttr::AT_NSReturnsNotRetained:
@@ -6152,7 +6140,8 @@ static void handleXReturnsXRetainedAttr(Sema &S, Decl *D,
bool Cf;
unsigned ParmDiagID = 2; // Pointer-to-CF-pointer
switch (AL.getKind()) {
- default: llvm_unreachable("invalid ownership attribute");
+ default:
+ llvm_unreachable("invalid ownership attribute");
case ParsedAttr::AT_NSReturnsRetained:
TypeOK = isValidSubjectOfNSReturnsRetainedAttribute(ReturnType);
Cf = false;
@@ -6187,11 +6176,7 @@ static void handleXReturnsXRetainedAttr(Sema &S, Decl *D,
<< AL << ParmDiagID << AL.getRange();
} else {
// Needs to be kept in sync with warn_ns_attribute_wrong_return_type.
- enum : unsigned {
- Function,
- Method,
- Property
- } SubjectKind = Function;
+ enum : unsigned { Function, Method, Property } SubjectKind = Function;
if (isa<ObjCMethodDecl>(D))
SubjectKind = Method;
else if (isa<ObjCPropertyDecl>(D))
@@ -6203,29 +6188,29 @@ static void handleXReturnsXRetainedAttr(Sema &S, Decl *D,
}
switch (AL.getKind()) {
- default:
- llvm_unreachable("invalid ownership attribute");
- case ParsedAttr::AT_NSReturnsAutoreleased:
- handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL);
- return;
- case ParsedAttr::AT_CFReturnsNotRetained:
- handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL);
- return;
- case ParsedAttr::AT_NSReturnsNotRetained:
- handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL);
- return;
- case ParsedAttr::AT_CFReturnsRetained:
- handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL);
- return;
- case ParsedAttr::AT_NSReturnsRetained:
- handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL);
- return;
- case ParsedAttr::AT_OSReturnsRetained:
- handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL);
- return;
- case ParsedAttr::AT_OSReturnsNotRetained:
- handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL);
- return;
+ default:
+ llvm_unreachable("invalid ownership attribute");
+ case ParsedAttr::AT_NSReturnsAutoreleased:
+ handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL);
+ return;
+ case ParsedAttr::AT_CFReturnsNotRetained:
+ handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL);
+ return;
+ case ParsedAttr::AT_NSReturnsNotRetained:
+ handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL);
+ return;
+ case ParsedAttr::AT_CFReturnsRetained:
+ handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL);
+ return;
+ case ParsedAttr::AT_NSReturnsRetained:
+ handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL);
+ return;
+ case ParsedAttr::AT_OSReturnsRetained:
+ handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL);
+ return;
+ case ParsedAttr::AT_OSReturnsNotRetained:
+ handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL);
+ return;
};
}
@@ -6261,14 +6246,14 @@ static void handleObjCRequiresSuperAttr(Sema &S, Decl *D,
const DeclContext *DC = Method->getDeclContext();
if (const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
- S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
- << 0;
+ S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol)
+ << Attrs << 0;
S.Diag(PDecl->getLocation(), diag::note_protocol_decl);
return;
}
if (Method->getMethodFamily() == OMF_dealloc) {
- S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
- << 1;
+ S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol)
+ << Attrs << 1;
return;
}
@@ -6354,9 +6339,9 @@ static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D,
return;
}
IdentifierInfo *ClassMethod =
- AL.getArgAsIdent(1) ? AL.getArgAsIdent(1)->Ident : nullptr;
+ AL.getArgAsIdent(1) ? AL.getArgAsIdent(1)->Ident : nullptr;
IdentifierInfo *InstanceMethod =
- AL.getArgAsIdent(2) ? AL.getArgAsIdent(2)->Ident : nullptr;
+ AL.getArgAsIdent(2) ? AL.getArgAsIdent(2)->Ident : nullptr;
D->addAttr(::new (S.Context) ObjCBridgeRelatedAttr(
S.Context, AL, RelatedClass, ClassMethod, InstanceMethod));
}
@@ -6435,10 +6420,8 @@ static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D,
const auto *VD = cast<ValueDecl>(D);
QualType QT = VD->getType();
- if (!QT->isDependentType() &&
- !QT->isObjCLifetimeType()) {
- S.Diag(AL.getLoc(), diag::err_objc_precise_lifetime_bad_type)
- << QT;
+ if (!QT->isDependentType() && !QT->isObjCLifetimeType()) {
+ S.Diag(AL.getLoc(), diag::err_objc_precise_lifetime_bad_type) << QT;
return;
}
@@ -6623,7 +6606,8 @@ static void checkSwiftAsyncErrorBlock(Sema &S, Decl *D,
uint32_t ParamIdx = ErrorAttr->getHandlerParamIdx();
if (ParamIdx == 0 || ParamIdx > BlockParams.size()) {
S.Diag(ErrorAttr->getLocation(),
- diag::err_attribute_argument_out_of_bounds) << ErrorAttr << 2;
+ diag::err_attribute_argument_out_of_bounds)
+ << ErrorAttr << 2;
return;
}
QualType ErrorParam = BlockParams[ParamIdx - 1];
@@ -6720,10 +6704,10 @@ static void handleSwiftAsyncError(Sema &S, Decl *D, const ParsedAttr &AL) {
// For a type, enum constant, property, or variable declaration, this will
// validate either a simple identifier, or a qualified
// <code>context.identifier</code> name.
-static bool
-validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc,
- StringRef Name, unsigned &SwiftParamCount,
- bool &IsSingleParamInit) {
+static bool validateSwiftFunctionName(Sema &S, const ParsedAttr &AL,
+ SourceLocation Loc, StringRef Name,
+ unsigned &SwiftParamCount,
+ bool &IsSingleParamInit) {
SwiftParamCount = 0;
IsSingleParamInit = false;
@@ -6784,7 +6768,7 @@ validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc,
// Setters and subscripts must have at least one parameter.
if (IsSubscript) {
S.Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
- << AL << /* have at least one parameter */1;
+ << AL << /* have at least one parameter */ 1;
return false;
}
@@ -6810,7 +6794,7 @@ validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc,
if (!isValidAsciiIdentifier(CurrentParam)) {
S.Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
- << AL << /*parameter*/2;
+ << AL << /*parameter*/ 2;
return false;
}
@@ -6841,20 +6825,20 @@ validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc,
// Only instance subscripts are currently supported.
if (IsSubscript && !SelfLocation) {
S.Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
- << AL << /*have a 'self:' parameter*/2;
+ << AL << /*have a 'self:' parameter*/ 2;
return false;
}
IsSingleParamInit =
- SwiftParamCount == 1 && BaseName == "init" && CurrentParam != "_";
+ SwiftParamCount == 1 && BaseName == "init" && CurrentParam != "_";
// Check the number of parameters for a getter/setter.
if (IsGetter || IsSetter) {
// Setters have one parameter for the new value.
unsigned NumExpectedParams = IsGetter ? 0 : 1;
- unsigned ParamDiag =
- IsGetter ? diag::warn_attr_swift_name_getter_parameters
- : diag::warn_attr_swift_name_setter_parameters;
+ unsigned ParamDiag = IsGetter
+ ? diag::warn_attr_swift_name_getter_parameters
+ : diag::warn_attr_swift_name_setter_parameters;
// Instance methods have one parameter for "self".
if (SelfLocation)
@@ -6877,7 +6861,8 @@ validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc,
return false;
}
if (NewValueCount > 1) {
- S.Diag(Loc, diag::warn_attr_swift_name_subscript_setter_multiple_newValues)
+ S.Diag(Loc,
+ diag::warn_attr_swift_name_subscript_setter_multiple_newValues)
<< AL;
return false;
}
@@ -6904,7 +6889,7 @@ validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc,
bool Sema::DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc,
const ParsedAttr &AL, bool IsAsync) {
if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
- ArrayRef<ParmVarDecl*> Params;
+ ArrayRef<ParmVarDecl *> Params;
unsigned ParamCount;
if (const auto *Method = dyn_cast<ObjCMethodDecl>(D)) {
@@ -6936,8 +6921,8 @@ bool Sema::DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc,
unsigned SwiftParamCount;
bool IsSingleParamInit;
- if (!validateSwiftFunctionName(*this, AL, Loc, Name,
- SwiftParamCount, IsSingleParamInit))
+ if (!validateSwiftFunctionName(*this, AL, Loc, Name, SwiftParamCount,
+ IsSingleParamInit))
return false;
bool ParamCountValid;
@@ -6978,14 +6963,14 @@ bool Sema::DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc,
BaseName = ContextName;
ContextName = StringRef();
} else if (!isValidAsciiIdentifier(ContextName)) {
- Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
- << /*context*/1;
+ Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
+ << AL << /*context*/ 1;
return false;
}
if (!isValidAsciiIdentifier(BaseName)) {
- Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
- << /*basename*/0;
+ Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
+ << AL << /*basename*/ 0;
return false;
}
} else {
@@ -7093,8 +7078,7 @@ static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
}
}
- auto *AsyncAttr =
- ::new (S.Context) SwiftAsyncAttr(S.Context, AL, Kind, Idx);
+ auto *AsyncAttr = ::new (S.Context) SwiftAsyncAttr(S.Context, AL, Kind, Idx);
D->addAttr(AsyncAttr);
if (auto *ErrorAttr = D->getAttr<SwiftAsyncErrorAttr>())
@@ -7198,7 +7182,8 @@ static void handleHLSLNumThreadsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
if (X > 1024) {
S.Diag(AL.getArgAsExpr(0)->getExprLoc(),
- diag::err_hlsl_numthreads_argument_oor) << 0 << 1024;
+ diag::err_hlsl_numthreads_argument_oor)
+ << 0 << 1024;
return;
}
uint32_t Y;
@@ -7206,7 +7191,8 @@ static void handleHLSLNumThreadsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
if (Y > 1024) {
S.Diag(AL.getArgAsExpr(1)->getExprLoc(),
- diag::err_hlsl_numthreads_argument_oor) << 1 << 1024;
+ diag::err_hlsl_numthreads_argument_oor)
+ << 1 << 1024;
return;
}
uint32_t Z;
@@ -7214,7 +7200,8 @@ static void handleHLSLNumThreadsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
if (Z > ZMax) {
S.Diag(AL.getArgAsExpr(2)->getExprLoc(),
- diag::err_hlsl_numthreads_argument_oor) << 2 << ZMax;
+ diag::err_hlsl_numthreads_argument_oor)
+ << 2 << ZMax;
return;
}
@@ -7505,8 +7492,8 @@ static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
ARMInterruptAttr::InterruptType Kind;
if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
- S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
- << ArgLoc;
+ S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+ << AL << Str << ArgLoc;
return;
}
@@ -7759,7 +7746,7 @@ static void handleBPFPreserveAIRecord(Sema &S, RecordDecl *RD) {
}
static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D,
- const ParsedAttr &AL) {
+ const ParsedAttr &AL) {
auto *Rec = cast<RecordDecl>(D);
handleBPFPreserveAIRecord(S, Rec);
Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
@@ -7819,8 +7806,8 @@ Sema::mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL) {
if (const auto *ExistingAttr = FD->getAttr<WebAssemblyImportModuleAttr>()) {
if (ExistingAttr->getImportModule() == AL.getImportModule())
return nullptr;
- Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
- << ExistingAttr->getImportModule() << AL.getImportModule();
+ Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import)
+ << 0 << ExistingAttr->getImportModule() << AL.getImportModule();
Diag(AL.getLoc(), diag::note_previous_attribute);
return nullptr;
}
@@ -7828,8 +7815,8 @@ Sema::mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL) {
Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
return nullptr;
}
- return ::new (Context) WebAssemblyImportModuleAttr(Context, AL,
- AL.getImportModule());
+ return ::new (Context)
+ WebAssemblyImportModuleAttr(Context, AL, AL.getImportModule());
}
WebAssemblyImportNameAttr *
@@ -7839,8 +7826,8 @@ Sema::mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL) {
if (const auto *ExistingAttr = FD->getAttr<WebAssemblyImportNameAttr>()) {
if (ExistingAttr->getImportName() == AL.getImportName())
return nullptr;
- Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1
- << ExistingAttr->getImportName() << AL.getImportName();
+ Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import)
+ << 1 << ExistingAttr->getImportName() << AL.getImportName();
Diag(AL.getLoc(), diag::note_previous_attribute);
return nullptr;
}
@@ -7848,12 +7835,12 @@ Sema::mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL) {
Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
return nullptr;
}
- return ::new (Context) WebAssemblyImportNameAttr(Context, AL,
- AL.getImportName());
+ return ::new (Context)
+ WebAssemblyImportNameAttr(Context, AL, AL.getImportName());
}
-static void
-handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D,
+ const ParsedAttr &AL) {
auto *FD = cast<FunctionDecl>(D);
StringRef Str;
@@ -7869,8 +7856,8 @@ handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
WebAssemblyImportModuleAttr(S.Context, AL, Str));
}
-static void
-handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+static void handleWebAssemblyImportNameAttr(Sema &S, Decl *D,
+ const ParsedAttr &AL) {
auto *FD = cast<FunctionDecl>(D);
StringRef Str;
@@ -7885,12 +7872,11 @@ handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
FD->addAttr(::new (S.Context) WebAssemblyImportNameAttr(S.Context, AL, Str));
}
-static void handleRISCVInterruptAttr(Sema &S, Decl *D,
- const ParsedAttr &AL) {
+static void handleRISCVInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// Warn about repeated attributes.
if (const auto *A = D->getAttr<RISCVInterruptAttr>()) {
S.Diag(AL.getRange().getBegin(),
- diag::warn_riscv_repeated_interrupt_attribute);
+ diag::warn_riscv_repeated_interrupt_attribute);
S.Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
return;
}
@@ -7923,20 +7909,20 @@ static void handleRISCVInterruptAttr(Sema &S, Decl *D,
if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
- << /*RISC-V*/ 2 << 0;
+ << /*RISC-V*/ 2 << 0;
return;
}
if (!getFunctionOrMethodResultType(D)->isVoidType()) {
S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
- << /*RISC-V*/ 2 << 1;
+ << /*RISC-V*/ 2 << 1;
return;
}
RISCVInterruptAttr::InterruptType Kind;
if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
- S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
- << ArgLoc;
+ S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+ << AL << Str << ArgLoc;
return;
}
@@ -8119,7 +8105,7 @@ static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D,
// Also don't warn on function pointer typedefs.
const auto *TD = dyn_cast<TypedefNameDecl>(D);
if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
- TD->getUnderlyingType()->isFunctionType()))
+ TD->getUnderlyingType()->isFunctionType()))
return;
// Attribute can only be applied to function types.
if (!isa<FunctionDecl>(D)) {
@@ -8210,10 +8196,10 @@ static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) {
D->addAttr(NewAttr);
}
-MSInheritanceAttr *
-Sema::mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI,
- bool BestCase,
- MSInheritanceModel Model) {
+MSInheritanceAttr *Sema::mergeMSInheritanceAttr(Decl *D,
+ const AttributeCommonInfo &CI,
+ bool BestCase,
+ MSInheritanceModel Model) {
if (MSInheritanceAttr *IA = D->getAttr<MSInheritanceAttr>()) {
if (IA->getInheritanceModel() == Model)
return nullptr;
@@ -8264,7 +8250,7 @@ static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
}
static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
- SmallVector<Expr*, 1> Args;
+ SmallVector<Expr *, 1> Args;
if (!checkLockFunAttrCommon(S, D, AL, Args))
return;
@@ -8274,7 +8260,7 @@ static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
static void handleAcquireCapabilityAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
- SmallVector<Expr*, 1> Args;
+ SmallVector<Expr *, 1> Args;
if (!checkLockFunAttrCommon(S, D, AL, Args))
return;
@@ -8284,7 +8270,7 @@ static void handleAcquireCapabilityAttr(Sema &S, Decl *D,
static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
- SmallVector<Expr*, 2> Args;
+ SmallVector<Expr *, 2> Args;
if (!checkTryLockFunAttrCommon(S, D, AL, Args))
return;
@@ -8308,7 +8294,7 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl *D,
return;
// check that all arguments are lockable objects
- SmallVector<Expr*, 1> Args;
+ SmallVector<Expr *, 1> Args;
checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
if (Args.empty())
return;
@@ -8382,7 +8368,8 @@ static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
SanitizerMask() &&
SanitizerName != "coverage")
S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
- else if (isGlobalVar(D) && !isSanitizerAttributeAllowedOnGlobals(SanitizerName))
+ else if (isGlobalVar(D) &&
+ !isSanitizerAttributeAllowedOnGlobals(SanitizerName))
S.Diag(D->getLocation(), diag::warn_attribute_type_not_supported_global)
<< AL << SanitizerName;
Sanitizers.push_back(SanitizerName);
@@ -8857,7 +8844,7 @@ static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
D->addAttr(AcquireHandleAttr::Create(S.Context, Argument, AL));
}
-template<typename Attr>
+template <typename Attr>
static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
StringRef Argument;
if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument))
@@ -8865,7 +8852,7 @@ static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
D->addAttr(Attr::Create(S.Context, Argument, AL));
}
-template<typename Attr>
+template <typename Attr>
static void handleUnsafeBufferUsage(Sema &S, Decl *D, const ParsedAttr &AL) {
D->addAttr(Attr::Create(S.Context, AL));
}
@@ -8889,14 +8876,11 @@ static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
D->addAttr(::new (S.Context) CFGuardAttr(S.Context, AL, Arg));
}
-
template <typename AttrTy>
static const AttrTy *findEnforceTCBAttrByName(Decl *D, StringRef Name) {
auto Attrs = D->specific_attrs<AttrTy>();
- auto I = llvm::find_if(Attrs,
- [Name](const AttrTy *A) {
- return A->getTCBName() == Name;
- });
+ auto I = llvm::find_if(
+ Attrs, [Name](const AttrTy *A) { return A->getTCBName() == Name; });
return I == Attrs.end() ? nullptr : *I;
}
@@ -8908,12 +8892,12 @@ static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
// A function cannot be have both regular and leaf membership in the same TCB.
if (const ConflictingAttrTy *ConflictingAttr =
- findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
+ findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
// We could attach a note to the other attribute but in this case
// there's no need given how the two are very close to each other.
S.Diag(AL.getLoc(), diag::err_tcb_conflicting_attributes)
- << AL.getAttrName()->getName() << ConflictingAttr->getAttrName()->getName()
- << Argument;
+ << AL.getAttrName()->getName()
+ << ConflictingAttr->getAttrName()->getName() << Argument;
// Error recovery: drop the non-leaf attribute so that to suppress
// all future warnings caused by erroneous attributes. The leaf attribute
@@ -8930,10 +8914,10 @@ static AttrTy *mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL) {
// Check if the new redeclaration has different leaf-ness in the same TCB.
StringRef TCBName = AL.getTCBName();
if (const ConflictingAttrTy *ConflictingAttr =
- findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
+ findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
S.Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
- << ConflictingAttr->getAttrName()->getName()
- << AL.getAttrName()->getName() << TCBName;
+ << ConflictingAttr->getAttrName()->getName()
+ << AL.getAttrName()->getName() << TCBName;
// Add a note so that the user could easily find the conflicting attribute.
S.Diag(AL.getLoc(), diag::note_conflicting_attribute);
@@ -8944,18 +8928,18 @@ static AttrTy *mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL) {
}
ASTContext &Context = S.getASTContext();
- return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
+ return ::new (Context) AttrTy(Context, AL, AL.getTCBName());
}
EnforceTCBAttr *Sema::mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL) {
- return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
- *this, D, AL);
+ return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(*this, D,
+ AL);
}
-EnforceTCBLeafAttr *Sema::mergeEnforceTCBLeafAttr(
- Decl *D, const EnforceTCBLeafAttr &AL) {
- return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
- *this, D, AL);
+EnforceTCBLeafAttr *
+Sema::mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL) {
+ return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(*this, D,
+ AL);
}
//===----------------------------------------------------------------------===//
@@ -9112,7 +9096,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
switch (AL.getKind()) {
default:
- if (AL.getInfo().handleDeclAttribute(S, D, AL) != ParsedAttrInfo::NotHandled)
+ if (AL.getInfo().handleDeclAttribute(S, D, AL) !=
+ ParsedAttrInfo::NotHandled)
break;
if (!AL.isStmtAttr()) {
assert(AL.isTypeAttr() && "Non-type attribute not handled");
@@ -9286,13 +9271,13 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
handlePassObjectSizeAttr(S, D, AL);
break;
case ParsedAttr::AT_Constructor:
- handleConstructorAttr(S, D, AL);
+ handleConstructorAttr(S, D, AL);
break;
case ParsedAttr::AT_Deprecated:
handleDeprecatedAttr(S, D, AL);
break;
case ParsedAttr::AT_Destructor:
- handleDestructorAttr(S, D, AL);
+ handleDestructorAttr(S, D, AL);
break;
case ParsedAttr::AT_EnableIf:
handleEnableIfAttr(S, D, AL);
@@ -9483,7 +9468,7 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
handleVecTypeHint(S, D, AL);
break;
case ParsedAttr::AT_InitPriority:
- handleInitPriorityAttr(S, D, AL);
+ handleInitPriorityAttr(S, D, AL);
break;
case ParsedAttr::AT_Packed:
handlePackedAttr(S, D, AL);
@@ -10015,8 +10000,8 @@ static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A) {
S.Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
<< AL << AL.getRange();
} else {
- S.Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
- << AL.getRange();
+ S.Diag(AL.getLoc(), diag::warn_attribute_not_on_decl)
+ << AL << AL.getRange();
}
}
}
@@ -10059,7 +10044,7 @@ NamedDecl *Sema::DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II,
// a typedef.
QualType FDTy = FD->getType();
if (const auto *FT = FDTy->getAs<FunctionProtoType>()) {
- SmallVector<ParmVarDecl*, 16> Params;
+ SmallVector<ParmVarDecl *, 16> Params;
for (const auto &AI : FT->param_types()) {
ParmVarDecl *Param = BuildParmVarDeclForTypedef(NewFD, Loc, AI);
Param->setScopeInfo(0, Params.size());
@@ -10189,8 +10174,7 @@ static bool isForbiddenTypeAllowed(Sema &S, Decl *D,
// Private ivars are always okay. Unfortunately, people don't
// always properly make their ivars private, even in system headers.
// Plus we need to make fields okay, too.
- if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
- !isa<FunctionDecl>(D))
+ if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) && !isa<FunctionDecl>(D))
return false;
// Silently accept unsupported uses of __weak in both user and system
@@ -10243,7 +10227,6 @@ static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD,
DD.Triggered = true;
}
-
void Sema::PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
assert(DelayedDiagnostics.getCurrentPool());
DelayedDiagnosticPool &poppedPool = *DelayedDiagnostics.getCurrentPool();
@@ -10252,7 +10235,8 @@ void Sema::PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
// When delaying diagnostics to run in the context of a parsed
// declaration, we only want to actually emit anything if parsing
// succeeds.
- if (!decl) return;
+ if (!decl)
+ return;
// We emit all the active diagnostics in this pool or any of its
// parents. In general, we'll get one pool for the decl spec
@@ -10264,10 +10248,11 @@ void Sema::PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
const DelayedDiagnosticPool *pool = &poppedPool;
do {
bool AnyAccessFailures = false;
- for (DelayedDiagnosticPool::pool_iterator
- i = pool->pool_begin(), e = pool->pool_end(); i != e; ++i) {
+ for (DelayedDiagnosticPool::pool_iterator i = pool->pool_begin(),
+ e = pool->pool_end();
+ i != e; ++i) {
// This const_cast is a bit lame. Really, Triggered should be mutable.
- DelayedDiagnostic &diag = const_cast<DelayedDiagnostic&>(*i);
+ DelayedDiagnostic &diag = const_cast<DelayedDiagnostic &>(*i);
if (diag.Triggered)
continue;
More information about the cfe-commits
mailing list