mirror of https://github.com/microsoft/clang.git
Support 'remark' in VerifyDiagnosticConsumer
After Diego added support for -Rpass=inliner we have now in-tree remarks which we can use to properly test this feature. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207765 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9de1702d31
commit
0d40b638c5
|
@ -28,7 +28,7 @@ public:
|
||||||
typedef DiagList::iterator iterator;
|
typedef DiagList::iterator iterator;
|
||||||
typedef DiagList::const_iterator const_iterator;
|
typedef DiagList::const_iterator const_iterator;
|
||||||
private:
|
private:
|
||||||
DiagList Errors, Warnings, Notes;
|
DiagList Errors, Warnings, Remarks, Notes;
|
||||||
public:
|
public:
|
||||||
const_iterator err_begin() const { return Errors.begin(); }
|
const_iterator err_begin() const { return Errors.begin(); }
|
||||||
const_iterator err_end() const { return Errors.end(); }
|
const_iterator err_end() const { return Errors.end(); }
|
||||||
|
@ -36,6 +36,9 @@ public:
|
||||||
const_iterator warn_begin() const { return Warnings.begin(); }
|
const_iterator warn_begin() const { return Warnings.begin(); }
|
||||||
const_iterator warn_end() const { return Warnings.end(); }
|
const_iterator warn_end() const { return Warnings.end(); }
|
||||||
|
|
||||||
|
const_iterator remark_begin() const { return Remarks.begin(); }
|
||||||
|
const_iterator remark_end() const { return Remarks.end(); }
|
||||||
|
|
||||||
const_iterator note_begin() const { return Notes.begin(); }
|
const_iterator note_begin() const { return Notes.begin(); }
|
||||||
const_iterator note_end() const { return Notes.end(); }
|
const_iterator note_end() const { return Notes.end(); }
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,12 @@ class FileEntry;
|
||||||
/// comment on the line that has the diagnostic, use:
|
/// comment on the line that has the diagnostic, use:
|
||||||
///
|
///
|
||||||
/// \code
|
/// \code
|
||||||
/// expected-{error,warning,note}
|
/// expected-{error,warning,remark,note}
|
||||||
/// \endcode
|
/// \endcode
|
||||||
///
|
///
|
||||||
/// to tag if it's an expected error or warning, and place the expected text
|
/// to tag if it's an expected error, remark or warning, and place the expected
|
||||||
/// between {{ and }} markers. The full text doesn't have to be included, only
|
/// text between {{ and }} markers. The full text doesn't have to be included,
|
||||||
/// enough to ensure that the correct diagnostic was emitted.
|
/// only enough to ensure that the correct diagnostic was emitted.
|
||||||
///
|
///
|
||||||
/// Here's an example:
|
/// Here's an example:
|
||||||
///
|
///
|
||||||
|
@ -184,11 +184,13 @@ public:
|
||||||
struct ExpectedData {
|
struct ExpectedData {
|
||||||
DirectiveList Errors;
|
DirectiveList Errors;
|
||||||
DirectiveList Warnings;
|
DirectiveList Warnings;
|
||||||
|
DirectiveList Remarks;
|
||||||
DirectiveList Notes;
|
DirectiveList Notes;
|
||||||
|
|
||||||
void Reset() {
|
void Reset() {
|
||||||
llvm::DeleteContainerPointers(Errors);
|
llvm::DeleteContainerPointers(Errors);
|
||||||
llvm::DeleteContainerPointers(Warnings);
|
llvm::DeleteContainerPointers(Warnings);
|
||||||
|
llvm::DeleteContainerPointers(Remarks);
|
||||||
llvm::DeleteContainerPointers(Notes);
|
llvm::DeleteContainerPointers(Notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@ void TextDiagnosticBuffer::HandleDiagnostic(DiagnosticsEngine::Level Level,
|
||||||
case DiagnosticsEngine::Warning:
|
case DiagnosticsEngine::Warning:
|
||||||
Warnings.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
Warnings.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
||||||
break;
|
break;
|
||||||
|
case DiagnosticsEngine::Remark:
|
||||||
|
Remarks.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
||||||
|
break;
|
||||||
case DiagnosticsEngine::Error:
|
case DiagnosticsEngine::Error:
|
||||||
case DiagnosticsEngine::Fatal:
|
case DiagnosticsEngine::Fatal:
|
||||||
Errors.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
Errors.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
||||||
|
@ -50,6 +53,9 @@ void TextDiagnosticBuffer::FlushDiagnostics(DiagnosticsEngine &Diags) const {
|
||||||
for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
|
for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
|
||||||
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Warning, "%0"))
|
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Warning, "%0"))
|
||||||
<< it->second;
|
<< it->second;
|
||||||
|
for (const_iterator it = remark_begin(), ie = remark_end(); it != ie; ++it)
|
||||||
|
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Remark, "%0"))
|
||||||
|
<< it->second;
|
||||||
for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
|
for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
|
||||||
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Note, "%0"))
|
Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Note, "%0"))
|
||||||
<< it->second;
|
<< it->second;
|
||||||
|
|
|
@ -330,6 +330,8 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
|
||||||
DL = ED ? &ED->Errors : NULL;
|
DL = ED ? &ED->Errors : NULL;
|
||||||
else if (PH.Next("warning"))
|
else if (PH.Next("warning"))
|
||||||
DL = ED ? &ED->Warnings : NULL;
|
DL = ED ? &ED->Warnings : NULL;
|
||||||
|
else if (PH.Next("remark"))
|
||||||
|
DL = ED ? &ED->Remarks : NULL;
|
||||||
else if (PH.Next("note"))
|
else if (PH.Next("note"))
|
||||||
DL = ED ? &ED->Notes : NULL;
|
DL = ED ? &ED->Notes : NULL;
|
||||||
else if (PH.Next("no-diagnostics")) {
|
else if (PH.Next("no-diagnostics")) {
|
||||||
|
@ -737,6 +739,10 @@ static unsigned CheckResults(DiagnosticsEngine &Diags, SourceManager &SourceMgr,
|
||||||
NumProblems += CheckLists(Diags, SourceMgr, "warning", ED.Warnings,
|
NumProblems += CheckLists(Diags, SourceMgr, "warning", ED.Warnings,
|
||||||
Buffer.warn_begin(), Buffer.warn_end());
|
Buffer.warn_begin(), Buffer.warn_end());
|
||||||
|
|
||||||
|
// See if there are remark mismatches.
|
||||||
|
NumProblems += CheckLists(Diags, SourceMgr, "remark", ED.Remarks,
|
||||||
|
Buffer.remark_begin(), Buffer.remark_end());
|
||||||
|
|
||||||
// See if there are note mismatches.
|
// See if there are note mismatches.
|
||||||
NumProblems += CheckLists(Diags, SourceMgr, "note", ED.Notes,
|
NumProblems += CheckLists(Diags, SourceMgr, "note", ED.Notes,
|
||||||
Buffer.note_begin(), Buffer.note_end());
|
Buffer.note_begin(), Buffer.note_end());
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
// designed to always trigger the inliner, so it should be independent
|
// designed to always trigger the inliner, so it should be independent
|
||||||
// of the optimization level.
|
// of the optimization level.
|
||||||
|
|
||||||
// RUN: %clang -c %s -Rpass=inline -O0 -gline-tables-only -S -o /dev/null 2> %t.err
|
// RUN: %clang_cc1 %s -Rpass=inline -O0 -gline-tables-only -emit-obj -verify -S -o /dev/null 2> %t.err
|
||||||
// RUN: FileCheck < %t.err %s --check-prefix=INLINE
|
|
||||||
|
|
||||||
// RUN: %clang -c %s -Rpass=inline -O0 -S -o /dev/null 2> %t.err
|
// RUN: %clang -c %s -Rpass=inline -O0 -S -o /dev/null 2> %t.err
|
||||||
// RUN: FileCheck < %t.err %s --check-prefix=INLINE-NO-LOC
|
// RUN: FileCheck < %t.err %s --check-prefix=INLINE-NO-LOC
|
||||||
|
@ -11,9 +10,9 @@
|
||||||
int foo(int x, int y) __attribute__((always_inline));
|
int foo(int x, int y) __attribute__((always_inline));
|
||||||
|
|
||||||
int foo(int x, int y) { return x + y; }
|
int foo(int x, int y) { return x + y; }
|
||||||
int bar(int j) { return foo(j, j - 2); }
|
|
||||||
|
|
||||||
// INLINE: remark: foo inlined into bar [-Rpass=inline]
|
// expected-remark@+1 {{foo inlined into bar}}
|
||||||
|
int bar(int j) { return foo(j, j - 2); }
|
||||||
|
|
||||||
// INLINE-NO-LOC: {{^remark: foo inlined into bar}}
|
// INLINE-NO-LOC: {{^remark: foo inlined into bar}}
|
||||||
// INLINE-NO-LOC: note: use -gline-tables-only -gcolumn-info to track
|
// INLINE-NO-LOC: note: use -gline-tables-only -gcolumn-info to track
|
||||||
|
|
Loading…
Reference in New Issue