Clang import; Handle clang-9 while loop better
This commit is contained in:
parent
206eb0f527
commit
f911495db3
|
@ -74,9 +74,9 @@ static bool isRefPtrArg(const Token *tok)
|
|||
static bool isNonReferenceArg(const Token *tok)
|
||||
{
|
||||
const Variable *var = tok->variable();
|
||||
if (var && !var->valueType())
|
||||
throw InternalError(tok, "var without valueType");
|
||||
return (var && var->isArgument() && !var->isReference() && (var->isPointer() || var->valueType()->type >= ValueType::Type::CONTAINER || var->type()));
|
||||
//if (var && !var->valueType())
|
||||
// throw InternalError(tok, "var without valueType");
|
||||
return (var && var->isArgument() && !var->isReference() && (var->isPointer() || (var->valueType() && var->valueType()->type >= ValueType::Type::CONTAINER) || var->type()));
|
||||
}
|
||||
|
||||
static bool isAutoVar(const Token *tok)
|
||||
|
|
|
@ -968,8 +968,8 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
|||
if (nodeType == VarDecl)
|
||||
return createTokensVarDecl(tokenList);
|
||||
if (nodeType == WhileStmt) {
|
||||
AstNodePtr cond = children[1];
|
||||
AstNodePtr body = children[2];
|
||||
AstNodePtr cond = children[children.size() - 2];
|
||||
AstNodePtr body = children.back();
|
||||
Token *whiletok = addtoken(tokenList, "while");
|
||||
Token *par1 = addtoken(tokenList, "(");
|
||||
par1->astOperand1(whiletok);
|
||||
|
|
|
@ -253,7 +253,7 @@ unsigned int CppCheck::check(const std::string &path)
|
|||
if (mSettings.clang) {
|
||||
mErrorLogger.reportOut(std::string("Checking ") + path + "...");
|
||||
|
||||
const std::string clang = Path::isCPP(path) ? "clang++" : "clang";
|
||||
const std::string clang = Path::isCPP(path) ? "clang++-9" : "clang";
|
||||
const std::string temp = mSettings.buildDir + "/__temp__.c";
|
||||
const std::string clangcmd = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, "") + ".clang-cmd";
|
||||
const std::string clangStderr = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, "") + ".clang-stderr";
|
||||
|
|
|
@ -87,7 +87,8 @@ private:
|
|||
TEST_CASE(vardecl3);
|
||||
TEST_CASE(vardecl4);
|
||||
TEST_CASE(vardecl5);
|
||||
TEST_CASE(whileStmt);
|
||||
TEST_CASE(whileStmt1);
|
||||
TEST_CASE(whileStmt2);
|
||||
|
||||
TEST_CASE(symbolDatabaseEnum1);
|
||||
TEST_CASE(symbolDatabaseFunction1);
|
||||
|
@ -818,7 +819,7 @@ private:
|
|||
ASSERT_EQUALS("const char *const [] sys_errlist@1 ;", parse(clang));
|
||||
}
|
||||
|
||||
void whileStmt() {
|
||||
void whileStmt1() {
|
||||
const char clang[] = "`-FunctionDecl 0x3d45b18 <1.c:1:1, line:3:1> line:1:6 foo 'void ()'\n"
|
||||
" `-CompoundStmt 0x3d45c48 <col:12, line:3:1>\n"
|
||||
" `-WhileStmt 0x3d45c28 <line:2:5, col:14>\n"
|
||||
|
@ -830,6 +831,18 @@ private:
|
|||
parse(clang));
|
||||
}
|
||||
|
||||
void whileStmt2() {
|
||||
// clang 9
|
||||
const char clang[] = "`-FunctionDecl 0x1c99ac8 <1.cpp:1:1, col:27> col:6 foo 'void ()'\n"
|
||||
" `-CompoundStmt 0x1c99c10 <col:12, col:27>\n"
|
||||
" `-WhileStmt 0x1c99bf8 <col:14, col:25>\n"
|
||||
" |-ImplicitCastExpr 0x1c99bd0 <col:21> 'bool' <IntegralToBoolean>\n"
|
||||
" | `-IntegerLiteral 0x1c99bb0 <col:21> 'int' 1\n"
|
||||
" `-CompoundStmt 0x1c99be8 <col:24, col:25>";
|
||||
ASSERT_EQUALS("void foo ( ) { while ( 1 ) { } }", parse(clang));
|
||||
}
|
||||
|
||||
|
||||
#define GET_SYMBOL_DB(clang) \
|
||||
Settings settings; \
|
||||
settings.clang = true; \
|
||||
|
|
Loading…
Reference in New Issue