Skip to content

Commit

Permalink
Update format to clang-format 12 (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort authored Aug 18, 2021
1 parent 63ca034 commit 0edcc57
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 32 deletions.
23 changes: 21 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ IndentWidth: 4
ColumnLimit: 120
PointerAlignment: Left

BreakBeforeBraces: Allman

AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
Expand All @@ -34,6 +32,27 @@ SpaceBeforeCpp11BracedList: false
DeriveLineEnding: false
UseCRLF: false

BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^(<vcpkg/base/system_headers\.h>|"pch\.h")$'
Expand Down
4 changes: 2 additions & 2 deletions include/vcpkg/base/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace vcpkg
{
#if defined(_WIN32)
return ::_fseeki64(m_fs, static_cast<long long>(offset), origin);
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
Checks::check_exit(VCPKG_LINE_INFO, offset < LLONG_MAX);
return ::fseek(m_fs, offset, origin);
#endif // ^^^ !_WIN32
Expand All @@ -163,7 +163,7 @@ namespace vcpkg
{
#if defined(_WIN32)
return ::_fseeki64(m_fs, offset, origin);
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
return ::fseek(m_fs, offset, origin);
#endif // ^^^ !_WIN32
}
Expand Down
2 changes: 1 addition & 1 deletion src/tls12-download.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static void set_delete_on_close_flag(const HANDLE std_out, const HANDLE target,

#ifndef NDEBUG
int main()
#else // ^^^ debug // !debug vvv
#else // ^^^ debug // !debug vvv
int __stdcall entry()
#endif // ^^^ !debug
{
Expand Down
14 changes: 7 additions & 7 deletions src/vcpkg-test/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ TEST_CASE ("vcpkg Path generic", "[filesystem][files]")
Path bp("some\\path\\/\\/with\\backslashes");
#if defined(_WIN32)
CHECK(bp.generic_u8string() == StringView("some/path////with/backslashes"));
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
CHECK(bp.generic_u8string() == StringView("some\\path\\/\\/with\\backslashes"));
#endif // _WIN32
}
Expand Down Expand Up @@ -227,7 +227,7 @@ TEST_CASE ("vcpkg Path::operator/", "[filesystem][files]")
test_op_slash("C:/a/b", "D:/c/d", "D:/c/d");
test_op_slash("C:/a/b", "D:c/d", "D:c/d");
test_op_slash("C:/a/b", "C:c/d", "C:/a/b\\c/d");
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
test_op_slash("C:/a/b", "c/d", "C:/a/b/c/d");
test_op_slash("C:a/b", "c/d", "C:a/b/c/d");
test_op_slash("C:a/b", "/c/d", "/c/d");
Expand Down Expand Up @@ -283,7 +283,7 @@ TEST_CASE ("vcpkg Path::preferred and Path::make_preferred", "[filesystem][files
#if defined(_WIN32)
test_preferred(R"(\\server/share\a/b)", R"(\\server\share\a\b)");
test_preferred(R"(//server/share\a/b)", R"(\\server\share\a\b)");
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
test_preferred(R"(//server/share\a/b)", R"(/server/share\a/b)");
test_preferred(R"(//server/share\a/b)", R"(/server/share\a/b)");
#endif // ^^^ !_WIN32
Expand Down Expand Up @@ -419,7 +419,7 @@ TEST_CASE ("Path::make_parent_path and Path::parent_path", "[filesystem][files]"
test_parent_path(R"(\\server\a)", R"(\\server\)");
test_parent_path(R"(\\server\a\)", R"(\\server\a)");
test_parent_path(R"(\\server\a\b)", R"(\\server\a)");
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
test_parent_path("C:/", "C:");
test_parent_path("C:/a", "C:");
test_parent_path("C:/a/", "C:/a");
Expand Down Expand Up @@ -470,15 +470,15 @@ TEST_CASE ("Path decomposition", "[filesystem][files]")
bool single_slash_is_absolute =
#if defined(_WIN32)
false
#else // ^^^ _WIN32 // !_WIN32 vvv
#else // ^^^ _WIN32 // !_WIN32 vvv
true
#endif // ^^^ !_WIN32
;

bool drive_is_absolute =
#if defined(_WIN32)
true
#else // ^^^ _WIN32 // !_WIN32 vvv
#else // ^^^ _WIN32 // !_WIN32 vvv
false
#endif // ^^^ !_WIN32
;
Expand All @@ -488,7 +488,7 @@ TEST_CASE ("Path decomposition", "[filesystem][files]")
#if defined(_WIN32)
test_path_decomposition("C:a", false, "a", "");
test_path_decomposition("C:a.ext", false, "a", ".ext");
#else // ^^^ _WIN32 // !_WIN32 vvv
#else // ^^^ _WIN32 // !_WIN32 vvv
test_path_decomposition("C:a", false, "C:a", "");
test_path_decomposition("C:a.ext", false, "C:a", ".ext");
#endif // ^^^ !_WIN32
Expand Down
36 changes: 18 additions & 18 deletions src/vcpkg/base/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace
{
#if defined(_WIN32)
return stdfs::path(Strings::to_utf16(utfpath.native()));
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
return stdfs::path(utfpath.native());
#endif // ^^^ !_WIN32
}
Expand All @@ -135,7 +135,7 @@ namespace
{
#if defined(_WIN32)
return Strings::to_utf8(stdpath.native());
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
return stdpath.native();
#endif // ^^^ !_WIN32
}
Expand Down Expand Up @@ -230,7 +230,7 @@ namespace

// no match
return first;
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
(void)last;
return first;
#endif // _WIN32
Expand Down Expand Up @@ -338,7 +338,7 @@ namespace
#if defined(_WIN32)
const auto ads = std::find(filename, last, ':'); // strip alternate data streams in intra-filename decomposition
const auto extension = find_extension(filename, ads);
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
const auto extension = find_extension(filename, last);
#endif // _WIN32
return StringView(filename, static_cast<size_t>(extension - filename));
Expand All @@ -354,7 +354,7 @@ namespace
const auto ads = std::find(filename, last, ':'); // strip alternate data streams in intra-filename decomposition
const auto extension = find_extension(filename, ads);
return StringView(extension, static_cast<size_t>(ads - extension));
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
const auto extension = find_extension(filename, last);
return StringView(extension, static_cast<size_t>(last - extension));
#endif // _WIN32
Expand All @@ -377,7 +377,7 @@ namespace
// if root-name is otherwise nonempty, then it must be one of the always-absolute prefixes like
// \\?\ or \\server, so the path is absolute. Otherwise it is relative.
return first != find_root_name_end(first, last);
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
return !str.empty() && str.byte_at_index(0) == '/';
#endif // ^^^ !_WIN32
}
Expand Down Expand Up @@ -431,7 +431,7 @@ namespace
{
ec.assign(GetLastError(), std::system_category());
}
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
struct stat s;
if (lstat(target.c_str(), &s))
{
Expand Down Expand Up @@ -485,7 +485,7 @@ namespace
{
ec.assign(GetLastError(), std::system_category());
}
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
if (rmdir(current_entry.path().c_str()))
{
ec.assign(errno, std::system_category());
Expand All @@ -498,7 +498,7 @@ namespace
stdfs::remove(current_entry.path(), ec);
if (err.check_ec(ec, current_entry)) return;
}
#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv
#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv
else
{
if (unlink(current_entry.path().c_str()))
Expand Down Expand Up @@ -698,8 +698,8 @@ namespace vcpkg
m_str.push_back(preferred_separator);
}
}
#else // ^^^ _WIN32 / !_WIN32 vvv
// (!has_root_directory && is_absolute) can't happen on POSIX, so this just becomes has_filename
#else // ^^^ _WIN32 / !_WIN32 vvv
// (!has_root_directory && is_absolute) can't happen on POSIX, so this just becomes has_filename
const auto my_relative_first = std::find_if_not(my_root_name_end, my_last, is_slash);
if (my_relative_first != my_last && !is_slash(my_last[-1]))
{
Expand Down Expand Up @@ -944,7 +944,7 @@ namespace vcpkg
{
#if defined(_WIN32)
ec.assign(::_wfopen_s(&m_fs, to_stdfs_path(file_path).c_str(), L"rb"), std::generic_category());
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
m_fs = ::fopen(file_path.c_str(), "rb");
if (m_fs)
{
Expand All @@ -961,7 +961,7 @@ namespace vcpkg
{
#if defined(_WIN32)
ec.assign(::_wfopen_s(&m_fs, to_stdfs_path(file_path).c_str(), L"wb"), std::generic_category());
#else // ^^^ _WIN32 / !_WIN32 vvv
#else // ^^^ _WIN32 / !_WIN32 vvv
m_fs = ::fopen(file_path.c_str(), "wb");
if (m_fs)
{
Expand Down Expand Up @@ -1590,7 +1590,7 @@ namespace vcpkg
{
#if VCPKG_USE_STD_FILESYSTEM
if (b->is_directory(ec))
#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv
#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv
if (stdfs::is_directory(b->path(), ec))
#endif // VCPKG_USE_STD_FILESYSTEM
{
Expand Down Expand Up @@ -1636,7 +1636,7 @@ namespace vcpkg
{
#if VCPKG_USE_STD_FILESYSTEM
if (b->is_regular_file(ec))
#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv
#else // ^^^ VCPKG_USE_STD_FILESYSTEM // !VCPKG_USE_STD_FILESYSTEM vvv
if (stdfs::is_regular_file(b->path(), ec))
#endif // VCPKG_USE_STD_FILESYSTEM
{
Expand Down Expand Up @@ -1722,7 +1722,7 @@ namespace vcpkg
auto written_bytes = sendfile(o_fd, i_fd, &bytes, info.st_size);
#elif defined(__APPLE__)
auto written_bytes = fcopyfile(i_fd, o_fd, 0, COPYFILE_ALL);
#else // ^^^ defined(__APPLE__) // !(defined(__APPLE__) || defined(__linux__)) vvv
#else // ^^^ defined(__APPLE__) // !(defined(__APPLE__) || defined(__linux__)) vvv
ssize_t written_bytes = 0;
{
constexpr std::size_t buffer_length = 4096;
Expand Down Expand Up @@ -1941,7 +1941,7 @@ namespace vcpkg
{
#if VCPKG_USE_STD_FILESYSTEM
return from_stdfs_path(stdfs::absolute(to_stdfs_path(target), ec));
#else // ^^^ VCPKG_USE_STD_FILESYSTEM / !VCPKG_USE_STD_FILESYSTEM vvv
#else // ^^^ VCPKG_USE_STD_FILESYSTEM / !VCPKG_USE_STD_FILESYSTEM vvv
if (target.is_absolute())
{
return target;
Expand Down Expand Up @@ -2119,7 +2119,7 @@ namespace vcpkg
{
#if defined(_WIN32)
static constexpr StringLiteral EXTS[] = {".cmd", ".exe", ".bat"};
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
static constexpr StringLiteral EXTS[] = {""};
#endif // ^^^!defined(_WIN32)
const Path pname = name;
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/commands.integrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
table.format("vcpkg integrate remove", "Remove user-wide integration");
table.format("vcpkg integrate project", "Generate a referencing nuget package for individual VS project use");
table.format("vcpkg integrate powershell", "Enable PowerShell tab-completion");
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
#else // ^^^ defined(_WIN32) // !defined(_WIN32) vvv
table.format("vcpkg integrate install", "Make installed packages available user-wide");
table.format("vcpkg integrate remove", "Remove user-wide integration");
table.format("vcpkg integrate bash", "Enable bash tab-completion");
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ namespace vcpkg
if (request) WinHttpCloseHandle(request);
if (connect) WinHttpCloseHandle(connect);
if (session) WinHttpCloseHandle(session);
#else // ^^^ _WIN32 // !_WIN32 vvv
#else // ^^^ _WIN32 // !_WIN32 vvv
(void)payload;
#endif // ^^^ !_WIN32
}
Expand Down

0 comments on commit 0edcc57

Please sign in to comment.