Avoid printing to stdout directly in library functions.
Previously GlslangToSpv() reported missing/TBD functionalities by directly writing to stdout using printf. That could cause problems to callers of GlslangToSpv(). This patch cleans up the error reporting logic in GlslangToSpv(), TGlslangToSpvTraverser, and spv::Builder a little bit to use ostringstream. Also fixed the usage of GlslangToSpv() in GTest fixtures to capture warnings/errors reported when translating AST to SPIR-V.
This commit is contained in:
@@ -53,16 +53,17 @@
|
||||
#include "spvIR.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
|
||||
namespace spv {
|
||||
|
||||
class Builder {
|
||||
public:
|
||||
Builder(unsigned int userNumber);
|
||||
Builder(unsigned int userNumber, std::ostringstream& warnError);
|
||||
virtual ~Builder();
|
||||
|
||||
static const int maxMatrixSize = 4;
|
||||
@@ -580,13 +581,16 @@ public:
|
||||
|
||||
// Our loop stack.
|
||||
std::stack<LoopBlocks> loops;
|
||||
|
||||
// The stream for outputing warnings and errors.
|
||||
std::ostringstream& warningsErrors;
|
||||
}; // end Builder class
|
||||
|
||||
// Use for non-fatal notes about what's not complete
|
||||
void TbdFunctionality(const char*);
|
||||
void TbdFunctionality(std::ostringstream&, const char*);
|
||||
|
||||
// Use for fatal missing functionality
|
||||
void MissingFunctionality(const char*);
|
||||
void MissingFunctionality(std::ostringstream&, const char*);
|
||||
|
||||
}; // end spv namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user