From 264c0cae8b0b7fadeff94005c20cebf310516339 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 4 Sep 2020 11:59:30 -0500 Subject: [PATCH] Formatting --- lib/checkautovariables.cpp | 6 ++++-- lib/valueflow.h | 3 ++- test/testautovariables.cpp | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index d67a02b14..7bc83e510 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -530,12 +530,14 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token } else if (tokvalue->variable() && isDeadScope(tokvalue->variable()->nameToken(), tok->scope())) { errorInvalidLifetime(tok, &val); break; - } else if (!tokvalue->variable() && isDeadTemporary(mTokenizer->isCPP(), tokvalue, tok, &mSettings->library)) { + } else if (!tokvalue->variable() && + isDeadTemporary(mTokenizer->isCPP(), tokvalue, tok, &mSettings->library)) { errorDanglingTemporaryLifetime(tok, &val); break; } } - if (tokvalue->variable() && (isInScope(tokvalue->variable()->nameToken(), tok->scope()) || (val.isSubFunctionLifetimeValue() && tokvalue->variable()->isLocal()))) { + if (tokvalue->variable() && (isInScope(tokvalue->variable()->nameToken(), tok->scope()) || + (val.isSubFunctionLifetimeValue() && tokvalue->variable()->isLocal()))) { const Variable * var = nullptr; const Token * tok2 = tok; if (Token::simpleMatch(tok->astParent(), "=")) { diff --git a/lib/valueflow.h b/lib/valueflow.h index 646f1aa2a..688cb53e1 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -217,7 +217,8 @@ namespace ValueFlow { return valueType == ValueType::LIFETIME && lifetimeScope == LifetimeScope::Argument; } - bool isSubFunctionLifetimeValue() const { + bool isSubFunctionLifetimeValue() const + { return valueType == ValueType::LIFETIME && lifetimeScope == LifetimeScope::SubFunction; } diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index b188d9e74..be8e62b1b 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -2167,7 +2167,9 @@ private: " add(&i);\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:8] -> [test.cpp:4] -> [test.cpp:7] -> [test.cpp:4]: (error) Non-local variable 'v' will use object that points to local variable 'i'.\n", errout.str()); + ASSERT_EQUALS( + "[test.cpp:8] -> [test.cpp:8] -> [test.cpp:4] -> [test.cpp:7] -> [test.cpp:4]: (error) Non-local variable 'v' will use object that points to local variable 'i'.\n", + errout.str()); } void danglingLifetime() {