您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ unless函数代码示例

51自学网 2021-06-03 09:10:39
  C++
这篇教程C++ unless函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中unless函数的典型用法代码示例。如果您正苦于以下问题:C++ unless函数的具体用法?C++ unless怎么用?C++ unless使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了unless函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: functionDecl

void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus)  	return;  const auto StrCat = functionDecl(hasName("::absl::StrCat"));  // The arguments of absl::StrCat are implicitly converted to AlphaNum. This   // matches to the arguments because of that behavior.   const auto AlphaNum = IgnoringTemporaries(cxxConstructExpr(      argumentCountIs(1), hasType(cxxRecordDecl(hasName("::absl::AlphaNum"))),      hasArgument(0, ignoringImpCasts(declRefExpr(to(equalsBoundNode("LHS")),                                                  expr().bind("Arg0"))))));  const auto HasAnotherReferenceToLhs =      callExpr(hasAnyArgument(expr(hasDescendant(declRefExpr(          to(equalsBoundNode("LHS")), unless(equalsBoundNode("Arg0")))))));  // Now look for calls to operator= with an object on the LHS and a call to  // StrCat on the RHS. The first argument of the StrCat call should be the same  // as the LHS. Ignore calls from template instantiations.  Finder->addMatcher(      cxxOperatorCallExpr(          unless(isInTemplateInstantiation()), hasOverloadedOperatorName("="),          hasArgument(0, declRefExpr(to(decl().bind("LHS")))),          hasArgument(1, IgnoringTemporaries(                             callExpr(callee(StrCat), hasArgument(0, AlphaNum),                                      unless(HasAnotherReferenceToLhs))                                 .bind("Call"))))          .bind("Op"),      this);}
开发者ID:ingowald,项目名称:llvm-project,代码行数:29,


示例2: cxxConstructorDecl

void PassByValueCheck::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;  Finder->addMatcher(      cxxConstructorDecl(          forEachConstructorInitializer(              cxxCtorInitializer(                  // Clang builds a CXXConstructExpr only whin it knows which                  // constructor will be called. In dependent contexts a                  // ParenListExpr is generated instead of a CXXConstructExpr,                  // filtering out templates automatically for us.                  withInitializer(cxxConstructExpr(                      has(ignoringParenImpCasts(declRefExpr(to(                          parmVarDecl(                              hasType(qualType(                                  // Match only const-ref or a non-const value                                  // parameters. Rvalues and const-values                                  // shouldn't be modified.                                  anyOf(constRefType(), nonConstValueType()))))                              .bind("Param"))))),                      hasDeclaration(cxxConstructorDecl(                          isCopyConstructor(), unless(isDeleted()),                          hasDeclContext(                              cxxRecordDecl(isMoveConstructible())))))))                  .bind("Initializer")))          .bind("Ctor"),      this);}
开发者ID:bbannier,项目名称:clang-tools-extra-1,代码行数:31,


示例3: hasArgument

void InaccurateEraseCheck::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 CheckForEndCall = hasArgument(      1, anyOf(cxxConstructExpr(has(ignoringParenImpCasts(                   cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))))                       .bind("InaccEndCall")))),               anything()));  Finder->addMatcher(      cxxMemberCallExpr(          on(hasType(namedDecl(matchesName("^::std::")))),          callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),          hasArgument(0, has(ignoringParenImpCasts(                             callExpr(callee(functionDecl(matchesName(                                          "^::std::(remove(_if)?|unique)$"))),                                      CheckForEndCall)                                 .bind("InaccAlgCall")))),          unless(isInTemplateInstantiation()))          .bind("InaccErase"),      this);}
开发者ID:ChrisCummins,项目名称:clang-tools-extra,代码行数:25,


示例4: callExpr

void InaccurateEraseCheck::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 EndCall =      callExpr(          callee(functionDecl(hasAnyName("remove", "remove_if", "unique"))),          hasArgument(              1,              anyOf(cxxConstructExpr(has(ignoringImplicit(                        cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))))                            .bind("end")))),                    anything())))          .bind("alg");  const auto DeclInStd = type(hasUnqualifiedDesugaredType(      tagType(hasDeclaration(decl(isInStdNamespace())))));  Finder->addMatcher(      cxxMemberCallExpr(          on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd)))),          callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),          hasArgument(0, has(ignoringImplicit(                             anyOf(EndCall, has(ignoringImplicit(EndCall)))))),          unless(isInTemplateInstantiation()))          .bind("erase"),      this);}
开发者ID:llvm-mirror,项目名称:clang-tools-extra,代码行数:29,


示例5: unless

void MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {  if (!isLanguageVersionSupported(getLangOpts()))    return;  // Calling make_smart_ptr from within a member function of a type with a  // private or protected constructor would be ill-formed.  auto CanCallCtor = unless(has(ignoringImpCasts(      cxxConstructExpr(hasDeclaration(decl(unless(isPublic())))))));  Finder->addMatcher(      cxxBindTemporaryExpr(has(ignoringParenImpCasts(          cxxConstructExpr(              hasType(getSmartPointerTypeMatcher()), argumentCountIs(1),              hasArgument(0,                          cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(                                         equalsBoundNode(PointerType))))),                                     CanCallCtor)                              .bind(NewExpression)),              unless(isInTemplateInstantiation()))              .bind(ConstructorCall)))),      this);  Finder->addMatcher(      cxxMemberCallExpr(          thisPointerType(getSmartPointerTypeMatcher()),          callee(cxxMethodDecl(hasName("reset"))),          hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),          unless(isInTemplateInstantiation()))          .bind(ResetCall),      this);}
开发者ID:staronj,项目名称:clang-tools-extra,代码行数:31,


示例6: parmVarDecl

void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) {  // Forwarding references require C++11 or later.  if (!getLangOpts().CPlusPlus11)    return;  auto ForwardingRefParm =      parmVarDecl(          hasType(qualType(rValueReferenceType(),                           references(templateTypeParmType(hasDeclaration(                               templateTypeParmDecl().bind("type-parm-decl")))),                           unless(references(isConstQualified())))))          .bind("parm-var");  DeclarationMatcher findOverload =      cxxConstructorDecl(          hasParameter(0, ForwardingRefParm),          unless(hasAnyParameter(              // No warning: enable_if as constructor parameter.              parmVarDecl(hasType(isEnableIf())))),          unless(hasParent(functionTemplateDecl(has(templateTypeParmDecl(              // No warning: enable_if as type parameter.              hasDefaultArgument(isEnableIf())))))))          .bind("ctor");  Finder->addMatcher(findOverload, this);}
开发者ID:kdeyev,项目名称:clang-tools-extra,代码行数:25,


示例7: allOf

void NonPrivateMemberVariablesInClassesCheck::registerMatchers(    MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus)    return;  // We can ignore structs/classes with all member variables being public.  auto ShouldIgnoreRecord =      allOf(boolean(IgnoreClassesWithAllMemberVariablesBeingPublic),            unless(hasNonPublicMemberVariable()));  // There are three visibility types: public, protected, private.  // If we are ok with public fields, then we only want to complain about  // protected fields, else we want to complain about all non-private fields.  // We can ignore public member variables in structs/classes, in unions.  auto InterestingField = fieldDecl(      IgnorePublicMemberVariables ? isProtected() : unless(isPrivate()));  // We only want the records that not only contain the mutable data (non-static  // member variables), but also have some logic (non-static member functions).  // We may optionally ignore records where all the member variables are public.  Finder->addMatcher(cxxRecordDecl(anyOf(isStruct(), isClass()), hasMethods(),                                   hasNonStaticMethod(),                                   unless(ShouldIgnoreRecord),                                   forEach(InterestingField.bind("field")))                         .bind("record"),                     this);}
开发者ID:vmiklos,项目名称:clang-tools-extra,代码行数:27,


示例8: switchStmt

void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {  Finder->addMatcher(      switchStmt(          hasCondition(allOf(              // Match on switch statements that have either a bit-field or              // an integer condition. The ordering in 'anyOf()' is              // important because the last condition is the most general.              anyOf(ignoringImpCasts(memberExpr(hasDeclaration(                        fieldDecl(isBitField()).bind("bitfield")))),                    ignoringImpCasts(declRefExpr().bind("non-enum-condition"))),              // 'unless()' must be the last match here and must be bound,              // otherwise the matcher does not work correctly, because it              // will not explicitly ignore enum conditions.              unless(ignoringImpCasts(                  declRefExpr(hasType(enumType())).bind("enum-condition"))))))          .bind("switch"),      this);  // This option is noisy, therefore matching is configurable.  if (WarnOnMissingElse) {    Finder->addMatcher(        ifStmt(allOf(hasParent(ifStmt()), unless(hasElse(anything()))))            .bind("else-if"),        this);  }}
开发者ID:staronj,项目名称:clang-tools-extra,代码行数:26,


示例9: methodDecl

void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {    Finder->addMatcher(        methodDecl(anyOf(constructorDecl(), hasOverloadedOperatorName("=")),                   unless(isImplicit()), unless(isDeleted()))        .bind("decl"),        this);}
开发者ID:nbstar,项目名称:clang-tools-extra,代码行数:7,


示例10: unless

void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {  Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),                                  unless(isExternC()))                         .bind(FunctionId),                     this);  Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);  auto ParenFunctionType = parenType(innerType(functionType()));  auto PointerToFunctionType = pointee(ParenFunctionType);  auto FunctionOrMemberPointer =      anyOf(hasType(pointerType(PointerToFunctionType)),            hasType(memberPointerType(PointerToFunctionType)));  Finder->addMatcher(fieldDecl(FunctionOrMemberPointer).bind(FieldId), this);  Finder->addMatcher(varDecl(FunctionOrMemberPointer).bind(VarId), this);  auto CastDestinationIsFunction =      hasDestinationType(pointsTo(ParenFunctionType));  Finder->addMatcher(      cStyleCastExpr(CastDestinationIsFunction).bind(CStyleCastId), this);  Finder->addMatcher(      cxxStaticCastExpr(CastDestinationIsFunction).bind(NamedCastId), this);  Finder->addMatcher(      cxxReinterpretCastExpr(CastDestinationIsFunction).bind(NamedCastId),      this);  Finder->addMatcher(      cxxConstCastExpr(CastDestinationIsFunction).bind(NamedCastId), this);  Finder->addMatcher(lambdaExpr().bind(LambdaId), this);}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:26,


示例11: methodDecl

void AssignOperatorSignatureCheck::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) {    const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(        pointee(unless(isConstQualified()),                hasDeclaration(equalsBoundNode("class"))))));    const auto IsSelf = qualType(anyOf(        hasDeclaration(equalsBoundNode("class")),        referenceType(pointee(hasDeclaration(equalsBoundNode("class"))))));    const auto IsSelfAssign =        methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),                   hasName("operator="), ofClass(recordDecl().bind("class")),                   hasParameter(0, parmVarDecl(hasType(IsSelf))))            .bind("method");    Finder->addMatcher(        methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),        this);    const auto BadSelf = referenceType(        anyOf(lValueReferenceType(pointee(unless(isConstQualified()))),              rValueReferenceType(pointee(isConstQualified()))));    Finder->addMatcher(        methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf))))            .bind("ArgumentType"),        this);    Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this);  }}
开发者ID:Arhzi,项目名称:clang-tools-extra,代码行数:34,


示例12: usingDecl

void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus17)    return;  std::string MatchText = "::std::uncaught_exception";  // Using declaration: warning and fix-it.  Finder->addMatcher(      usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(hasName(MatchText))))          .bind("using_decl"),      this);  // DeclRefExpr: warning, no fix-it.  Finder->addMatcher(declRefExpr(allOf(to(functionDecl(hasName(MatchText))),                                       unless(callExpr())))                         .bind("decl_ref_expr"),                     this);  // CallExpr: warning, fix-it.  Finder->addMatcher(      callExpr(allOf(hasDeclaration(functionDecl(hasName(MatchText))),                     unless(hasAncestor(initListExpr()))))          .bind("call_expr"),      this);  // CallExpr in initialisation list: warning, fix-it with avoiding narrowing  // conversions.  Finder->addMatcher(      callExpr(allOf(hasAncestor(initListExpr()),                     hasDeclaration(functionDecl(hasName(MatchText)))))          .bind("init_call_expr"),      this);}
开发者ID:staronj,项目名称:clang-tools-extra,代码行数:32,


示例13: allOf

void SuspiciousEnumUsageCheck::registerMatchers(MatchFinder *Finder) {  const auto enumExpr = [](StringRef RefName, StringRef DeclName) {    return allOf(ignoringImpCasts(expr().bind(RefName)),                 ignoringImpCasts(hasType(enumDecl().bind(DeclName))));  };  Finder->addMatcher(      binaryOperator(hasOperatorName("|"), hasLHS(enumExpr("", "enumDecl")),                     hasRHS(allOf(enumExpr("", "otherEnumDecl"),                                  ignoringImpCasts(hasType(enumDecl(                                      unless(equalsBoundNode("enumDecl"))))))))          .bind("diffEnumOp"),      this);  Finder->addMatcher(      binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("|")),                     hasLHS(enumExpr("lhsExpr", "enumDecl")),                     hasRHS(allOf(enumExpr("rhsExpr", ""),                                  ignoringImpCasts(hasType(enumDecl(                                      equalsBoundNode("enumDecl"))))))),      this);  Finder->addMatcher(      binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("|")),                     hasEitherOperand(                         allOf(hasType(isInteger()), unless(enumExpr("", "")))),                     hasEitherOperand(enumExpr("enumExpr", "enumDecl"))),      this);  Finder->addMatcher(      binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("+=")),                     hasRHS(enumExpr("enumExpr", "enumDecl"))),      this);}
开发者ID:kdeyev,项目名称:clang-tools-extra,代码行数:34,


示例14: cxxMethodDecl

void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {  auto PrivateSpecialFn = cxxMethodDecl(      isPrivate(),      anyOf(cxxConstructorDecl(anyOf(isDefaultConstructor(),                                     isCopyConstructor(), isMoveConstructor())),            cxxMethodDecl(                anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator())),            cxxDestructorDecl()));  Finder->addMatcher(      cxxMethodDecl(          PrivateSpecialFn,          unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),                       ast_matchers::isTemplateInstantiation(),                       // Ensure that all methods except private special member                       // functions are defined.                       hasParent(cxxRecordDecl(hasMethod(unless(                           anyOf(PrivateSpecialFn, hasBody(stmt()), isPure(),                                 isDefaulted(), isDeleted()))))))))          .bind(SpecialFunction),      this);  Finder->addMatcher(      cxxMethodDecl(isDeleted(), unless(isPublic())).bind(DeletedNotPublic),      this);}
开发者ID:cierpuchaw,项目名称:clang-tools-extra,代码行数:26,


示例15: parmVarDecl

void NonConstReferences::registerMatchers(MatchFinder *Finder) {  Finder->addMatcher(      parmVarDecl(          unless(isInstantiated()),          hasType(references(              qualType(unless(isConstQualified())).bind("referenced_type"))),          unless(hasType(rValueReferenceType())))          .bind("param"),      this);}
开发者ID:primitivorm,项目名称:clang-tools-extra,代码行数:10,


示例16: functionDecl

void FunctionSizeCheck::registerMatchers(MatchFinder *Finder) {  Finder->addMatcher(      functionDecl(          unless(isInstantiated()),          forEachDescendant(              stmt(unless(compoundStmt()),                   hasParent(stmt(anyOf(compoundStmt(), ifStmt(),                                        anyOf(whileStmt(), doStmt(),                                              forRangeStmt(), forStmt())))))                  .bind("stmt"))).bind("func"),      this);}
开发者ID:309972460,项目名称:software,代码行数:12,


示例17: cStyleCastExpr

voidAvoidCStyleCastsCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {  Finder->addMatcher(      cStyleCastExpr(          // Filter out (EnumType)IntegerLiteral construct, which is generated          // for non-type template arguments of enum types.          // FIXME: Remove this once this is fixed in the AST.          unless(hasParent(substNonTypeTemplateParmExpr())),          // Avoid matches in template instantiations.          unless(isInTemplateInstantiation())).bind("cast"),      this);}
开发者ID:309972460,项目名称:software,代码行数:12,


示例18: parmVarDecl

void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {  const auto ExpensiveValueParamDecl =      parmVarDecl(hasType(hasCanonicalType(allOf(matchers::isExpensiveToCopy(),                                                 unless(referenceType())))),                  decl().bind("param"));  Finder->addMatcher(      functionDecl(isDefinition(), unless(cxxMethodDecl(isOverride())),                   unless(isInstantiated()),                   has(typeLoc(forEach(ExpensiveValueParamDecl))),                   decl().bind("functionDecl")),      this);}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:12,


示例19: cxxMethodDecl

void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {  // Only register the matchers for C++11; the functionality currently does not  // provide any benefit to other languages, despite being benign.  if (!getLangOpts().CPlusPlus11)    return;  Finder->addMatcher(      cxxMethodDecl(anyOf(cxxConstructorDecl(), hasOverloadedOperatorName("=")),                    unless(isImplicit()), unless(isDeleted()))          .bind("decl"),      this);}
开发者ID:cierpuchaw,项目名称:clang-tools-extra,代码行数:12,


示例20: cxxMethodDecl

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);}
开发者ID:ingowald,项目名称:llvm-project,代码行数:51,


示例21: cxxThrowExpr

void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus)    return;  Finder->addMatcher(      cxxThrowExpr(allOf(has(expr(unless(hasType(qualType(hasCanonicalType(                             hasDeclaration(cxxRecordDecl(isSameOrDerivedFrom(                                 hasName("std::exception")))))))))),                         has(expr(unless(cxxUnresolvedConstructExpr()))),                         eachOf(has(expr(hasType(namedDecl().bind("decl")))),                                anything())))          .bind("bad_throw"),      this);}
开发者ID:kdeyev,项目名称:clang-tools-extra,代码行数:14,


示例22: start_link_threads

/*{{{  start link threads */static void start_link_threads(int index, char *argv){ int	linkno, channel;  unless (sscanf(argv, "%d.%d", &linkno, &channel) == 2)   Fatal("invalid link specification %s", argv);  NumberThreads++;  unless(Fork(StackSize, &link_receiver, 3 * sizeof(int), index, linkno, channel))   Fatal("out of memory starting receiver for link %d", linkno);  NumberThreads++;  unless(Fork(StackSize, &link_sender, 3 * sizeof(int), index, linkno, channel+1))   Fatal("out of memory starting sender for link %d", linkno);}
开发者ID:jamjr,项目名称:Helios-NG,代码行数:15,


示例23: classTemplateSpecializationDecl

void InefficientAlgorithmCheck::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 std::string Algorithms =      "^::std::(find|count|equal_range|lower_bound|upper_bound)$";  const auto ContainerMatcher = classTemplateSpecializationDecl(      matchesName("^::std::(unordered_)?(multi)?(set|map)$"));  const auto Matcher =      callExpr(          callee(functionDecl(matchesName(Algorithms))),          hasArgument(              0, constructExpr(has(memberCallExpr(                     callee(methodDecl(hasName("begin"))),                     on(declRefExpr(                            hasDeclaration(decl().bind("IneffContObj")),                            anyOf(hasType(ContainerMatcher.bind("IneffCont")),                                  hasType(pointsTo(                                      ContainerMatcher.bind("IneffContPtr")))))                            .bind("IneffContExpr")))))),          hasArgument(1, constructExpr(has(memberCallExpr(                             callee(methodDecl(hasName("end"))),                             on(declRefExpr(hasDeclaration(                                 equalsBoundNode("IneffContObj")))))))),          hasArgument(2, expr().bind("AlgParam")),          unless(isInTemplateInstantiation()))          .bind("IneffAlg");  Finder->addMatcher(Matcher, this);}
开发者ID:nick-schultz,项目名称:clang-tools-extra,代码行数:32,


示例24: cxxConstructorDecl

void ExplicitConstructorCheck::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)    Finder->addMatcher(        cxxConstructorDecl(unless(isInstantiated())).bind("ctor"), this);}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:7,


示例25: implicitCastExpr

void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus)    return;  // The only allowed array to pointer decay  // 1) just before array subscription  // 2) inside a range-for over an array  // 3) if it converts a string literal to a pointer  Finder->addMatcher(      implicitCastExpr(unless(hasParent(arraySubscriptExpr())),                       unless(hasParentIgnoringImpCasts(explicitCastExpr())),                       unless(isInsideOfRangeBeginEndStmt()),                       unless(hasSourceExpression(stringLiteral())))          .bind("cast"),      this);}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:16,


示例26: memberExpr

void ShrinkToFitCheck::registerMatchers(MatchFinder *Finder) {  // Swap as a function need not to be considered, because rvalue can not  // be bound to a non-const reference.  const auto ShrinkableAsMember =      memberExpr(member(valueDecl().bind("ContainerDecl")));  const auto ShrinkableAsDecl =      declRefExpr(hasDeclaration(valueDecl().bind("ContainerDecl")));  const auto CopyCtorCall = constructExpr(      hasArgument(0, anyOf(ShrinkableAsMember, ShrinkableAsDecl,                           unaryOperator(has(ShrinkableAsMember)),                           unaryOperator(has(ShrinkableAsDecl)))));  const auto SwapParam = expr(anyOf(      memberExpr(member(equalsBoundNode("ContainerDecl"))),      declRefExpr(hasDeclaration(equalsBoundNode("ContainerDecl"))),      unaryOperator(has(memberExpr(member(equalsBoundNode("ContainerDecl"))))),      unaryOperator(          has(declRefExpr(hasDeclaration(equalsBoundNode("ContainerDecl")))))));  Finder->addMatcher(      memberCallExpr(on(hasType(namedDecl(stlShrinkableContainer()))),                     callee(methodDecl(hasName("swap"))),                     has(memberExpr(hasDescendant(CopyCtorCall))),                     hasArgument(0, SwapParam.bind("ContainerToShrink")),                     unless(isInTemplateInstantiation()))          .bind("CopyAndSwapTrick"),      this);}
开发者ID:nick-schultz,项目名称:clang-tools-extra,代码行数:27,


示例27: binaryOperator

void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus)    return;  // Flag all operators +, -, +=, -=, ++, -- that result in a pointer  Finder->addMatcher(      binaryOperator(          anyOf(hasOperatorName("+"), hasOperatorName("-"),                hasOperatorName("+="), hasOperatorName("-=")),          hasType(pointerType()),          unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit()))))))          .bind("expr"),      this);  Finder->addMatcher(      unaryOperator(anyOf(hasOperatorName("++"), hasOperatorName("--")),                    hasType(pointerType()))          .bind("expr"),      this);  // Array subscript on a pointer (not an array) is also pointer arithmetic  Finder->addMatcher(      arraySubscriptExpr(          hasBase(ignoringImpCasts(              anyOf(hasType(pointerType()),                    hasType(decayedType(hasDecayedType(pointerType())))))))          .bind("expr"),      this);}
开发者ID:cierpuchaw,项目名称:clang-tools-extra,代码行数:29,


示例28: expr

void FasterStringFindCheck::registerMatchers(MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus)    return;  const auto SingleChar =      expr(ignoringParenCasts(stringLiteral(hasSize(1)).bind("literal")));  const auto StringFindFunctions =      anyOf(hasName("find"), hasName("rfind"), hasName("find_first_of"),            hasName("find_first_not_of"), hasName("find_last_of"),            hasName("find_last_not_of"));  llvm::Optional<ast_matchers::internal::Matcher<NamedDecl>> IsStringClass;  for (const auto &ClassName : StringLikeClasses) {    const auto HasName = hasName(ClassName);    IsStringClass = IsStringClass ? anyOf(*IsStringClass, HasName) : HasName;  }  if (IsStringClass) {    Finder->addMatcher(        cxxMemberCallExpr(            callee(functionDecl(StringFindFunctions).bind("func")),            anyOf(argumentCountIs(1), argumentCountIs(2)),            hasArgument(0, SingleChar),            on(expr(hasType(recordDecl(*IsStringClass)),                    unless(hasSubstitutedType())))),        this);  }}
开发者ID:adiog,项目名称:clang-tools-extra,代码行数:30,


示例29: cxxRecordDecl

void UseNodiscardCheck::registerMatchers(MatchFinder *Finder) {  // If we use ``[[nodiscard]]`` attribute, we require at least C++17. Use a  // macro or ``__attribute__`` with pre c++17 compilers by using  // ReplacementString option.  if ((NoDiscardMacro == "[[nodiscard]]" && !getLangOpts().CPlusPlus17) ||      !getLangOpts().CPlusPlus)    return;  auto FunctionObj =      cxxRecordDecl(hasAnyName("::std::function", "::boost::function"));  // Find all non-void const methods which have not already been marked to  // warn on unused result.  Finder->addMatcher(      cxxMethodDecl(          allOf(isConst(), isDefinitionOrInline(),                unless(anyOf(                    returns(voidType()), isNoReturn(), isOverloadedOperator(),                    isVariadic(), hasTemplateReturnType(),                    hasClassMutableFields(), isConversionOperator(),                    hasAttr(clang::attr::WarnUnusedResult),                    hasType(isInstantiationDependentType()),                    hasAnyParameter(anyOf(                        parmVarDecl(anyOf(hasType(FunctionObj),                                          hasType(references(FunctionObj)))),                        hasType(isNonConstReferenceOrPointer()),                        hasParameterPack()))))))          .bind("no_discard"),      this);}
开发者ID:ingowald,项目名称:llvm-project,代码行数:30,


示例30: cStyleCastExpr

void ProTypeCstyleCastCheck::registerMatchers(MatchFinder *Finder) {  if (!getLangOpts().CPlusPlus)    return;  Finder->addMatcher(      cStyleCastExpr(unless(isInTemplateInstantiation())).bind("cast"), this);}
开发者ID:cierpuchaw,项目名称:clang-tools-extra,代码行数:7,



注:本文中的unless函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ unlikely函数代码示例
C++ unknown_fields函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。