forked from OSchip/llvm-project
add a virtual method to DiagnosticClient to get rid of some fragile
casting in clang-cc. llvm-svn: 69377
This commit is contained in:
parent
5ceb1a2dd9
commit
c6b5613460
|
@ -27,6 +27,7 @@ namespace clang {
|
|||
class SourceRange;
|
||||
class DiagnosticBuilder;
|
||||
class IdentifierInfo;
|
||||
class LangOptions;
|
||||
|
||||
// Import the diagnostic enums themselves.
|
||||
namespace diag {
|
||||
|
@ -667,6 +668,13 @@ class DiagnosticClient {
|
|||
public:
|
||||
virtual ~DiagnosticClient();
|
||||
|
||||
/// setLangOptions - This is set by clients of diagnostics when they know the
|
||||
/// language parameters of the diagnostics that may be sent through. Note
|
||||
/// that this can change over time if a DiagClient has multiple languages sent
|
||||
/// through it. It may also be set to null (e.g. when processing command line
|
||||
/// options).
|
||||
virtual void setLangOptions(const LangOptions *LO) {}
|
||||
|
||||
/// IncludeInDiagnosticCounts - This method (whose default implementation
|
||||
/// returns true) indicates whether the diagnostics handled by this
|
||||
/// DiagnosticClient should be included in the number of diagnostics
|
||||
|
|
|
@ -50,8 +50,8 @@ public:
|
|||
PrintRangeInfo(printRangeInfo),
|
||||
PrintDiagnosticOption(printDiagnosticOption) {}
|
||||
|
||||
void SetLangOpts(const LangOptions &LO) {
|
||||
LangOpts = &LO;
|
||||
void setLangOptions(const LangOptions *LO) {
|
||||
LangOpts = LO;
|
||||
}
|
||||
|
||||
void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM);
|
||||
|
|
|
@ -2301,11 +2301,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
// Initialize language options, inferring file types from input filenames.
|
||||
LangOptions LangInfo;
|
||||
|
||||
if (!VerifyDiagnostics)
|
||||
static_cast<TextDiagnosticPrinter*>(TextDiagClient)
|
||||
->SetLangOpts(LangInfo);
|
||||
|
||||
TextDiagClient->setLangOptions(&LangInfo);
|
||||
|
||||
InitializeBaseLanguage();
|
||||
LangKind LK = GetLanguage(InFile);
|
||||
|
@ -2346,7 +2342,8 @@ int main(int argc, char **argv) {
|
|||
// Process the source file.
|
||||
ProcessInputFile(*PP, PPFactory, InFile, ProgAction);
|
||||
|
||||
HeaderInfo.ClearFileInfo();
|
||||
HeaderInfo.ClearFileInfo();
|
||||
TextDiagClient->setLangOptions(0);
|
||||
}
|
||||
|
||||
if (Verbose)
|
||||
|
|
Loading…
Reference in New Issue