Revert "Remove separate compilerdebug.h in favor of debug.h"
Causing compile warnings in Release:
1>compiler\translator\CallDAG.cpp(238): error C2220: warning treated as error - no 'object' file generated
1>compiler\translator\CallDAG.cpp(238): warning C4189: 'op' : local variable is initialized but not referenced
1>compiler\translator\IntermNode.cpp(1495): error C2220: warning treated as error - no 'object' file generated
1>compiler\translator\IntermNode.cpp(1495): warning C4189: 'replaced' : local variable is initialized but not referenced
1>compiler\translator\IntermNode.cpp(1517): warning C4189: 'replaced' : local variable is initialized but not referenced
This reverts commit 5271025865b34685da71d0309131c5aff2e32f71.
Change-Id: Icdf1c37eef22a13d083767609ab0b0285d3dc517
Reviewed-on: https://chromium-review.googlesource.com/267359
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/BaseTypes.h b/src/compiler/translator/BaseTypes.h
index c174dfc..18dcd3e 100644
--- a/src/compiler/translator/BaseTypes.h
+++ b/src/compiler/translator/BaseTypes.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATOR_BASETYPES_H_
#define COMPILER_TRANSLATOR_BASETYPES_H_
-#include "common/debug.h"
+#include "compiler/translator/compilerdebug.h"
//
// Precision qualifiers
diff --git a/src/compiler/translator/Common.h b/src/compiler/translator/Common.h
index 5759302..ac1aef0 100644
--- a/src/compiler/translator/Common.h
+++ b/src/compiler/translator/Common.h
@@ -14,9 +14,9 @@
#include <limits>
#include <stdio.h>
-#include "common/angleutils.h"
-#include "common/debug.h"
#include "compiler/translator/PoolAlloc.h"
+#include "compiler/translator/compilerdebug.h"
+#include "common/angleutils.h"
struct TSourceLoc {
int first_file;
diff --git a/src/compiler/translator/Diagnostics.cpp b/src/compiler/translator/Diagnostics.cpp
index 593137f..92db3e5 100644
--- a/src/compiler/translator/Diagnostics.cpp
+++ b/src/compiler/translator/Diagnostics.cpp
@@ -6,7 +6,7 @@
#include "compiler/translator/Diagnostics.h"
-#include "common/debug.h"
+#include "compiler/translator/compilerdebug.h"
#include "compiler/translator/InfoSink.h"
#include "compiler/preprocessor/SourceLocation.h"
@@ -50,6 +50,11 @@
sink << "'" << token << "' : " << reason << " " << extra << "\n";
}
+void TDiagnostics::writeDebug(const std::string& str)
+{
+ mInfoSink.debug << str;
+}
+
void TDiagnostics::print(ID id,
const pp::SourceLocation& loc,
const std::string& text)
diff --git a/src/compiler/translator/Diagnostics.h b/src/compiler/translator/Diagnostics.h
index df65968..078bc97 100644
--- a/src/compiler/translator/Diagnostics.h
+++ b/src/compiler/translator/Diagnostics.h
@@ -29,6 +29,8 @@
const std::string& token,
const std::string& extra);
+ void writeDebug(const std::string& str);
+
protected:
virtual void print(ID id,
const pp::SourceLocation& loc,
diff --git a/src/compiler/translator/DirectiveHandler.cpp b/src/compiler/translator/DirectiveHandler.cpp
index 084c22d..936c00a 100644
--- a/src/compiler/translator/DirectiveHandler.cpp
+++ b/src/compiler/translator/DirectiveHandler.cpp
@@ -8,7 +8,7 @@
#include <sstream>
-#include "common/debug.h"
+#include "compiler/translator/compilerdebug.h"
#include "compiler/translator/Diagnostics.h"
static TBehavior getBehavior(const std::string& str)
diff --git a/src/compiler/translator/InitializeVariables.cpp b/src/compiler/translator/InitializeVariables.cpp
index 68e2b53..2bb609a 100644
--- a/src/compiler/translator/InitializeVariables.cpp
+++ b/src/compiler/translator/InitializeVariables.cpp
@@ -5,8 +5,7 @@
//
#include "compiler/translator/InitializeVariables.h"
-
-#include "common/debug.h"
+#include "compiler/translator/compilerdebug.h"
namespace
{
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index 54069e0..6f7568e 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -5,8 +5,7 @@
//
#include "compiler/translator/OutputGLSLBase.h"
-
-#include "common/debug.h"
+#include "compiler/translator/compilerdebug.h"
#include <cfloat>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 46fbf44..03aab78 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -11,7 +11,6 @@
#include <stdio.h>
#include "common/angleutils.h"
-#include "common/debug.h"
#include "common/utilities.h"
#include "compiler/translator/BuiltInFunctionEmulator.h"
#include "compiler/translator/BuiltInFunctionEmulatorHLSL.h"
@@ -27,6 +26,7 @@
#include "compiler/translator/UniformHLSL.h"
#include "compiler/translator/UtilsHLSL.h"
#include "compiler/translator/blocklayout.h"
+#include "compiler/translator/compilerdebug.h"
#include "compiler/translator/util.h"
namespace sh
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 7e5dcb3..9b9ca3a 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -198,6 +198,11 @@
srcLoc, reason, token, extraInfo);
}
+void TParseContext::trace(const char* str)
+{
+ diagnostics.writeDebug(str);
+}
+
//
// Same error message for all places assignments don't work.
//
diff --git a/src/compiler/translator/ParseContext.h b/src/compiler/translator/ParseContext.h
index a79f727..2c3d373 100644
--- a/src/compiler/translator/ParseContext.h
+++ b/src/compiler/translator/ParseContext.h
@@ -78,6 +78,7 @@
const char* extraInfo="");
void warning(const TSourceLoc& loc, const char* reason, const char* token,
const char* extraInfo="");
+ void trace(const char* str);
void recover();
// This method is guaranteed to succeed, even if no variable with 'name' exists.
diff --git a/src/compiler/translator/RegenerateStructNames.cpp b/src/compiler/translator/RegenerateStructNames.cpp
index 5e0db2a..767b180 100644
--- a/src/compiler/translator/RegenerateStructNames.cpp
+++ b/src/compiler/translator/RegenerateStructNames.cpp
@@ -4,8 +4,8 @@
// found in the LICENSE file.
//
-#include "common/debug.h"
#include "compiler/translator/RegenerateStructNames.h"
+#include "compiler/translator/compilerdebug.h"
void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
{
diff --git a/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp b/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
index c1fdf50..8857ad5 100644
--- a/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
+++ b/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
@@ -4,8 +4,8 @@
// found in the LICENSE file.
//
-#include "common/debug.h"
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
+#include "compiler/translator/compilerdebug.h"
#include <algorithm>
diff --git a/src/compiler/translator/ShaderVars.cpp b/src/compiler/translator/ShaderVars.cpp
index 590655f..0dbbc9e 100644
--- a/src/compiler/translator/ShaderVars.cpp
+++ b/src/compiler/translator/ShaderVars.cpp
@@ -9,7 +9,7 @@
#include <GLSLANG/ShaderLang.h>
-#include "common/debug.h"
+#include "compiler/translator/compilerdebug.h"
namespace sh
{
diff --git a/src/compiler/translator/Types.h b/src/compiler/translator/Types.h
index f81f93d..6355025 100644
--- a/src/compiler/translator/Types.h
+++ b/src/compiler/translator/Types.h
@@ -8,10 +8,10 @@
#define COMPILER_TRANSLATOR_TYPES_H_
#include "common/angleutils.h"
-#include "common/debug.h"
#include "compiler/translator/BaseTypes.h"
#include "compiler/translator/Common.h"
+#include "compiler/translator/compilerdebug.h"
struct TPublicType;
class TType;
diff --git a/src/compiler/translator/compilerdebug.cpp b/src/compiler/translator/compilerdebug.cpp
new file mode 100644
index 0000000..10cbe43
--- /dev/null
+++ b/src/compiler/translator/compilerdebug.cpp
@@ -0,0 +1,37 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// debug.cpp: Debugging utilities.
+
+#include "compiler/translator/compilerdebug.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "compiler/translator/InitializeParseContext.h"
+#include "compiler/translator/ParseContext.h"
+
+#ifdef TRACE_ENABLED
+static const int kTraceBufferLen = 1024;
+
+extern "C" {
+void Trace(const char *format, ...) {
+ if (!format) return;
+
+ TParseContext* parseContext = GetGlobalParseContext();
+ if (parseContext) {
+ char buf[kTraceBufferLen];
+ va_list args;
+ va_start(args, format);
+ vsnprintf(buf, kTraceBufferLen, format, args);
+ va_end(args);
+
+ parseContext->trace(buf);
+ }
+}
+} // extern "C"
+#endif // TRACE_ENABLED
+
diff --git a/src/compiler/translator/compilerdebug.h b/src/compiler/translator/compilerdebug.h
new file mode 100644
index 0000000..84a12ad
--- /dev/null
+++ b/src/compiler/translator/compilerdebug.h
@@ -0,0 +1,53 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// debug.h: Debugging utilities.
+
+#ifndef COMPILER_TRANSLATOR_COMPILERDEBUG_H_
+#define COMPILER_TRANSLATOR_COMPILERDEBUG_H_
+
+#include <assert.h>
+
+#ifdef _DEBUG
+#define TRACE_ENABLED // define to enable debug message tracing
+#endif // _DEBUG
+
+// Outputs text to the debug log
+#ifdef TRACE_ENABLED
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+void Trace(const char* format, ...);
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#else // TRACE_ENABLED
+
+#define Trace(...) ((void)0)
+
+#endif // TRACE_ENABLED
+
+// A macro asserting a condition and outputting failures to the debug log
+#define ASSERT(expression) do { \
+ if(!(expression)) \
+ Trace("Assert failed: %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
+ assert(expression); \
+} while(0)
+
+#define UNIMPLEMENTED() do { \
+ Trace("Unimplemented invoked: %s(%d)\n", __FUNCTION__, __LINE__); \
+ assert(false); \
+} while(0)
+
+#define UNREACHABLE() do { \
+ Trace("Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
+ assert(false); \
+} while(0)
+
+#endif // COMPILER_TRANSLATOR_COMPILERDEBUG_H_
+