Fix frequent warnings on gcc and clang (#4175)

This commit is contained in:
Minmin Gong 2022-01-20 13:43:05 -08:00 коммит произвёл GitHub
Родитель e9378896be
Коммит 2bd9843e95
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 14 добавлений и 10 удалений

Просмотреть файл

@ -79,7 +79,7 @@ PointerInfo GetPointerInfo(Value* V, PointerInfoMap &ptrInfoMap) {
// }
}
return ptrInfoMap[V];
};
}
struct ValueInfo {
bool isCbuffer : 1;

Просмотреть файл

@ -1094,7 +1094,7 @@ private:
void UpdateFunctionToShaderCompat(const llvm::Function* dxilFunc) {
#define SFLAG(stage) ((unsigned)1 << (unsigned)DXIL::ShaderKind::stage)
for (const auto &user : dxilFunc->users()) {
for (const llvm::User *user : dxilFunc->users()) {
if (const llvm::CallInst *CI = dyn_cast<const llvm::CallInst>(user)) {
// Find calling function
const llvm::Function *F = cast<const llvm::Function>(CI->getParent()->getParent());
@ -1214,7 +1214,7 @@ private:
}
void UpdateFunctionDependency(llvm::Function *F) {
for (const auto &user : F->users()) {
for (const llvm::User *user : F->users()) {
llvm::SmallVector<const llvm::Function*, 8> functions;
FindUsingFunctions(user, functions);
for (const llvm::Function *userFunction : functions) {

Просмотреть файл

@ -894,7 +894,7 @@ private:
SmallVector<StringRef, 14> Splits;
ArgSpec.split(Splits, ",");
for (const StringRef Split : Splits)
for (const StringRef &Split : Splits)
{
StringRef Field = Split.trim();
StringRef HighLevelArgInfo;

Просмотреть файл

@ -2441,7 +2441,7 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
}
// Add target-dependent experimental function attributes
for (const auto &Attr : FD->specific_attrs<HLSLExperimentalAttr>()) {
for (const HLSLExperimentalAttr *Attr : FD->specific_attrs<HLSLExperimentalAttr>()) {
F->addFnAttr(Twine("exp-", Attr->getName()).str(), Attr->getValue());
}

Просмотреть файл

@ -39,7 +39,7 @@
namespace CGHLSLMSHelper
{
struct Scope;
};
}
namespace llvm {
class BasicBlock;

Просмотреть файл

@ -282,7 +282,7 @@ std::pair<uint32_t, uint32_t> AlignmentSizeCalculator::getAlignmentAndSize(
// If this struct is derived from some other structs, place an implicit
// field at the very beginning for the base struct.
if (const auto *cxxDecl = dyn_cast<CXXRecordDecl>(structType->getDecl())) {
for (const auto base : cxxDecl->bases()) {
for (const auto &base : cxxDecl->bases()) {
uint32_t memberAlignment = 0, memberSize = 0;
std::tie(memberAlignment, memberSize) =
getAlignmentAndSize(base.getType(), rule, isRowMajor, stride);

Просмотреть файл

@ -45,6 +45,8 @@ public:
/// regardless of their polymorphism.
bool visitInstruction(SpirvInstruction *);
using Visitor::visit;
private:
/// Emits error to the diagnostic engine associated with this visitor.
template <unsigned N>

Просмотреть файл

@ -446,7 +446,7 @@ const SpirvType *LowerTypeVisitor::lowerType(QualType type,
// If this struct is derived from some other struct, place an implicit
// field at the very beginning for the base struct.
if (const auto *cxxDecl = dyn_cast<CXXRecordDecl>(decl)) {
for (const auto base : cxxDecl->bases()) {
for (const auto &base : cxxDecl->bases()) {
fields.push_back(HybridStructType::FieldInfo(base.getType()));
}
}

Просмотреть файл

@ -48,6 +48,8 @@ public:
/// regardless of their polymorphism.
bool visitInstruction(SpirvInstruction *) { return true; }
using Visitor::visit;
private:
// Invokes visitor for each operand of the debug instruction `di`. If
// `visitor` returns false, it stops and returns.

Просмотреть файл

@ -10401,9 +10401,9 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
// HLSL Change Starts
// Handle HLSL binary operands differently
if (getLangOpts().HLSL &&
if ((getLangOpts().HLSL &&
(!getLangOpts().EnableOperatorOverloading ||
!hlsl::IsUserDefinedRecordType(LHSExpr->getType())) ||
!hlsl::IsUserDefinedRecordType(LHSExpr->getType()))) ||
!hlsl::DoesTypeDefineOverloadedOperator(
LHSExpr->getType(), clang::BinaryOperator::getOverloadedOperator(Opc),
RHSExpr->getType())) {