|
@@ -164,8 +164,9 @@ namespace {
|
|
class StandardDirective : public Directive {
|
|
class StandardDirective : public Directive {
|
|
public:
|
|
public:
|
|
StandardDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
|
|
StandardDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
|
|
- StringRef Text, unsigned Min, unsigned Max)
|
|
|
|
- : Directive(DirectiveLoc, DiagnosticLoc, Text, Min, Max) { }
|
|
|
|
|
|
+ bool MatchAnyLine, StringRef Text, unsigned Min,
|
|
|
|
+ unsigned Max)
|
|
|
|
+ : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max) { }
|
|
|
|
|
|
bool isValid(std::string &Error) override {
|
|
bool isValid(std::string &Error) override {
|
|
// all strings are considered valid; even empty ones
|
|
// all strings are considered valid; even empty ones
|
|
@@ -182,8 +183,10 @@ public:
|
|
class RegexDirective : public Directive {
|
|
class RegexDirective : public Directive {
|
|
public:
|
|
public:
|
|
RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
|
|
RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
|
|
- StringRef Text, unsigned Min, unsigned Max, StringRef RegexStr)
|
|
|
|
- : Directive(DirectiveLoc, DiagnosticLoc, Text, Min, Max), Regex(RegexStr) { }
|
|
|
|
|
|
+ bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max,
|
|
|
|
+ StringRef RegexStr)
|
|
|
|
+ : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max),
|
|
|
|
+ Regex(RegexStr) { }
|
|
|
|
|
|
bool isValid(std::string &Error) override {
|
|
bool isValid(std::string &Error) override {
|
|
if (Regex.isValid(Error))
|
|
if (Regex.isValid(Error))
|
|
@@ -371,6 +374,7 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
|
|
|
|
|
|
// Next optional token: @
|
|
// Next optional token: @
|
|
SourceLocation ExpectedLoc;
|
|
SourceLocation ExpectedLoc;
|
|
|
|
+ bool MatchAnyLine = false;
|
|
if (!PH.Next("@")) {
|
|
if (!PH.Next("@")) {
|
|
ExpectedLoc = Pos;
|
|
ExpectedLoc = Pos;
|
|
} else {
|
|
} else {
|
|
@@ -411,6 +415,10 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
|
|
|
|
|
|
if (PH.Next(Line) && Line > 0)
|
|
if (PH.Next(Line) && Line > 0)
|
|
ExpectedLoc = SM.translateFileLineCol(FE, Line, 1);
|
|
ExpectedLoc = SM.translateFileLineCol(FE, Line, 1);
|
|
|
|
+ else if (PH.Next("*")) {
|
|
|
|
+ MatchAnyLine = true;
|
|
|
|
+ ExpectedLoc = SM.translateFileLineCol(FE, 1, 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (ExpectedLoc.isInvalid()) {
|
|
if (ExpectedLoc.isInvalid()) {
|
|
@@ -495,7 +503,8 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
|
|
|
|
|
|
// Construct new directive.
|
|
// Construct new directive.
|
|
std::unique_ptr<Directive> D(
|
|
std::unique_ptr<Directive> D(
|
|
- Directive::create(RegexKind, Pos, ExpectedLoc, Text, Min, Max));
|
|
|
|
|
|
+ Directive::create(RegexKind, Pos, ExpectedLoc, MatchAnyLine, Text,
|
|
|
|
+ Min, Max));
|
|
|
|
|
|
std::string Error;
|
|
std::string Error;
|
|
if (D->isValid(Error)) {
|
|
if (D->isValid(Error)) {
|
|
@@ -644,8 +653,11 @@ static unsigned PrintExpected(DiagnosticsEngine &Diags, SourceManager &SourceMgr
|
|
llvm::raw_svector_ostream OS(Fmt);
|
|
llvm::raw_svector_ostream OS(Fmt);
|
|
for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) {
|
|
for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) {
|
|
Directive &D = **I;
|
|
Directive &D = **I;
|
|
- OS << "\n File " << SourceMgr.getFilename(D.DiagnosticLoc)
|
|
|
|
- << " Line " << SourceMgr.getPresumedLineNumber(D.DiagnosticLoc);
|
|
|
|
|
|
+ OS << "\n File " << SourceMgr.getFilename(D.DiagnosticLoc);
|
|
|
|
+ if (D.MatchAnyLine)
|
|
|
|
+ OS << " Line *";
|
|
|
|
+ else
|
|
|
|
+ OS << " Line " << SourceMgr.getPresumedLineNumber(D.DiagnosticLoc);
|
|
if (D.DirectiveLoc != D.DiagnosticLoc)
|
|
if (D.DirectiveLoc != D.DiagnosticLoc)
|
|
OS << " (directive at "
|
|
OS << " (directive at "
|
|
<< SourceMgr.getFilename(D.DirectiveLoc) << ':'
|
|
<< SourceMgr.getFilename(D.DirectiveLoc) << ':'
|
|
@@ -692,9 +704,11 @@ static unsigned CheckLists(DiagnosticsEngine &Diags, SourceManager &SourceMgr,
|
|
for (unsigned i = 0; i < D.Max; ++i) {
|
|
for (unsigned i = 0; i < D.Max; ++i) {
|
|
DiagList::iterator II, IE;
|
|
DiagList::iterator II, IE;
|
|
for (II = Right.begin(), IE = Right.end(); II != IE; ++II) {
|
|
for (II = Right.begin(), IE = Right.end(); II != IE; ++II) {
|
|
- unsigned LineNo2 = SourceMgr.getPresumedLineNumber(II->first);
|
|
|
|
- if (LineNo1 != LineNo2)
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (!D.MatchAnyLine) {
|
|
|
|
+ unsigned LineNo2 = SourceMgr.getPresumedLineNumber(II->first);
|
|
|
|
+ if (LineNo1 != LineNo2)
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
if (!IsFromSameFile(SourceMgr, D.DiagnosticLoc, II->first))
|
|
if (!IsFromSameFile(SourceMgr, D.DiagnosticLoc, II->first))
|
|
continue;
|
|
continue;
|
|
@@ -859,10 +873,11 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
|
|
}
|
|
}
|
|
|
|
|
|
Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc,
|
|
Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc,
|
|
- SourceLocation DiagnosticLoc, StringRef Text,
|
|
|
|
- unsigned Min, unsigned Max) {
|
|
|
|
|
|
+ SourceLocation DiagnosticLoc, bool MatchAnyLine,
|
|
|
|
+ StringRef Text, unsigned Min, unsigned Max) {
|
|
if (!RegexKind)
|
|
if (!RegexKind)
|
|
- return new StandardDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max);
|
|
|
|
|
|
+ return new StandardDirective(DirectiveLoc, DiagnosticLoc, MatchAnyLine,
|
|
|
|
+ Text, Min, Max);
|
|
|
|
|
|
// Parse the directive into a regular expression.
|
|
// Parse the directive into a regular expression.
|
|
std::string RegexStr;
|
|
std::string RegexStr;
|
|
@@ -887,6 +902,6 @@ Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return new RegexDirective(DirectiveLoc, DiagnosticLoc, Text, Min, Max,
|
|
|
|
- RegexStr);
|
|
|
|
|
|
+ return new RegexDirective(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text,
|
|
|
|
+ Min, Max, RegexStr);
|
|
}
|
|
}
|