本文整理汇总了C++中llvm::SmallVector::back方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallVector::back方法的具体用法?C++ SmallVector::back怎么用?C++ SmallVector::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::SmallVector
的用法示例。
在下文中一共展示了SmallVector::back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFileStream
void MetaProcessor::setFileStream(llvm::StringRef file, bool append, int fd,
llvm::SmallVector<llvm::SmallString<128>, 2>& prevFileStack) {
// If we have a fileName to redirect to store it.
if (!file.empty()) {
prevFileStack.push_back(file);
// pop and push a null terminating 0.
// SmallVectorImpl<T> does not have a c_str(), thus instead of casting to
// a SmallString<T> we null terminate the data that we have and pop the
// 0 char back.
prevFileStack.back().push_back(0);
prevFileStack.back().pop_back();
if (!append) {
FILE * f;
if (!(f = fopen(file.data(), "w"))) {
llvm::errs() << "cling::MetaProcessor::setFileStream:"
" The file path " << file.data() << "is not valid.";
} else {
fclose(f);
}
}
// Else unredirection, so switch to the previous file.
} else {
// If there is no previous file on the stack we pop the file
if (!prevFileStack.empty()) {
prevFileStack.pop_back();
}
}
}
示例2: rankArgsMatch
/**
* Check if rank arguments of send, recv pair match.
*
* @return is matching
*/
bool MPICheckerAST::rankArgsMatch(const MPICall &sendCall,
const MPICall &recvCall,
const MPIRankCase &sendCase,
const MPIRankCase &recvCase) const {
// match special case
if (isFirstLastPair(sendCall, recvCall, sendCase, recvCase)) return true;
// compare ranks
const auto &rankArgSend = sendCall.arg(MPIPointToPoint::kRank);
const auto &rankArgRecv = recvCall.arg(MPIPointToPoint::kRank);
if (rankArgSend.valueSequence().size() !=
rankArgRecv.valueSequence().size())
return false;
// build sequences without last operator(skip first element)
const llvm::SmallVector<std::string, 4> sendValSeq{
rankArgSend.valueSequence().begin() + 1,
rankArgSend.valueSequence().end()},
recvValSeq{rankArgRecv.valueSequence().begin() + 1,
rankArgRecv.valueSequence().end()};
bool containsSubtraction{false};
for (size_t i = 0; i < sendValSeq.size(); ++i) {
if (sendValSeq[i] == "-" || recvValSeq[i] == "-") {
containsSubtraction = true;
break;
}
}
// check ordered
if (containsSubtraction && (sendValSeq != recvValSeq)) return false;
// check permutation
if (!containsSubtraction &&
(!cont::isPermutation(sendValSeq, recvValSeq))) {
return false;
}
// last (value|var|function) must be identical
if (sendValSeq.back() != recvValSeq.back()) return false;
// last operator must be inverse
if (!rankArgSend.isLastOperatorInverse(rankArgRecv)) return false;
return true;
}