clang API Documentation
#include "clang/Frontend/VerifyDiagnosticConsumer.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/FileManager.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/raw_ostream.h"
Go to the source code of this file.
Typedefs | |
typedef VerifyDiagnosticConsumer::Directive | Directive |
typedef VerifyDiagnosticConsumer::DirectiveList | DirectiveList |
typedef VerifyDiagnosticConsumer::ExpectedData | ExpectedData |
typedef TextDiagnosticBuffer::DiagList | DiagList |
typedef TextDiagnosticBuffer::const_iterator | const_diag_iterator |
Functions | |
static bool | ParseDirective (StringRef S, ExpectedData *ED, SourceManager &SM, Preprocessor *PP, SourceLocation Pos, VerifyDiagnosticConsumer::DirectiveStatus &Status) |
static bool | findDirectives (SourceManager &SM, FileID FID, const LangOptions &LangOpts) |
Lex the specified source file to determine whether it contains any expected-* directives. As a Lexer is used rather than a full-blown Preprocessor, directives inside skipped #if blocks will still be found. | |
static unsigned | PrintUnexpected (DiagnosticsEngine &Diags, SourceManager *SourceMgr, const_diag_iterator diag_begin, const_diag_iterator diag_end, const char *Kind) |
Takes a list of diagnostics that have been generated but not matched by an expected-* directive and produces a diagnostic to the user from this. | |
static unsigned | PrintExpected (DiagnosticsEngine &Diags, SourceManager &SourceMgr, std::vector< Directive * > &DL, const char *Kind) |
Takes a list of diagnostics that were expected to have been generated but were not and produces a diagnostic to the user from this. | |
static bool | IsFromSameFile (SourceManager &SM, SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc) |
Determine whether two source locations come from the same file. | |
static unsigned | CheckLists (DiagnosticsEngine &Diags, SourceManager &SourceMgr, const char *Label, DirectiveList &Left, const_diag_iterator d2_begin, const_diag_iterator d2_end) |
static unsigned | CheckResults (DiagnosticsEngine &Diags, SourceManager &SourceMgr, const TextDiagnosticBuffer &Buffer, ExpectedData &ED) |
Definition at line 155 of file VerifyDiagnosticConsumer.cpp.
Definition at line 154 of file VerifyDiagnosticConsumer.cpp.
Definition at line 26 of file VerifyDiagnosticConsumer.cpp.
Definition at line 27 of file VerifyDiagnosticConsumer.cpp.
Definition at line 28 of file VerifyDiagnosticConsumer.cpp.
static unsigned CheckLists | ( | DiagnosticsEngine & | Diags, |
SourceManager & | SourceMgr, | ||
const char * | Label, | ||
DirectiveList & | Left, | ||
const_diag_iterator | d2_begin, | ||
const_diag_iterator | d2_end | ||
) | [static] |
CheckLists - Compare expected to seen diagnostic lists and return the the difference between them.
Definition at line 690 of file VerifyDiagnosticConsumer.cpp.
References clang::VerifyDiagnosticConsumer::Directive::DiagnosticLoc, clang::SourceManager::getPresumedLineNumber(), IsFromSameFile(), clang::VerifyDiagnosticConsumer::Directive::match(), clang::VerifyDiagnosticConsumer::Directive::MatchAnyLine, clang::VerifyDiagnosticConsumer::Directive::Max, clang::VerifyDiagnosticConsumer::Directive::Min, PrintExpected(), and PrintUnexpected().
Referenced by CheckResults().
static unsigned CheckResults | ( | DiagnosticsEngine & | Diags, |
SourceManager & | SourceMgr, | ||
const TextDiagnosticBuffer & | Buffer, | ||
ExpectedData & | ED | ||
) | [static] |
CheckResults - This compares the expected results to those that were actually reported. It emits any discrepencies. Return "true" if there were problems. Return "false" otherwise.
Definition at line 738 of file VerifyDiagnosticConsumer.cpp.
References CheckLists(), clang::TextDiagnosticBuffer::err_begin(), clang::TextDiagnosticBuffer::err_end(), clang::VerifyDiagnosticConsumer::ExpectedData::Errors, clang::TextDiagnosticBuffer::note_begin(), clang::TextDiagnosticBuffer::note_end(), clang::VerifyDiagnosticConsumer::ExpectedData::Notes, clang::TextDiagnosticBuffer::remark_begin(), clang::TextDiagnosticBuffer::remark_end(), clang::VerifyDiagnosticConsumer::ExpectedData::Remarks, clang::TextDiagnosticBuffer::warn_begin(), clang::TextDiagnosticBuffer::warn_end(), and clang::VerifyDiagnosticConsumer::ExpectedData::Warnings.
static bool findDirectives | ( | SourceManager & | SM, |
FileID | FID, | ||
const LangOptions & | LangOpts | ||
) | [static] |
Lex the specified source file to determine whether it contains any expected-* directives. As a Lexer is used rather than a full-blown Preprocessor, directives inside skipped #if blocks will still be found.
Definition at line 581 of file VerifyDiagnosticConsumer.cpp.
References clang::comments::tok::eof, clang::SourceManager::getBuffer(), clang::Token::getLocation(), clang::Lexer::getSpelling(), clang::VerifyDiagnosticConsumer::HasNoDirectives, clang::Token::is(), clang::FileID::isInvalid(), clang::Token::isNot(), clang::Lexer::LexFromRawLexer(), ParseDirective(), clang::Lexer::SetCommentRetentionState(), and clang::Token::setKind().
Referenced by clang::VerifyDiagnosticConsumer::UpdateParsedFileStatus().
static bool IsFromSameFile | ( | SourceManager & | SM, |
SourceLocation | DirectiveLoc, | ||
SourceLocation | DiagnosticLoc | ||
) | [static] |
Determine whether two source locations come from the same file.
Definition at line 672 of file VerifyDiagnosticConsumer.cpp.
References clang::SourceManager::getFileEntryForID(), clang::SourceManager::getFileID(), clang::SourceManager::getImmediateMacroCallerLoc(), clang::SourceLocation::isMacroID(), clang::SourceManager::isWrittenInMainFile(), and clang::SourceManager::isWrittenInSameFile().
Referenced by CheckLists().
static bool ParseDirective | ( | StringRef | S, |
ExpectedData * | ED, | ||
SourceManager & | SM, | ||
Preprocessor * | PP, | ||
SourceLocation | Pos, | ||
VerifyDiagnosticConsumer::DirectiveStatus & | Status | ||
) | [static] |
ParseDirective - Go through the comment and see if it indicates expected diagnostics. If so, then put them in the appropriate directive list.
Returns true if any valid directives were found.
Definition at line 310 of file VerifyDiagnosticConsumer.cpp.
References clang::SrcMgr::C_User, clang::serialized_diags::create(), clang::SourceManager::createFileID(), clang::diag::Error, clang::VerifyDiagnosticConsumer::ExpectedData::Errors, clang::Preprocessor::getDiagnostics(), clang::SourceManager::getDiagnostics(), clang::SourceManager::getFileID(), clang::SourceLocation::getLocWithOffset(), clang::SourceManager::getSpellingLineNumber(), clang::VerifyDiagnosticConsumer::HasExpectedNoDiagnostics, clang::VerifyDiagnosticConsumer::HasOtherExpectedDirectives, clang::FileID::isInvalid(), clang::SourceLocation::isInvalid(), Line, clang::Preprocessor::LookupFile(), clang::VerifyDiagnosticConsumer::Directive::MaxCount, clang::VerifyDiagnosticConsumer::ExpectedData::Notes, clang::VerifyDiagnosticConsumer::ExpectedData::Remarks, clang::DiagnosticsEngine::Report(), clang::SourceManager::translateFile(), clang::SourceManager::translateFileLineCol(), clang::SourceManager::translateLineCol(), and clang::VerifyDiagnosticConsumer::ExpectedData::Warnings.
Referenced by findDirectives(), and clang::VerifyDiagnosticConsumer::HandleComment().
static unsigned PrintExpected | ( | DiagnosticsEngine & | Diags, |
SourceManager & | SourceMgr, | ||
std::vector< Directive * > & | DL, | ||
const char * | Kind | ||
) | [static] |
Takes a list of diagnostics that were expected to have been generated but were not and produces a diagnostic to the user from this.
Definition at line 644 of file VerifyDiagnosticConsumer.cpp.
References clang::VerifyDiagnosticConsumer::Directive::DiagnosticLoc, clang::VerifyDiagnosticConsumer::Directive::DirectiveLoc, clang::SourceManager::getFilename(), clang::SourceManager::getPresumedLineNumber(), clang::VerifyDiagnosticConsumer::Directive::MatchAnyLine, clang::DiagnosticsEngine::Report(), clang::DiagnosticBuilder::setForceEmit(), and clang::VerifyDiagnosticConsumer::Directive::Text.
Referenced by CheckLists().
static unsigned PrintUnexpected | ( | DiagnosticsEngine & | Diags, |
SourceManager * | SourceMgr, | ||
const_diag_iterator | diag_begin, | ||
const_diag_iterator | diag_end, | ||
const char * | Kind | ||
) | [static] |
Takes a list of diagnostics that have been generated but not matched by an expected-* directive and produces a diagnostic to the user from this.
Definition at line 616 of file VerifyDiagnosticConsumer.cpp.
References clang::SourceManager::getFileEntryForID(), clang::SourceManager::getFileID(), clang::SourceManager::getPresumedLineNumber(), clang::DiagnosticsEngine::Report(), clang::DiagnosticBuilder::setForceEmit(), and SourceMgr.
Referenced by CheckLists().