æã ãã³ã³ãã€ã©ã®æ¬¡ã®ããŒãžã§ã³ã®ãã§ãã¯ã«é¢ããèšäºãæžããªããã°ãªããŸãããé¢çœããªãã§ãããã ããå®è·µã瀺ãããã«ããããé·æéè¡ãããªãå Žåã人ã ã¯PVS-Studioã¢ãã©ã€ã¶ãŒããã°ãæœåšçãªè匱æ§ã®åªãããã£ããã£ãŒã®ç§°å·ã«å€ãããã©ããçåã«æãå§ããŸãããããããæ°ããã³ã³ãã€ã©ã¯ãã§ã«ãããè¡ãæ¹æ³ãç¥ã£ãŠããŸããïŒã¯ããã³ã³ãã€ã©ã¯éæ¢ããŠããŸããããã ããPVS-Studioãéçºäžã§ãããã³ã³ãã€ã©ãªã©ã®é«å質ãããžã§ã¯ãã®ã³ãŒãã§ããšã©ãŒãæ€åºã§ããããšãäœåºŠã瀺ããŠããŸãã
Clangã³ãŒããå確èªããæé
æ£çŽãªãšããããã®ããã¹ãã®åºç€ãšããŠããPVS-Studioã䜿çšããGCC10ã³ã³ãã€ã©ã®ãã§ãã¯ããšããèšäºãåãäžããŸããããããã£ãŠããã§ã«ã©ããã§ããã€ãã®æ®µèœãèªãã ããã«æãããå Žåã¯ãããã¯æããªãã§ããã:)ã
ã³ã³ãã€ã©ãŒã«ç¬èªã®éçã³ãŒãã¢ãã©ã€ã¶ãŒãçµã¿èŸŒãŸããŠããããšã¯åšç¥ã®äºå®ã§ãããããããéçºãããŠããŸãããããã£ãŠãPVS-Studioéçã¢ãã©ã€ã¶ãŒãã³ã³ãã€ã©ãŒå ã§ããšã©ãŒãæ€åºããæ¹æ³ãšãäœãããã«ãã³ãé£ã¹ãŠããªãããšã«ã€ããŠã®èšäºãæã æžããŠããŸã:)ã
å®éãåŸæ¥ã®éçã¢ãã©ã€ã¶ãŒãã³ã³ãã€ã©ãŒãšæ¯èŒããããšã¯ã§ããŸãããéçã¢ãã©ã€ã¶ãŒã¯ãã³ãŒãå ã®ãšã©ãŒãèŠã€ããã ãã§ãªããéçºãããã€ã³ãã©ã¹ãã©ã¯ãã£ãŒã§ããããŸããããšãã°ãããã¯SonarQubeãPlatformIOãAzure DevOpsãTravis CIãCircleCIãGitLab CI / CDãJenkinsãVisualStudioãªã©ã®ã·ã¹ãã ãšã®çµ±åã§ãããããã¯èŠåã倧éã«æå¶ããããã®é«åºŠãªã¡ã«ããºã ã§ããã倧èŠæš¡ãªå€ããããžã§ã¯ãã§ãPVS-Studioã®äœ¿çšããã°ããéå§ã§ããŸããããã¯éç¥é åžã§ãããªã©ãªã©ããã ããããã§ãæåã«å°ãããã質åã¯ããPVS-Studioã¯ãã³ã³ãã€ã©ãŒãèŠã€ããããªããã®ãèŠã€ããããšãã§ãããããšãããã®ã§ããããã¯ããããã®ã³ã³ãã€ã©èªäœã®ãã§ãã¯ã«é¢ããèšäºãäœåºŠãæžãããšãæå³ããŸãã
Clangãããžã§ã¯ãã®ãã§ãã¯ã®ãããã¯ã«æ»ããŸãããããã®ãããžã§ã¯ãã«ãã ããå¿ èŠã¯ãªãããããäœã§ããããäŒããå¿ èŠã¯ãããŸãããå®éãClang 11èªäœã®ã³ãŒãã ãã§ãªãããããæ§ç¯ãããŠããLLVM11ã©ã€ãã©ãªããã¹ããããŸããããã®èšäºã®èŠ³ç¹ããã¯ãã³ã³ãã€ã©ãŸãã¯ã©ã€ãã©ãªã³ãŒãã®ã©ã¡ãã«æ¬ é¥ãèŠã€ãã£ããã¯é¢ä¿ãããŸããã
Clang / LLVMã³ãŒãã¯ãGCCã³ãŒããããã¯ããã«æ確ã«èŠããŸãããå°ãªããšããããã®ã²ã©ããã¯ãã¯ãã¹ãŠæ¬ èœããŠãããC ++èšèªã®ææ°æ©èœãç©æ¥µçã«äœ¿çšãããŠããŸãã
ããã«ããããããããããžã§ã¯ãã¯å€§èŠæš¡ã§ãããã¢ãã©ã€ã¶ãŒã®äºåèšå®ããªããšãã¬ããŒãã衚瀺ããã®ã¯äŸç¶ãšããŠéåžžã«é¢åã§ããåºæ¬çã«ãå誀æ€ç¥ã¯å¹²æžããŸãããååœãéœæ§ãšã¯ãã¢ãã©ã€ã¶ãŒãæ£åŒã«æ£ããããèŠåã«æå³ããªãç¶æ³ãæå³ããŸããããšãã°ããã®ãããªããžãã£ãã®å€ãã¯ããŠããããã¹ããšçæãããã³ãŒãã«å¯ŸããŠçºè¡ãããŸãã
ãã¹ãã®äŸïŒ
Spaces.SpacesInParentheses = false; // <=
Spaces.SpacesInCStyleCastParentheses = true; // <=
verifyFormat("Type *A = ( Type * )P;", Spaces);
verifyFormat("Type *A = ( vector<Type *, int *> )P;", Spaces);
verifyFormat("x = ( int32 )y;", Spaces);
verifyFormat("int a = ( int )(2.0f);", Spaces);
verifyFormat("#define AA(X) sizeof((( X * )NULL)->a)", Spaces);
verifyFormat("my_int a = ( my_int )sizeof(int);", Spaces);
verifyFormat("#define x (( int )-1)", Spaces);
// Run the first set of tests again with:
Spaces.SpacesInParentheses = false; // <=
Spaces.SpaceInEmptyParentheses = true;
Spaces.SpacesInCStyleCastParentheses = true; // <=
verifyFormat("call(x, y, z);", Spaces);
verifyFormat("call( );", Spaces);
ã¢ãã©ã€ã¶ãŒã¯ãå€æ°ã«ãã§ã«å«ãŸããŠããã®ãšåãå€ãå²ãåœãŠãããŠããããšãèŠåããŸãïŒ
- V1048'Spaces.SpacesInParentheses 'å€æ°ã«åãå€ãå²ãåœãŠãããŸãããFormatTest.cpp 11554
- V1048'Spaces.SpacesInCStyleCastParentheses 'å€æ°ã«åãå€ãå²ãåœãŠãããŸãããFormatTest.cpp 11556
æ£åŒã«ã¯ãã¢ãã©ã€ã¶ãŒã¯æ£ããå¿çãè¿ããŸãããããã¯ãç°¡ç¥åãŸãã¯ä¿®æ£ããå¿ èŠãããã³ãŒããã©ã°ã¡ã³ãã§ããåæã«ãå®éã«ã¯ãã¹ãŠãæ£åžžã§ãããäœããç·šéããŠãæå³ããªãããšã¯æããã§ãã
å¥ã®äŸïŒã¢ãã©ã€ã¶ãŒã¯ãèªåçæãããOptions.incãã¡ã€ã«ã«èšå€§ãªæ°ã®èŠåãçºè¡ããŸãããã¡ã€ã«ã«ãã³ãŒãã·ãŒããããããŸãã
ãããŠãPVS-Studioã¯ããããã¹ãŠã«èŠåãéä¿¡ããŸãã
- V501 '=='æŒç®åã®å·ŠåŽãšå³åŽã«åäžã®éšååŒããããŸãïŒnullptr == nullptr Options.inc 26
- V501 '=='æŒç®åã®å·ŠåŽãšå³åŽã«åäžã®éšååŒããããŸãïŒnullptr == nullptr Options.inc 27
- V501 '=='æŒç®åã®å·ŠåŽãšå³åŽã«åäžã®éšååŒããããŸãïŒnullptr == nullptr Options.inc 28
- åè¡ã«ã€ããŠãªã©...
ããã¯ãã¹ãŠæãããšã§ã¯ãããŸãããããã¯ãã¹ãŠç¡å¹ã«ããããšãã§ããŸããäžèŠãªãã¡ã€ã«ã®ãã§ãã¯ãç¡å¹ã«ããããäžéšã®ãã¯ããé¢æ°ãããŒã¯ã¢ããããããç¹å®ã®çš®é¡ã®ã¢ã©ãŒã ãæå¶ãããããŸããå¯èœã§ãããèšäºãæžãã¿ã¹ã¯ã®äžéšãšããŠãããè¡ãããšã¯é¢çœããããŸããããããã£ãŠãGCCã³ã³ãã€ã©ã«é¢ããèšäºãšãŸã£ããåãããšãããŸãããèšäºãæžãããã®11ã®èå³æ·±ãã³ãŒãäŸãã§ãããŸã§ãã¬ããŒãã調ã¹ãŸããããªã11ïŒClangã®ããŒãžã§ã³ã¯11ãªã®ã§ããã©ã°ã¡ã³ãã11ã«ãããšæããŸãã:)ã
11ã®çãããã³ãŒãã¹ãããã
ãã©ã°ã¡ã³ãN1ã1ã«ããã¢ãžã¥ãé€ç®
ãã£ãããééãïŒç§ã¯ãããã倧奜ãïŒ
void Act() override {
....
// If the value type is a vector, and we allow vector select, then in 50%
// of the cases generate a vector select.
if (isa<FixedVectorType>(Val0->getType()) && (getRandom() % 1)) {
unsigned NumElem =
cast<FixedVectorType>(Val0->getType())->getNumElements();
CondTy = FixedVectorType::get(CondTy, NumElem);
}
....
}
PVS-StudioèŠåïŒV10631åã®æäœã«ããã¢ãžã¥ãã¯ç¡æå³ã§ããçµæã¯åžžã«ãŒãã«ãªããŸãã llvm-stress.cpp 631ã¢ãžã¥ã
é€ç®ã¯ã0ãŸãã¯1ã®ã©ã³ãã å€ãååŸããããã«äœ¿çšãããŸããããããæããã«ããã®1ã®å€ã¯çŽããããã2ã§å²ãå¿ èŠã¯ãããŸããã人ã ã¯1ã§å²ããšããå€å žçãªãšã©ãŒãã¿ãŒã³ãäœæããŸããçµæã¯åžžã«0ã§ãããããæäœXïŒ 1ã¯ç¡æå³ã§ããã³ãŒãã®æ£ããããŒãžã§ã³ïŒ
if (isa<FixedVectorType>(Val0->getType()) && (getRandom() % 2)) {
æè¿PVS-Studioã«ç»å ŽããDiagnosticsV1063ã¯ãšãŠã€ããªãã·ã³ãã«ã§ãããã芧ã®ãšãããæ©èœããŸãã
ãåç¥ã®ããã«ãã³ã³ãã€ã©éçºè ã¯ç§ãã¡ãè¡ã£ãŠããããšãèŠãŠããã¹ããã©ã¯ãã£ã¹ãåããŠããŸããããã¯äœãæªãããšã§ã¯ãããŸãããPVS-Studioãé²æ©ã®åååã§ããããšãå¬ããæããŸããåã蚺æãClangãšGCCã«è¡šç€ºããããŸã§ã®æéãèšå®ããŸã:)ã
ãã©ã°ã¡ã³ãN2ãç¶æ ã®ã¿ã€ããã¹
class ReturnValueSlot {
....
bool isNull() const { return !Addr.isValid(); }
....
};
static bool haveSameParameterTypes(ASTContext &Context, const FunctionDecl *F1,
const FunctionDecl *F2, unsigned NumParams) {
....
unsigned I1 = 0, I2 = 0;
for (unsigned I = 0; I != NumParams; ++I) {
QualType T1 = NextParam(F1, I1, I == 0);
QualType T2 = NextParam(F2, I2, I == 0);
if (!T1.isNull() && !T1.isNull() && !Context.hasSameUnqualifiedType(T1, T2))
return false;
}
return true;
}
PVS-StudioèŠåïŒV501 '&&'æŒç®åã®å·ŠåŽãšå³åŽã«åäžã®éšååŒããããŸãïŒïŒT1.isNullïŒïŒ&&ïŒT1.isNullïŒïŒSemaOverload.cpp 9493
2åãã§ãã¯ããŠããŸãïŒT1.isNull ïŒïŒãããã¯æãããªã¿ã€ããã¹ã§ãããæ¡ä»¶ã®2çªç®ã®éšåã¯T2å€æ°ããã§ãã¯ããå¿ èŠããããŸãã
ãã©ã°ã¡ã³ãN3ãã¢ã¬ã€ã®ç¯å²å€ã®å¯èœæ§
std::vector<Decl *> DeclsLoaded;
SourceLocation ASTReader::getSourceLocationForDeclID(GlobalDeclID ID) {
....
unsigned Index = ID - NUM_PREDEF_DECL_IDS;
if (Index > DeclsLoaded.size()) {
Error("declaration ID out-of-range for AST file");
return SourceLocation();
}
if (Decl *D = DeclsLoaded[Index])
return D->getLocation();
....
}
PVS-Studioã®èŠåïŒV557ã¢ã¬ã€ã®ãªãŒããŒã©ã³ãçºçããå¯èœæ§ããããŸãããã€ã³ããã¯ã¹ãã€ã³ããã¯ã¹ã¯ãé åã®å¢çãè¶ ããŠããŸããASTReader.cpp 7318
é åã«1ã€ã®èŠçŽ ãå«ãŸããIndexå€æ°ã1ã€ã§ãããšããŸããæ¡ä»¶ïŒ1> 1ïŒã¯åœã§ããããã®çµæãé åã¯ãªãŒããŒã©ã³ããŸããæ£ãããã§ãã¯ïŒ
if (Index >= DeclsLoaded.size()) {
ãã©ã°ã¡ã³ãN4ãåŒæ°ã®è©äŸ¡ã®é åº
void IHexELFBuilder::addDataSections() {
....
uint32_t SecNo = 1;
....
Section = &Obj->addSection<OwnedDataSection>(
".sec" + std::to_string(SecNo++), RecAddr,
ELF::SHF_ALLOC | ELF::SHF_WRITE, SecNo);
....
}
PVS-StudioèŠåïŒV567äžç¹å®ã®åäœã'addSection'é¢æ°ã§ã¯ãåŒæ°ã®è©äŸ¡é åºãå®çŸ©ãããŠããŸããã'SecNo'å€æ°ã調ã¹ãããšãæ€èšããŠãã ãããObject.cpp 1223 SecNo
åŒæ°ã2å䜿çšãããéäžã§ã€ã³ã¯ãªã¡ã³ããããããšã«æ³šæããŠãã ãããåŒæ°ãã©ã®ãããªé åºã§è©äŸ¡ãããããèšãããšã¯äžå¯èœã§ãããããã£ãŠãçµæã¯ã³ã³ãã€ã©ã®ããŒãžã§ã³ãŸãã¯ã³ã³ãã€ã«èšå®ã«ãã£ãŠç°ãªããŸãã
ãããç·åçãªäŸã§èª¬æããŸãããã
#include <cstdio>
int main()
{
int i = 1;
printf("%d, %d\n", i, i++);
return 0;
}
ã³ã³ãã€ã©ã«ãã£ãŠã¯ãã1ã2ããšã2ã1ãã®äž¡æ¹ãå°å·ã§ããŸããã³ã³ãã€ã©ãšã¯ã¹ãããŒã©ã䜿çšãããšã次ã®çµæãåŸãããŸãã
- Clang 11.0.0ã§ã³ã³ãã€ã«ãããããã°ã©ã ã¯ã1ã1ãçæããŸãã
- GCC 10.2ã§ã³ã³ãã€ã«ãããããã°ã©ã ã¯ã2ã1ãçæããŸãã
èå³æ·±ãããšã«ããã®åçŽãªã±ãŒã¹ã§ã¯ãClangã³ã³ãã€ã©ã¯èŠåãçºè¡ããŸãã
<source>:6:26: warning:
unsequenced modification and access to 'i' [-Wunsequenced]
printf("%d, %d\n", i, i++);
ã©ããããå®éã®ç¶æ³ã§ã¯ããã®èŠåã¯åœ¹ã«ç«ã¡ãŸããã§ããã蚺æã¯å®éã®äœ¿çšã«äžäŸ¿ã§ããããç¡å¹ã«ãªã£ãŠããããã³ã³ãã€ã©ãããè€éãªã±ãŒã¹ã«ã€ããŠèŠåã§ããŸããã§ããã
ãã©ã°ã¡ã³ãN5ãå¥åŠãªåãã¹ã
template <class ELFT>
void GNUStyle<ELFT>::printVersionSymbolSection(const ELFFile<ELFT> *Obj,
const Elf_Shdr *Sec) {
....
Expected<StringRef> NameOrErr =
this->dumper()->getSymbolVersionByIndex(Ndx, IsDefault);
if (!NameOrErr) {
if (!NameOrErr) {
unsigned SecNdx = Sec - &cantFail(Obj->sections()).front();
this->reportUniqueWarning(createError(
"unable to get a version for entry " + Twine(I) +
" of SHT_GNU_versym section with index " + Twine(SecNdx) + ": " +
toString(NameOrErr.takeError())));
}
Versions.emplace_back("<corrupt>");
continue;
}
....
}
PVS-Studioã®èŠåïŒV571å®æçãªãã§ãã¯ã'ifïŒïŒNameOrErrïŒ'æ¡ä»¶ã¯ã4666è¡ç®ã§ãã§ã«ç¢ºèªãããŠããŸããELFDumper.cpp46672
çªç®ã®ãã§ãã¯ã¯æåã®ãã§ãã¯ãšéè€ããŠãããåé·ã§ããããããã2çªç®ã®ãã§ãã¯ã¯ç°¡åã«åé€ã§ããŸãããã ããããã¯ã¿ã€ããã¹ã§ããå¯èœæ§ãé«ãã2çªç®ã®æ¡ä»¶ã§ã¯å¥ã®å€æ°ã䜿çšããå¿ èŠããããŸãã
ã¹ããããN6ãæœåšçã«nullãã€ã³ã¿ãéåç §
void RewriteObjCFragileABI::RewriteObjCClassMetaData(
ObjCImplementationDecl *IDecl, std::string &Result)
{
ObjCInterfaceDecl *CDecl = IDecl->getClassInterface();
if (CDecl->isImplicitInterfaceDecl()) {
RewriteObjCInternalStruct(CDecl, Result);
}
unsigned NumIvars = !IDecl->ivar_empty()
? IDecl->ivar_size()
: (CDecl ? CDecl->ivar_size() : 0);
....
}
PVS-StudioèŠåïŒV595 nullptrã«å¯ŸããŠæ€èšŒãããåã«ããCDeclããã€ã³ã¿ãŒã䜿çšãããŸããããã§ãã¯è¡ïŒ5275ã5284ãRewriteObjC.cpp 5275
æåã®ãã§ãã¯äžãCDeclãã€ã³ã¿ãŒã¯åžžã«å€§èã«éåç §ãããŸãã
if (CDecl->isImplicitInterfaceDecl())
ãããŠã以äžã«æžãããã³ãŒãããã®ã¿ããã®ãã€ã³ã¿ãŒãnullã«ãªãå¯èœæ§ãããããšãæããã«ãªããŸãã
(CDecl ? CDecl->ivar_size() : 0)
ã»ãšãã©ã®å Žåãæåã®ãã§ãã¯ã¯æ¬¡ã®ããã«ãªããŸãã
if (CDecl && CDecl->isImplicitInterfaceDecl())
ã¹ããããN7ãæœåšçã«nullãã€ã³ã¿ãéåç §
bool
Sema::InstantiateClass(....)
{
....
NamedDecl *ND = dyn_cast<NamedDecl>(I->NewDecl);
CXXRecordDecl *ThisContext =
dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
CXXThisScopeRAII ThisScope(*this, ThisContext, Qualifiers(),
ND && ND->isCXXInstanceMember());
....
}
PVS-StudioèŠåïŒV595 nullptrã«å¯ŸããŠæ€èšŒãããåã«ããNDããã€ã³ã¿ãŒã䜿çšãããŸããããã§ãã¯è¡ïŒ2803ã2805ãSemaTemplateInstantiate.cpp2803
åã®ãšã©ãŒã®ããªãšãŒã·ã§ã³ãåçãã£ã¹ãã䜿çšããŠå€ãååŸãããŠãããã©ãããæåã«ç¢ºèªããã«ãã€ã³ã¿ãéåç §ããããšã¯å±éºã§ããããã«ã以äžã®ã³ãŒãããããã®ãããªãã§ãã¯ãå¿ èŠã§ããããšã¯æããã§ãã
ãã©ã°ã¡ã³ãN8ãé¢æ°ã¯ãšã©ãŒç¶æ ã«ããããããå®è¡ãç¶ç¶ããŸã
bool VerifyObject(llvm::yaml::Node &N,
std::map<std::string, std::string> Expected) {
....
auto *V = llvm::dyn_cast_or_null<llvm::yaml::ScalarNode>(Prop.getValue());
if (!V) {
ADD_FAILURE() << KS << " is not a string";
Match = false;
}
std::string VS = V->getValue(Tmp).str();
....
}
PVS-StudioèŠåïŒV1004 nullptrã«å¯ŸããŠæ€èšŒãããåŸããVããã€ã³ã¿ãŒãå®å šã«äœ¿çšãããŸããã§ããããã§ãã¯ã©ã€ã³ïŒ61ã65ãTraceTests.cpp65
ãã€ã³ã¿Vãnullã®å¯èœæ§ããããŸããããã¯æããã«èª€ã£ãç¶æ ã§ãããå ±åãããŠããŸãããã ãããã®åŸãé¢æ°ã¯äœãèµ·ãããªãã£ããã®ããã«å®è¡ãç¶è¡ããŸããããã«ããããã®éåžžã«nullã®ãã€ã³ã¿ãŒãéåç §ãããŸãããããã圌ãã¯æ©èœãäžæããã®ãå¿ããŠããã®ã§ãæ£ãããªãã·ã§ã³ã¯æ¬¡ã®ããã«ãªããŸãã
auto *V = llvm::dyn_cast_or_null<llvm::yaml::ScalarNode>(Prop.getValue());
if (!V) {
ADD_FAILURE() << KS << " is not a string";
Match = false;
return false;
}
std::string VS = V->getValue(Tmp).str();
ã¹ããããN9ãã¿ã€ããã¹
const char *tools::SplitDebugName(const ArgList &Args, const InputInfo &Input,
const InputInfo &Output) {
if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
if (StringRef(A->getValue()) == "single")
return Args.MakeArgString(Output.getFilename());
Arg *FinalOutput = Args.getLastArg(options::OPT_o);
if (FinalOutput && Args.hasArg(options::OPT_c)) {
SmallString<128> T(FinalOutput->getValue());
llvm::sys::path::replace_extension(T, "dwo");
return Args.MakeArgString(T);
} else {
// Use the compilation dir.
SmallString<128> T(
Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput()));
llvm::sys::path::replace_extension(F, "dwo");
T += F;
return Args.MakeArgString(F); // <=
}
}
PVS-StudioèŠåïŒV1001ãTãå€æ°ãå²ãåœãŠãããŠããŸãããé¢æ°ã®æåŸã§ã¯äœ¿çšãããŠããŸãããCommonArgs.cpp873
é¢æ°ã®çµããã«æ³šæããŠãã ãããããŒã«ã«å€æ°Tã¯å€æŽãããŸããã䜿çšãããŸãããã»ãšãã©ã®å Žåãããã¯ã¿ã€ããã¹ã§ãããé¢æ°ã¯æ¬¡ã®ã³ãŒãè¡ã§çµäºããå¿ èŠããããŸãã
T += F;
return Args.MakeArgString(T);
ãã©ã°ã¡ã³ãN10ãé€æ°ã¯ãŒã
typedef int32_t si_int;
typedef uint32_t su_int;
typedef union {
du_int all;
struct {
#if _YUGA_LITTLE_ENDIAN
su_int low;
su_int high;
#else
su_int high;
su_int low;
#endif // _YUGA_LITTLE_ENDIAN
} s;
} udwords;
COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int *rem) {
....
if (d.s.low == 0) {
if (d.s.high == 0) {
// K X
// ---
// 0 0
if (rem)
*rem = n.s.high % d.s.low;
return n.s.high / d.s.low;
}
....
}
PVS-Studioã®èŠåïŒ
- ãŒãã«ããV609Modãåæ¯ 'dslow' == 0.udivmoddi4.c 61
- V609ãŒãã§é€ç®ããŸããåæ¯ 'dslow' == 0.udivmoddi4.c 62
ãããééããªã®ãããªãããŒãªã¢ã€ãã¢ãªã®ãã¯ããããŸããããã³ãŒãã¯éåžžã«å¥åŠã§ããéåžžã®æŽæ°å€æ°ã¯2ã€ãããäžæ¹ã¯ããäžæ¹ã§å²ãåããŸããèå³æ·±ãããšã«ãããã¯äž¡æ¹ã®å€æ°ããŒãã®å Žåã«ã®ã¿çºçããŸããããã¯ã©ãããæå³ã§ããïŒ
ãã©ã°ã¡ã³ãN11ãã³ããŒïŒããŒã¹ã
bool MallocChecker::mayFreeAnyEscapedMemoryOrIsModeledExplicitly(....)
{
....
StringRef FName = II->getName();
....
if (FName == "postEvent" &&
FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
return true;
}
if (FName == "postEvent" &&
FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
return true;
}
....
}
PVS-StudioèŠåïŒV581äºãã«äžŠãã§é 眮ãããŠãããifãã¹ããŒãã¡ã³ãã®æ¡ä»¶åŒã¯åãã§ãããã§ãã¯è¡ïŒ3108ã3113ãMallocChecker.cpp 3113
ã³ãŒãã¹ããããã¯ã³ããŒãããŸããããå€æŽãããŠããŸããã2çªç®ã®ã¹ããããã¯ãããã€ãã®æçšãªãã§ãã¯ã®å®è¡ãéå§ããããã«åé€ãŸãã¯å€æŽããå¿ èŠããããŸãã
çµè«
ãã®ç¡æã®ã©ã€ã»ã³ã¹ãªãã·ã§ã³ ã䜿çšããŠããªãŒãã³ãœãŒã¹ãããžã§ã¯ãã確èªã§ããããšããç¥ããããŸããã¡ãªã¿ã«ãPVS-Studioã®ç¡æã©ã€ã»ã³ã¹ã«ã¯ãã¯ããŒãºããããžã§ã¯ããå«ãä»ã®ãªãã·ã§ã³ããããŸãããããã¯ããã«ãªã¹ããããŠããŸãïŒãç¡æã®PVS-Studioã©ã€ã»ã³ã¹ãªãã·ã§ã³ããæž èŽããããšãããããŸããã
ã³ã³ãã€ã©ãã§ãã¯ã«é¢ãããã®ä»ã®èšäº
- LLVMïŒClangïŒåæïŒ2011幎8æïŒã2çªç®ã®åæïŒ2012幎8æïŒã3çªç®ã®åæïŒ2016幎10æïŒã4çªç®ã®åæïŒ2019幎4æïŒ
- GCCåæïŒ2016幎8æïŒã2åç®ã®åæïŒ2020幎4æïŒ
- Huawei Arkã³ã³ãã€ã©åæïŒ2019幎12æïŒ
- .NETã³ã³ãã€ã©ãã©ãããã©ãŒã ïŒãRoslynãïŒåæïŒ2015幎12æïŒã2åç®ã®åæïŒ2019幎4æïŒ
- Roslynã¢ãã©ã€ã¶ãŒåæïŒ2019幎8æïŒ
- PascalABC.NETåæïŒ2017幎3æïŒ
ãã®èšäºãè±èªã話ãèŽè¡ãšå ±æãããå Žåã¯ã翻蚳ãªã³ã¯ã䜿çšããŠãã ããïŒAndreyKarpovãPVS-Studioã§Clang11ããã§ãã¯ããŠããŸãã