Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:

runs-on: ubuntu-22.04

env:
UNCRUSTIFY_VERSION: 0.80.1

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -31,17 +34,19 @@ jobs:
with:
path: |
~/uncrustify
key: ${{ runner.os }}-uncrustify
key: ${{ runner.os }}-uncrustify-${{ env.UNCRUSTIFY_VERSION }}

- name: build uncrustify
if: steps.cache-uncrustify.outputs.cache-hit != 'true'
run: |
wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.72.0.tar.gz
tar xzvf uncrustify-0.72.0.tar.gz && cd uncrustify-uncrustify-0.72.0
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5
set -x
wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-${{ env.UNCRUSTIFY_VERSION }}.tar.gz
tar xzvf uncrustify-${{ env.UNCRUSTIFY_VERSION }}.tar.gz
cd uncrustify-uncrustify-${{ env.UNCRUSTIFY_VERSION }}
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -- -j$(nproc) -s
mkdir ~/uncrustify
cd build && cp uncrustify ~/uncrustify/
cp build/uncrustify ~/uncrustify/

- name: Uncrustify check
run: |
Expand Down
23 changes: 20 additions & 3 deletions .uncrustify.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Uncrustify-0.72.0_f
# Uncrustify-0.80.1_f

# The original size of tabs in the input.
#
Expand Down Expand Up @@ -133,14 +133,31 @@ indent_class = true # true/false
# Default: 1
indent_access_spec = -4 # number

# Whether to collapse empty blocks between '{' and '}'.
# If true, overrides nl_inside_empty_func
# Whether to collapse empty blocks between '{' and '}' except for functions.
# Use nl_collapse_empty_body_functions to specify how empty function braces
# should be formatted.
nl_collapse_empty_body = true # true/false

# Whether to collapse empty blocks between '{' and '}' for functions only.
# If true, overrides nl_inside_empty_func.
nl_collapse_empty_body_functions = true # true/false

# Whether to convert all tabs to spaces in comments. If false, tabs in
# comments are left alone, unless used for indenting.
cmt_convert_tab_to_spaces = true # true/false

# An offset value that controls the indentation of the body of a multiline #define.
# 'body' refers to all the lines of a multiline #define except the first line.
# Requires 'pp_ignore_define_body = false'.
#
# <0: Absolute column: the body indentation starts off at the specified column
# (ex. -3 ==> the body is indented starting from column 3)
# >=0: Relative to the column of the '#' of '#define'
# (ex. 3 ==> the body is indented starting 3 columns at the right of '#')
#
# Default: 8
pp_multiline_define_body_indent = 4 # number

# The value might be used twice:
# - at the assignment
# - at the opening brace
Expand Down
10 changes: 5 additions & 5 deletions lib/checkersreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const
const bool cppcheckPremium = isCppcheckPremium(mSettings);

auto reportSection = [&fout, cppcheckPremium]
(const std::string& title,
const Settings& settings,
const std::set<std::string>& activeCheckers,
const std::map<std::string, std::string>& premiumCheckers,
const std::string& substring) {
(const std::string& title,
const Settings& settings,
const std::set<std::string>& activeCheckers,
const std::map<std::string, std::string>& premiumCheckers,
const std::string& substring) {
fout << std::endl << std::endl;
fout << title << std::endl;
fout << std::string(title.size(), '-') << std::endl;
Expand Down
12 changes: 6 additions & 6 deletions lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,12 +1502,12 @@ void clangimport::AstNode::createTokensForCXXRecord(TokenList &tokenList)
std::vector<AstNodePtr> children2;
std::copy_if(children.cbegin(), children.cend(), std::back_inserter(children2), [](const AstNodePtr& child) {
return child->nodeType == CXXConstructorDecl ||
child->nodeType == CXXDestructorDecl ||
child->nodeType == CXXMethodDecl ||
child->nodeType == FieldDecl ||
child->nodeType == VarDecl ||
child->nodeType == AccessSpecDecl ||
child->nodeType == TypedefDecl;
child->nodeType == CXXDestructorDecl ||
child->nodeType == CXXMethodDecl ||
child->nodeType == FieldDecl ||
child->nodeType == VarDecl ||
child->nodeType == AccessSpecDecl ||
child->nodeType == TypedefDecl;
});
Scope *scope = createScope(tokenList, isStruct ? ScopeType::eStruct : ScopeType::eClass, children2, classToken);
const std::string addr = mExtTokens[0];
Expand Down
2 changes: 1 addition & 1 deletion lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ static ValueFlow::Value evaluate(const std::string& op, const ValueFlow::Value&
return result;
}

using BuiltinLibraryFunction = std::function<ValueFlow::Value(const std::vector<ValueFlow::Value>&)>;
using BuiltinLibraryFunction = std::function<ValueFlow::Value (const std::vector<ValueFlow::Value>&)>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks undesired.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I agree it is undesired

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but imho it's not a blocker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I just highlighted it out so I won't forget looking into it later on.

static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibraryFunctions()
{
std::unordered_map<std::string, BuiltinLibraryFunction> functions;
Expand Down
10 changes: 5 additions & 5 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5735,11 +5735,11 @@ static bool hasMatchingConstructor(const Scope* classScope, const ValueType* arg
return false;
const ValueType* vt = f.getArgumentVar(0)->valueType();
return vt &&
vt->type == argType->type &&
(argType->sign == ValueType::Sign::UNKNOWN_SIGN || vt->sign == argType->sign) &&
vt->pointer == argType->pointer &&
(vt->constness & 1) >= (argType->constness & 1) &&
(vt->volatileness & 1) >= (argType->volatileness & 1);
vt->type == argType->type &&
(argType->sign == ValueType::Sign::UNKNOWN_SIGN || vt->sign == argType->sign) &&
vt->pointer == argType->pointer &&
(vt->constness & 1) >= (argType->constness & 1) &&
(vt->volatileness & 1) >= (argType->volatileness & 1);
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2542,7 +2542,7 @@ bool Token::hasKnownSymbolicValue(const Token* tok) const
return mImpl->mValues &&
std::any_of(mImpl->mValues->begin(), mImpl->mValues->end(), [&](const ValueFlow::Value& value) {
return value.isKnown() && value.isSymbolicValue() && value.tokvalue &&
value.tokvalue->exprId() == tok->exprId();
value.tokvalue->exprId() == tok->exprId();
});
}

Expand Down Expand Up @@ -2615,7 +2615,7 @@ const ValueFlow::Value* Token::getMovedValue() const
return nullptr;
const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [](const ValueFlow::Value& value) {
return value.isMovedValue() && !value.isImpossible() &&
value.moveKind != ValueFlow::Value::MoveKind::NonMovedVariable;
value.moveKind != ValueFlow::Value::MoveKind::NonMovedVariable;
});
return it == mImpl->mValues->end() ? nullptr : &*it;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ class CPPCHECKLIB Token {
fIsInitBracket = (1ULL << 44), // Is this bracket used as a part of variable initialization i.e: int a{5}, b(2);
};

enum : std::uint8_t {
enum : std::uint8_t {
efMaxSize = sizeof(nonneg int) * 8,
efIsUnique = efMaxSize - 2,
};
Expand Down
8 changes: 4 additions & 4 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10852,10 +10852,10 @@ bool Tokenizer::hasIfdef(const Token *start, const Token *end) const
const auto& directives = mDirectives;
return std::any_of(directives.cbegin(), directives.cend(), [&](const Directive& d) {
return startsWith(d.str, "#if") &&
d.linenr >= start->linenr() &&
d.linenr <= end->linenr() &&
start->fileIndex() < list.getFiles().size() &&
d.file == list.getFiles()[start->fileIndex()];
d.linenr >= start->linenr() &&
d.linenr <= end->linenr() &&
start->fileIndex() < list.getFiles().size() &&
d.file == list.getFiles()[start->fileIndex()];
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,7 @@ static void valueFlowLifetimeFunction(Token *tok, const TokenList &tokenlist, Er
const Token* varTok = args[iArg - 1];
if (varTok->variable() && varTok->variable()->isLocal())
LifetimeStore{ varTok, "Passed to '" + tok->str() + "'.", ValueFlow::Value::LifetimeKind::Address }.byRef(
tok->next(), tokenlist, errorLogger, settings);
tok->next(), tokenlist, errorLogger, settings);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vf_settokenvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ namespace ValueFlow
args2.begin(),
[&](const Token* atok, const Token* btok) {
return atok->getKnownIntValue() ==
btok->getKnownIntValue();
btok->getKnownIntValue();
});
} else {
equal = false;
Expand Down
Loading