Skip to content

Commit d0d1e42

Browse files
committed
add @throws for transitive calls [skip ci]
1 parent bbeb2f2 commit d0d1e42

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

simplecpp.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::st
490490
try {
491491
FileStream stream(filename, filenames);
492492
readfile(stream,filename,outputList);
493-
} catch (const simplecpp::Output & e) { // TODO handle extra type of errors
493+
} catch (const simplecpp::Output & e) {
494494
outputList->push_back(e);
495495
}
496496
}
@@ -2626,7 +2626,7 @@ static std::string dirPath(const std::string& path, bool withTrailingSlash=true)
26262626

26272627
static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader);
26282628

2629-
/** Evaluate sizeof(type)
2629+
/** Evaluate __has_include(include)
26302630
* @throws std::runtime_error thrown on missing arguments or invalid expression
26312631
*/
26322632
static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI &dui)
@@ -2685,7 +2685,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26852685
}
26862686
}
26872687

2688-
/** Evaluate sizeof(type)
2688+
/** Evaluate name
26892689
* @throws std::runtime_error thrown on undefined function-like macro
26902690
*/
26912691
static void simplifyName(simplecpp::TokenList &expr)
@@ -2929,6 +2929,9 @@ long long simplecpp::characterLiteralToLL(const std::string& str)
29292929
return multivalue;
29302930
}
29312931

2932+
/**
2933+
* @throws std::runtime_error thrown on invalid literal
2934+
*/
29322935
static void simplifyNumbers(simplecpp::TokenList &expr)
29332936
{
29342937
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
@@ -2951,6 +2954,10 @@ static void simplifyComments(simplecpp::TokenList &expr)
29512954
}
29522955
}
29532956

2957+
/**
2958+
* @throws std::runtime_error thrown on invalid literals, missing sizeof arguments or invalid expressions,
2959+
* missing __has_include() arguments or expressions, undefined function-like macros, invalid number literals
2960+
*/
29542961
static long long evaluate(simplecpp::TokenList &expr, const simplecpp::DUI &dui, const std::map<std::string, std::size_t> &sizeOfType)
29552962
{
29562963
simplifyComments(expr);
@@ -3684,7 +3691,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36843691
const long long result = evaluate(expr, dui, sizeOfType);
36853692
conditionIsTrue = (result != 0);
36863693
}
3687-
} catch (const std::exception &e) {
3694+
} catch (const std::runtime_error &e) {
36883695
if (outputList) {
36893696
std::string msg = "failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition";
36903697
if (e.what() && *e.what())

0 commit comments

Comments
 (0)