Avoid parameter shadowing in source/diagnostic.h
authorDavid Neto <dneto@google.com>
Mon, 4 Jan 2016 22:27:34 +0000 (17:27 -0500)
committerDavid Neto <dneto@google.com>
Wed, 6 Jan 2016 18:11:42 +0000 (13:11 -0500)
Change the offending class to more closely follow Google C++ style:
- Member names have a trailing underscore.
- Use an accessor method for the stream_ member.

source/diagnostic.h

index 7c82b7f..9841df2 100644 (file)
@@ -37,21 +37,22 @@ namespace libspirv {
 
 class diagnostic_helper {
  public:
-  diagnostic_helper(spv_position_t& position, spv_diagnostic* pDiagnostic)
-      : position(&position), pDiagnostic(pDiagnostic) {}
+  diagnostic_helper(spv_position_t& position, spv_diagnostic* diagnostic)
+      : position_(&position), diagnostic_(diagnostic) {}
 
-  diagnostic_helper(spv_position position, spv_diagnostic* pDiagnostic)
-      : position(position), pDiagnostic(pDiagnostic) {}
+  diagnostic_helper(spv_position position, spv_diagnostic* diagnostic)
+      : position_(position), diagnostic_(diagnostic) {}
 
   ~diagnostic_helper() {
-    *pDiagnostic = spvDiagnosticCreate(position, stream.str().c_str());
+    *diagnostic_ = spvDiagnosticCreate(position_, stream().str().c_str());
   }
 
-  std::stringstream stream;
+  std::stringstream& stream() { return stream_; }
 
  private:
-  spv_position position;
-  spv_diagnostic* pDiagnostic;
+  std::stringstream stream_;
+  spv_position position_;
+  spv_diagnostic* diagnostic_;
 };
 
 // A DiagnosticStream remembers the current position of the input and an error
@@ -99,7 +100,7 @@ class DiagnosticStream {
 
 #define DIAGNOSTIC                                           \
   libspirv::diagnostic_helper helper(position, pDiagnostic); \
-  helper.stream
+  helper.stream()
 
 }  // namespace libspirv