Skip to content

Commit 01b9ad9

Browse files
committed
Do not output preprocessed source if diagnostics are enabled
1 parent 5424807 commit 01b9ad9

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CommandLine.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ using namespace std;
3737
bool debugOutput;
3838
bool outputDiagnostics;
3939
bool outputOnlyNeededPrototypes;
40+
bool outputPreprocessedSketch = true;
4041

4142
static cl::OptionCategory arduinoToolCategory("Arduino options");
4243
// TODO: add complete help
@@ -74,6 +75,8 @@ CommonOptionsParser doCommandLineParsing(int argc, const char **argv) {
7475
debugOutput = debugOutputOpt.getValue();
7576
outputOnlyNeededPrototypes = outputOnlyNeededPrototypesOpt.getValue();
7677
outputDiagnostics = outputDiagnosticsOpt.getValue();
77-
78+
if (outputDiagnostics) {
79+
outputPreprocessedSketch = false;
80+
}
7881
return optParser;
7982
}

CommandLine.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ using namespace llvm;
3939
extern bool debugOutput;
4040
extern bool outputOnlyNeededPrototypes;
4141
extern bool outputDiagnostics;
42+
extern bool outputPreprocessedSketch;
4243

4344
CommonOptionsParser doCommandLineParsing(int argc, const char **argv);

main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ class INOPreprocessAction : public ASTFrontendAction {
241241
outs() << out.str();
242242
}
243243

244+
if (!outputPreprocessedSketch) {
245+
return;
246+
}
247+
244248
const FileID mainFileID = rewriter.getSourceMgr().getMainFileID();
245249
const RewriteBuffer *buf = rewriter.getRewriteBufferFor(mainFileID);
246250
if (buf == nullptr) {

0 commit comments

Comments
 (0)