Skip to content

Commit 4cd1404

Browse files
authored
Fix all compile warnings (llvm#2832)
Most are about unused variables and functions.
1 parent d7ddf53 commit 4cd1404

File tree

9 files changed

+8
-151
lines changed

9 files changed

+8
-151
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -15540,38 +15540,6 @@ static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T) {
1554015540
return Ctx.getIntWidth(T) >= Ctx.getIntWidth(Ctx.IntTy);
1554115541
}
1554215542

15543-
static Expr *ExpandAMDGPUPredicateBI(ASTContext &Ctx, CallExpr *CE) {
15544-
if (!CE->getBuiltinCallee())
15545-
return CXXBoolLiteralExpr::Create(Ctx, false, Ctx.BoolTy, CE->getExprLoc());
15546-
15547-
if (Ctx.getTargetInfo().getTriple().isSPIRV()) {
15548-
CE->setType(Ctx.getLogicalOperationType());
15549-
return CE;
15550-
}
15551-
15552-
bool P = false;
15553-
auto &TI = Ctx.getTargetInfo();
15554-
15555-
if (CE->getDirectCallee()->getName() == "__builtin_amdgcn_processor_is") {
15556-
auto *GFX = dyn_cast<StringLiteral>(CE->getArg(0)->IgnoreParenCasts());
15557-
auto TID = TI.getTargetID();
15558-
if (GFX && TID) {
15559-
auto N = GFX->getString();
15560-
P = TI.isValidCPUName(GFX->getString()) && TID->find(N) == 0;
15561-
}
15562-
} else {
15563-
auto *FD = cast<FunctionDecl>(CE->getArg(0)->getReferencedDeclOfCallee());
15564-
15565-
StringRef RF = Ctx.BuiltinInfo.getRequiredFeatures(FD->getBuiltinID());
15566-
llvm::StringMap<bool> CF;
15567-
Ctx.getFunctionFeatureMap(CF, FD);
15568-
15569-
P = Builtin::evaluateRequiredTargetFeatures(RF, CF);
15570-
}
15571-
15572-
return CXXBoolLiteralExpr::Create(Ctx, P, Ctx.BoolTy, CE->getExprLoc());
15573-
}
15574-
1557515543
ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
1557615544
UnaryOperatorKind Opc, Expr *InputExpr,
1557715545
bool IsAfterAmp) {
@@ -20465,88 +20433,6 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
2046520433
}
2046620434
}
2046720435

20468-
static bool ValidateAMDGPUPredicateBI(Sema &Sema, CallExpr *CE) {
20469-
if (CE->getDirectCallee()->getName() == "__builtin_amdgcn_processor_is") {
20470-
auto *GFX = dyn_cast<StringLiteral>(CE->getArg(0)->IgnoreParenCasts());
20471-
if (!GFX) {
20472-
Sema.Diag(CE->getExprLoc(),
20473-
diag::err_amdgcn_processor_is_arg_not_literal);
20474-
return false;
20475-
}
20476-
auto N = GFX->getString();
20477-
if (!Sema.getASTContext().getTargetInfo().isValidCPUName(N) &&
20478-
(!Sema.getASTContext().getAuxTargetInfo() ||
20479-
!Sema.getASTContext().getAuxTargetInfo()->isValidCPUName(N))) {
20480-
Sema.Diag(CE->getExprLoc(),
20481-
diag::err_amdgcn_processor_is_arg_invalid_value)
20482-
<< N;
20483-
return false;
20484-
}
20485-
} else {
20486-
auto *Arg = CE->getArg(0);
20487-
if (!Arg || Arg->getType() != Sema.getASTContext().BuiltinFnTy) {
20488-
Sema.Diag(CE->getExprLoc(),
20489-
diag::err_amdgcn_is_invocable_arg_invalid_value)
20490-
<< Arg;
20491-
return false;
20492-
}
20493-
}
20494-
20495-
return true;
20496-
}
20497-
20498-
static Expr *MaybeHandleAMDGPUPredicateBI(Sema &Sema, Expr *E, bool &Invalid) {
20499-
if (auto *UO = dyn_cast<UnaryOperator>(E)) {
20500-
auto *SE = dyn_cast<CallExpr>(UO->getSubExpr());
20501-
if (IsAMDGPUPredicateBI(SE)) {
20502-
assert(UO->getOpcode() == UnaryOperator::Opcode::UO_LNot &&
20503-
"__builtin_amdgcn_processor_is and __builtin_amdgcn_is_invocable "
20504-
"can only be used as operands of logical ops!");
20505-
20506-
if (!ValidateAMDGPUPredicateBI(Sema, SE)) {
20507-
Invalid = true;
20508-
return nullptr;
20509-
}
20510-
20511-
UO->setSubExpr(ExpandAMDGPUPredicateBI(Sema.getASTContext(), SE));
20512-
UO->setType(Sema.getASTContext().getLogicalOperationType());
20513-
20514-
return UO;
20515-
}
20516-
}
20517-
if (auto *BO = dyn_cast<BinaryOperator>(E)) {
20518-
auto *LHS = dyn_cast<CallExpr>(BO->getLHS());
20519-
auto *RHS = dyn_cast<CallExpr>(BO->getRHS());
20520-
if (IsAMDGPUPredicateBI(LHS) && IsAMDGPUPredicateBI(RHS)) {
20521-
assert(BO->isLogicalOp() &&
20522-
"__builtin_amdgcn_processor_is and __builtin_amdgcn_is_invocable "
20523-
"can only be used as operands of logical ops!");
20524-
20525-
if (!ValidateAMDGPUPredicateBI(Sema, LHS) ||
20526-
!ValidateAMDGPUPredicateBI(Sema, RHS)) {
20527-
Invalid = true;
20528-
return nullptr;
20529-
}
20530-
20531-
BO->setLHS(ExpandAMDGPUPredicateBI(Sema.getASTContext(), LHS));
20532-
BO->setRHS(ExpandAMDGPUPredicateBI(Sema.getASTContext(), RHS));
20533-
BO->setType(Sema.getASTContext().getLogicalOperationType());
20534-
20535-
return BO;
20536-
}
20537-
}
20538-
if (auto *CE = dyn_cast<CallExpr>(E))
20539-
if (IsAMDGPUPredicateBI(CE)) {
20540-
if (!ValidateAMDGPUPredicateBI(Sema, CE)) {
20541-
Invalid = true;
20542-
return nullptr;
20543-
}
20544-
return ExpandAMDGPUPredicateBI(Sema.getASTContext(), CE);
20545-
}
20546-
20547-
return nullptr;
20548-
}
20549-
2055020436
ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E,
2055120437
bool IsConstexpr) {
2055220438
DiagnoseAssignmentAsCondition(E);

compiler-rt/lib/asan/asan_errors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,14 @@ static uptr ScanForMagicUp(uptr start, uptr hi, uptr magic0, uptr magic1) {
737737

738738
void ErrorNonSelfAMDGPU::PrintMallocStack() {
739739
// Facts about asan malloc on device
740-
const uptr magic = 0xfedcba1ee1abcdefULL;
740+
const uptr magic = static_cast<uptr>(0xfedcba1ee1abcdefULL);
741741
const uptr offset = 32;
742742
const uptr min_chunk_size = 96;
743743
const uptr min_alloc_size = 48;
744744

745745
Decorator d;
746746
HeapAddressDescription addr_description;
747-
747+
748748
if (GetHeapAddressInformation(device_address[0], access_size,
749749
&addr_description) &&
750750
addr_description.chunk_access.chunk_size >= min_chunk_size) {

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
20182018
if (ProcessedLifetimes.insert(L).second) {
20192019
if (auto *AddCU = dyn_cast<DICompileUnit>(GV->getScope())) {
20202020
AddCULifetimeMap[AddCU].push_back(L);
2021-
} else if (auto *AddNS = dyn_cast<DINamespace>(GV->getScope())) {
2021+
} else if (isa<DINamespace>(GV->getScope())) {
20222022
// FIXME(KZHURAVL): Properly support DINamespace.
20232023
} else if (auto *AddSP = dyn_cast<DISubprogram>(GV->getScope())) {
20242024
SPLifetimeMap[AddSP].push_back(L);

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,9 @@ std::optional<NewOpResult> DwarfExpression::traverse(DIOp::Arg Arg,
991991
if (IsFragment)
992992
emitOp(dwarf::DW_OP_lit0);
993993

994-
unsigned RegSize = 0;
995994
for (auto &Reg : Regs) {
996995
if (Reg.SubRegSize % 8)
997996
return std::nullopt;
998-
RegSize += Reg.SubRegSize;
999997
if (Reg.DwarfRegNo >= 0)
1000998
addReg(Reg.DwarfRegNo, Reg.Comment);
1001999
emitOp(dwarf::DW_OP_piece);

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
14431443
const DbgDefInst &DDI = *cast<DbgDefInst>(II);
14441444
const Value *Referrer = DDI.getReferrer();
14451445
assert(Referrer);
1446-
if (const auto *UV = dyn_cast<UndefValue>(Referrer)) {
1446+
if (isa<UndefValue>(Referrer)) {
14471447
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
14481448
TII.get(TargetOpcode::DBG_DEF))
14491449
.addMetadata(DDI.getLifetime())

llvm/lib/Debuginfod/Debuginfod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Expected<std::string> getCachedOrDownloadArtifact(
305305
Error Err = Client.perform(Request, Handler);
306306
if (Err)
307307
return std::move(Err);
308-
if (Err = Handler.commit())
308+
if ((Err = Handler.commit()))
309309
return std::move(Err);
310310

311311
unsigned Code = Client.responseCode();

llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -209,27 +209,6 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
209209
SecName.str().c_str());
210210
}
211211

212-
static Error dumpRawDataURIToFile(StringRef Filename, int64_t Offset,
213-
int64_t Size, ObjectFile &Obj) {
214-
SmallString<2048> NameBuf;
215-
raw_svector_ostream OutputFileName(NameBuf);
216-
OutputFileName << Obj.getFileName().str() << "-offset" << Offset << "-size"
217-
<< Size << ".co";
218-
219-
Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
220-
FileOutputBuffer::create(OutputFileName.str(), Size);
221-
222-
if (!BufferOrErr)
223-
return BufferOrErr.takeError();
224-
225-
MemoryBufferRef Input = Obj.getMemoryBufferRef();
226-
std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr);
227-
std::copy(Input.getBufferStart(), Input.getBufferStart() + Size,
228-
Buf->getBufferStart());
229-
230-
return Buf->commit();
231-
}
232-
233212
Error Object::compressOrDecompressSections(const CommonConfig &Config) {
234213
// Build a list of sections we are going to replace.
235214
// We can't call `addSection` while iterating over sections,

llvm/tools/llvm-objcopy/ObjcopyOptions.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static Expected<uint8_t> parseVisibilityType(StringRef VisType) {
286286
return type;
287287
}
288288

289-
static void llvm::objcopy::parseDumpOffloadBundle(StringRef URI) {
289+
static void parseDumpOffloadBundle(StringRef URI) {
290290
if (Error Err = object::extractOffloadBundleByURI(URI))
291291
outs() << "Failed to extract from URI.";
292292
}
@@ -758,9 +758,8 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
758758
"too many positional arguments");
759759

760760
if (Arg *A = InputArgs.getLastArg(OBJCOPY_dump_offload_bundle)) {
761-
for (StringRef URIStr : llvm::split(A->getValue(), ",")) {
762-
llvm::objcopy::parseDumpOffloadBundle(URIStr);
763-
}
761+
for (StringRef URIStr : llvm::split(A->getValue(), ","))
762+
parseDumpOffloadBundle(URIStr);
764763
}
765764

766765
if (Config.NeedPositional) {

llvm/tools/llvm-objcopy/ObjcopyOptions.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr,
5151
Expected<DriverConfig>
5252
parseStripOptions(ArrayRef<const char *> ArgsArr,
5353
llvm::function_ref<Error(Error)> ErrorCallback);
54-
55-
// parseDumpURI reads a URI as a string, and extracts the raw memory into a
56-
// code object file named from the URI string given
57-
static void parseDumpOffloadBundle(StringRef URI);
58-
5954
} // namespace objcopy
6055
} // namespace llvm
6156

0 commit comments

Comments
 (0)