diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index 15c8d1af1876e38793f77a8556ff743209dcd0c7..f663f9658e66d0e692881f3d1012df2ca22e6bbc 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index f49494976a191bccfe97a5a419304cfd341cb4e8..d017892872e8cba213582e42bce07ae2c4278466 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/deplibs/libmplutil.a b/src/deplibs/libmplutil.a index a5552ca88ff23b13f9e2389c545485b5e5d3bab2..f36e3829ab84c2e3c849fef9a2ac5e41633f2e64 100644 Binary files a/src/deplibs/libmplutil.a and b/src/deplibs/libmplutil.a differ diff --git a/src/maple_driver/src/option_parser.cpp b/src/maple_driver/src/option_parser.cpp index 070dfe2b7662480214c55824e80edd6e9bac0b49..d0a0935cf0e2d74b51b26f91dcacd2faff1f1c65 100644 --- a/src/maple_driver/src/option_parser.cpp +++ b/src/maple_driver/src/option_parser.cpp @@ -41,7 +41,7 @@ void OptionParser::InsertExtraUsage(const Descriptor &usage) { InsertOption(usage.longOption, tempUsage); } rawUsages.push_back(tempUsage); - index++; + ++index; } } diff --git a/src/maple_ipa/src/callgraph.cpp b/src/maple_ipa/src/callgraph.cpp index afbfe8162f669ec4e6e881dfa201e42cd738955f..752e33a5697bff3c8e48f071999e860c2769b9b6 100644 --- a/src/maple_ipa/src/callgraph.cpp +++ b/src/maple_ipa/src/callgraph.cpp @@ -96,7 +96,7 @@ void CGNode::DumpDetail() const { LogInfo::MapleLogger() << std::endl; } if (HasSetVCallCandidates()) { - for (uint32 i = 0; i < vcallCands.size(); i++) { + for (uint32 i = 0; i < vcallCands.size(); ++i) { LogInfo::MapleLogger() << " virtual call candidates: " << vcallCands[i]->GetName() << "\n"; } } @@ -327,6 +327,7 @@ CGNode *CallGraph::GetOrGenCGNode(PUIdx puIdx, bool isVcall, bool isIcall) { if (isVcall && !node->IsVcallCandidatesValid()) { MIRFunction *mirFunc = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(puIdx); Klass *klass = nullptr; + CHECK_NULL_FATAL(mirFunc); if (StringUtils::StartsWith(mirFunc->GetBaseClassName(), JARRAY_PREFIX_STR)) { // Array klass = klassh->GetKlassFromName(namemangler::kJavaLangObjectStr); } else { @@ -422,8 +423,8 @@ void CallGraph::HandleBody(MIRFunction &func, BlockNode &body, CGNode &node, uin if (op == OP_comment) { continue; } else if (op == OP_doloop) { - DoloopNode *n = static_cast(stmt); - HandleBody(func, *n->GetDoBody(), node, loopDepth + 1); + DoloopNode *doloopNode = static_cast(stmt); + HandleBody(func, *doloopNode->GetDoBody(), node, loopDepth + 1); } else if (op == OP_dowhile || op == OP_while) { WhileStmtNode *n = static_cast(stmt); HandleBody(func, *n->GetBody(), node, loopDepth + 1); @@ -439,8 +440,8 @@ void CallGraph::HandleBody(MIRFunction &func, BlockNode &body, CGNode &node, uin switch (ct) { case kCallTypeVirtualCall: { PUIdx calleePUIdx = (static_cast(stmt))->GetPUIdx(); - MIRFunction *calleefunc = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(calleePUIdx); - CallInfo *callInfo = GenCallInfo(kCallTypeVirtualCall, calleefunc, stmt, loopDepth, stmt->GetStmtID()); + MIRFunction *calleeFunc = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(calleePUIdx); + CallInfo *callInfo = GenCallInfo(kCallTypeVirtualCall, calleeFunc, stmt, loopDepth, stmt->GetStmtID()); // Retype makes object type more inaccurate. StmtNode *stmtPrev = static_cast(stmt)->GetPrev(); if (stmtPrev != nullptr && stmtPrev->GetOpCode() == OP_dassign) { @@ -457,8 +458,8 @@ void CallGraph::HandleBody(MIRFunction &func, BlockNode &body, CGNode &node, uin CHECK_FATAL(type->IsMIRPtrType(), "Must be ptr type."); MIRPtrType *ptrType = static_cast(type); MIRType *targetType = ptrType->GetPointedType(); - MIRFunction *calleefuncT = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(calleePUIdx); - GStrIdx calleeFuncStrIdx = calleefuncT->GetBaseFuncNameWithTypeStrIdx(); + MIRFunction *calleeFuncT = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(calleePUIdx); + GStrIdx calleeFuncStrIdx = calleeFuncT->GetBaseFuncNameWithTypeStrIdx(); Klass *klass = klassh->GetKlassFromTyIdx(targetType->GetTypeIndex()); if (klass != nullptr) { const MIRFunction *method = klass->GetMethod(calleeFuncStrIdx); @@ -467,7 +468,7 @@ void CallGraph::HandleBody(MIRFunction &func, BlockNode &body, CGNode &node, uin } else { std::string funcName = klass->GetKlassName(); funcName.append((namemangler::kNameSplitterStr)); - funcName.append(calleefuncT->GetBaseFuncNameWithType()); + funcName.append(calleeFuncT->GetBaseFuncNameWithType()); MIRFunction *methodT = mirBuilder->GetOrCreateFunction(funcName, (TyIdx) (PTY_void)); methodT->SetBaseClassNameStrIdx(klass->GetKlassNameStrIdx()); methodT->SetBaseFuncNameWithTypeStrIdx(calleeFuncStrIdx); @@ -477,7 +478,7 @@ void CallGraph::HandleBody(MIRFunction &func, BlockNode &body, CGNode &node, uin } } } - // Add a call node whether or not the calleefunc has its body + // Add a call node whether or not the calleeFunc has its body CGNode *calleeNode = GetOrGenCGNode(calleePUIdx, true); CHECK_FATAL(calleeNode != nullptr, "calleenode is null"); CHECK_FATAL(calleeNode->IsVcallCandidatesValid(), "vcall candidate must be valid"); @@ -523,7 +524,6 @@ void CallGraph::HandleBody(MIRFunction &func, BlockNode &body, CGNode &node, uin if (klass == nullptr) { // Fix CI continue; } - ASSERT(klass != nullptr, "Klass not found"); MapleVector *cands = klass->GetCandidates(calleeFunc->GetBaseFuncNameWithTypeStrIdx()); // continue to search its implinterfaces if (cands == nullptr) { @@ -590,7 +590,7 @@ void CallGraph::AddCallGraphNode(MIRFunction &func) { } static void ResetInferredType(std::vector &inferredSymbols) { - for (unsigned int i = 0; i < inferredSymbols.size(); i++) { + for (unsigned int i = 0; i < inferredSymbols.size(); ++i) { inferredSymbols[i]->SetInferredTyIdx(TyIdx()); } inferredSymbols.clear(); @@ -604,7 +604,7 @@ static void ResetInferredType(std::vector &inferredSymbols, MIRSymbo return; } unsigned int i = 0; - for (; i < inferredSymbols.size(); i++) { + for (; i < inferredSymbols.size(); ++i) { if (inferredSymbols[i] == s) { s->SetInferredTyIdx(TyIdx()); inferredSymbols.erase(inferredSymbols.begin() + i); @@ -616,7 +616,7 @@ static void ResetInferredType(std::vector &inferredSymbols, MIRSymbo static void SetInferredType(std::vector &inferredSymbols, MIRSymbol &s, TyIdx idx) { s.SetInferredTyIdx(idx); unsigned int i = 0; - for (; i < inferredSymbols.size(); i++) { + for (; i < inferredSymbols.size(); ++i) { if (inferredSymbols[i] == &s) { break; } @@ -629,7 +629,7 @@ static void SetInferredType(std::vector &inferredSymbols, MIRSymbol void IPODevirtulize::SearchDefInClinit(const Klass &klass) { MIRClassType *classType = static_cast(klass.GetMIRStructType()); std::vector staticFinalPrivateSymbols; - for (uint32 i = 0; i < classType->GetStaticFields().size(); i++) { + for (uint32 i = 0; i < classType->GetStaticFields().size(); ++i) { FieldAttrs attribute = classType->GetStaticFields()[i].second.second; if (attribute.GetAttr(FLDATTR_final)) { staticFinalPrivateSymbols.push_back( @@ -659,7 +659,7 @@ void IPODevirtulize::SearchDefInClinit(const Klass &klass) { DassignNode *dassignNode = static_cast(stmt); MIRSymbol *leftSymbol = func->GetLocalOrGlobalSymbol(dassignNode->GetStIdx()); unsigned i = 0; - for (; i < staticFinalPrivateSymbols.size(); i++) { + for (; i < staticFinalPrivateSymbols.size(); ++i) { if (staticFinalPrivateSymbols[i] == leftSymbol) { break; } @@ -706,12 +706,12 @@ void IPODevirtulize::SearchDefInClinit(const Klass &klass) { // ignore all side effect of initizlizor continue; } - for (unsigned int i = 0; i < callNode->GetReturnVec().size(); i++) { + for (unsigned int i = 0; i < callNode->GetReturnVec().size(); ++i) { StIdx stIdx = callNode->GetReturnVec()[i].first; MIRSymbol *tmpSymbol = func->GetLocalOrGlobalSymbol(stIdx); ResetInferredType(gcmallocSymbols, tmpSymbol); } - for (size_t i = 0; i < callNode->GetNopndSize(); i++) { + for (size_t i = 0; i < callNode->GetNopndSize(); ++i) { BaseNode *node = callNode->GetNopndAt(i); CHECK_NULL_FATAL(node); if (node->GetOpCode() != OP_dread) { @@ -741,7 +741,7 @@ void IPODevirtulize::SearchDefInMemberMethods(const Klass &klass) { SearchDefInClinit(klass); MIRClassType *classType = static_cast(klass.GetMIRStructType()); std::vector finalPrivateFieldID; - for (uint32 i = 0; i < classType->GetFieldsSize(); i++) { + for (uint32 i = 0; i < classType->GetFieldsSize(); ++i) { FieldAttrs attribute = classType->GetFields()[i].second.second; if (attribute.GetAttr(FLDATTR_final)) { FieldID id = mirBuilder->GetStructFieldIDFromFieldNameParentFirst( @@ -762,7 +762,7 @@ void IPODevirtulize::SearchDefInMemberMethods(const Klass &klass) { } ASSERT(!initMethods.empty(), "Must have initializor"); StmtNode *stmtNext = nullptr; - for (unsigned int i = 0; i < initMethods.size(); i++) { + for (unsigned int i = 0; i < initMethods.size(); ++i) { MIRFunction *func = initMethods[i]; if (func->GetBody() == nullptr) { continue; @@ -803,12 +803,12 @@ void IPODevirtulize::SearchDefInMemberMethods(const Klass &klass) { // ignore all side effect of initizlizor continue; } - for (size_t j = 0; j < callNode->GetReturnVec().size(); j++) { + for (size_t j = 0; j < callNode->GetReturnVec().size(); ++j) { StIdx stIdx = callNode->GetReturnVec()[j].first; MIRSymbol *tmpSymbol = func->GetLocalOrGlobalSymbol(stIdx); ResetInferredType(gcmallocSymbols, tmpSymbol); } - for (size_t j = 0; j < callNode->GetNopndSize(); j++) { + for (size_t j = 0; j < callNode->GetNopndSize(); ++j) { BaseNode *node = callNode->GetNopndAt(j); if (node->GetOpCode() != OP_dread) { continue; @@ -835,7 +835,7 @@ void IPODevirtulize::SearchDefInMemberMethods(const Klass &klass) { // set field of current class FieldID fieldID = iassignNode->GetFieldID(); unsigned j = 0; - for (; j < finalPrivateFieldID.size(); j++) { + for (; j < finalPrivateFieldID.size(); ++j) { if (finalPrivateFieldID[j] == fieldID) { break; } @@ -932,7 +932,7 @@ void DoDevirtual(const Klass &klass, const KlassHierarchy &klassh) { std::vector klassVector; klassVector.push_back(currKlass); bool hasDevirtualed = false; - for (unsigned int index = 0; index < klassVector.size(); index++) { + for (unsigned int index = 0; index < klassVector.size(); ++index) { Klass *tmpKlass = klassVector[index]; for (MIRFunction *const &method : tmpKlass->GetMethods()) { if (calleeFunc->GetBaseFuncNameWithTypeStrIdx() == method->GetBaseFuncNameWithTypeStrIdx()) { @@ -964,7 +964,7 @@ void DoDevirtual(const Klass &klass, const KlassHierarchy &klassh) { } } if (hasDevirtualed) { - for (size_t i = 0; i < calleeNode->GetNopndSize(); i++) { + for (size_t i = 0; i < calleeNode->GetNopndSize(); ++i) { BaseNode *node = calleeNode->GetNopndAt(i); CHECK_NULL_FATAL(node); if (node->GetOpCode() != OP_dread) { @@ -976,7 +976,7 @@ void DoDevirtual(const Klass &klass, const KlassHierarchy &klassh) { } if (op == OP_interfacecallassigned || op == OP_virtualcallassigned) { CallNode *callNode = static_cast(stmt); - for (unsigned int i = 0; i < callNode->GetReturnVec().size(); i++) { + for (unsigned int i = 0; i < callNode->GetReturnVec().size(); ++i) { StIdx stIdx = callNode->GetReturnVec()[i].first; MIRSymbol *tmpSymbol = func->GetLocalOrGlobalSymbol(stIdx); ResetInferredType(inferredSymbols, tmpSymbol); @@ -1121,7 +1121,7 @@ void DoDevirtual(const Klass &klass, const KlassHierarchy &klassh) { LogInfo::MapleLogger() << " To :" << GlobalTables::GetFunctionTable().GetFunctionFromPuidx(calleeNode->GetPUIdx())->GetName() << '\n'; } - for (size_t i = 0; i < calleeNode->GetNopndSize(); i++) { + for (size_t i = 0; i < calleeNode->GetNopndSize(); ++i) { BaseNode *node = calleeNode->GetNopndAt(i); if (node->GetOpCode() != OP_dread) { continue; @@ -1132,7 +1132,7 @@ void DoDevirtual(const Klass &klass, const KlassHierarchy &klassh) { } if (op == OP_interfacecallassigned || op == OP_virtualcallassigned) { CallNode *callNode = static_cast(stmt); - for (unsigned int i = 0; i < callNode->GetReturnVec().size(); i++) { + for (unsigned int i = 0; i < callNode->GetReturnVec().size(); ++i) { StIdx stidx = callNode->GetReturnVec()[i].first; MIRSymbol *tmpSymbol = func->GetLocalOrGlobalSymbol(stidx); ResetInferredType(inferredSymbols, tmpSymbol); @@ -1147,12 +1147,12 @@ void DoDevirtual(const Klass &klass, const KlassHierarchy &klassh) { case OP_call: case OP_callassigned: { CallNode *callNode = static_cast(stmt); - for (size_t i = 0; i < callNode->GetReturnVec().size(); i++) { + for (size_t i = 0; i < callNode->GetReturnVec().size(); ++i) { StIdx stIdx = callNode->GetReturnVec()[i].first; MIRSymbol *tmpSymbol = func->GetLocalOrGlobalSymbol(stIdx); ResetInferredType(inferredSymbols, tmpSymbol); } - for (size_t i = 0; i < callNode->GetNopndSize(); i++) { + for (size_t i = 0; i < callNode->GetNopndSize(); ++i) { BaseNode *node = callNode->GetNopndAt(i); if (node->GetOpCode() != OP_dread) { continue; @@ -1179,11 +1179,11 @@ void IPODevirtulize::DevirtualFinal() { if (klass->IsClass()) { MIRClassType *classType = static_cast(klass->GetMIRStructType()); // Initialize inferred type of member fileds as kInitTyidx - for (unsigned int i = 0; i < classType->GetFieldsSize(); i++) { // Don't include parent's field + for (unsigned int i = 0; i < classType->GetFieldsSize(); ++i) { // Don't include parent's field classType->SetElemInferredTyIdx(i, kInitTyIdx); } SearchDefInMemberMethods(*klass); - for (unsigned int i = 0; i < classType->GetFieldInferredTyIdx().size(); i++) { + for (unsigned int i = 0; i < classType->GetFieldInferredTyIdx().size(); ++i) { if (classType->GetElemInferredTyIdx(i) != kInitTyIdx && classType->GetElemInferredTyIdx(i) != kNoneTyIdx && debugFlag) { FieldID tmpID = i; @@ -1192,7 +1192,7 @@ void IPODevirtulize::DevirtualFinal() { GlobalTables::GetStrTable().GetStringFromStrIdx(pair.first) << '\n'; } } - for (uint32 i = 0; i < classType->GetStaticFields().size(); i++) { + for (uint32 i = 0; i < classType->GetStaticFields().size(); ++i) { FieldAttrs attribute = classType->GetStaticFields()[i].second.second; if (GlobalTables::GetGsymTable().GetSymbolFromStrIdx(classType->GetStaticFields()[i].first) == nullptr) { continue; @@ -1368,7 +1368,7 @@ void CallGraph::SetCompilationFunclist() const { mirModule->GetCompilationList().clear(); mirModule->GetFunctionList().clear(); const MapleVector &sccTopVec = GetSCCTopVec(); - for (int i = sccTopVec.size() - 1; i >= 0; i--) { + for (int i = sccTopVec.size() - 1; i >= 0; --i) { SCCNode *sccNode = sccTopVec[i]; std::sort(sccNode->GetCGNodes().begin(), sccNode->GetCGNodes().end(), CGNodeCompare); for (auto const kIt : sccNode->GetCGNodes()) { @@ -1451,7 +1451,7 @@ void SCCNode::DumpCycle() const { CGNode *calleeNode = cgIt; if (calleeNode->GetSCCNode() == this) { unsigned int j = 0; - for (; j < invalidNodes.size(); j++) { + for (; j < invalidNodes.size(); ++j) { if (invalidNodes[j] == calleeNode) { break; } @@ -1460,7 +1460,7 @@ void SCCNode::DumpCycle() const { if (j < invalidNodes.size()) { continue; } - for (j = 0; j < searched.size(); j++) { + for (j = 0; j < searched.size(); ++j) { if (searched[j] == calleeNode) { break; } @@ -1483,7 +1483,7 @@ void SCCNode::DumpCycle() const { currNode = searched[searched.size() - 1]; } } - for (auto it = searched.begin(); it != searched.end(); it++) { + for (auto it = searched.begin(); it != searched.end(); ++it) { LogInfo::MapleLogger() << (*it)->GetMIRFunction()->GetName() << '\n'; } } @@ -1513,7 +1513,7 @@ void SCCNode::Setup() { calleeScc.insert(calleeNode->GetSCCNode()); } } - for (auto itCaller = node->CallerBegin(); itCaller != node->CallerEnd(); itCaller++) { + for (auto itCaller = node->CallerBegin(); itCaller != node->CallerEnd(); ++itCaller) { CGNode *callerNode = *itCaller; if (callerNode->GetSCCNode() == this) { continue; @@ -1531,7 +1531,7 @@ void CallGraph::BuildSCCDFS(CGNode &caller, uint32 &visitIndex, std::vector &sccNodes) { } } // Top-down iterates all nodes - for (unsigned i = 0; i < sccTopologicalVec.size(); i++) { + for (unsigned i = 0; i < sccTopologicalVec.size(); ++i) { SCCNode *sccNode = sccTopologicalVec[i]; for (SCCNode *callee : sccNode->GetCalleeScc()) { if (inQueue.find(callee) == inQueue.end()) { diff --git a/src/maple_ipa/src/clone.cpp b/src/maple_ipa/src/clone.cpp index 8fc5174c60d3464f790631d8d8b7f4644ea8e324..f0610c1401519fc7689518ef5bcb085299135b86 100644 --- a/src/maple_ipa/src/clone.cpp +++ b/src/maple_ipa/src/clone.cpp @@ -15,7 +15,7 @@ #include "clone.h" #include #include -#include +#include "mir_symbol.h" // For some funcs, when we can ignore their return-values, we clone a new func of // them without return-values. We configure a list to save these funcs and clone diff --git a/src/maple_ipa/src/retype.cpp b/src/maple_ipa/src/retype.cpp index 99ec7d9bb8e5bd93d5ca8a01b44930cadb1594ec..96e6f5a8ac0add609fa140b29ae3782820ac0485 100644 --- a/src/maple_ipa/src/retype.cpp +++ b/src/maple_ipa/src/retype.cpp @@ -13,7 +13,6 @@ * See the Mulan PSL v1 for more details. */ #include "retype.h" -#include #include namespace maple { diff --git a/src/maple_me/include/me_abco.h b/src/maple_me/include/me_abco.h index 31247eb56e4f1a5385d9f7ed012f758da31d7d79..4c9d9464fea2f8de9fe210eeb670d0cddf81a35c 100755 --- a/src/maple_me/include/me_abco.h +++ b/src/maple_me/include/me_abco.h @@ -239,7 +239,7 @@ class MeABC { ESSABaseNode *GetOrCreateRHSNode(MeExpr &expr); void BuildPhiInGraph(MePhiNode &phi); void BuildSoloPiInGraph(const PiassignMeStmt &piMeStmt); - bool PiExcuteBeforeCurrentCheck(const PiassignMeStmt &piMeStmt); + bool PiExecuteBeforeCurrentCheck(const PiassignMeStmt &piMeStmt); bool BuildArrayCheckInGraph(MeStmt &meStmt); bool BuildBrMeStmtInGraph(MeStmt &meStmt); bool BuildAssignInGraph(MeStmt &meStmt); diff --git a/src/maple_me/src/me_abco.cpp b/src/maple_me/src/me_abco.cpp index aab83546c649e534bd288298a8e0a34ce23602e7..6e7637553ce2ad0993907661d1066bcefa30957b 100755 --- a/src/maple_me/src/me_abco.cpp +++ b/src/maple_me/src/me_abco.cpp @@ -650,7 +650,7 @@ void MeABC::BuildSoloPiInGraph(const PiassignMeStmt &piMeStmt) { (void)inequalityGraph->AddEdge(*piLHSNode, *piRHSNode, 0, EdgeType::kLower); } -bool MeABC::PiExcuteBeforeCurrentCheck(const PiassignMeStmt &piMeStmt) { +bool MeABC::PiExecuteBeforeCurrentCheck(const PiassignMeStmt &piMeStmt) { BB *currentCheckBB = currentCheck->GetBB(); BB *piBB = piMeStmt.GetBB(); if (currentCheckBB != piBB) { @@ -672,7 +672,7 @@ bool MeABC::BuildArrayCheckInGraph(MeStmt &meStmt) { CHECK_FATAL(meStmt.GetOp() == OP_piassign, "must be"); auto *piMeStmt = static_cast(&meStmt); BuildSoloPiInGraph(*piMeStmt); - if (!PiExcuteBeforeCurrentCheck(*piMeStmt)) { + if (!PiExecuteBeforeCurrentCheck(*piMeStmt)) { return true; } MeStmt *generatedByMeStmt = piMeStmt->GetGeneratedBy(); diff --git a/src/maple_phase/include/phase.h b/src/maple_phase/include/phase.h index 419a343d55595563b2bcb2b6d747f0557c41c5b5..4420d9daa402ae02b52aadb9cb5cb2cc50a8bebc 100644 --- a/src/maple_phase/include/phase.h +++ b/src/maple_phase/include/phase.h @@ -148,8 +148,8 @@ class AnalysisResultManager { std::pair key = std::make_pair(id, ir); auto it = analysisResults.find(key); if (it != analysisResults.end()) { - AnalysisResult *r = analysisResults[key]; - r->EraseMemPool(); + AnalysisResult *result = analysisResults[key]; + result->EraseMemPool(); analysisResults.erase(it); } } @@ -164,9 +164,9 @@ class AnalysisResultManager { void InvalidAllResults() { for (auto it = analysisResults.begin(); it != analysisResults.end(); ++it) { - AnalysisResult *r = it->second; - ASSERT(r != nullptr, "r is null in AnalysisResultManager::InvalidAllResults"); - r->EraseMemPool(); + AnalysisResult *result = it->second; + ASSERT(result != nullptr, "result is null in AnalysisResultManager::InvalidAllResults"); + result->EraseMemPool(); } analysisResults.clear(); } diff --git a/src/maple_util/include/mpl_logging.h b/src/maple_util/include/mpl_logging.h index ad20ff175b4d6310b99f88c0c90174c86e04ea60..71ae18b6c655a471ae2cacbc3a98549581f114e3 100644 --- a/src/maple_util/include/mpl_logging.h +++ b/src/maple_util/include/mpl_logging.h @@ -163,7 +163,7 @@ class LogInfo { fclose(outStream); } - static std::ostream &MapleLogger(LogLevel l = kLlLog); + static std::ostream &MapleLogger(LogLevel level = kLlLog); static std::ios::fmtflags flags(); void EmitLogForUser(enum LogNumberCode num, enum LogLevel ll, const char *fmt, ...) const; void EmitLogForUser(enum LogNumberCode num, enum LogLevel ll, const std::string &message) const; diff --git a/src/maple_util/include/mpl_number.h b/src/maple_util/include/mpl_number.h index 67f0deed3ac79ef8a335bc8933c18fb32c3861f1..f4db2a0534be43c5a3dec434f98b31bda198fd22 100644 --- a/src/maple_util/include/mpl_number.h +++ b/src/maple_util/include/mpl_number.h @@ -20,7 +20,7 @@ namespace maple { namespace utils { -template +template class Number { public: static_assert(std::is_integral::value, "Type for Number should be an integral."); @@ -31,7 +31,7 @@ class Number { explicit Number(ElementType data) : val(data) {} - template ::value>> + template::value>> explicit Number(U data) : val(static_cast(data)) {} Number(const Number &num) : val(num.val) {} @@ -70,18 +70,18 @@ class Number { return val; } - template + template operator std::enable_if_t::value, U>() const noexcept { return val; } - template + template operator std::enable_if_t>, std::is_same>::value, U>() const noexcept { return static_cast(val); } - template >, + template>, meta_not>>::value>> explicit operator U() const noexcept { return static_cast(val); @@ -137,151 +137,151 @@ class Number { ElementType val = 0; }; -template +template inline bool operator==(const Number &lhs, const Number &rhs) { return lhs.get() == rhs.get(); } -template +template inline bool operator!=(const Number &lhs, const Number &rhs) { return !(lhs == rhs); } -template +template inline bool operator<(const Number &lhs, const Number &rhs) { return lhs.get() < rhs.get(); } -template +template inline bool operator<=(const Number &lhs, const Number &rhs) { return lhs.get() <= rhs.get(); } -template +template inline bool operator>(const Number &lhs, const Number &rhs) { return !(lhs <= rhs); } -template +template inline bool operator>=(const Number &lhs, const Number &rhs) { return !(lhs < rhs); } -template +template inline Number operator+(const Number &lhs, const Number &rhs) { return Number(lhs.get() + rhs.get()); } -template +template inline Number operator-(const Number &lhs, const Number &rhs) { return Number(lhs.get() - rhs.get()); } -template , std::is_enum>::value>> inline bool operator==(const Number &lhs, const U &rhs) { return lhs.get() == rhs; } -template , std::is_enum>::value>> inline bool operator==(const U &lhs, const Number &rhs) { return lhs == rhs.get(); } -template , std::is_enum>::value>> inline bool operator!=(const Number &lhs, const U &rhs) { return !(lhs == rhs); } -template , std::is_enum>::value>> inline bool operator!=(const U &lhs, const Number &rhs) { return !(lhs == rhs); } -template , std::is_enum>::value>> inline bool operator<(const Number &lhs, const U &rhs) { return lhs.get() < rhs; } -template , std::is_enum>::value>> inline bool operator<(const U &lhs, const Number &rhs) { return lhs < rhs.get(); } -template , std::is_enum>::value>> inline bool operator<=(const Number &lhs, const U &rhs) { return lhs.get() <= rhs; } -template , std::is_enum>::value>> inline bool operator<=(const U &lhs, const Number &rhs) { return lhs <= rhs.get(); } -template , std::is_enum>::value>> inline bool operator>(const Number &lhs, const U &rhs) { return !(lhs <= rhs); } -template , std::is_enum>::value>> inline bool operator>(const U &lhs, const Number &rhs) { return !(lhs <= rhs); } -template , std::is_enum>::value>> inline bool operator>=(const Number &lhs, const U &rhs) { return !(lhs < rhs); } -template , std::is_enum>::value>> inline bool operator>=(const U &lhs, const Number &rhs) { return !(lhs < rhs); } -template ::value>> +template::value>> inline Number operator+(const Number &lhs, const U &rhs) { return Number(lhs.get() + rhs); } -template ::value>> +template::value>> inline Number operator+(const U &lhs, const Number &rhs) { return Number(lhs + rhs.get()); } -template ::value>> +template::value>> inline Number operator-(const Number &lhs, const U &rhs) { return Number(lhs.get() - rhs); } -template ::value>> +template::value>> inline Number operator-(const U &lhs, const Number &rhs) { return Number(lhs - rhs.get()); } -template +template inline OS &operator<<(OS &os, const Number &num) { os << num.get(); return os; } -template +template using Index = Number; }} namespace std { - template + template inline string to_string(maple::utils::Number val) { return std::to_string (val.get()); } diff --git a/src/maple_util/include/ptr.h b/src/maple_util/include/ptr.h index 295b17e6e51389e5ba9ae76ec74ac8195200f9ce..a6a8a6b790401bec57e8c7eb06f289e75732aca9 100644 --- a/src/maple_util/include/ptr.h +++ b/src/maple_util/include/ptr.h @@ -19,7 +19,7 @@ namespace maple { namespace utils { template -using PtrCheckerType = void (*)(const T*); +using PtrCheckerType = void(*)(const T*); template inline constexpr void CheckNothing(const T*) {} diff --git a/src/maple_util/include/safe_cast.h b/src/maple_util/include/safe_cast.h index bcebd323efa0231673b4c3652e082644c7810358..5b42bd9eb1439ea49a8fdc909f9686e52d1a092a 100644 --- a/src/maple_util/include/safe_cast.h +++ b/src/maple_util/include/safe_cast.h @@ -17,20 +17,20 @@ #include "utils/meta.h" namespace maple { -template +template struct SafeCastCondition : std::false_type {}; #define REGISTER_SAFE_CAST(type, condition) \ -template <> \ +template<> \ struct SafeCastCondition : std::true_type { \ - template \ + template \ static inline bool DoIt(const FromT &from) { \ return (condition); \ } \ } namespace impl { -template ::value>> struct InstanceOfImpl { static inline bool DoIt(const FromT &from) { @@ -38,30 +38,30 @@ struct InstanceOfImpl { } }; -template +template struct InstanceOfImpl::value>> { static inline bool DoIt(const FromT&) { return true; } }; -template +template struct EnabledSafeCast : utils::meta_or, SafeCastCondition>::type {}; } -template ::value>> inline bool instance_of(FromT &from) { return impl::InstanceOfImpl::DoIt(from); } -template ::value>> inline bool instance_of(FromT *from) { return (from != nullptr && instance_of(*from)); } -template ::value || std::is_const>::value, std::add_pointer_t>>, @@ -71,7 +71,7 @@ inline RetT safe_cast(FromT &from) { return (instance_of(from) ? static_cast(&from) : nullptr); } -template ::value || std::is_const>::value, std::add_pointer_t>>, diff --git a/src/maple_util/include/safe_ptr.h b/src/maple_util/include/safe_ptr.h index 76b537fe9ff5c96e467da2b87c203d2749f4be1f..3bea5d76b5cb06fbc5422fd27304c1a13a0c3f53 100644 --- a/src/maple_util/include/safe_ptr.h +++ b/src/maple_util/include/safe_ptr.h @@ -35,38 +35,30 @@ class SafePtr { constexpr SafePtr(std::nullptr_t) noexcept = delete; - SafePtr(pointer ptr) - : base(ptr) {} + SafePtr(pointer ptr) : base(ptr) {} - SafePtr(T &ref) - : base(ref, CheckNothing) {} + SafePtr(T &ref) : base(ref, CheckNothing) {} SafePtr(T &&ref) = delete; template::value>> - SafePtr(U *ptr) - : base(ptr) {} + SafePtr(U *ptr) : base(ptr) {} template::value>> - SafePtr(U &ref) - : base(ref, CheckNothing) {} + SafePtr(U &ref) : base(ref, CheckNothing) {} template::value>> SafePtr(U &&ref) = delete; - SafePtr(const SafePtr &other) - : base(other.base) {} + SafePtr(const SafePtr &other) : base(other.base) {} - SafePtr(SafePtr &&other) noexcept - : base(std::move(other.base)) {} + SafePtr(SafePtr &&other) noexcept : base(std::move(other.base)) {} template::value>> - explicit SafePtr(const SafePtr &other) - : base(other.get(), CheckNothing) {} + explicit SafePtr(const SafePtr &other) : base(other.get(), CheckNothing) {} template::value>> - explicit SafePtr(SafePtr &&other) - : base(other.get(), CheckNothing) {} + explicit SafePtr(SafePtr &&other) : base(other.get(), CheckNothing) {} ~SafePtr() = default; @@ -200,15 +192,15 @@ inline bool operator>=(const SafePtr &lhs, std::nullptr_t) = delete; template inline bool operator>=(std::nullptr_t, const SafePtr &rhs) = delete; -template +template inline T &ToRef(SafePtr ptr) { return *ptr; } -}} +} +} -namespace std -{ -template +namespace std { +template struct hash> { std::size_t operator()(const maple::utils::SafePtr &safePtr) const { return hash::pointer>()(safePtr.get()); diff --git a/src/mpl2mpl/src/reflection_analysis.cpp b/src/mpl2mpl/src/reflection_analysis.cpp index cf50eb7bb730bd2aeddcd28b9489eb1407c6d187..6cb49f0561b8d126ece3383185adc4609cdf8390 100755 --- a/src/mpl2mpl/src/reflection_analysis.cpp +++ b/src/mpl2mpl/src/reflection_analysis.cpp @@ -539,7 +539,7 @@ uint16 GetFieldHash(const std::vector> &fieldV, con MIRSymbol *ReflectionAnalysis::GetOrCreateSymbol(const std::string &name, TyIdx tyIdx, bool needInit = false) { const GStrIdx strIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(name); - MIRSymbol *st; + MIRSymbol *st = nullptr; std::string symbolOfJavaLangString(namemangler::kJavaLangStringStr); if (name == CLASSINFO_PREFIX_STR + symbolOfJavaLangString) { // Previous String Symbol have been generated in dex2mpl, so this Symbol won't create again here