layers: Emit safe_*::ptr() members to eliminate some cast noise

These casts were annoying noise, and uncheckable. Move them into the
generator where we know the one type that makes sense.

Drop spurious reinterpret_cast of stage create info to itself -- it's
all raw types once the root pCreateInfo is unwrapped.

Signed-off-by: Chris Forbes <chrisforbes@google.com>
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 8d4a387..b5b911f 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -2501,7 +2501,7 @@
 // Validate that the shaders used by the given pipeline and store the active_slots
 //  that are actually used by the pipeline into pPipeline->active_slots
 static bool validate_and_capture_pipeline_shader_state(layer_data *my_data, PIPELINE_NODE *pPipeline) {
-    auto pCreateInfo = reinterpret_cast<VkGraphicsPipelineCreateInfo const *>(&pPipeline->graphicsPipelineCI);
+    auto pCreateInfo = pPipeline->graphicsPipelineCI.ptr();
     int vertex_stage = get_shader_stage_id(VK_SHADER_STAGE_VERTEX_BIT);
     int fragment_stage = get_shader_stage_id(VK_SHADER_STAGE_FRAGMENT_BIT);
 
@@ -2515,8 +2515,7 @@
     auto pipelineLayout = pCreateInfo->layout != VK_NULL_HANDLE ? &my_data->pipelineLayoutMap[pCreateInfo->layout] : nullptr;
 
     for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
-        VkPipelineShaderStageCreateInfo const *pStage =
-            reinterpret_cast<VkPipelineShaderStageCreateInfo const *>(&pCreateInfo->pStages[i]);
+        auto pStage = &pCreateInfo->pStages[i];
         auto stage_id = get_shader_stage_id(pStage->stage);
         pass &= validate_pipeline_shader_stage(my_data, pStage, pPipeline, pipelineLayout,
                                                &shaders[stage_id], &entrypoints[stage_id]);
@@ -2562,7 +2561,7 @@
 }
 
 static bool validate_compute_pipeline(layer_data *my_data, PIPELINE_NODE *pPipeline) {
-    auto pCreateInfo = reinterpret_cast<VkComputePipelineCreateInfo const *>(&pPipeline->computePipelineCI);
+    auto pCreateInfo = pPipeline->computePipelineCI.ptr();
 
     auto pipelineLayout = pCreateInfo->layout != VK_NULL_HANDLE ? &my_data->pipelineLayoutMap[pCreateInfo->layout] : nullptr;
 
diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h
index 05e2893..ecc6601 100644
--- a/layers/descriptor_sets.h
+++ b/layers/descriptor_sets.h
@@ -163,12 +163,12 @@
 VkDescriptorSetLayoutBinding const *DescriptorSetLayout::GetDescriptorSetLayoutBindingPtrFromBinding(const uint32_t binding) {
     if (!binding_to_index_map_.count(binding))
         return nullptr;
-    return reinterpret_cast<VkDescriptorSetLayoutBinding const *>(bindings_[binding_to_index_map_[binding]]);
+    return bindings_[binding_to_index_map_[binding]]->ptr();
 }
 VkDescriptorSetLayoutBinding const *DescriptorSetLayout::GetDescriptorSetLayoutBindingPtrFromIndex(const uint32_t index) {
     if (index >= bindings_.size())
         return nullptr;
-    return reinterpret_cast<VkDescriptorSetLayoutBinding const *>(bindings_[index]);
+    return bindings_[index]->ptr();
 }
 // Return descriptorCount for given binding, 0 if index is unavailable
 uint32_t DescriptorSetLayout::GetDescriptorCountFromBinding(const uint32_t binding) {
@@ -271,4 +271,4 @@
     }
     return true;
 }
-#endif // CORE_VALIDATION_DESCRIPTOR_SETS_H_
\ No newline at end of file
+#endif // CORE_VALIDATION_DESCRIPTOR_SETS_H_
diff --git a/vk_helper.py b/vk_helper.py
index c9ee9cd..a4e7948 100755
--- a/vk_helper.py
+++ b/vk_helper.py
@@ -1602,6 +1602,8 @@
             ss_decls.append("    %s();" % (ss_name))
             ss_decls.append("    ~%s();" % (ss_name))
             ss_decls.append("    void initialize(const %s* pInStruct);" % (s))
+            ss_decls.append("    %s *ptr() { return reinterpret_cast<%s *>(this); }" % (s, s))
+            ss_decls.append("    %s const *ptr() const { return reinterpret_cast<%s const *>(this); }" % (s, s))
             ss_decls.append("};")
             if s in ifdef_dict:
                 ss_decls.append('#endif')