# Extract changed files to a temporary directory
mkdir $tmpdir/org
if [[ $action == *-index ]] ; then
- git checkout-index --prefix=$tmpdir/org/
+ git checkout-index --prefix=$tmpdir/org/ --stdin <$tmpdir/filelist_all
else
- rsync -a $srcdir/src/ $tmpdir/org/src/
+ rsync --files-from=$tmpdir/filelist_all -a $srcdir/ $tmpdir/org/
fi
# check for the existence of the compile_commands.json file and abort
# if it is not present. If we don't have a build directory, try the
# Need to have compilation database file available somewhere above where we are using it
rsync -a $builddir/compile_commands.json $tmpdir/org
fi
-# Duplicate the original files to a separate directory, where all changes will
-# be made.
+# Prepare directory to use for comparing changed and original files
cp -r $tmpdir/org $tmpdir/new
# Create output file for what was done (in case no messages get written)
# Can only perform clang-tidy on a non-empty list of files
cd $tmpdir/new
if [[ $tidy_mode != "off" && -s $tmpdir/filelist_clangtidy ]] ; then
- $RUN_CLANG_TIDY `cat $tmpdir/filelist_clangtidy` -- -header-filter=.* -j $concurrency -fix -fix-errors --cuda-host-only -nocudainc -quiet >$tmpdir/clang-tidy.out 2>&1
- awk '/warning/,/clang-tidy|^$/' $tmpdir/clang-tidy.out | grep -v "warnings generated." | grep -v "Suppressed .* warnings" | grep -v "clang-analyzer" | grep -v "to display errors from all non" | sed '/^\s*$/d' > $tmpdir/clang-tidy-errors.out
- cp $tmpdir/clang-tidy.out $tmpdir/clang-tidy-errors.out $srcdir
+ $RUN_CLANG_TIDY `cat $tmpdir/filelist_clangtidy` -header-filter=.* -j $concurrency -fix -quiet -extra-arg=--cuda-host-only -extra-arg=-nocudainc>$tmpdir/clang-tidy.out 2>&1
+ awk '/warning/,/clang-tidy|^$/' $tmpdir/clang-tidy.out | grep -v "warnings generated." | grep -v "Suppressed .* warnings" | grep -v "clang-analyzer" | grep -v "to display errors from all non" | sed '/^\s*$/d' > $tmpdir/clang-tidy-warnings.out
+ awk '/.*error.*/' $tmpdir/clang-tidy.out > $tmpdir/clang-tidy-errors.out || true
if [ -s $tmpdir/clang-tidy-errors.out ]; then
- echo "Running code tidying failed. Check output below for errors:"
+ echo "Running of clang-tidy failed. Check output below for errors:"
cat $tmpdir/clang-tidy-errors.out
rm -rf $tmpdir
exit 2
if [[ $action == update-* ]] ; then
msg="clang-tidy performed"
fi
+ rsync --files-from=$tmpdir/filelist_all -a $srcdir/ ./
+ rsync -a $tmpdir/org/ $srcdir/
git diff --no-index --name-only ../org/ . | \
awk -v msg="$msg" '{sub(/.\//,""); print $0 ": " msg}' >> $tmpdir/messages
fi
popd >/dev/null
# Report what was done
-sort $tmpdir/messages | tee $warning_file
+if [ -s $tmpdir/clang-tidy-warnings.out ] ; then
+ cat $tmpdir/clang-tidy-warnings.out | tee $warning_file
+fi
+sort $tmpdir/messages | tee -a $warning_file
rm -rf $tmpdir
exit $changes
clangtidy_mode=`git config hooks.clangtidymode`
clangformat_mode=`git config hooks.clangformatmode`
copyright_mode=`git config hooks.copyrightmode`
-if [ -z "$uncrustify_mode" ]
+if [ -z "$clangtidy_mode" ]
then
clangtidy_mode=off
fi
variables:
COMPILER_MAJOR_VERSION: 9
BUILD_DIR: build-clang-tidy
- CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON
+ CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
clang-tidy:configure-schedule:
extends:
clang-tidy:test:
extends:
- .gromacs:base:build
- - .use-ccache
- .variables:default
- .rules:basic-push
stage: source-check
script:
# TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
# See discussion at https://gitlab.com/gromacs/gromacs/-/merge_requests/67
- - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+ - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base --fork-point FETCH_HEAD HEAD`)
- RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=$REV -B=$BUILD_DIR
- grep -iq "found code issues" clang-tidy.log | tee code-lint.txt || true
- if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* \todo Not yet implemented.
*/
- NodeKey addNode(std::unique_ptr<NodeSpecification> spec);
+ static NodeKey addNode(std::unique_ptr<NodeSpecification> spec);
/*!
* \brief Get the node specification for a provided key.
* \param[in] ic Structure holding the table constant
* \param[in] tableExtensionLength Length by which to extend the tables. Taken from the input record.
*/
-void init_interaction_const_tables(FILE* fp, interaction_const_t* ic, const real tableExtensionLength);
+void init_interaction_const_tables(FILE* fp, interaction_const_t* ic, real tableExtensionLength);
/*! \brief Initialize forcerec structure.
*
std::string appendPath(const char* id) const;
//! Creates an entry with given parameters and fills it with \p checker.
- ReferenceDataEntry::EntryPointer createEntry(const char* type,
- const char* id,
- const IReferenceDataEntryChecker& checker) const
+ static ReferenceDataEntry::EntryPointer createEntry(const char* type,
+ const char* id,
+ const IReferenceDataEntryChecker& checker)
{
ReferenceDataEntry::EntryPointer entry(new ReferenceDataEntry(type, id));
checker.fillEntry(entry.get());
return entry;
}
//! Checks an entry for correct type and using \p checker.
- ::testing::AssertionResult checkEntry(const ReferenceDataEntry& entry,
- const std::string& fullId,
- const char* type,
- const IReferenceDataEntryChecker& checker) const
+ static ::testing::AssertionResult checkEntry(const ReferenceDataEntry& entry,
+ const std::string& fullId,
+ const char* type,
+ const IReferenceDataEntryChecker& checker)
{
if (entry.type() != type)
{