diff options
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Basic/DiagnosticFrontendKinds.td | 2 | ||||
-rw-r--r-- | include/clang/Basic/SourceManager.h | 8 | ||||
-rw-r--r-- | include/clang/Frontend/VerifyDiagnosticConsumer.h | 22 |
3 files changed, 27 insertions, 5 deletions
diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 6fd7d2264b..f8d3b10a19 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -63,6 +63,8 @@ def warn_fe_serialized_diag_failure : Warning< "unable to open file %0 for serializing diagnostics (%1)">, InGroup<DiagGroup<"serialized-diagnostics">>; +def err_verify_missing_line : Error< + "missing or invalid line number following '@' in expected %0">; def err_verify_missing_start : Error< "cannot find start ('{{') of expected %0">; def err_verify_missing_end : Error< diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 0cb3b834d7..415b017b73 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -36,6 +36,7 @@ #define LLVM_CLANG_SOURCEMANAGER_H #include "clang/Basic/LLVM.h" +#include "clang/Basic/FileManager.h" #include "clang/Basic/SourceLocation.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/DataTypes.h" @@ -897,6 +898,13 @@ public: return getFileIDSlow(SLocOffset); } + /// \brief Return the filename of the file containing a SourceLocation. + StringRef getFilename(SourceLocation SpellingLoc) const { + if (const FileEntry *F = getFileEntryForID(getFileID(SpellingLoc))) + return F->getName(); + return StringRef(); + } + /// \brief Return the source location corresponding to the first byte of /// the specified file. SourceLocation getLocForStartOfFile(FileID FID) const { diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h index 6462371787..0df24e2a15 100644 --- a/include/clang/Frontend/VerifyDiagnosticConsumer.h +++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -44,6 +44,15 @@ class TextDiagnosticBuffer; /// You can place as many diagnostics on one line as you wish. To make the code /// more readable, you can use slash-newline to separate out the diagnostics. /// +/// Alternatively, it is possible to specify the line on which the diagnostic +/// should appear by appending "@<line>" to "expected-<type>", for example: +/// +/// #warning some text +/// // expected-warning@10 {{some text}} +/// +/// The line number may be absolute (as above), or relative to the current +/// line by prefixing the number with either '+' or '-'. +/// /// The simple syntax above allows each specification to match exactly one /// error. You can use the extended syntax to customize this. The extended /// syntax is "expected-<type> <n> {{diag text}}", where \<type> is one of @@ -74,13 +83,15 @@ public: /// class Directive { public: - static Directive *create(bool RegexKind, const SourceLocation &Location, + static Directive *create(bool RegexKind, SourceLocation DirectiveLoc, + SourceLocation DiagnosticLoc, StringRef Text, unsigned Count); public: /// Constant representing one or more matches aka regex "+". static const unsigned OneOrMoreCount = UINT_MAX; - SourceLocation Location; + SourceLocation DirectiveLoc; + SourceLocation DiagnosticLoc; const std::string Text; unsigned Count; @@ -94,9 +105,10 @@ public: virtual bool match(StringRef S) = 0; protected: - Directive(const SourceLocation &Location, StringRef Text, - unsigned Count) - : Location(Location), Text(Text), Count(Count) { } + Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, + StringRef Text, unsigned Count) + : DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc), + Text(Text), Count(Count) { } private: Directive(const Directive&); // DO NOT IMPLEMENT |