Refactor include of latest spir-v header versions
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 87819d5..9f4d3eb 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -70,7 +70,7 @@
 macro(spvtools_glsl_tables VERSION)
   set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/spirv.core.grammar.json")
   set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/extinst.glsl.std.450.grammar.json")
-  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/glsl.std.450.insts-${VERSION}.inc")
+  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/glsl.std.450.insts.inc")
   add_custom_command(OUTPUT ${GRAMMAR_INC_FILE}
     COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
       --spirv-core-grammar=${CORE_GRAMMAR_JSON_FILE}
@@ -84,7 +84,7 @@
 macro(spvtools_opencl_tables VERSION)
   set(CORE_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/spirv.core.grammar.json")
   set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/extinst.opencl.std.100.grammar.json")
-  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/opencl.std.insts-${VERSION}.inc")
+  set(GRAMMAR_INC_FILE "${spirv-tools_BINARY_DIR}/opencl.std.insts.inc")
   add_custom_command(OUTPUT ${GRAMMAR_INC_FILE}
     COMMAND ${PYTHON_EXECUTABLE} ${GRAMMAR_PROCESSING_SCRIPT}
       --spirv-core-grammar=${CORE_GRAMMAR_JSON_FILE}
@@ -113,8 +113,8 @@
 spvtools_core_tables("1.1")
 spvtools_core_tables("1.2")
 spvtools_enum_string_mapping("1.2")
-spvtools_opencl_tables("1.0")
-spvtools_glsl_tables("1.0")
+spvtools_opencl_tables("1.2")
+spvtools_glsl_tables("1.2")
 spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter")
 spvtools_vendor_tables("spv-amd-shader-trinary-minmax")
 spvtools_vendor_tables("spv-amd-gcn-shader")
@@ -210,6 +210,9 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/extensions.h
   ${CMAKE_CURRENT_SOURCE_DIR}/id_descriptor.h
   ${CMAKE_CURRENT_SOURCE_DIR}/instruction.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_glsl_std_450_header.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_opencl_std_header.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/latest_version_spirv_header.h
   ${CMAKE_CURRENT_SOURCE_DIR}/macro.h
   ${CMAKE_CURRENT_SOURCE_DIR}/name_mapper.h
   ${CMAKE_CURRENT_SOURCE_DIR}/opcode.h
diff --git a/source/assembly_grammar.h b/source/assembly_grammar.h
index bfbfe76..e37c457 100644
--- a/source/assembly_grammar.h
+++ b/source/assembly_grammar.h
@@ -15,9 +15,9 @@
 #ifndef LIBSPIRV_ASSEMBLY_GRAMMAR_H_
 #define LIBSPIRV_ASSEMBLY_GRAMMAR_H_
 
+#include "latest_version_spirv_header.h"
 #include "operand.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "table.h"
 
 namespace libspirv {
diff --git a/source/comp/markv_codec.cpp b/source/comp/markv_codec.cpp
index dec4d73..ff1c582 100644
--- a/source/comp/markv_codec.cpp
+++ b/source/comp/markv_codec.cpp
@@ -34,9 +34,9 @@
 #include <unordered_set>
 #include <vector>
 
-#include "spirv/1.2/GLSL.std.450.h"
-#include "spirv/1.2/OpenCL.std.h"
-#include "spirv/1.2/spirv.h"
+#include "latest_version_glsl_std_450_header.h"
+#include "latest_version_opencl_std_header.h"
+#include "latest_version_spirv_header.h"
 
 #include "binary.h"
 #include "diagnostic.h"
diff --git a/source/comp/markv_model.h b/source/comp/markv_model.h
index 630942c..606396e 100644
--- a/source/comp/markv_model.h
+++ b/source/comp/markv_model.h
@@ -19,8 +19,8 @@
 #include <unordered_set>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "util/huffman_codec.h"
 
 namespace spvtools {
diff --git a/source/enum_set.h b/source/enum_set.h
index b956b49..75a49f0 100644
--- a/source/enum_set.h
+++ b/source/enum_set.h
@@ -21,7 +21,7 @@
 #include <set>
 #include <utility>
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 namespace libspirv {
 
diff --git a/source/ext_inst.cpp b/source/ext_inst.cpp
index fc8a486..fa2c9b6 100644
--- a/source/ext_inst.cpp
+++ b/source/ext_inst.cpp
@@ -17,14 +17,14 @@
 #include <cassert>
 #include <cstring>
 
-#include "spirv/1.0/GLSL.std.450.h"
-#include "spirv/1.0/OpenCL.std.h"
+#include "latest_version_glsl_std_450_header.h"
+#include "latest_version_opencl_std_header.h"
 #include "spirv_definition.h"
 
 #include "macro.h"
 
-#include "glsl.std.450.insts-1.0.inc"  // defines glsl_entries
-#include "opencl.std.insts-1.0.inc"    // defines opencl_entries
+#include "glsl.std.450.insts.inc"  // defines glsl_entries
+#include "opencl.std.insts.inc"    // defines opencl_entries
 
 #include "spv-amd-gcn-shader.insts.inc"
 #include "spv-amd-shader-ballot.insts.inc"
diff --git a/source/instruction.h b/source/instruction.h
index 2afa6d4..884276d 100644
--- a/source/instruction.h
+++ b/source/instruction.h
@@ -18,8 +18,8 @@
 #include <cstdint>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 // Describes an instruction.
 struct spv_instruction_t {
diff --git a/source/latest_version_glsl_std_450_header.h b/source/latest_version_glsl_std_450_header.h
new file mode 100644
index 0000000..3fbddb8
--- /dev/null
+++ b/source/latest_version_glsl_std_450_header.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef LIBSPIRV_LATEST_VERSION_GLSL_STD_450_HEADER_H_
+#define LIBSPIRV_LATEST_VERSION_GLSL_STD_450_HEADER_H_
+
+#include "spirv/1.2/GLSL.std.450.h"
+
+#endif  // LIBSPIRV_LATEST_VERSION_GLSL_STD_450_HEADER_H_
diff --git a/source/latest_version_opencl_std_header.h b/source/latest_version_opencl_std_header.h
new file mode 100644
index 0000000..aa68f08
--- /dev/null
+++ b/source/latest_version_opencl_std_header.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef LIBSPIRV_LATEST_VERSION_OPENCL_STD_HEADER_H_
+#define LIBSPIRV_LATEST_VERSION_OPENCL_STD_HEADER_H_
+
+#include "spirv/1.2/OpenCL.std.h"
+
+#endif  // LIBSPIRV_LATEST_VERSION_OPENCL_STD_HEADER_H_
diff --git a/source/latest_version_spirv_header.h b/source/latest_version_spirv_header.h
new file mode 100644
index 0000000..ea9f45c
--- /dev/null
+++ b/source/latest_version_spirv_header.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2017 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef LIBSPIRV_LATEST_VERSION_SPIRV_HEADER_H_
+#define LIBSPIRV_LATEST_VERSION_SPIRV_HEADER_H_
+
+#include "spirv/1.2/spirv.h"
+
+#endif  // LIBSPIRV_LATEST_VERSION_SPIRV_HEADER_H_
diff --git a/source/opcode.h b/source/opcode.h
index 3ba99df..25c8de9 100644
--- a/source/opcode.h
+++ b/source/opcode.h
@@ -16,8 +16,8 @@
 #define LIBSPIRV_OPCODE_H_
 
 #include "instruction.h"
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "table.h"
 
 // Returns the name of a registered SPIR-V generator as a null-terminated
diff --git a/source/opt/aggressive_dead_code_elim_pass.cpp b/source/opt/aggressive_dead_code_elim_pass.cpp
index 512cdd7..b9b5486 100644
--- a/source/opt/aggressive_dead_code_elim_pass.cpp
+++ b/source/opt/aggressive_dead_code_elim_pass.cpp
@@ -18,7 +18,7 @@
 
 #include "cfa.h"
 #include "iterator.h"
-#include "spirv/1.0/GLSL.std.450.h"
+#include "latest_version_glsl_std_450_header.h"
 
 #include <stack>
 
diff --git a/source/opt/instruction.h b/source/opt/instruction.h
index 1bd1344..3ddf741 100644
--- a/source/opt/instruction.h
+++ b/source/opt/instruction.h
@@ -24,8 +24,8 @@
 #include "operand.h"
 #include "util/ilist_node.h"
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 namespace spvtools {
 namespace ir {
diff --git a/source/opt/instruction_list.h b/source/opt/instruction_list.h
index 2b7b931..182317f 100644
--- a/source/opt/instruction_list.h
+++ b/source/opt/instruction_list.h
@@ -25,8 +25,8 @@
 #include "operand.h"
 #include "util/ilist.h"
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 namespace spvtools {
 namespace ir {
@@ -104,11 +104,10 @@
 
   // Runs the given function |f| on the instructions in the list and optionally
   // on the preceding debug line instructions.
-  inline void ForEachInst(
-      const std::function<void(Instruction*)>& f,
-      bool run_on_debug_line_insts) {
+  inline void ForEachInst(const std::function<void(Instruction*)>& f,
+                          bool run_on_debug_line_insts) {
     auto next = begin();
-    for( auto i = next; i != end(); i = next ) {
+    for (auto i = next; i != end(); i = next) {
       ++next;
       i->ForEachInst(f, run_on_debug_line_insts);
     }
diff --git a/source/opt/ir_context.cpp b/source/opt/ir_context.cpp
index 9f68db7..c899591 100644
--- a/source/opt/ir_context.cpp
+++ b/source/opt/ir_context.cpp
@@ -13,9 +13,9 @@
 // limitations under the License.
 
 #include "ir_context.h"
+#include "latest_version_glsl_std_450_header.h"
 #include "log.h"
 #include "mem_pass.h"
-#include "spirv/1.0/GLSL.std.450.h"
 
 #include <cstring>
 
diff --git a/source/opt/local_single_store_elim_pass.cpp b/source/opt/local_single_store_elim_pass.cpp
index 139f53c..cb40ba0 100644
--- a/source/opt/local_single_store_elim_pass.cpp
+++ b/source/opt/local_single_store_elim_pass.cpp
@@ -18,7 +18,7 @@
 
 #include "cfa.h"
 #include "iterator.h"
-#include "spirv/1.0/GLSL.std.450.h"
+#include "latest_version_glsl_std_450_header.h"
 
 namespace spvtools {
 namespace opt {
diff --git a/source/opt/reflect.h b/source/opt/reflect.h
index ce5c331..c5fd653 100644
--- a/source/opt/reflect.h
+++ b/source/opt/reflect.h
@@ -15,7 +15,7 @@
 #ifndef LIBSPIRV_OPT_REFLECT_H_
 #define LIBSPIRV_OPT_REFLECT_H_
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 namespace spvtools {
 namespace ir {
diff --git a/source/opt/types.h b/source/opt/types.h
index b6b62c5..f1c8e3e 100644
--- a/source/opt/types.h
+++ b/source/opt/types.h
@@ -21,8 +21,8 @@
 #include <unordered_map>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 namespace spvtools {
 namespace opt {
diff --git a/source/spirv_constant.h b/source/spirv_constant.h
index c70ade1..92ccd15 100644
--- a/source/spirv_constant.h
+++ b/source/spirv_constant.h
@@ -15,8 +15,8 @@
 #ifndef LIBSPIRV_SPIRV_CONSTANT_H_
 #define LIBSPIRV_SPIRV_CONSTANT_H_
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 
 // Version number macros.
 
diff --git a/source/spirv_definition.h b/source/spirv_definition.h
index b82bda1..9e22108 100644
--- a/source/spirv_definition.h
+++ b/source/spirv_definition.h
@@ -17,7 +17,7 @@
 
 #include <cstdint>
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 #define spvIsInBitfield(value, bitfield) ((value) == ((value)&bitfield))
 
diff --git a/source/table.h b/source/table.h
index 1422db4..dc185e2 100644
--- a/source/table.h
+++ b/source/table.h
@@ -15,7 +15,7 @@
 #ifndef LIBSPIRV_TABLE_H_
 #define LIBSPIRV_TABLE_H_
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 #include "extensions.h"
 #include "message.h"
diff --git a/source/val/basic_block.h b/source/val/basic_block.h
index f42d624..c2a5bb8 100644
--- a/source/val/basic_block.h
+++ b/source/val/basic_block.h
@@ -15,7 +15,7 @@
 #ifndef LIBSPIRV_VAL_BASICBLOCK_H_
 #define LIBSPIRV_VAL_BASICBLOCK_H_
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 #include <cstdint>
 
diff --git a/source/val/decoration.h b/source/val/decoration.h
index e6e85ea..b1d894a 100644
--- a/source/val/decoration.h
+++ b/source/val/decoration.h
@@ -19,7 +19,7 @@
 #include <unordered_map>
 #include <vector>
 
-#include "spirv/1.2/spirv.h"
+#include "latest_version_spirv_header.h"
 
 namespace libspirv {
 
diff --git a/source/val/function.h b/source/val/function.h
index eb23201..f6afb71 100644
--- a/source/val/function.h
+++ b/source/val/function.h
@@ -23,8 +23,8 @@
 #include <unordered_set>
 #include <vector>
 
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "val/basic_block.h"
 #include "val/construct.h"
 
diff --git a/source/val/validation_state.h b/source/val/validation_state.h
index 6005605..986d759 100644
--- a/source/val/validation_state.h
+++ b/source/val/validation_state.h
@@ -26,8 +26,8 @@
 #include "decoration.h"
 #include "diagnostic.h"
 #include "enum_set.h"
+#include "latest_version_spirv_header.h"
 #include "spirv-tools/libspirv.h"
-#include "spirv/1.2/spirv.h"
 #include "spirv_definition.h"
 #include "val/function.h"
 #include "val/instruction.h"