void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not // provide any benefit to other languages, despite being benign. if (!getLangOpts().CPlusPlus) return; const auto ValidContainer = cxxRecordDecl(isSameOrDerivedFrom( namedDecl( has(cxxMethodDecl( isConst(), parameterCountIs(0), isPublic(), hasName("size"), returns(qualType(isInteger(), unless(booleanType())))) .bind("size")), has(cxxMethodDecl(isConst(), parameterCountIs(0), isPublic(), hasName("empty"), returns(booleanType())) .bind("empty"))) .bind("container"))); const auto WrongUse = anyOf( hasParent(binaryOperator( matchers::isComparisonOperator(), hasEitherOperand(ignoringImpCasts(anyOf( integerLiteral(equals(1)), integerLiteral(equals(0)))))) .bind("SizeBinaryOp")), hasParent(implicitCastExpr( hasImplicitDestinationType(booleanType()), anyOf( hasParent(unaryOperator(hasOperatorName("!")).bind("NegOnSize")), anything()))), hasParent(explicitCastExpr(hasDestinationType(booleanType())))); Finder->addMatcher( cxxMemberCallExpr(on(expr(anyOf(hasType(ValidContainer), hasType(pointsTo(ValidContainer)), hasType(references(ValidContainer)))) .bind("STLObject")), callee(cxxMethodDecl(hasName("size"))), WrongUse) .bind("SizeCallExpr"), this); }
void PnlPlnrCtpKCalcdomprp::handleDpchAppDataStgiacqry( DbsPlnr* dbsplnr , QryPlnrCtpKCalcdomprp::StgIac* _stgiacqry , DpchEngPlnr** dpcheng ) { set<uint> diffitems; set<uint> moditems; diffitems = _stgiacqry->diff(&(qry->stgiac)); ubigint refSelNew = 0; muteRefresh = true; if (!diffitems.empty()) { qry->stgiac = *_stgiacqry; if (has(diffitems, QryPlnrCtpKCalcdomprp::StgIac::JNUM)) refSelNew = qry->getRefByJnum(_stgiacqry->jnum); if (!has(diffitems, QryPlnrCtpKCalcdomprp::StgIac::JNUM) || (diffitems.size() > 1)) { qry->refresh(dbsplnr); insert(moditems, {DpchEngData::STATSHRQRY, DpchEngData::RST}); }; if (has(diffitems, QryPlnrCtpKCalcdomprp::StgIac::JNUM)) { if (refSelNew == 0) refSelNew = qry->getRefByJnum(_stgiacqry->jnum); xchg->addRefPreset(VecPlnrVPreset::PREPLNRREFSEL, jref, refSelNew); qry->refreshJnum(); }; refresh(dbsplnr, moditems); }; muteRefresh = false; insert(moditems, DpchEngData::STGIACQRY); *dpcheng = getNewDpchEng(moditems); };
bool add(GraphNode *node) { if (has(node->get_stream_id())) { return false; } m_nodes[node->get_stream_id()] = node; if (node->m_stream->m_self_start) { m_roots.push_back(node); } return true; }
/*! * @return true if a record with the id column value exists */ bool record::exists() const { auto pk = schema()->primary_key(); if (!has(pk)) { return false; } select_query query(schema()); query.where(op::equals(pk, get(pk))); return query.count() > 0; }
std::shared_ptr<Font> FontManager::get(const std::string &fontPath) { std::shared_ptr<Font> font; if(!has(fontPath)) { font = load(fontPath); } else { font = m_fonts[fontPath].lock(); } return font; }
void PnlFmncArt1NStockitem::handleDpchAppDataStgiacqry( DbsFmnc* dbsfmnc , QryFmncArt1NStockitem::StgIac* _stgiacqry , DpchEngFmnc** dpcheng ) { set<uint> diffitems; set<uint> moditems; diffitems = _stgiacqry->diff(&(qry->stgiac)); ubigint refSelNew = 0; muteRefresh = true; if (!diffitems.empty()) { qry->stgiac = *_stgiacqry; if (has(diffitems, QryFmncArt1NStockitem::StgIac::JNUM)) refSelNew = qry->getRefByJnum(_stgiacqry->jnum); if (!has(diffitems, QryFmncArt1NStockitem::StgIac::JNUM) || (diffitems.size() > 1)) { qry->refresh(dbsfmnc); insert(moditems, {DpchEngData::STATSHRQRY, DpchEngData::RST}); }; if (has(diffitems, QryFmncArt1NStockitem::StgIac::JNUM)) { if (refSelNew == 0) refSelNew = qry->getRefByJnum(_stgiacqry->jnum); xchg->addRefPreset(VecFmncVPreset::PREFMNCREFSEL, jref, refSelNew); qry->refreshJnum(); }; refresh(dbsfmnc, moditems); }; muteRefresh = false; insert(moditems, DpchEngData::STGIACQRY); *dpcheng = getNewDpchEng(moditems); };
void dijkstra(long s){ heap* pq=heap_init(); elem* entries[n+1]; edge result; memset(result.i,0,n+1); int i,ml[n+1]; for(i=1;i<=n;++i){ ml[i]=i; entries[i]=heap_insert(&pq,MAX,ml+i); //printf("%d %lld\n",*(int*)entries[i]->value,entries[i]->key); } heap_decrease_key(&pq,entries[s],0); //printf("%d %lld\n",*(int*)entries[s]->value,entries[s]->key); //printf("decrease ok\n"); while(!is_empty(pq)){ data curr=heap_extract_min(&pq); //print_data(curr); int cv=*(int*) curr.value; result.i[cv]=1; result.v[cv]=curr.key; for(i=1;i<=n;++i){ if(has(result,i)) continue; if(!has(g.v[cv],i)){ continue; } printf("path %d ->%d\n",cv,i); ll pathCost=index(result,i)+ g.v[cv].v[i]; elem* dest=entries[i]; printf("pC=%lld key=%lld\n",pathCost,dest->key); if( dest->key> pathCost){ printf("desc key\n"); heap_decrease_key(&pq,dest,pathCost); } } } for(i=1;i<=n;++i){ res[s][i]=result.v[i]; } }
void UnconventionalAssignOperatorCheck::registerMatchers( ast_matchers::MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not // provide any benefit to other languages, despite being benign. if (!getLangOpts().CPlusPlus) return; const auto HasGoodReturnType = cxxMethodDecl(returns(lValueReferenceType( pointee(unless(isConstQualified()), anyOf(autoType(), hasDeclaration(equalsBoundNode("class"))))))); const auto IsSelf = qualType( anyOf(hasDeclaration(equalsBoundNode("class")), referenceType(pointee(hasDeclaration(equalsBoundNode("class")))))); const auto IsAssign = cxxMethodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())), hasName("operator="), ofClass(recordDecl().bind("class"))) .bind("method"); const auto IsSelfAssign = cxxMethodDecl(IsAssign, hasParameter(0, parmVarDecl(hasType(IsSelf)))) .bind("method"); Finder->addMatcher( cxxMethodDecl(IsAssign, unless(HasGoodReturnType)).bind("ReturnType"), this); const auto BadSelf = referenceType( anyOf(lValueReferenceType(pointee(unless(isConstQualified()))), rValueReferenceType(pointee(isConstQualified())))); Finder->addMatcher( cxxMethodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf)))) .bind("ArgumentType"), this); Finder->addMatcher( cxxMethodDecl(IsSelfAssign, anyOf(isConst(), isVirtual())).bind("cv"), this); const auto IsBadReturnStatement = returnStmt(unless(has(ignoringParenImpCasts( anyOf(unaryOperator(hasOperatorName("*"), hasUnaryOperand(cxxThisExpr())), cxxOperatorCallExpr(argumentCountIs(1), callee(unresolvedLookupExpr()), hasArgument(0, cxxThisExpr()))))))); const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType); Finder->addMatcher(returnStmt(IsBadReturnStatement, forFunction(IsGoodAssign)) .bind("returnStmt"), this); }
void ConfigurationBackend::set(const std::string& domain, const std::string& section, const std::string& name, const std::string& value) { ConfigurationKey key(domain, section, name); if (has(key)) { long id = _configurationtable.key2id(key); ConfigurationEntry entry = _configurationtable.byid(id); entry.value = value; _configurationtable.update(id, entry); } else { ConfigurationEntry entry(key, value); _configurationtable.add(entry); } }
void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) { const auto ControlFlowInterruptorMatcher = stmt(anyOf(returnStmt().bind("return"), continueStmt().bind("continue"), breakStmt().bind("break"), expr(ignoringImplicit(cxxThrowExpr().bind("throw"))))); Finder->addMatcher( compoundStmt(forEach( ifStmt(hasThen(stmt( anyOf(ControlFlowInterruptorMatcher, compoundStmt(has(ControlFlowInterruptorMatcher))))), hasElse(stmt().bind("else"))) .bind("if"))), this); }
TextureHnd TextureManager::addTexture(std::string name, std::string uri, WindowHnd win, bool allowOverwrite){ if (allowOverwrite || !has(name)){ if (!hasByURI(uri)){ try{ TexturePtr t = TexturePtr(new Texture(uri, win)); mResources.insert(std::pair<std::string, TexturePtr>(name, t)); return TextureHnd(t); } catch (std::runtime_error e){ throw e; } } } return TextureHnd(); }
static std::vector<std::pair<std::string, std::string>> resolvePorts( const Poco::JSON::Object::Ptr &topObj, const std::string &blockId, const std::string &portName, const bool resolveSrc ) { assert(topObj); std::vector<std::pair<std::string, std::string>> results; const auto blocksObj = topObj->getObject("blocks"); assert(blocksObj); if (not blocksObj->has(blockId)) return results; const auto blockObj = blocksObj->getObject(blockId); assert(blockObj); if (not blockIsHier(blockObj)) { results.push_back(std::make_pair(blockId, portName)); return results; } const auto connsArray = blockObj->getArray("connections"); for (size_t c_i = 0; c_i < connsArray->size(); c_i++) { const auto subConnObj = connsArray->getObject(c_i); assert(subConnObj); std::string subId, subName; if (resolveSrc) { if (subConnObj->getValue<std::string>("dstId") != blockId) continue; if (subConnObj->getValue<std::string>("dstName") != portName) continue; subId = subConnObj->getValue<std::string>("srcId"); subName = subConnObj->getValue<std::string>("srcName"); } else { if (subConnObj->getValue<std::string>("srcId") != blockId) continue; if (subConnObj->getValue<std::string>("srcName") != portName) continue; subId = subConnObj->getValue<std::string>("dstId"); subName = subConnObj->getValue<std::string>("dstName"); } //ignore pass-through connections in this loop if (subId != blockId) results.push_back(std::make_pair(subId, subName)); } return results; }
float Task::urgency_age () const { assert (has ("entry")); Date now; Date entry (get_date ("entry")); int age = (now - entry) / 86400; // in days float max = context.config.getReal ("urgency.age.max"); if (max == 0 || age > max) return 1.0; return (1.0 * age/max); }
static Poco::JSON::Array::Ptr getConnectedPortInfos( const Poco::JSON::Object::Ptr &topObj, const std::string &blockId, const bool enbFilter, const bool isInput) { const auto connsArray = topObj->getArray("connections"); const auto blocksObj = topObj->getObject("blocks"); const auto blockObj = blocksObj->getObject(blockId); //grab the raw ports info Poco::JSON::Array::Ptr portsInfo(new Poco::JSON::Array()); if (isInput and blockObj->has("inputs")) portsInfo = blockObj->getArray("inputs"); if (not isInput and blockObj->has("outputs")) portsInfo = blockObj->getArray("outputs"); //no filtering? return ASAP if (not enbFilter) return portsInfo; Poco::JSON::Array::Ptr filteredPortsInfo(new Poco::JSON::Array()); for (size_t i = 0; i < portsInfo->size(); i++) { const auto portInfo = portsInfo->getObject(i); for (size_t c_i = 0; c_i < connsArray->size(); c_i++) { const auto conn = connsArray->getObject(c_i); if ( (not isInput and blockId == conn->getValue<std::string>("srcId") and portInfo->getValue<std::string>("name") == conn->getValue<std::string>("srcName")) or (isInput and blockId == conn->getValue<std::string>("dstId") and portInfo->getValue<std::string>("name") == conn->getValue<std::string>("dstName")) ) { filteredPortsInfo->add(portInfo); break; } } } return filteredPortsInfo; }
bool Task::hasTag (const std::string& tag) const { // Synthetic tags - dynamically generated, but do not occupy storage space. if (tag == "BLOCKED") return is_blocked; if (tag == "UNBLOCKED") return !is_blocked; if (tag == "BLOCKING") return is_blocking; if (tag == "DUE") return is_due (); if (tag == "DUETODAY") return is_duetoday (); if (tag == "TODAY") return is_duetoday (); if (tag == "OVERDUE") return is_overdue (); if (tag == "ACTIVE") return has ("start"); if (tag == "SCHEDULED") return has ("scheduled"); if (tag == "CHILD") return has ("parent"); if (tag == "UNTIL") return has ("until"); if (tag == "WAITING") return has ("wait"); if (tag == "ANNOTATED") return hasAnnotations (); /* TODO YESTERDAY - due yesterday TODO TOMORROW - due tomorrow TODO WEEK - due this week TODO MONTH - due this month TODO YEAR - due this year TODO READY - is ready TODO WAITING - is waiting TODO PARENT - is a parent */ // Concrete tags. std::vector <std::string> tags; split (tags, get ("tags"), ','); if (std::find (tags.begin (), tags.end (), tag) != tags.end ()) return true; return false; }
void overmapbuffer::fix_npcs( overmap &new_overmap ) { // First step: move all npcs that are located outside of the given overmap // into a separate container. After that loop, new_overmap.npcs is no // accessed anymore! decltype( overmap::npcs ) to_relocate; for( auto it = new_overmap.npcs.begin(); it != new_overmap.npcs.end(); ) { npc &np = **it; const tripoint npc_omt_pos = np.global_omt_location(); const point npc_om_pos = omt_to_om_copy( npc_omt_pos.x, npc_omt_pos.y ); const point &loc = new_overmap.pos(); if( npc_om_pos == loc ) { // Nothing to do ++it; continue; } to_relocate.push_back( *it ); it = new_overmap.npcs.erase( it ); } // Second step: put them back where they belong. This step involves loading // new overmaps (via `get`), which does in turn call this function for the // newly loaded overmaps. This in turn may move NPCs from the second overmap // back into the first overmap. This messes up the iteration of it. The // iteration is therefore done in a separate step above (which does *not* // involve loading new overmaps). for( auto &ptr : to_relocate ) { npc &np = *ptr; const tripoint npc_omt_pos = np.global_omt_location(); const point npc_om_pos = omt_to_om_copy( npc_omt_pos.x, npc_omt_pos.y ); const point &loc = new_overmap.pos(); if( !has( npc_om_pos.x, npc_om_pos.y ) ) { // This can't really happen without save editing // We have no sane option here, just place the NPC on the edge debugmsg( "NPC %s is out of bounds, on non-generated overmap %d,%d", np.name.c_str(), loc.x, loc.y ); point npc_sm = om_to_sm_copy( npc_om_pos ); point min = om_to_sm_copy( loc ); point max = om_to_sm_copy( loc + point( 1, 1 ) ) - point( 1, 1 ); npc_sm.x = clamp( npc_sm.x, min.x, max.x ); npc_sm.y = clamp( npc_sm.y, min.y, max.y ); np.spawn_at_sm( npc_sm.x, npc_sm.y, np.posz() ); new_overmap.npcs.push_back( ptr ); continue; } // Simplest case: just move the pointer get( npc_om_pos.x, npc_om_pos.y ).insert_npc( ptr ); } }
void PnlFmncAdrDetail::DpchEngData::writeXML( const uint ixFmncVLocale , pthread_mutex_t* mScr , map<ubigint,string>& scr , map<string,ubigint>& descr , xmlTextWriter* wr ) { xmlTextWriterStartElement(wr, BAD_CAST "DpchEngFmncAdrDetailData"); xmlTextWriterWriteAttribute(wr, BAD_CAST "xmlns", BAD_CAST "http://www.epsitechnologies.com/fmnc"); if (has(JREF)) writeString(wr, "scrJref", Scr::scramble(mScr, scr, descr, jref)); if (has(CONTIAC)) contiac.writeXML(wr); if (has(CONTINF)) continf.writeXML(wr); if (has(FEEDFPUPATY)) feedFPupAty.writeXML(wr); if (has(FEEDFPUPCRY)) feedFPupCry.writeXML(wr); if (has(FEEDFPUPHKT)) feedFPupHkt.writeXML(wr); if (has(STATAPP)) StatApp::writeXML(wr); if (has(STATSHR)) statshr.writeXML(wr); if (has(TAG)) Tag::writeXML(ixFmncVLocale, wr); xmlTextWriterEndElement(wr); };
/// This is the third test, a stress test, which uses a hash table of /// long keys and long values (negated). /// @param seed a seed for the random number generator void testStress(int seed) { const size_t NUM_ELEMENTS = 40000; // 40,000 elements long* elements = (long*) malloc(NUM_ELEMENTS * sizeof(long)); if (elements == NULL) { fprintf(stderr, "testStress failed\n"); assert(NULL); } printf("testStress()...\n"); srand(seed); // seed the rng // populate elements with random integers for (size_t i=0; i<NUM_ELEMENTS; ++i) { elements[i] = rand(); } // create hash table, key=int, value=int Table* t = create(longHash, longEquals, longLongPrint); // put all elements for (size_t i=0; i<NUM_ELEMENTS; ++i) { put(t, (void*)elements[i], (void*)-elements[i]); } // check that has finds each element for (size_t i=0; i<NUM_ELEMENTS; ++i) { if (has(t, (void*)elements[i]) != true) { fprintf(stderr, "testStress, has() checked failed"); free(elements); assert(NULL); } } // check that get works for (size_t i=0; i<NUM_ELEMENTS; ++i) { if (-(long)get(t, (void*)elements[i]) != elements[i]) { fprintf(stderr, "testStress, get() checked failed"); free(elements); assert(NULL); } } // these results depend on whether any duplicate values are randomly // generated dump(t, false); destroy(t); free(elements); }
void PnlFmncFabList::handleDpchAppDataStgiacqry( DbsFmnc* dbsfmnc , QryFmncFabList::StgIac* _stgiacqry , DpchEngFmnc** dpcheng ) { set<uint> diffitems; set<uint> moditems; diffitems = _stgiacqry->diff(&(qry->stgiac)); ubigint refSelNew = 0; muteRefresh = true; if (!diffitems.empty()) { qry->stgiac = *_stgiacqry; if (has(diffitems, QryFmncFabList::StgIac::JNUM)) refSelNew = qry->getRefByJnum(_stgiacqry->jnum); if (!has(diffitems, QryFmncFabList::StgIac::JNUM) || (diffitems.size() > 1)) { qry->refresh(dbsfmnc); refresh(dbsfmnc, moditems); insert(moditems, {DpchEngData::STATSHRQRY, DpchEngData::RST}); }; if (has(diffitems, QryFmncFabList::StgIac::JNUM)) { if (refSelNew == 0) refSelNew = qry->getRefByJnum(_stgiacqry->jnum); xchg->triggerIxRefCall(dbsfmnc, VecFmncVCall::CALLFMNCREFPRESET, jref, VecFmncVPreset::PREFMNCREFFAB, refSelNew); }; }; muteRefresh = false; insert(moditems, DpchEngData::STGIACQRY); *dpcheng = getNewDpchEng(moditems); };
void PbArgs::check() { if (has("nocheck")) return; for(map<string, DataElement>::iterator it = mData.begin(); it != mData.end(); it++) { if (!it->second.visited) errMsg("Argument '" + it->first + "' given, which is not defined"); } for(size_t i=0; i<mLinData.size(); i++) { if (!mLinData[i].visited) { stringstream s; s << "Function does not read argument number #" << i; errMsg(s.str()); } } }
string PnlFmncSmpDetail::DpchEngData::getSrefsMask() { vector<string> ss; string srefs; if (has(JREF)) ss.push_back("jref"); if (has(CONTIAC)) ss.push_back("contiac"); if (has(CONTINF)) ss.push_back("continf"); if (has(FEEDFPUPJ)) ss.push_back("feedFPupJ"); if (has(FEEDFPUPSTE)) ss.push_back("feedFPupSte"); if (has(STATAPP)) ss.push_back("statapp"); if (has(STATSHR)) ss.push_back("statshr"); if (has(TAG)) ss.push_back("tag"); StrMod::vectorToString(ss, srefs); return(srefs); };
void Request::getCredentials(const std::string& header, std::string& scheme, std::string& authInfo) const { scheme.clear(); authInfo.clear(); if (has(header)) { const std::string& auth = get(header); std::string::const_iterator it = auth.begin(); std::string::const_iterator end = auth.end(); while (it != end && ::isspace(*it)) ++it; while (it != end && !::isspace(*it)) scheme += *it++; while (it != end && ::isspace(*it)) ++it; while (it != end) authInfo += *it++; } else throw std::runtime_error("Request is not authenticated"); }
void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++. if (!getLangOpts().CPlusPlus11) return; // Skip list initialization and constructors with an initializer list. auto ConstructExpr = cxxConstructExpr( unless(anyOf(hasDeclaration(cxxConstructorDecl(isExplicit())), isListInitialization(), hasDescendant(initListExpr()), isInTemplateInstantiation()))) .bind("ctor"); auto CtorAsArgument = materializeTemporaryExpr(anyOf( has(ConstructExpr), has(cxxFunctionalCastExpr(has(ConstructExpr))))); Finder->addMatcher( functionDecl(isDefinition(), // Declarations don't have return statements. returns(unless(anyOf(builtinType(), autoType()))), hasDescendant(returnStmt(hasReturnValue( has(cxxConstructExpr(has(CtorAsArgument))))))) .bind("fn"), this); }
void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) { const auto Calc = expr(anyOf(binaryOperator( anyOf(hasOperatorName("+"), hasOperatorName("-"), hasOperatorName("*"), hasOperatorName("<<"))), unaryOperator(hasOperatorName("~"))), hasType(isInteger())) .bind("Calc"); const auto ExplicitCast = explicitCastExpr(hasDestinationType(isInteger()), has(ignoringParenImpCasts(Calc))); const auto ImplicitCast = implicitCastExpr(hasImplicitDestinationType(isInteger()), has(ignoringParenImpCasts(Calc))); const auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast"); Finder->addMatcher(varDecl(hasInitializer(Cast)), this); Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this); Finder->addMatcher(callExpr(hasAnyArgument(Cast)), this); Finder->addMatcher(binaryOperator(hasOperatorName("="), hasRHS(Cast)), this); Finder->addMatcher( binaryOperator(matchers::isComparisonOperator(), hasEitherOperand(Cast)), this); }
bool Task::is_overdue () const { if (has ("due")) { Task::status status = getStatus (); if (status != Task::completed && status != Task::deleted) { if (getDueState (get ("due")) == 3) return true; } } return false; }
//////////////////////////////////////////////////////////////////////////////// // The timestamp is part of the name: // annotation_1234567890:"..." // // Note that the time is incremented (one second) in order to find a unique // timestamp. void Task::addAnnotation (const std::string& description) { time_t now = time (NULL); std::string key; do { key = "annotation_" + format ((int) now); ++now; } while (has (key)); (*this)[key] = description; ++annotation_count; recalc_urgency = true; }
void HTTPRequest::getCredentials(const std::string& header, std::string& scheme, std::string& authInfo) const { scheme.clear(); authInfo.clear(); if (has(header)) { const std::string& auth = get(header); std::string::const_iterator it = auth.begin(); std::string::const_iterator end = auth.end(); while (it != end && Poco::Ascii::isSpace(*it)) ++it; while (it != end && !Poco::Ascii::isSpace(*it)) scheme += *it++; while (it != end && Poco::Ascii::isSpace(*it)) ++it; while (it != end) authInfo += *it++; } else throw NotAuthenticatedException(); }
bool PCTypeMap::add(const std::string& id, const std::string& newid, const std::string& color, const std::string& prefix, int layer, bool discard, bool allowFill) { if (has(id)) { return false; } TypeDef td; td.id = newid; td.color = RGBColor::parseColor(color); td.layer = layer; td.discard = discard; td.allowFill = allowFill; td.prefix = prefix; myTypes[id] = td; return true; }
void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( expr(unless(isInTemplateInstantiation()), expr(sizeOfExpr(has(ignoringParenImpCasts( expr(hasType(hasCanonicalType(hasDeclaration(cxxRecordDecl( matchesName("^(::std::|::string)"), unless(matchesName("^::std::(bitset|array)$")), hasMethod(cxxMethodDecl(hasName("size"), isPublic(), isConst()))))))))))) .bind("sizeof"), // Ignore ARRAYSIZE(<array of containers>) pattern. unless(hasAncestor(binaryOperator( anyOf(hasOperatorName("/"), hasOperatorName("%")), hasLHS(ignoringParenCasts(sizeOfExpr(expr()))), hasRHS(ignoringParenCasts(equalsBoundNode("sizeof"))))))), this); }
void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) { const auto ConstParamDecl = parmVarDecl(hasType(qualType(isConstQualified()))).bind("param"); Finder->addMatcher( functionDecl(unless(isDefinition()), // Lambdas are always their own definition, but they // generate a non-definition FunctionDecl too. Ignore those. // Class template instantiations have a non-definition // CXXMethodDecl for methods that aren't used in this // translation unit. Ignore those, as the template will have // already been checked. unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf( isLambda(), ast_matchers::isTemplateInstantiation()))))), has(typeLoc(forEach(ConstParamDecl)))) .bind("func"), this); }