Do not turn errors into warnings by default
Not required anymore since the resource dir is specified correctly.
This commit is contained in:
parent
21e7f83995
commit
8587d62583
|
@ -36,6 +36,7 @@ CodeFactory::CodeFactory(
|
|||
, m_clangOptions(clangOptions)
|
||||
, m_os(os)
|
||||
, m_compilerInstance(nullptr)
|
||||
, m_errorResilient(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
bool run();
|
||||
clang::CompilerInstance *compilerInstance();
|
||||
void setCompilerInstance(clang::CompilerInstance *compilerInstance);
|
||||
bool isErrorResilient() const;
|
||||
void setErrorResilient(bool errorResilient);
|
||||
|
||||
private:
|
||||
struct ToolInvocation;
|
||||
|
@ -55,6 +57,7 @@ private:
|
|||
std::vector<std::unique_ptr<CodeGenerator>> m_generators;
|
||||
std::unique_ptr<ToolInvocation> m_toolInvocation;
|
||||
clang::CompilerInstance *m_compilerInstance;
|
||||
bool m_errorResilient;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -129,6 +132,22 @@ inline void CodeFactory::setCompilerInstance(clang::CompilerInstance *compilerIn
|
|||
m_compilerInstance = compilerInstance;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns whether most errors will be turned into warnings (by default false).
|
||||
*/
|
||||
inline bool CodeFactory::isErrorResilient() const
|
||||
{
|
||||
return m_errorResilient;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets whether most errors will be turned into warnings (by default false).
|
||||
*/
|
||||
inline void CodeFactory::setErrorResilient(bool errorResilient)
|
||||
{
|
||||
m_errorResilient = errorResilient;
|
||||
}
|
||||
|
||||
} // namespace ReflectiveRapidJSON
|
||||
|
||||
#endif // REFLECTIVE_RAPIDJSON_CODE_FACTORY_H
|
||||
|
|
|
@ -61,10 +61,11 @@ void DiagConsumer::finish()
|
|||
*/
|
||||
void DiagConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level diagLevel, const clang::Diagnostic &info)
|
||||
{
|
||||
bool shouldReset = false;
|
||||
if (m_errorResilient) {
|
||||
const auto diagId = info.getID();
|
||||
const auto category = info.getDiags()->getDiagnosticIDs()->getCategoryNumberForDiag(diagId);
|
||||
|
||||
bool shouldReset = false;
|
||||
if (diagLevel >= clang::DiagnosticsEngine::Error) {
|
||||
if (category == 2 /* 2 means "Semantic Issue" */) {
|
||||
if (!m_realErrorCount) {
|
||||
|
@ -75,6 +76,7 @@ void DiagConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level diagLevel, c
|
|||
++m_realErrorCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DiagnosticConsumer::HandleDiagnostic(diagLevel, info);
|
||||
m_proxy->HandleDiagnostic(diagLevel, info);
|
||||
|
|
|
@ -50,7 +50,7 @@ inline Consumer::Consumer(CodeFactory &factory, clang::CompilerInstance &compile
|
|||
*/
|
||||
class DiagConsumer : public clang::DiagnosticConsumer {
|
||||
public:
|
||||
DiagConsumer(std::unique_ptr<DiagnosticConsumer> Previous);
|
||||
DiagConsumer(std::unique_ptr<DiagnosticConsumer> previous, bool errorResilient);
|
||||
unsigned int realErrorCount() const;
|
||||
|
||||
void BeginSourceFile(const clang::LangOptions &langOpts, const clang::Preprocessor *pp = nullptr) override;
|
||||
|
@ -62,11 +62,13 @@ public:
|
|||
private:
|
||||
std::unique_ptr<DiagnosticConsumer> m_proxy;
|
||||
unsigned int m_realErrorCount;
|
||||
bool m_errorResilient;
|
||||
};
|
||||
|
||||
inline DiagConsumer::DiagConsumer(std::unique_ptr<clang::DiagnosticConsumer> Previous)
|
||||
: m_proxy(std::move(Previous))
|
||||
inline DiagConsumer::DiagConsumer(std::unique_ptr<clang::DiagnosticConsumer> previous, bool errorResilient)
|
||||
: m_proxy(std::move(previous))
|
||||
, m_realErrorCount(0)
|
||||
, m_errorResilient(errorResilient)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,10 @@ int main(int argc, char *argv[])
|
|||
generatorsArg.setCombinable(true);
|
||||
ConfigValueArgument clangOptionsArg("clang-opt", '\0', "specifies arguments/options to be passed to Clang", { "option" });
|
||||
clangOptionsArg.setRequiredValueCount(Argument::varValueCount);
|
||||
ConfigValueArgument errorResilientArg("error-resilient", '\0', "turns most errors into warnings");
|
||||
HelpArgument helpArg(parser);
|
||||
NoColorArgument noColorArg;
|
||||
generateArg.setSubArguments({ &inputFileArg, &outputFileArg, &generatorsArg, &clangOptionsArg });
|
||||
generateArg.setSubArguments({ &inputFileArg, &outputFileArg, &generatorsArg, &clangOptionsArg, &errorResilientArg });
|
||||
JsonSerializationCodeGenerator::Options jsonOptions;
|
||||
jsonOptions.appendTo(&generateArg);
|
||||
parser.setMainArguments({ &generateArg, &noColorArg, &helpArg });
|
||||
|
@ -83,9 +84,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
// instantiate the code factory and add generators to it
|
||||
CodeFactory factory(parser.executable(), inputFileArg.values(0), clangOptions, *os);
|
||||
factory.setErrorResilient(errorResilientArg.isPresent());
|
||||
// add specified generators if the --generator argument is present; otherwise add default generators
|
||||
if (generatorsArg.isPresent()) {
|
||||
// define mapping of generator names to generator constructions (add new generators here!)
|
||||
// define mapping of generator names to generator constructors (add new generators here!)
|
||||
// clang-format off
|
||||
const std::unordered_map<std::string, std::function<void()>> generatorsByName{
|
||||
{ "json", factory.bindGenerator<JsonSerializationCodeGenerator, const JsonSerializationCodeGenerator::Options &>(jsonOptions) }
|
||||
|
|
Loading…
Reference in New Issue