@@ -414,6 +414,9 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
414414
415415class FileStream : public simplecpp ::TokenList::Stream {
416416public:
417+ /* *
418+ * @throws simplecpp::Output thrown is file is not found
419+ */
417420 // cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
418421 explicit FileStream (const std::string &filename, std::vector<std::string> &files)
419422 : file(fopen(filename.c_str(), "rb"))
@@ -1488,6 +1491,9 @@ namespace simplecpp {
14881491 public:
14891492 explicit Macro (std::vector<std::string> &f) : nameTokDef(nullptr ), valueToken(nullptr ), endToken(nullptr ), files(f), tokenListDefine(f), variadic(false ), variadicOpt(false ), valueDefinedInCode_(false ) {}
14901493
1494+ /* *
1495+ * @throws std::runtime_error thrown on bad macro syntax
1496+ */
14911497 Macro (const Token *tok, std::vector<std::string> &f) : nameTokDef(nullptr ), files(f), tokenListDefine(f), valueDefinedInCode_(true ) {
14921498 if (sameline (tok->previousSkipComments (), tok))
14931499 throw std::runtime_error (" bad macro syntax" );
@@ -1504,6 +1510,9 @@ namespace simplecpp {
15041510 throw std::runtime_error (" bad macro syntax" );
15051511 }
15061512
1513+ /* *
1514+ * @throws std::runtime_error thrown on bad macro syntax
1515+ */
15071516 Macro (const std::string &name, const std::string &value, std::vector<std::string> &f) : nameTokDef(nullptr ), files(f), tokenListDefine(f), valueDefinedInCode_(false ) {
15081517 const std::string def (name + ' ' + value);
15091518 StdCharBufStream stream (reinterpret_cast <const unsigned char *>(def.data ()), def.size ());
@@ -1552,7 +1561,9 @@ namespace simplecpp {
15521561 * @param macros list of macros
15531562 * @param inputFiles the input files
15541563 * @return token after macro
1555- * @throw Can throw wrongNumberOfParameters or invalidHashHash
1564+ * @throws Error thrown on missing or invalid preprocessor directives
1565+ * @throws wrongNumberOfParameters thrown on invalid number of parameters
1566+ * @throws invalidHashHash thrown on invalid ## usage
15561567 */
15571568 const Token * expand (TokenList & output,
15581569 const Token * rawtok,
@@ -2544,7 +2555,9 @@ namespace simplecpp {
25442555 }
25452556}
25462557
2547- /* * Evaluate sizeof(type) */
2558+ /* * Evaluate sizeof(type)
2559+ * @throws std::runtime_error thrown on missing arguments or invalid expression
2560+ */
25482561static void simplifySizeof (simplecpp::TokenList &expr, const std::map<std::string, std::size_t > &sizeOfType)
25492562{
25502563 for (simplecpp::Token *tok = expr.front (); tok; tok = tok->next ) {
@@ -2612,6 +2625,10 @@ static std::string dirPath(const std::string& path, bool withTrailingSlash=true)
26122625}
26132626
26142627static std::string openHeader (std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader);
2628+
2629+ /* * Evaluate sizeof(type)
2630+ * @throws std::runtime_error thrown on missing arguments or invalid expression
2631+ */
26152632static void simplifyHasInclude (simplecpp::TokenList &expr, const simplecpp::DUI &dui)
26162633{
26172634 if (!isCpp17OrLater (dui) && !isGnu (dui))
@@ -2668,6 +2685,9 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26682685 }
26692686}
26702687
2688+ /* * Evaluate sizeof(type)
2689+ * @throws std::runtime_error thrown on undefined function-like macro
2690+ */
26712691static void simplifyName (simplecpp::TokenList &expr)
26722692{
26732693 for (simplecpp::Token *tok = expr.front (); tok; tok = tok->next ) {
@@ -2696,7 +2716,7 @@ static void simplifyName(simplecpp::TokenList &expr)
26962716 * unsigned long long value, updating pos to point to the first
26972717 * unused element of s.
26982718 * Returns ULLONG_MAX if the result is not representable and
2699- * throws if the above requirements were not possible to satisfy.
2719+ * @ throws std::runtime_error thrown if the above requirements were not possible to satisfy.
27002720 */
27012721static unsigned long long stringToULLbounded (
27022722 const std::string& s,
@@ -2716,34 +2736,6 @@ static unsigned long long stringToULLbounded(
27162736 return value;
27172737}
27182738
2719- /* Converts character literal (including prefix, but not ud-suffix)
2720- * to long long value.
2721- *
2722- * Assumes ASCII-compatible single-byte encoded str for narrow literals
2723- * and UTF-8 otherwise.
2724- *
2725- * For target assumes
2726- * - execution character set encoding matching str
2727- * - UTF-32 execution wide-character set encoding
2728- * - requirements for __STDC_UTF_16__, __STDC_UTF_32__ and __STDC_ISO_10646__ satisfied
2729- * - char16_t is 16bit wide
2730- * - char32_t is 32bit wide
2731- * - wchar_t is 32bit wide and unsigned
2732- * - matching char signedness to host
2733- * - matching sizeof(int) to host
2734- *
2735- * For host assumes
2736- * - ASCII-compatible execution character set
2737- *
2738- * For host and target assumes
2739- * - CHAR_BIT == 8
2740- * - two's complement
2741- *
2742- * Implements multi-character narrow literals according to GCC's behavior,
2743- * except multi code unit universal character names are not supported.
2744- * Multi-character wide literals are not supported.
2745- * Limited support of universal character names for non-UTF-8 execution character set encodings.
2746- */
27472739long long simplecpp::characterLiteralToLL (const std::string& str)
27482740{
27492741 // default is wide/utf32
0 commit comments