Skip to content

Commit 101146d

Browse files
author
Your Name
committed
Remove some flags
1 parent 5b3bdbb commit 101146d

4 files changed

Lines changed: 19 additions & 36 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
static const Type* findVariableTypeInBase(const Scope* scope, const Token* typeTok);
6060

61-
SymbolDatabase::SymbolDatabase(Tokenizer& tokenizer, bool deferFinalizePhases)
61+
SymbolDatabase::SymbolDatabase(Tokenizer& tokenizer)
6262
: mTokenizer(tokenizer)
6363
, mSettings(tokenizer.getSettings())
6464
, mErrorLogger(tokenizer.getErrorLogger())
@@ -88,17 +88,10 @@ SymbolDatabase::SymbolDatabase(Tokenizer& tokenizer, bool deferFinalizePhases)
8888
createSymbolDatabaseSetSmartPointerType();
8989
setValueTypeInTokenList(false);
9090
createSymbolDatabaseEnums();
91-
92-
if (!deferFinalizePhases)
93-
finalize();
9491
}
9592

9693
void SymbolDatabase::finalize()
9794
{
98-
if (mFinalized)
99-
return;
100-
mFinalized = true;
101-
10295
if (!mTokenizer.tokens())
10396
return;
10497

lib/symboldatabase.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,11 +1340,11 @@ class CPPCHECKLIB SymbolDatabase {
13401340
friend class TestSymbolDatabase;
13411341
public:
13421342
/**
1343-
* @param deferFinalizePhases don't run the phases that only later analysis
1344-
* (ValueFlow, checks) needs - finalize() must be called when the token list is
1345-
* final. Used while the template simplifier still changes the token list.
1343+
* The phases that only later analysis (ValueFlow, checks) needs are not run by the
1344+
* constructor - call finalize() when the token list is final, e.g. after the
1345+
* template simplifier can no longer change it.
13461346
*/
1347-
explicit SymbolDatabase(Tokenizer& tokenizer, bool deferFinalizePhases = false);
1347+
explicit SymbolDatabase(Tokenizer& tokenizer);
13481348
~SymbolDatabase();
13491349

13501350
/** @brief Information about all namespaces/classes/structures */
@@ -1457,8 +1457,8 @@ class CPPCHECKLIB SymbolDatabase {
14571457
void addSymbolsForNewTokenRanges(const std::vector<std::pair<Token*, Token*>>& newRanges);
14581458

14591459
/**
1460-
* Run the phases that only later analysis (ValueFlow, checks) needs. Called once
1461-
* when the token list is final - does nothing when already finalized.
1460+
* Run the phases that only later analysis (ValueFlow, checks) needs. Call exactly
1461+
* once, when the token list is final.
14621462
*/
14631463
void finalize();
14641464

@@ -1564,9 +1564,6 @@ class CPPCHECKLIB SymbolDatabase {
15641564

15651565
ValueType::Sign mDefaultSignedness;
15661566

1567-
/** true when the finalize() phases have run */
1568-
bool mFinalized{};
1569-
15701567
mutable std::map<const Type*, bool> mIsRecordTypeWithoutSideEffectsMap;
15711568
};
15721569

lib/tokenize.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3537,28 +3537,27 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration, int fileIndex)
35373537
list.validateAst(mSettings.debugnormal);
35383538
});
35393539

3540-
// while pending type deductions may still change the token list, the symbol
3541-
// database phases that only later analysis needs are deferred to finalize()
3542-
const bool typeDeductionsPending = isCPP() && mTemplateSimplifier->hasPendingTypeDeductions();
3543-
35443540
Timer::run("Tokenizer::simplifyTokens1::createSymbolDatabase", mTimerResults, [&]() {
3545-
createSymbolDatabase(typeDeductionsPending);
3541+
createSymbolDatabase();
35463542
});
35473543

35483544
Timer::run("Tokenizer::simplifyTokens1::setValueType", mTimerResults, [&]() {
35493545
mSymbolDatabase->setValueTypeInTokenList(false);
35503546
mSymbolDatabase->setValueTypeInTokenList(true);
35513547
});
35523548

3553-
if (typeDeductionsPending) {
3549+
if (isCPP() && mTemplateSimplifier->hasPendingTypeDeductions()) {
35543550
Timer::run("Tokenizer::simplifyTokens1::simplifyTemplatesUsingTypeInformation", mTimerResults, [&]() {
35553551
simplifyTemplatesUsingTypeInformation();
35563552
});
3557-
Timer::run("Tokenizer::simplifyTokens1::finalizeSymbolDatabase", mTimerResults, [&]() {
3558-
mSymbolDatabase->finalize();
3559-
});
35603553
}
35613554

3555+
// the phases that only later analysis needs run when the template simplifier can
3556+
// no longer change the token list
3557+
Timer::run("Tokenizer::simplifyTokens1::finalizeSymbolDatabase", mTimerResults, [&]() {
3558+
mSymbolDatabase->finalize();
3559+
});
3560+
35623561
if (!mSettings.buildDir.empty())
35633562
Summaries::create(*this, configuration, fileIndex);
35643563

@@ -4340,7 +4339,7 @@ void Tokenizer::rebuildTokenDataAfterTemplateSimplification()
43404339
mSymbolDatabase = nullptr;
43414340
// the phases that only later analysis needs are run by finalize() after the
43424341
// template simplification is done
4343-
createSymbolDatabase(/*deferFinalizePhases*/ true);
4342+
createSymbolDatabase();
43444343
mSymbolDatabase->setValueTypeInTokenList(false);
43454344
mSymbolDatabase->setValueTypeInTokenList(true);
43464345
}
@@ -10824,10 +10823,10 @@ void Tokenizer::simplifyBorland()
1082410823
}
1082510824
}
1082610825

10827-
void Tokenizer::createSymbolDatabase(bool deferFinalizePhases)
10826+
void Tokenizer::createSymbolDatabase()
1082810827
{
1082910828
if (!mSymbolDatabase)
10830-
mSymbolDatabase = new SymbolDatabase(*this, deferFinalizePhases);
10829+
mSymbolDatabase = new SymbolDatabase(*this);
1083110830
mSymbolDatabase->validate();
1083210831
}
1083310832

lib/tokenize.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,7 @@ class CPPCHECKLIB Tokenizer {
606606
const SymbolDatabase *getSymbolDatabase() const {
607607
return mSymbolDatabase;
608608
}
609-
/**
610-
* Create the symbol database.
611-
* @param deferFinalizePhases skip the phases that only later analysis needs;
612-
* SymbolDatabase::finalize() must be called when the token list is final. Used
613-
* while the template simplifier still changes the token list.
614-
*/
615-
void createSymbolDatabase(bool deferFinalizePhases = false);
609+
void createSymbolDatabase();
616610

617611
/** print --debug output if debug flags match the simplification:
618612
*/

0 commit comments

Comments
 (0)