MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / invalidHashHash

Class invalidHashHash

externals/simplecpp/simplecpp.cpp:1722–1745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1720
1721 /** Struct that is thrown when there is invalid ## usage */
1722 struct invalidHashHash : public Error {
1723 static inline std::string format(const std::string &macroName, const std::string &message) {
1724 return "Invalid ## usage when expanding \'" + macroName + "\': " + message;
1725 }
1726
1727 invalidHashHash(const Location &loc, const std::string &macroName, const std::string &message)
1728 : Error(loc, format(macroName, message)) {}
1729
1730 static inline invalidHashHash unexpectedToken(const Location &loc, const std::string &macroName, const Token *tokenA) {
1731 return {loc, macroName, "Unexpected token '"+ tokenA->str()+"'"};
1732 }
1733
1734 static inline invalidHashHash cannotCombine(const Location &loc, const std::string &macroName, const Token *tokenA, const Token *tokenB) {
1735 return {loc, macroName, "Combining '"+ tokenA->str()+ "' and '"+ tokenB->str() + "' yields an invalid token."};
1736 }
1737
1738 static inline invalidHashHash unexpectedNewline(const Location &loc, const std::string &macroName) {
1739 return {loc, macroName, "Unexpected newline"};
1740 }
1741
1742 static inline invalidHashHash universalCharacterUB(const Location &loc, const std::string &macroName, const Token* tokenA, const std::string& strAB) {
1743 return {loc, macroName, "Combining '\\"+ tokenA->str()+ "' and '"+ strAB.substr(tokenA->str().size()) + "' yields universal character '\\" + strAB + "'. This is undefined behavior according to C standard chapter 5.1.1.2, paragraph 4."};
1744 }
1745 };
1746 private:
1747 /** Create new token where Token::macro is set for replaced tokens */
1748 Token *newMacroToken(const TokenString &str, const Location &loc, bool replaced, const Token *expandedFromToken=nullptr) const {

Callers 1

expandHashHashMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected