add cmake config option to enable clang-tidy with preferred options
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://lammps.sandia.gov/, Sandia National Laboratories
|
||||
@ -14,8 +13,8 @@
|
||||
|
||||
#include "arg_info.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -29,46 +28,51 @@ using namespace LAMMPS_NS;
|
||||
* \param arg string with possible reference
|
||||
* \param allowed integer with bitmap of allowed types of references */
|
||||
|
||||
ArgInfo::ArgInfo(const std::string &arg, int allowed)
|
||||
: type(NONE), dim(0), index1(-1), index2(-1)
|
||||
ArgInfo::ArgInfo(const std::string &arg, int allowed) : type(NONE), dim(0), index1(-1), index2(-1)
|
||||
{
|
||||
if ((arg.size() > 2) && (arg[1] == '_')) {
|
||||
if ((arg[0] == 'c') && (allowed & COMPUTE)) type = COMPUTE;
|
||||
else if ((arg[0] == 'f') && (allowed & FIX)) type = FIX;
|
||||
else if ((arg[0] == 'v') && (allowed & VARIABLE)) type = VARIABLE;
|
||||
else if ((arg[0] == 'd') && (allowed & DNAME)) type = DNAME;
|
||||
else if ((arg[0] == 'i') && (allowed & INAME)) type = INAME;
|
||||
if ((arg[0] == 'c') && (allowed & COMPUTE))
|
||||
type = COMPUTE;
|
||||
else if ((arg[0] == 'f') && (allowed & FIX))
|
||||
type = FIX;
|
||||
else if ((arg[0] == 'v') && (allowed & VARIABLE))
|
||||
type = VARIABLE;
|
||||
else if ((arg[0] == 'd') && (allowed & DNAME))
|
||||
type = DNAME;
|
||||
else if ((arg[0] == 'i') && (allowed & INAME))
|
||||
type = INAME;
|
||||
else {
|
||||
index1 = 0;
|
||||
name = arg;
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t has_idx1 = arg.find('[',2);
|
||||
std::size_t has_idx1 = arg.find('[', 2);
|
||||
if (has_idx1 != std::string::npos) {
|
||||
name = arg.substr(2,has_idx1-2);
|
||||
name = arg.substr(2, has_idx1 - 2);
|
||||
dim = 1;
|
||||
|
||||
std::size_t has_idx2 = arg.find('[',has_idx1+1);
|
||||
std::size_t has_idx2 = arg.find('[', has_idx1 + 1);
|
||||
if (has_idx2 != std::string::npos) {
|
||||
dim = 2;
|
||||
|
||||
if (arg[arg.size()-1] != ']') {
|
||||
if (arg[arg.size() - 1] != ']') {
|
||||
type = UNKNOWN;
|
||||
} else {
|
||||
try {
|
||||
index2 = std::stoi(arg.substr(has_idx2+1,arg.size()-(has_idx2+2)));
|
||||
index2 = std::stoi(arg.substr(has_idx2 + 1, arg.size() - (has_idx2 + 2)));
|
||||
} catch (std::invalid_argument &) {
|
||||
type = UNKNOWN;
|
||||
}
|
||||
}
|
||||
} else has_idx2 = arg.size();
|
||||
} else
|
||||
has_idx2 = arg.size();
|
||||
|
||||
if (arg[has_idx2-1] != ']') {
|
||||
if (arg[has_idx2 - 1] != ']') {
|
||||
type = UNKNOWN;
|
||||
} else {
|
||||
try {
|
||||
index1 = std::stoi(arg.substr(has_idx1+1,arg.size()-(has_idx2+2)));
|
||||
index1 = std::stoi(arg.substr(has_idx1 + 1, arg.size() - (has_idx2 + 2)));
|
||||
} catch (std::invalid_argument &) {
|
||||
type = UNKNOWN;
|
||||
}
|
||||
@ -97,8 +101,7 @@ ArgInfo::ArgInfo(const std::string &arg, int allowed)
|
||||
|
||||
char *ArgInfo::copy_name()
|
||||
{
|
||||
char *dest = new char[name.size()+1];
|
||||
strcpy(dest,name.c_str());
|
||||
char *dest = new char[name.size() + 1];
|
||||
strcpy(dest, name.c_str()); // NOLINT
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user