Visitar URL original
Merge remote-tracking branch 'danmar/master' · cppcheck-opensource/cppcheck@4f39635 · GitHub
Skip to content

Commit 4f39635

Browse files
committed
Merge remote-tracking branch 'danmar/master'
Merge in upstream changes.
2 parents 7b2121a + 2b41641 commit 4f39635

11 files changed

Lines changed: 539 additions & 93 deletions

File tree

‎cfg/std.cfg‎

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3513,7 +3513,7 @@
35133513
<arg nr="2"/>
35143514
</function>
35153515
<!-- size_t mbrtowc(wchar_t* pwc, const char* pmb, size_t max, mbstate_t* ps); -->
3516-
<function name="mbrtowc">
3516+
<function name="mbrtowc,std::mbrtowc">
35173517
<noreturn>false</noreturn>
35183518
<leak-ignore/>
35193519
<arg nr="2">
@@ -3526,8 +3526,8 @@
35263526
<not-uninit/>
35273527
</arg>
35283528
</function>
3529-
<!-- wchar_t* wcstok(wchar_t *s, const wchar *ct, wchar_t **ptr); -->
3530-
<function name="wcstok">
3529+
<!-- wchar_t* wcstok(wchar_t *s, const wchar_t *ct, wchar_t **ptr); -->
3530+
<function name="wcstok,std::wcstok">
35313531
<noreturn>false</noreturn>
35323532
<leak-ignore/>
35333533
<arg nr="1">
@@ -3541,9 +3541,9 @@
35413541
<not-null/>
35423542
</arg>
35433543
</function>
3544-
<!-- intmax_t wcstoimax(const wchar_t *s, wchar ** endp, int base); -->
3545-
<!-- uintmax_t wcstoumax(const wchar_t *s, wchar ** endp, int base); -->
3546-
<function name="wcstoimax,wcstoumax">
3544+
<!-- intmax_t wcstoimax(const wchar_t *s, wchar_t ** endp, int base); -->
3545+
<!-- uintmax_t wcstoumax(const wchar_t *s, wchar_t ** endp, int base); -->
3546+
<function name="wcstoimax,std::wcstoimax,wcstoumax,std::wcstoumax">
35473547
<use-retval/>
35483548
<noreturn>false</noreturn>
35493549
<leak-ignore/>
@@ -3560,7 +3560,7 @@
35603560
<!-- long long wcstoll(const wchar_t *s, wchar ** endp, int base); -->
35613561
<!-- unsigned long wcstoul(const wchar_t *s, wchar ** endp, int base); -->
35623562
<!-- unsigned long long wcstoull(const wchar_t *s, wchar ** endp, int base); -->
3563-
<function name="wcstol,wcstoll,wcstoul,wcstoull">
3563+
<function name="wcstol,std::wcstol,wcstoll,std::wcstoll,wcstoul,std::wcstoul,wcstoull,std::wcstoull">
35643564
<use-retval/>
35653565
<noreturn>false</noreturn>
35663566
<leak-ignore/>
@@ -3574,7 +3574,7 @@
35743574
</arg>
35753575
</function>
35763576
<!-- int wprintf(const wchar_t *format, ...); -->
3577-
<function name="wprintf">
3577+
<function name="wprintf,std::wprintf">
35783578
<noreturn>false</noreturn>
35793579
<leak-ignore/>
35803580
<formatstr/>
@@ -3587,193 +3587,211 @@
35873587
</arg>
35883588
</function>
35893589
<!-- int sprintf(char *s, const char *format, ...); -->
3590-
<function name="sprintf">
3590+
<function name="sprintf,std::sprintf">
35913591
<noreturn>false</noreturn>
35923592
<leak-ignore/>
35933593
<arg nr="1">
35943594
<minsize type="strlen" arg="2"/>
35953595
</arg>
35963596
<formatstr/>
35973597
<arg nr="2">
3598+
<not-uninit/>
35983599
<formatstr/>
35993600
<not-null/>
36003601
</arg>
3602+
<arg nr="any">
3603+
<not-uninit/>
3604+
</arg>
36013605
</function>
36023606
<!-- int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...); -->
3603-
<function name="swprintf">
3607+
<function name="swprintf,std::swprintf">
36043608
<noreturn>false</noreturn>
36053609
<leak-ignore/>
36063610
<arg nr="2">
36073611
<not-uninit/>
36083612
</arg>
36093613
<arg nr="3">
3614+
<not-uninit/>
36103615
<not-null/>
36113616
</arg>
36123617
</function>
36133618
<!-- int vsprintf(char *s, const char *format, va_list arg); -->
3614-
<function name="vsprintf">
3619+
<function name="vsprintf,std::vsprintf">
36153620
<noreturn>false</noreturn>
36163621
<leak-ignore/>
36173622
<formatstr/>
36183623
<arg nr="2">
3624+
<not-uninit/>
36193625
<formatstr/>
36203626
<not-null/>
36213627
</arg>
36223628
<arg nr="3"/>
36233629
</function>
36243630
<!-- int vswprintf(wchar_t *s, size_t n, const wchar_t *format, va_list arg); -->
3625-
<function name="vswprintf">
3631+
<function name="vswprintf,std::vswprintf">
36263632
<noreturn>false</noreturn>
36273633
<leak-ignore/>
36283634
<arg nr="2">
36293635
<not-uninit/>
36303636
</arg>
36313637
<formatstr/>
36323638
<arg nr="3">
3639+
<not-uninit/>
36333640
<formatstr/>
36343641
<not-null/>
36353642
</arg>
36363643
<arg nr="4"/>
36373644
</function>
36383645
<!-- int fwprintf(FILE* stream, const wchar_t* format, ...); -->
3639-
<function name="fwprintf">
3646+
<function name="fwprintf,std::fwprintf">
36403647
<noreturn>false</noreturn>
36413648
<leak-ignore/>
36423649
<arg nr="1">
36433650
<not-null/>
36443651
</arg>
36453652
<formatstr/>
36463653
<arg nr="2">
3654+
<not-uninit/>
36473655
<formatstr/>
36483656
<not-null/>
36493657
</arg>
3658+
<arg nr="any">
3659+
<not-uninit/>
3660+
</arg>
36503661
</function>
36513662
<!-- int snprintf(char *s, size_t n, const char *format, ...); -->
3652-
<function name="snprintf">
3663+
<function name="snprintf,std::snprintf">
36533664
<noreturn>false</noreturn>
36543665
<leak-ignore/>
36553666
<arg nr="2">
36563667
<not-uninit/>
36573668
</arg>
36583669
<formatstr/>
36593670
<arg nr="3">
3671+
<not-uninit/>
36603672
<formatstr/>
36613673
<not-null/>
36623674
</arg>
3675+
<arg nr="any">
3676+
<not-uninit/>
3677+
</arg>
36633678
</function>
36643679
<!-- int vsnprintf(char *s, size_t n, const char *format, va_list arg); -->
3665-
<function name="vsnprintf">
3680+
<function name="vsnprintf,std::vsnprintf">
36663681
<noreturn>false</noreturn>
36673682
<leak-ignore/>
36683683
<arg nr="2">
36693684
<not-uninit/>
36703685
</arg>
36713686
<formatstr/>
36723687
<arg nr="3">
3688+
<not-uninit/>
36733689
<formatstr/>
36743690
<not-null/>
36753691
</arg>
36763692
<arg nr="4"/>
36773693
</function>
3678-
<function name="fnprintf">
3679-
<noreturn>false</noreturn>
3680-
<leak-ignore/>
3681-
<formatstr/>
3682-
<arg nr="3">
3683-
<formatstr/>
3684-
</arg>
3685-
</function>
36863694
<!-- int wscanf(const wchar_t *format, ...); -->
3687-
<function name="wscanf">
3695+
<function name="wscanf,std::wscanf">
36883696
<noreturn>false</noreturn>
36893697
<leak-ignore/>
36903698
<formatstr scan="true"/>
36913699
<arg nr="1">
3700+
<not-uninit/>
36923701
<formatstr/>
36933702
<not-null/>
36943703
</arg>
36953704
</function>
36963705
<!-- int sscanf(const char *string, const char * format, ...); -->
3697-
<function name="sscanf">
3706+
<function name="sscanf,std::sscanf">
36983707
<noreturn>false</noreturn>
36993708
<leak-ignore/>
3709+
<arg nr="1">
3710+
<not-uninit/>
3711+
</arg>
37003712
<formatstr scan="true"/>
37013713
<arg nr="2">
37023714
<formatstr/>
3715+
<not-uninit/>
3716+
<not-null/>
37033717
</arg>
37043718
</function>
37053719
<!-- int fwscanf(FILE* stream, const wchar_t* format, ...); -->
3706-
<function name="fwscanf">
3720+
<function name="fwscanf,std::fwscanf">
37073721
<noreturn>false</noreturn>
37083722
<leak-ignore/>
37093723
<arg nr="1">
3710-
<not-null/>
3724+
<not-uninit/>
37113725
</arg>
37123726
<formatstr scan="true"/>
37133727
<arg nr="2">
37143728
<formatstr/>
3715-
<not-null/>
3729+
<not-uninit/>
37163730
</arg>
37173731
</function>
37183732
<!-- int swscanf(const wchar_t *string, const wchar_t *format, ...); -->
3719-
<function name="swscanf">
3733+
<function name="swscanf,std::swscanf">
37203734
<noreturn>false</noreturn>
37213735
<leak-ignore/>
3736+
<arg nr="1">
3737+
<not-uninit/>
3738+
</arg>
37223739
<formatstr scan="true"/>
37233740
<arg nr="2">
37243741
<formatstr/>
3742+
<not-uninit/>
37253743
</arg>
37263744
</function>
37273745
<!-- int system(const char *command); -->
3728-
<function name="system">
3746+
<function name="system,std::system">
37293747
<noreturn>false</noreturn>
37303748
<leak-ignore/>
37313749
<arg nr="1">
37323750
<not-uninit/>
37333751
</arg>
37343752
</function>
37353753
<!-- /*unspecified*/ setw(int n); -->
3736-
<function name="setw">
3754+
<function name="setw,std::setw">
37373755
<noreturn>false</noreturn>
37383756
<leak-ignore/>
37393757
<arg nr="1">
37403758
<not-uninit/>
37413759
</arg>
37423760
</function>
37433761
<!-- /*unspecified*/ setiosflags(ios_base::fmtflags mask); -->
3744-
<function name="setiosflags">
3762+
<function name="setiosflags,std::setiosflags">
37453763
<noreturn>false</noreturn>
37463764
<leak-ignore/>
37473765
<arg nr="1">
37483766
<not-uninit/>
37493767
</arg>
37503768
</function>
37513769
<!-- /*unspecified*/ resetiosflags(ios_base::fmtflags mask); -->
3752-
<function name="resetiosflags">
3770+
<function name="resetiosflags,std::resetiosflags">
37533771
<noreturn>false</noreturn>
37543772
<leak-ignore/>
37553773
<arg nr="1">
37563774
<not-uninit/>
37573775
</arg>
37583776
</function>
37593777
<!-- /*unspecified*/ setfill(char_type c); -->
3760-
<function name="setfill">
3778+
<function name="setfill,std::setfill">
37613779
<noreturn>false</noreturn>
37623780
<leak-ignore/>
37633781
<arg nr="1">
37643782
<not-uninit/>
37653783
</arg>
37663784
</function>
37673785
<!-- /*unspecified*/ setprecision(int n); -->
3768-
<function name="setprecision">
3786+
<function name="setprecision,std::setprecision">
37693787
<noreturn>false</noreturn>
37703788
<leak-ignore/>
37713789
<arg nr="1">
37723790
<not-uninit/>
37733791
</arg>
37743792
</function>
37753793
<!-- /*unspecified*/ setbase(int base); -->
3776-
<function name="setbase">
3794+
<function name="setbase,std::setbase">
37773795
<noreturn>false</noreturn>
37783796
<leak-ignore/>
37793797
<arg nr="1">
@@ -3793,7 +3811,8 @@
37933811
<not-uninit/>
37943812
</arg>
37953813
</function>
3796-
<!--Not part of standard, but widely supported by runtime libraries-->
3814+
<!-- Not part of standard, but widely supported by runtime libraries. -->
3815+
<!-- char * itoa (int value, char * str, int base); -->
37973816
<function name="itoa">
37983817
<noreturn>false</noreturn>
37993818
<leak-ignore/>

‎lib/checkautovariables.cpp‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,17 @@ void CheckAutoVariables::autoVariables()
166166
errorAutoVariableAssignment(tok->next(), false);
167167
} else if (Token::Match(tok, "[;{}] %var% . %var% = & %var%")) {
168168
// TODO: check if the parameter is only changed temporarily (#2969)
169-
if (printInconclusive) {
170-
if (isPtrArg(tok->next())) {
171-
const Token * const var2tok = tok->tokAt(6);
172-
if (isAutoVar(var2tok) && checkRvalueExpression(var2tok))
173-
errorAutoVariableAssignment(tok->next(), true);
174-
}
169+
if (printInconclusive && isPtrArg(tok->next())) {
170+
const Token * const var2tok = tok->tokAt(6);
171+
if (isAutoVar(var2tok) && checkRvalueExpression(var2tok))
172+
errorAutoVariableAssignment(tok->next(), true);
175173
}
176174
tok = tok->tokAt(6);
177175
} else if (Token::Match(tok, "[;{}] %var% . %var% = %var% ;")) {
178176
// TODO: check if the parameter is only changed temporarily (#2969)
179-
if (printInconclusive) {
180-
if (isPtrArg(tok->next())) {
181-
if (isAutoVarArray(tok->tokAt(5)))
182-
errorAutoVariableAssignment(tok->next(), true);
183-
}
177+
if (printInconclusive && isPtrArg(tok->next())) {
178+
if (isAutoVarArray(tok->tokAt(5)))
179+
errorAutoVariableAssignment(tok->next(), true);
184180
}
185181
tok = tok->tokAt(5);
186182
} else if (Token::Match(tok, "[;{}] * %var% = %var% ;")) {

‎lib/checksizeof.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void CheckSizeof::sizeofCalculation()
251251
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
252252
if (Token::simpleMatch(tok, "sizeof (")) {
253253
const Token *argument = tok->next()->astOperand2();
254-
if (argument && argument->isCalculation(true) && (!argument->isExpandedMacro() || printInconclusive))
254+
if (argument && argument->isCalculation() && (!argument->isExpandedMacro() || printInconclusive))
255255
sizeofCalculationError(argument, argument->isExpandedMacro());
256256
}
257257
}

‎lib/token.cpp‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,19 +1136,8 @@ void Token::astOperand2(Token *tok)
11361136
_astOperand2 = tok;
11371137
}
11381138

1139-
bool Token::isCalculation(bool goDownwards) const
1139+
bool Token::isCalculation() const
11401140
{
1141-
if (goDownwards && Token::Match(this, "[|(|,")) {
1142-
bool ret = false;
1143-
if (this->astOperand1())
1144-
ret = this->astOperand1()->isCalculation(true);
1145-
if (ret)
1146-
return true;
1147-
if (this->astOperand2())
1148-
ret = this->astOperand2()->isCalculation(true);
1149-
return ret;
1150-
1151-
}
11521141
if (!Token::Match(this, "%cop%|++|--"))
11531142
return false;
11541143

‎lib/token.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,9 @@ class CPPCHECKLIB Token {
872872
* For '*' and '&' tokens it is looked up if this is a
873873
* dereference or address-of. A dereference or address-of is not
874874
* counted as a calculation.
875-
* @param goDownwards the function will look for calculations in all children of the tree
876875
* @return returns true if current token is a calculation
877876
*/
878-
bool isCalculation(bool goDownwards = false) const;
877+
bool isCalculation() const;
879878

880879
void clearAst() {
881880
_astOperand1 = _astOperand2 = _astParent = NULL;

0 commit comments

Comments
 (0)