Skip to content

Commit

Permalink
parser-common: rename LangDetector -> ImpliedAttrDigger
Browse files Browse the repository at this point in the history
... so that its purpose can be extended to cover other attributes

No changes in behavior intended by this commit.
  • Loading branch information
kdudka committed May 5, 2022
1 parent 3daaaa3 commit eb60f1b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/csparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ struct CovParser::Private {
EToken code;
KeyEventDigger keDigger;
AnnotHandler annotHdl;
LangDetector langDetector;
ImpliedAttrDigger digger;

Private(InStream &input_):
lexer(input_.str()),
Expand Down Expand Up @@ -611,7 +611,7 @@ bool CovParser::Private::parseNext(Defect *def)

this->keDigger.initVerbosity(def);
this->annotHdl.handleDef(def);
this->langDetector.inferLangFromChecker(def);
this->digger.inferLangFromChecker(def);

// all OK
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/gcc-parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ bool BasicGccParser::hasError() const
using namespace GccParserImpl;

struct GccPostProcessor::Private {
const LangDetector langDetector;
const ImpliedAttrDigger digger;

void transGccAnal(Defect *pDef) const;
void polishGccAnal(Defect *pDef) const;
Expand Down Expand Up @@ -678,7 +678,7 @@ void GccPostProcessor::apply(Defect *pDef) const
d->polishGccAnal(pDef);
d->polishClangAnal(pDef);

d->langDetector.inferLangFromChecker(pDef);
d->digger.inferLangFromChecker(pDef);
}

struct GccParser::Private {
Expand Down
10 changes: 6 additions & 4 deletions src/parser-common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ int parse_int(const std::string &str, const int fallback)
}
}

struct LangDetector::Private {
struct ImpliedAttrDigger::Private {
typedef std::map<std::string, std::string> TMap;
TMap langByChecker;
};

LangDetector::LangDetector():
ImpliedAttrDigger::ImpliedAttrDigger():
d(new Private)
{
d->langByChecker["CLANG_WARNING"] = "c/c++";
Expand All @@ -48,12 +48,14 @@ LangDetector::LangDetector():
d->langByChecker["SMATCH_WARNING"] = "c/c++";
}

LangDetector::~LangDetector()
ImpliedAttrDigger::~ImpliedAttrDigger()
{
delete d;
}

void LangDetector::inferLangFromChecker(Defect *pDef, const bool onlyIfMissing)
void ImpliedAttrDigger::inferLangFromChecker(
Defect *pDef,
const bool onlyIfMissing)
const
{
if (onlyIfMissing && !pDef->language.empty())
Expand Down
6 changes: 3 additions & 3 deletions src/parser-common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

int parse_int(const std::string &, int fallback = 0);

class LangDetector {
class ImpliedAttrDigger {
public:
LangDetector();
~LangDetector();
ImpliedAttrDigger();
~ImpliedAttrDigger();

void inferLangFromChecker(Defect *, bool onlyIfMissing = true) const;

Expand Down

0 comments on commit eb60f1b

Please sign in to comment.