Skip to content

Commit 1f4b843

Browse files
committed
Fix for #pragma asm
1 parent 59335f8 commit 1f4b843

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

lib/cppcheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
212212

213213
// Get directives
214214
preprocessor.setDirectives(tokens1);
215+
preprocessor.simplifyPragmaAsm(&tokens1);
215216

216217
preprocessor.setPlatformInfo(&tokens1);
217218

lib/preprocessor.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,6 @@ void Preprocessor::loadFiles(const simplecpp::TokenList &rawtokens, std::vector<
566566
simplecpp::OutputList outputList;
567567

568568
tokenlists = simplecpp::load(rawtokens, files, dui, &outputList);
569-
570-
for (std::map<std::string, simplecpp::TokenList *>::iterator it = tokenlists.begin(); it != tokenlists.end(); ++it) {
571-
Preprocessor::simplifyPragmaAsm(it->second);
572-
}
573569
}
574570

575571
void Preprocessor::removeComments()
@@ -886,6 +882,14 @@ unsigned int Preprocessor::calculateChecksum(const simplecpp::TokenList &tokens1
886882
}
887883

888884
void Preprocessor::simplifyPragmaAsm(simplecpp::TokenList *tokenList)
885+
{
886+
Preprocessor::simplifyPragmaAsmPrivate(tokenList);
887+
for (std::map<std::string, simplecpp::TokenList *>::iterator it = tokenlists.begin(); it != tokenlists.end(); ++it) {
888+
Preprocessor::simplifyPragmaAsmPrivate(it->second);
889+
}
890+
}
891+
892+
void Preprocessor::simplifyPragmaAsmPrivate(simplecpp::TokenList *tokenList)
889893
{
890894
// assembler code..
891895
for (simplecpp::Token *tok = tokenList->front(); tok; tok = tok->next) {

lib/preprocessor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ class CPPCHECKLIB Preprocessor {
171171
*/
172172
unsigned int calculateChecksum(const simplecpp::TokenList &tokens1, const std::string &toolinfo) const;
173173

174-
static void simplifyPragmaAsm(simplecpp::TokenList *tokenList);
174+
void simplifyPragmaAsm(simplecpp::TokenList *tokenList);
175175

176176
private:
177177

178+
static void simplifyPragmaAsmPrivate(simplecpp::TokenList *tokenList);
179+
178180
/**
179181
* Remove space that has new line character on left or right side of it.
180182
*

test/testpreprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class TestPreprocessor : public TestFixture {
253253
std::vector<std::string> files;
254254
simplecpp::TokenList tokens(istr, files, filename, &outputList);
255255
tokens.removeComments();
256-
Preprocessor::simplifyPragmaAsm(&tokens);
256+
preprocessor0.simplifyPragmaAsm(&tokens);
257257
const std::set<std::string> configs(preprocessor0.getConfigs(tokens));
258258
preprocessor0.setDirectives(tokens);
259259
for (std::set<std::string>::const_iterator it = configs.begin(); it != configs.end(); ++it) {

0 commit comments

Comments
 (0)