Fix for #pragma asm

This commit is contained in:
Daniel Marjamäki 2017-05-17 21:58:46 +02:00
parent 59335f80d2
commit 1f4b84379d
4 changed files with 13 additions and 6 deletions

View File

@ -212,6 +212,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
// Get directives
preprocessor.setDirectives(tokens1);
preprocessor.simplifyPragmaAsm(&tokens1);
preprocessor.setPlatformInfo(&tokens1);

View File

@ -566,10 +566,6 @@ void Preprocessor::loadFiles(const simplecpp::TokenList &rawtokens, std::vector<
simplecpp::OutputList outputList;
tokenlists = simplecpp::load(rawtokens, files, dui, &outputList);
for (std::map<std::string, simplecpp::TokenList *>::iterator it = tokenlists.begin(); it != tokenlists.end(); ++it) {
Preprocessor::simplifyPragmaAsm(it->second);
}
}
void Preprocessor::removeComments()
@ -886,6 +882,14 @@ unsigned int Preprocessor::calculateChecksum(const simplecpp::TokenList &tokens1
}
void Preprocessor::simplifyPragmaAsm(simplecpp::TokenList *tokenList)
{
Preprocessor::simplifyPragmaAsmPrivate(tokenList);
for (std::map<std::string, simplecpp::TokenList *>::iterator it = tokenlists.begin(); it != tokenlists.end(); ++it) {
Preprocessor::simplifyPragmaAsmPrivate(it->second);
}
}
void Preprocessor::simplifyPragmaAsmPrivate(simplecpp::TokenList *tokenList)
{
// assembler code..
for (simplecpp::Token *tok = tokenList->front(); tok; tok = tok->next) {

View File

@ -171,10 +171,12 @@ public:
*/
unsigned int calculateChecksum(const simplecpp::TokenList &tokens1, const std::string &toolinfo) const;
static void simplifyPragmaAsm(simplecpp::TokenList *tokenList);
void simplifyPragmaAsm(simplecpp::TokenList *tokenList);
private:
static void simplifyPragmaAsmPrivate(simplecpp::TokenList *tokenList);
/**
* Remove space that has new line character on left or right side of it.
*

View File

@ -253,7 +253,7 @@ private:
std::vector<std::string> files;
simplecpp::TokenList tokens(istr, files, filename, &outputList);
tokens.removeComments();
Preprocessor::simplifyPragmaAsm(&tokens);
preprocessor0.simplifyPragmaAsm(&tokens);
const std::set<std::string> configs(preprocessor0.getConfigs(tokens));
preprocessor0.setDirectives(tokens);
for (std::set<std::string>::const_iterator it = configs.begin(); it != configs.end(); ++it) {