This commit is contained in:
parent
6031bed5a2
commit
29e2a7ed34
|
@ -895,7 +895,7 @@ namespace {
|
|||
bool canReplace(const Token* tok) {
|
||||
if (mNameToken == tok)
|
||||
return false;
|
||||
if (!Token::Match(tok->previous(), "%name%|;|{|}|(|,|<") && !Token::Match(tok, "%name% ("))
|
||||
if (!Token::Match(tok->previous(), "%name%|;|{|}|(|,|<") && !Token::Match(tok->previous(), "!!. %name% ("))
|
||||
return false;
|
||||
if (!Token::Match(tok, "%name% %name%|*|&|&&|;|(|)|,|::")) {
|
||||
if (Token::Match(tok->previous(), "( %name% =") && Token::Match(tok->linkAt(-1), ") %name%|{") && !tok->tokAt(-2)->isKeyword())
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
TEST_CASE(c2);
|
||||
TEST_CASE(canreplace1);
|
||||
TEST_CASE(canreplace2);
|
||||
TEST_CASE(canreplace3);
|
||||
TEST_CASE(cconst);
|
||||
TEST_CASE(cstruct1);
|
||||
TEST_CASE(cstruct2);
|
||||
|
@ -342,6 +343,17 @@ private:
|
|||
ASSERT_EQUALS("void f ( ) { dostuff ( entry * y < z ) ; }", simplifyTypedefC(code3));
|
||||
}
|
||||
|
||||
void canreplace3() {
|
||||
const char code1[] = "typedef char* c_str;\n" // #11640
|
||||
"struct S {\n"
|
||||
" const char* g() const {\n"
|
||||
" return s.c_str();\n"
|
||||
" }\n"
|
||||
" std::string s;\n"
|
||||
"};\n";
|
||||
ASSERT_EQUALS("struct S { const char * g ( ) const { return s . c_str ( ) ; } std :: string s ; } ;", simplifyTypedefC(code1));
|
||||
}
|
||||
|
||||
void cconst() {
|
||||
const char code1[] = "typedef void* HWND;\n"
|
||||
"const HWND x;";
|
||||
|
|
Loading…
Reference in New Issue