Skip to content

Commit

Permalink
Fixed warning from static code analyser
Browse files Browse the repository at this point in the history
.
  • Loading branch information
mshelego authored and sys-cmllvm committed Feb 6, 2024
1 parent ef56cac commit 1ba2c43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion GenXIntrinsics/include/llvmVCWrapper/IR/Function.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*========================== begin_copyright_notice ============================
Copyright (C) 2020-2021 Intel Corporation
Copyright (C) 2020-2024 Intel Corporation
SPDX-License-Identifier: MIT
Expand All @@ -15,6 +15,22 @@ namespace VCINTR {

namespace Function {

inline llvm::Argument *getArg(const llvm::Function &F, unsigned ArgNo) {
assert(F.arg_size() > ArgNo);
llvm::Argument *Arg = nullptr;

#if LLVM_VERSION_MAJOR < 10
// similar to lvm::Function::getArg implementation
auto ArgIt = F.arg_begin();
std::advance(ArgIt, ArgNo);
Arg = const_cast<llvm::Argument *>(&*ArgIt);
#else
Arg = F.getArg(ArgNo);
#endif

return Arg;
}

inline void addAttributeAtIndex(llvm::Function &F, unsigned Index,
llvm::Attribute Attr) {
#if VC_INTR_LLVM_VERSION_MAJOR >= 14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void SEVUtil::manageSEVAttributes(Function &OldF, Function &NewF) {
for (Function::arg_iterator ArgIt = NewF.arg_begin(), E = NewF.arg_end();
ArgIt != E; ++ArgIt) {
auto ArgNo = ArgIt->getArgNo();
auto *OldTy = (OldF.arg_begin() + ArgNo)->getType();
auto *OldTy = VCINTR::Function::getArg(OldF, ArgNo)->getType();
auto *NewTy = ArgIt->getType();
manageSEVAttribute(NewF, OldTy, NewTy, ArgNo + 1);
}
Expand Down

0 comments on commit 1ba2c43

Please sign in to comment.