Skip to content

Commit 8173ff0

Browse files
committed
added @throws to documentation [skip ci]
1 parent f934fa3 commit 8173ff0

13 files changed

Lines changed: 87 additions & 12 deletions

lib/calculate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ bool isZero(T x)
4646
return isEqual(x, T(0));
4747
}
4848

49+
/**
50+
* @throws InternalError thrown in case of unknown operator
51+
*/
4952
template<class R, class T>
5053
R calculate(const std::string& s, const T& x, const T& y, bool* error = nullptr)
5154
{

lib/checkleakautovar.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
119119
/** check for leaks in all scopes */
120120
void check();
121121

122-
/** check for leaks in a function scope */
122+
/** check for leaks in a function scope
123+
* @throws InternalError thrown if recursion cound is exceeded
124+
*/
123125
bool checkScope(const Token * startToken,
124126
VarInfo &varInfo,
125127
std::set<int> notzero,

lib/checkother.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ class CPPCHECKLIB CheckOther : public Check {
195195

196196
void checkModuloOfOne();
197197

198+
/**
199+
* @throws InternalError thrown if largest union member could not be found
200+
*/
198201
void checkUnionZeroInit();
199202

200203
void checkOverlappingWrite();

lib/cppcheck.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ static std::string detectPython(const CppCheck::ExecuteCmdFn &executeCommand)
424424
return "";
425425
}
426426

427+
/**
428+
* @throws InternalError thrown when execution fails
429+
*/
427430
static std::vector<picojson::value> executeAddon(const AddonInfo &addonInfo,
428431
const std::string &defaultPythonExe,
429432
const std::string &file,

lib/symboldatabase.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,9 @@ class CPPCHECKLIB Function {
777777
nonneg int initializedArgCount() const {
778778
return initArgCount;
779779
}
780+
/**
781+
* @throws InternalError thrown on unrecognized lambda
782+
*/
780783
void addArguments(const Scope *scope);
781784

782785
/** @brief check if this function is virtual in the base classes */
@@ -1438,6 +1441,9 @@ class CPPCHECKLIB SymbolDatabase {
14381441
friend class Function;
14391442

14401443
// Create symboldatabase...
1444+
/**
1445+
* @throws InternalError thrown on unhandled code
1446+
*/
14411447
void createSymbolDatabaseFindAllScopes();
14421448
void createSymbolDatabaseClassInfo();
14431449
void createSymbolDatabaseVariableInfo();
@@ -1461,6 +1467,9 @@ class CPPCHECKLIB SymbolDatabase {
14611467
void addClassFunction(Scope *&scope, const Token *&tok, const Token *argStart);
14621468
RET_NONNULL static Function *addGlobalFunctionDecl(Scope*& scope, const Token* tok, const Token *argStart, const Token* funcStart);
14631469
Function *addGlobalFunction(Scope*& scope, const Token*& tok, const Token *argStart, const Token* funcStart);
1470+
/**
1471+
* @throws InternalError thrown on unrecognized function
1472+
*/
14641473
void addNewFunction(Scope *&scope, const Token *&tok);
14651474
bool isFunction(const Token *tok, const Scope* outerScope, const Token *&funcStart, const Token *&argStart, const Token*& declEnd) const;
14661475
const Type *findTypeInNested(const Token *startTok, const Scope *startScope) const;
@@ -1485,6 +1494,7 @@ class CPPCHECKLIB SymbolDatabase {
14851494
void validateExecutableScopes() const;
14861495
/**
14871496
* @brief Check variable list, e.g. variables w/o scope
1497+
* @throws InternalError thrown on variable without scope
14881498
*/
14891499
void validateVariables() const;
14901500

lib/templatesimplifier.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,11 @@ class CPPCHECKLIB TemplateSimplifier {
150150
TokenAndName(Token *token, std::string scope);
151151
/**
152152
* Constructor used for declarations.
153-
* \param token template declaration token "template < ... >"
154-
* \param scope full qualification of template(scope)
155-
* \param nameToken template name token "template < ... > class name"
156-
* \param paramEnd template parameter end token ">"
153+
* @param token template declaration token "template < ... >"
154+
* @param scope full qualification of template(scope)
155+
* @param nameToken template name token "template < ... > class name"
156+
* @param paramEnd template parameter end token ">"
157+
* @throws InternalError thrown on template issues
157158
*/
158159
TokenAndName(Token *token, std::string scope, const Token *nameToken, const Token *paramEnd);
159160
TokenAndName(const TokenAndName& other);
@@ -319,6 +320,7 @@ class CPPCHECKLIB TemplateSimplifier {
319320
* @param tok start token
320321
* @return true if modifications to token-list are done.
321322
* false if no modifications are done.
323+
* @throws InternalError thrown on dvision by zero in template instantiation
322324
*/
323325
static bool simplifyNumericCalculations(Token *tok, bool isTemplate = true);
324326

@@ -459,7 +461,9 @@ class CPPCHECKLIB TemplateSimplifier {
459461
*/
460462
static bool removeTemplate(Token *tok, std::map<Token*, Token*>* forwardDecls = nullptr);
461463

462-
/** Syntax error */
464+
/** Syntax error
465+
* @throws InternalError thrown unconditionally
466+
*/
463467
NORETURN static void syntaxError(const Token *tok);
464468

465469
static bool matchSpecialization(

lib/token.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ void Token::replace(Token *replaceThis, Token *start, Token *end)
403403
delete replaceThis;
404404
}
405405

406+
/**
407+
* @throws InternalError thrown on unexpected command or missing varid with %varid%
408+
*/
406409
static
407410
#if defined(__GNUC__)
408411
// GCC does not inline this by itself

lib/token.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,9 @@ class CPPCHECKLIB Token {
902902
return tok;
903903
}
904904

905+
/**
906+
* @throws InternalError thrown if index if out of range
907+
*/
905908
template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
906909
static T *linkAtImpl(T *thisTok, int index)
907910
{
@@ -1532,7 +1535,9 @@ class CPPCHECKLIB Token {
15321535
}
15331536

15341537
/** Updates internal property cache like _isName or _isBoolean.
1535-
Called after any mStr() modification. */
1538+
Called after any mStr() modification.
1539+
@throws InternalError thrown if a bool literal has a varid
1540+
*/
15361541
void update_property_info();
15371542

15381543
/** Update internal property cache about isStandardType() */
@@ -1548,6 +1553,9 @@ class CPPCHECKLIB Token {
15481553
public:
15491554
void astOperand1(Token *tok);
15501555
void astOperand2(Token *tok);
1556+
/**
1557+
* @throws InternalError thrown on cyclic dependency
1558+
*/
15511559
void astParent(Token* tok);
15521560

15531561
Token * astOperand1() {
@@ -1602,6 +1610,9 @@ class CPPCHECKLIB Token {
16021610
return ret;
16031611
}
16041612

1613+
/**
1614+
* @throws InternalError thrown if start or end cannot be found
1615+
*/
16051616
std::pair<const Token *, const Token *> findExpressionStartEndTokens() const;
16061617

16071618
/**

lib/tokenize.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ namespace {
669669
return mNameToken ? mNameToken->str() : "";
670670
}
671671

672+
/**
673+
* @throws InternalError thrown if simplification failed
674+
*/
672675
void replace(Token* tok) {
673676
if (tok == mNameToken)
674677
return;
@@ -4234,6 +4237,9 @@ void VariableMap::addVariable(const std::string& varname, bool globalNamespace)
42344237
it->second = ++mVarId;
42354238
}
42364239

4240+
/**
4241+
* @throws Token* thrown when closing brackets are missing
4242+
*/
42374243
static bool setVarIdParseDeclaration(Token*& tok, const VariableMap& variableMap, bool executableScope, Standards::cstd_t cStandard)
42384244
{
42394245
const Token* const tok1 = tok;

lib/tokenize.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,25 @@ class CPPCHECKLIB Tokenizer {
376376

377377
public:
378378

379-
/** Syntax error */
379+
/** Syntax error
380+
* @throws InternalError thrown unconditionally
381+
*/
380382
NORETURN void syntaxError(const Token *tok, const std::string &code = "") const;
381383

382-
/** Syntax error. Unmatched character. */
384+
/** Syntax error. Unmatched character.
385+
* @throws InternalError thrown unconditionally
386+
*/
383387
NORETURN void unmatchedToken(const Token *tok) const;
384388

385389
private:
386-
/** Syntax error. C++ code in C file. */
390+
/** Syntax error. C++ code in C file.
391+
* @throws InternalError thrown unconditionally
392+
*/
387393
NORETURN void syntaxErrorC(const Token *tok, const std::string &what) const;
388394

389-
/** Warn about unknown macro(s), configuration is recommended */
395+
/** Warn about unknown macro(s), configuration is recommended #
396+
* @throws InternalError thrown unconditionally
397+
*/
390398
NORETURN void unknownMacroError(const Token *tok1) const;
391399

392400
void unhandledCharLiteral(const Token *tok, const std::string& msg) const;

0 commit comments

Comments
 (0)