32
32
#include " token.h"
33
33
34
34
#include < algorithm>
35
+ #include < cassert>
35
36
#include < cctype>
36
37
#include < cstdint>
37
38
#include < exception>
45
46
46
47
#include < simplecpp.h>
47
48
48
- // #define N_ASSERT_LANG
49
-
50
- #ifndef N_ASSERT_LANG
51
- #include < cassert>
52
- #define ASSERT_LANG (x ) assert(x)
53
- #else
54
- #define ASSERT_LANG (x )
55
- #endif
56
-
57
49
// How many compileExpression recursions are allowed?
58
50
// For practical code this could be endless. But in some special torture test
59
51
// there needs to be a limit.
@@ -97,25 +89,9 @@ void TokenList::deallocateTokens()
97
89
mFiles .clear ();
98
90
}
99
91
100
- void TokenList::determineCppC ()
101
- {
102
- // only try to determine if it wasn't enforced
103
- if (mLang == Standards::Language::None) {
104
- ASSERT_LANG (!getSourceFilePath ().empty ());
105
- mLang = Path::identify (getSourceFilePath (), mSettings .cppHeaderProbe );
106
- // TODO: cannot enable assert as this might occur for unknown extensions
107
- // ASSERT_LANG(mLang != Standards::Language::None);
108
- if (mLang == Standards::Language::None) {
109
- // TODO: should default to C instead like we do for headers
110
- // default to C++
111
- mLang = Standards::Language::CPP;
112
- }
113
- }
114
- }
115
-
116
92
int TokenList::appendFileIfNew (std::string fileName)
117
93
{
118
- ASSERT_LANG (!fileName.empty ());
94
+ assert (!fileName.empty ());
119
95
120
96
// Has this file been tokenized already?
121
97
auto it = std::find_if (mFiles .cbegin (), mFiles .cend (), [&](const std::string& f) {
@@ -127,10 +103,6 @@ int TokenList::appendFileIfNew(std::string fileName)
127
103
// The "mFiles" vector remembers what files have been tokenized..
128
104
mFiles .push_back (std::move (fileName));
129
105
130
- // Update mIsC and mIsCpp properties
131
- if (mFiles .size () == 1 ) { // Update only useful if first file added to _files
132
- determineCppC ();
133
- }
134
106
return mFiles .size () - 1 ;
135
107
}
136
108
@@ -378,8 +350,6 @@ void TokenList::createTokens(simplecpp::TokenList&& tokenList)
378
350
else
379
351
mFiles .clear ();
380
352
381
- determineCppC ();
382
-
383
353
for (const simplecpp::Token *tok = tokenList.cfront (); tok;) {
384
354
385
355
// TODO: move from TokenList
@@ -2247,23 +2217,11 @@ bool TokenList::isKeyword(const std::string &str) const
2247
2217
2248
2218
bool TokenList::isC () const
2249
2219
{
2250
- ASSERT_LANG (mLang != Standards::Language::None);
2251
-
2252
- // TODO: remove the fallback
2253
- if (mLang == Standards::Language::None)
2254
- return false ; // treat as C++ by default
2255
-
2256
2220
return mLang == Standards::Language::C;
2257
2221
}
2258
2222
2259
2223
bool TokenList::isCPP () const
2260
2224
{
2261
- ASSERT_LANG (mLang != Standards::Language::None);
2262
-
2263
- // TODO: remove the fallback
2264
- if (mLang == Standards::Language::None)
2265
- return true ; // treat as C++ by default
2266
-
2267
2225
return mLang == Standards::Language::CPP;
2268
2226
}
2269
2227
0 commit comments