| 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 ¯oName, const std::string &message) { |
| 1724 | return "Invalid ## usage when expanding \'" + macroName + "\': " + message; |
| 1725 | } |
| 1726 | |
| 1727 | invalidHashHash(const Location &loc, const std::string ¯oName, const std::string &message) |
| 1728 | : Error(loc, format(macroName, message)) {} |
| 1729 | |
| 1730 | static inline invalidHashHash unexpectedToken(const Location &loc, const std::string ¯oName, const Token *tokenA) { |
| 1731 | return {loc, macroName, "Unexpected token '"+ tokenA->str()+"'"}; |
| 1732 | } |
| 1733 | |
| 1734 | static inline invalidHashHash cannotCombine(const Location &loc, const std::string ¯oName, 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 ¯oName) { |
| 1739 | return {loc, macroName, "Unexpected newline"}; |
| 1740 | } |
| 1741 | |
| 1742 | static inline invalidHashHash universalCharacterUB(const Location &loc, const std::string ¯oName, 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 { |