CGFunctionInfo::CGFunctionInfo(QualType ResTy, const llvm::SmallVector<QualType, 16> &ArgTys) { NumArgs = ArgTys.size(); Args = new ArgInfo[1 + NumArgs]; Args[0].type = ResTy; for (unsigned i = 0; i < NumArgs; ++i) Args[1 + i].type = ArgTys[i]; }
std::string clang_c_convertert::parse_float( llvm::SmallVector<char, 32> &src, mp_integer &significand, mp_integer &exponent) { // {digit}{dot}{31 digits}[+-]{exponent} unsigned p = 0; // get whole number std::string str_whole_number = ""; str_whole_number += src[p++]; // skip dot assert(src[p] == '.'); p++; // get fraction part std::string str_fraction_part = ""; while (src[p] != 'E') str_fraction_part += src[p++]; // skip E assert(src[p] == 'E'); p++; // get exponent assert(src[p] == '+' || src[p] == '-'); // skip + if(src[p] == '+') p++; std::string str_exponent = ""; str_exponent += src[p++]; while (p < src.size()) str_exponent += src[p++]; std::string str_number = str_whole_number + str_fraction_part; if (str_number.empty()) significand = 0; else significand = string2integer(str_number); if (str_exponent.empty()) exponent = 0; else exponent = string2integer(str_exponent); exponent -= str_fraction_part.size(); return str_whole_number; }
CGFunctionInfo::CGFunctionInfo(unsigned _CallingConvention, QualType ResTy, const llvm::SmallVector<QualType, 16> &ArgTys) : CallingConvention(_CallingConvention), EffectiveCallingConvention(_CallingConvention) { NumArgs = ArgTys.size(); Args = new ArgInfo[1 + NumArgs]; Args[0].type = ResTy; for (unsigned i = 0; i < NumArgs; ++i) Args[1 + i].type = ArgTys[i]; }
/** * 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; }
///\brief Checks for clashing names when trying to extract a declaration. /// ///\returns true if there is another declaration with the same name bool DeclExtractor::CheckForClashingNames( const llvm::SmallVector<NamedDecl*, 4>& Decls, DeclContext* DC, Scope* S) { for (size_t i = 0; i < Decls.size(); ++i) { NamedDecl* ND = Decls[i]; if (TagDecl* TD = dyn_cast<TagDecl>(ND)) { LookupResult Previous(*m_Sema, ND->getDeclName(), ND->getLocation(), Sema::LookupTagName, Sema::ForRedeclaration ); m_Sema->LookupName(Previous, S); // There is no function diagnosing the redeclaration of tags (eg. enums). // So either we have to do it by hand or we can call the top-most // function that does the check. Currently the top-most clang function // doing the checks creates an AST node, which we don't want. if (!CheckTagDeclaration(TD, Previous)) return true; } else if (VarDecl* VD = dyn_cast<VarDecl>(ND)) { LookupResult Previous(*m_Sema, ND->getDeclName(), ND->getLocation(), Sema::LookupOrdinaryName, Sema::ForRedeclaration ); m_Sema->LookupName(Previous, S); m_Sema->CheckVariableDeclaration(VD, Previous); if (VD->isInvalidDecl()) return true; // This var decl will likely get referenced later; claim that it's used. VD->setIsUsed(); } } return false; }