/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
unsigned NonDefaultArgCount = 0; for (unsigned I = 0; I < Call->getNumArgs(); I++) { if (!isa<CXXDefaultArgExpr>(Call->getArg(I))) {
NonDefaultArgCount++;
}
}
constchar *Kind = nullptr; if (isa<CXXOperatorCallExpr>(Call)) {
Kind = "operator";
} elseif (Func->hasAttr<FormatAttr>()) {
Kind = "printf-like";
} elseif (NonDefaultArgCount == 1) { auto *Ident = Func->getIdentifier(); if (Ident && (Ident->isStr("BitwiseCast") || Ident->isStr("bit_cast"))) { return; // These are casts, and don't look at the string
}
Kind = "single-argument";
} if (!Kind) { return;
}
for (unsigned I = 0; I < Call->getNumArgs(); I++) { const Expr *BareArg = Call->getArg(I); const Expr *Arg = IgnoreTrivials(BareArg);
const CallExpr *ArgCall = dyn_cast<CallExpr>(Arg); if (!ArgCall) { continue;
}
const FunctionDecl *ArgCallee = ArgCall->getDirectCallee(); if (!ArgCallee) { continue;
}
// We may have been cast to another type like `void*`, in whichc ase we // shouldn't fire the diagnostic. const clang::PointerType *PT =
BareArg->getType()->template getAs<clang::PointerType>(); if (!PT) { continue;
}
if (hasCustomAttribute<moz_non_terminated_string>(ArgCallee)) {
Check.diag(ArgCall->getBeginLoc(), "MOZ_NON_TERMINATED_STRING return value from '%0' passed as " "an argument to %1 function '%2'",
DiagnosticIDs::Error)
<< ArgCallee->getQualifiedNameAsString() << Kind
<< Func->getQualifiedNameAsString();
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.