trick/trick_source/codegen/Interface_Code_Gen/ICGDiagnosticConsumer.hh
Hong Chen d72312c602
Customize clang diagnostic handling. (#1707)
* Cutomize clang diagnostic handling.

* Removed code that was commented out.
2024-05-14 10:53:11 -05:00

43 lines
1.1 KiB
C++

#ifndef ICG_DIAGNOSTICCONSUMER_HH
#define ICG_DIAGNOSTICCONSUMER_HH
#include "llvm/Support/raw_ostream.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
class HeaderSearchDirs;
/**
This class is passed to the clang parser as a DiagnosticConsumer.
It will terminate the trick build if an error found is from user code.
@date May 2024
*/
class ICGDiagnosticConsumer : public clang::TextDiagnosticPrinter {
public:
ICGDiagnosticConsumer(llvm::raw_ostream &os, clang::DiagnosticOptions *diags, clang::CompilerInstance &in_ci, HeaderSearchDirs &in_hsd);
~ICGDiagnosticConsumer() override;
void HandleDiagnostic(clang::DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) override;
/** Flag for if any error found in user code. */
bool error_in_user_code;
protected:
/** The compiler instance. */
clang::CompilerInstance &ci ;
/** The header search directories. */
HeaderSearchDirs &hsd ;
};
#endif