Make clang-format-all.sh git aware

clang-format-all.sh will modify every file in the repository that isn't properly formatted. However, if you only care about the formatting of the files touched in a CL, this is over-zealous. So the default behavior is to only modify a file list derived from git's current set of files. You can still use the script to format the entire repo with -a or --all. clang-format has been run on all files in the repository to bring them up-to-date with the latest format. Bug: b/187094215 Change-Id: I2753c83e00d36817eddb0d8e641100240a2e8e23 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/54048Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Commit-Queue: Sean Risser <srisser@google.com> Tested-by: 's avatarSean Risser <srisser@google.com>
parent 37cb6a5d
...@@ -717,7 +717,7 @@ void SpirvShader::Fence(spv::MemorySemanticsMask semantics) const ...@@ -717,7 +717,7 @@ void SpirvShader::Fence(spv::MemorySemanticsMask semantics) const
{ {
if(semantics == spv::MemorySemanticsMaskNone) if(semantics == spv::MemorySemanticsMaskNone)
{ {
return; //no-op return; // no-op
} }
rr::Fence(MemoryOrder(semantics)); rr::Fence(MemoryOrder(semantics));
} }
......
...@@ -93,7 +93,7 @@ private: ...@@ -93,7 +93,7 @@ private:
LRUCache &operator=(const LRUCache &) = delete; LRUCache &operator=(const LRUCache &) = delete;
LRUCache &operator=(LRUCache &&) = delete; LRUCache &operator=(LRUCache &&) = delete;
//Keyed holds a key. See find() for more information. // Keyed holds a key. See find() for more information.
struct Keyed struct Keyed
{ {
Key key = {}; Key key = {};
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
} }
VkSemaphoreType getSemaphoreType() const; VkSemaphoreType getSemaphoreType() const;
//static size_t ComputeRequiredAllocationSize(const VkSemaphoreCreateInfo *pCreateInfo); // static size_t ComputeRequiredAllocationSize(const VkSemaphoreCreateInfo *pCreateInfo);
protected: protected:
VkSemaphoreType type; VkSemaphoreType type;
......
...@@ -365,7 +365,7 @@ static const ExtensionProperties deviceExtensionProperties[] = { ...@@ -365,7 +365,7 @@ static const ExtensionProperties deviceExtensionProperties[] = {
{ { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION } }, { { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION } },
{ { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION } }, { { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION } },
{ { VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME, VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION } }, { { VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME, VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION } },
{ { VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION} }, { { VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION } },
// Only 1.1 core version of this is supported. The extension has additional requirements // Only 1.1 core version of this is supported. The extension has additional requirements
//{{ VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION }}, //{{ VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION }},
{ { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION } }, { { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION } },
......
...@@ -47,4 +47,4 @@ private: ...@@ -47,4 +47,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_DIRECTFBSURFACEEXT_HPP #endif // SWIFTSHADER_DIRECTFBSURFACEEXT_HPP
...@@ -60,4 +60,4 @@ private: ...@@ -60,4 +60,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_DISPLAYSURFACEKHR_HPP #endif // SWIFTSHADER_DISPLAYSURFACEKHR_HPP
...@@ -34,4 +34,4 @@ public: ...@@ -34,4 +34,4 @@ public:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_HEADLESSSURFACEKHR_HPP #endif // SWIFTSHADER_HEADLESSSURFACEKHR_HPP
...@@ -65,4 +65,4 @@ public: ...@@ -65,4 +65,4 @@ public:
#endif #endif
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_METALSURFACE_HPP #endif // SWIFTSHADER_METALSURFACE_HPP
...@@ -109,4 +109,4 @@ static inline SurfaceKHR *Cast(VkSurfaceKHR object) ...@@ -109,4 +109,4 @@ static inline SurfaceKHR *Cast(VkSurfaceKHR object)
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_VKSURFACEKHR_HPP_ #endif // SWIFTSHADER_VKSURFACEKHR_HPP_
...@@ -63,4 +63,4 @@ static inline SwapchainKHR *Cast(VkSwapchainKHR object) ...@@ -63,4 +63,4 @@ static inline SwapchainKHR *Cast(VkSwapchainKHR object)
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_VKSWAPCHAINKHR_HPP #endif // SWIFTSHADER_VKSWAPCHAINKHR_HPP
...@@ -54,4 +54,4 @@ private: ...@@ -54,4 +54,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_WAYLANDSURFACEKHR_HPP #endif // SWIFTSHADER_WAYLANDSURFACEKHR_HPP
...@@ -60,4 +60,4 @@ private: ...@@ -60,4 +60,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_WIN32SURFACEKHR_HPP #endif // SWIFTSHADER_WIN32SURFACEKHR_HPP
...@@ -49,4 +49,4 @@ private: ...@@ -49,4 +49,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_XCBSURFACEKHR_HPP #endif // SWIFTSHADER_XCBSURFACEKHR_HPP
...@@ -49,4 +49,4 @@ private: ...@@ -49,4 +49,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_XLIBSURFACEKHR_HPP #endif // SWIFTSHADER_XLIBSURFACEKHR_HPP
#! /usr/bin/env sh
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="$( cd "${SRC_DIR}/.." >/dev/null 2>&1 && pwd )" ROOT_DIR="$( cd "${SRC_DIR}/.." >/dev/null 2>&1 && pwd )"
TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )" TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )"
...@@ -5,10 +7,45 @@ TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )" ...@@ -5,10 +7,45 @@ TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )"
CLANG_FORMAT=${CLANG_FORMAT:-clang-format} CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
${CLANG_FORMAT} --version ${CLANG_FORMAT} --version
for DIR in "${SRC_DIR}/Device" "${SRC_DIR}/Pipeline" "${SRC_DIR}/Reactor" "${SRC_DIR}/System" "${SRC_DIR}/Vulkan" "${SRC_DIR}/WSI" "${TESTS_DIR}" show_help()
{
# Tells cat to stop reading file when EOF is detected
cat << EOF
Usage: ./clang-format-all.sh [-ah]
Format files in the SwiftShader repository
-h, --help Display this message and exit
-a, --all Format all files (default is to format only files active in a git CL)
EOF
# cat finishes printing
}
while [[ $# -gt 0 ]]
do do
case $1 in
-a|--all)
all=1
shift
;;
-h|--help)
show_help
exit 0
;;
esac
done
if [[ $all -eq 1 ]]
then
for DIR in "${SRC_DIR}/Device" "${SRC_DIR}/Pipeline" "${SRC_DIR}/Reactor" "${SRC_DIR}/System" "${SRC_DIR}/Vulkan" "${SRC_DIR}/WSI" "${TESTS_DIR}"
do
# Double clang-format, as it seems that one pass isn't always enough # Double clang-format, as it seems that one pass isn't always enough
find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file
find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file
done done
else
BASEDIR=$(git rev-parse --show-toplevel)
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -v '\.sh')
for FILE in $FILES
do
${CLANG_FORMAT} -i -style=file "$BASEDIR/$FILE"
done
fi
...@@ -637,7 +637,7 @@ TEST(ReactorUnitTests, StoreBeforeIndirectStore) ...@@ -637,7 +637,7 @@ TEST(ReactorUnitTests, StoreBeforeIndirectStore)
{ {
FunctionT<int(int)> function; FunctionT<int(int)> function;
{ {
//Int b = function.Arg<0>(); // Int b = function.Arg<0>();
Int b; Int b;
Pointer<Int> p = &b; Pointer<Int> p = &b;
......
...@@ -29,7 +29,7 @@ Buffer::Buffer(vk::Device device, vk::DeviceSize size, vk::BufferUsageFlags usag ...@@ -29,7 +29,7 @@ Buffer::Buffer(vk::Device device, vk::DeviceSize size, vk::BufferUsageFlags usag
vk::MemoryAllocateInfo allocInfo{}; vk::MemoryAllocateInfo allocInfo{};
allocInfo.allocationSize = memRequirements.size; allocInfo.allocationSize = memRequirements.size;
allocInfo.memoryTypeIndex = 0; //TODO: getMemoryTypeIndex(memRequirements.memoryTypeBits, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent); allocInfo.memoryTypeIndex = 0; // TODO: getMemoryTypeIndex(memRequirements.memoryTypeBits, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent);
bufferMemory = device.allocateMemory(allocInfo); bufferMemory = device.allocateMemory(allocInfo);
device.bindBufferMemory(buffer, bufferMemory, 0); device.bindBufferMemory(buffer, bufferMemory, 0);
......
...@@ -282,7 +282,7 @@ void VulkanTester::initialize() ...@@ -282,7 +282,7 @@ void VulkanTester::initialize()
return strcmp(layer, lp.layerName) == 0; return strcmp(layer, lp.layerName) == 0;
}) != layerProperties.end()) }) != layerProperties.end())
{ {
//std::cout << "Enabled layer: " << layer << std::endl; // std::cout << "Enabled layer: " << layer << std::endl;
layers.push_back(layer); layers.push_back(layer);
} }
}; };
...@@ -318,7 +318,7 @@ void VulkanTester::initialize() ...@@ -318,7 +318,7 @@ void VulkanTester::initialize()
VkDebugUtilsMessageTypeFlagsEXT messageTypes, VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) -> VkBool32 { void *pUserData) -> VkBool32 {
//assert(false); // assert(false);
std::cerr << "[DebugInfoCallback] " << pCallbackData->pMessage << std::endl; std::cerr << "[DebugInfoCallback] " << pCallbackData->pMessage << std::endl;
return VK_FALSE; return VK_FALSE;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment