-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically format with clang-tools #6721
Changes from all commits
421bddd
8c76aa7
c641eaf
a6bb0f9
f494644
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
BasedOnStyle: LLVM | ||
IndentWidth: 4 | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterStruct: true | ||
AfterClass: true | ||
AfterFunction: true | ||
AfterUnion: true | ||
SplitEmptyRecord: false | ||
PointerAlignment: Middle | ||
FixNamespaceComments: false | ||
SortIncludes: Never | ||
#IndentPPDirectives: BeforeHash | ||
SpaceAfterCStyleCast: true | ||
SpaceAfterTemplateKeyword: false | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: AlwaysBreak | ||
AlignEscapedNewlines: DontAlign | ||
ColumnLimit: 120 | ||
BreakStringLiterals: false | ||
BitFieldColonSpacing: None | ||
AllowShortFunctionsOnASingleLine: Empty | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackParameters: false | ||
BreakConstructorInitializers: BeforeComma | ||
EmptyLineAfterAccessModifier: Leave # change to always/never later? | ||
EmptyLineBeforeAccessModifier: Leave | ||
#PackConstructorInitializers: BinPack | ||
BreakBeforeBinaryOperators: NonAssignment | ||
AlwaysBreakBeforeMultilineStrings: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Fill in. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
find . -type f -name '*.cc' -o -name '*.hh' | xargs --max-args=8 --max-procs "$(nproc)" clang-format -i |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
#include <nlohmann/json.hpp> | ||
|
||
extern char * * environ __attribute__((weak)); | ||
extern char ** environ __attribute__((weak)); | ||
|
||
namespace nix { | ||
|
||
|
@@ -20,7 +20,8 @@ nix::Commands RegisterCommand::getCommandsFor(const std::vector<std::string> & p | |
if (name.size() == prefix.size() + 1) { | ||
bool equal = true; | ||
for (size_t i = 0; i < prefix.size(); ++i) | ||
if (name[i] != prefix[i]) equal = false; | ||
if (name[i] != prefix[i]) | ||
equal = false; | ||
if (equal) | ||
res.insert_or_assign(name[prefix.size()], command); | ||
} | ||
|
@@ -33,9 +34,7 @@ nlohmann::json NixMultiCommand::toJSON() | |
return MultiCommand::toJSON(); | ||
} | ||
|
||
StoreCommand::StoreCommand() | ||
{ | ||
} | ||
StoreCommand::StoreCommand() {} | ||
|
||
ref<Store> StoreCommand::getStore() | ||
{ | ||
|
@@ -110,17 +109,15 @@ ref<EvalState> EvalCommand::getEvalState() | |
{ | ||
if (!evalState) { | ||
evalState = | ||
#if HAVE_BOEHMGC | ||
std::allocate_shared<EvalState>(traceable_allocator<EvalState>(), | ||
searchPath, getEvalStore(), getStore()) | ||
#else | ||
std::make_shared<EvalState>( | ||
searchPath, getEvalStore(), getStore()) | ||
#endif | ||
#if HAVE_BOEHMGC | ||
std::allocate_shared<EvalState>(traceable_allocator<EvalState>(), searchPath, getEvalStore(), getStore()) | ||
#else | ||
std::make_shared<EvalState>(searchPath, getEvalStore(), getStore()) | ||
#endif | ||
; | ||
|
||
if (startReplOnEvalErrors) { | ||
evalState->debugRepl = &runRepl; | ||
evalState->debugRepl = &runRepl; | ||
}; | ||
} | ||
return ref<EvalState>(evalState); | ||
|
@@ -183,8 +180,7 @@ void BuiltPathsCommand::run(ref<Store> store) | |
|
||
StorePathsCommand::StorePathsCommand(bool recursive) | ||
: BuiltPathsCommand(recursive) | ||
{ | ||
} | ||
{} | ||
|
||
void StorePathsCommand::run(ref<Store> store, BuiltPaths && paths) | ||
{ | ||
|
@@ -211,60 +207,58 @@ Strings editorFor(const Path & file, uint32_t line) | |
{ | ||
auto editor = getEnv("EDITOR").value_or("cat"); | ||
auto args = tokenizeString<Strings>(editor); | ||
if (line > 0 && ( | ||
editor.find("emacs") != std::string::npos || | ||
editor.find("nano") != std::string::npos || | ||
editor.find("vim") != std::string::npos || | ||
editor.find("kak") != std::string::npos)) | ||
if (line > 0 | ||
&& (editor.find("emacs") != std::string::npos || editor.find("nano") != std::string::npos | ||
|| editor.find("vim") != std::string::npos || editor.find("kak") != std::string::npos)) | ||
args.push_back(fmt("+%d", line)); | ||
args.push_back(file); | ||
return args; | ||
} | ||
|
||
MixProfile::MixProfile() | ||
{ | ||
addFlag({ | ||
.longName = "profile", | ||
.description = "The profile to update.", | ||
.labels = {"path"}, | ||
.handler = {&profile}, | ||
.completer = completePath | ||
}); | ||
addFlag( | ||
{.longName = "profile", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change to the formatting of designated initializers causes a huge diff, but I don't see a way to keep the old style... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could use |
||
.description = "The profile to update.", | ||
.labels = {"path"}, | ||
.handler = {&profile}, | ||
.completer = completePath}); | ||
} | ||
|
||
void MixProfile::updateProfile(const StorePath & storePath) | ||
{ | ||
if (!profile) return; | ||
if (!profile) | ||
return; | ||
auto store = getStore().dynamic_pointer_cast<LocalFSStore>(); | ||
if (!store) throw Error("'--profile' is not supported for this Nix store"); | ||
if (!store) | ||
throw Error("'--profile' is not supported for this Nix store"); | ||
auto profile2 = absPath(*profile); | ||
switchLink(profile2, | ||
createGeneration( | ||
ref<LocalFSStore>(store), | ||
profile2, storePath)); | ||
switchLink(profile2, createGeneration(ref<LocalFSStore>(store), profile2, storePath)); | ||
} | ||
|
||
void MixProfile::updateProfile(const BuiltPaths & buildables) | ||
{ | ||
if (!profile) return; | ||
if (!profile) | ||
return; | ||
|
||
std::vector<StorePath> result; | ||
|
||
for (auto & buildable : buildables) { | ||
std::visit(overloaded { | ||
[&](const BuiltPath::Opaque & bo) { | ||
result.push_back(bo.path); | ||
std::visit( | ||
overloaded{ | ||
[&](const BuiltPath::Opaque & bo) { result.push_back(bo.path); }, | ||
[&](const BuiltPath::Built & bfd) { | ||
for (auto & output : bfd.outputs) { | ||
result.push_back(output.second); | ||
} | ||
}, | ||
}, | ||
[&](const BuiltPath::Built & bfd) { | ||
for (auto & output : bfd.outputs) { | ||
result.push_back(output.second); | ||
} | ||
}, | ||
}, buildable.raw()); | ||
buildable.raw()); | ||
} | ||
|
||
if (result.size() != 1) | ||
throw UsageError("'--profile' requires that the arguments produce a single store path, but there are %d", result.size()); | ||
throw UsageError( | ||
"'--profile' requires that the arguments produce a single store path, but there are %d", result.size()); | ||
|
||
updateProfile(result[0]); | ||
} | ||
|
@@ -274,7 +268,8 @@ MixDefaultProfile::MixDefaultProfile() | |
profile = getDefaultProfile(); | ||
} | ||
|
||
MixEnvironment::MixEnvironment() : ignoreEnvironment(false) | ||
MixEnvironment::MixEnvironment() | ||
: ignoreEnvironment(false) | ||
{ | ||
addFlag({ | ||
.longName = "ignore-environment", | ||
|
@@ -300,14 +295,16 @@ MixEnvironment::MixEnvironment() : ignoreEnvironment(false) | |
}); | ||
} | ||
|
||
void MixEnvironment::setEnviron() { | ||
void MixEnvironment::setEnviron() | ||
{ | ||
if (ignoreEnvironment) { | ||
if (!unset.empty()) | ||
throw UsageError("--unset does not make sense with --ignore-environment"); | ||
|
||
for (const auto & var : keep) { | ||
auto val = getenv(var.c_str()); | ||
if (val) stringsEnv.emplace_back(fmt("%s=%s", var.c_str(), val)); | ||
if (val) | ||
stringsEnv.emplace_back(fmt("%s=%s", var.c_str(), val)); | ||
} | ||
|
||
vectorEnv = stringsToCharPtrs(stringsEnv); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might help reduce the diff some, but the nixpkgs pinned in the flake has clang-format 13 and this option is introduced in 14.