mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 07:22:43 +01:00
Apply clang-format universally.
* It is tough to contribute to a project that doesn't use a formatter, * It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files * Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose, Let's rip the bandaid off? Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
This commit is contained in:
parent
41bf87ec70
commit
e4f62e4608
587 changed files with 23258 additions and 23135 deletions
|
|
@ -31,29 +31,27 @@ std::optional<LinesOfCode> Pos::getCodeLines() const
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
std::optional<std::string> Pos::getSource() const
|
||||
{
|
||||
return std::visit(overloaded {
|
||||
[](const std::monostate &) -> std::optional<std::string> {
|
||||
return std::nullopt;
|
||||
},
|
||||
[](const Pos::Stdin & s) -> std::optional<std::string> {
|
||||
// Get rid of the null terminators added by the parser.
|
||||
return std::string(s.source->c_str());
|
||||
},
|
||||
[](const Pos::String & s) -> std::optional<std::string> {
|
||||
// Get rid of the null terminators added by the parser.
|
||||
return std::string(s.source->c_str());
|
||||
},
|
||||
[](const SourcePath & path) -> std::optional<std::string> {
|
||||
try {
|
||||
return path.readFile();
|
||||
} catch (Error &) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
}, origin);
|
||||
return std::visit(
|
||||
overloaded{
|
||||
[](const std::monostate &) -> std::optional<std::string> { return std::nullopt; },
|
||||
[](const Pos::Stdin & s) -> std::optional<std::string> {
|
||||
// Get rid of the null terminators added by the parser.
|
||||
return std::string(s.source->c_str());
|
||||
},
|
||||
[](const Pos::String & s) -> std::optional<std::string> {
|
||||
// Get rid of the null terminators added by the parser.
|
||||
return std::string(s.source->c_str());
|
||||
},
|
||||
[](const SourcePath & path) -> std::optional<std::string> {
|
||||
try {
|
||||
return path.readFile();
|
||||
} catch (Error &) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}},
|
||||
origin);
|
||||
}
|
||||
|
||||
std::optional<SourcePath> Pos::getSourcePath() const
|
||||
|
|
@ -66,12 +64,13 @@ std::optional<SourcePath> Pos::getSourcePath() const
|
|||
void Pos::print(std::ostream & out, bool showOrigin) const
|
||||
{
|
||||
if (showOrigin) {
|
||||
std::visit(overloaded {
|
||||
[&](const std::monostate &) { out << "«none»"; },
|
||||
[&](const Pos::Stdin &) { out << "«stdin»"; },
|
||||
[&](const Pos::String & s) { out << "«string»"; },
|
||||
[&](const SourcePath & path) { out << path; }
|
||||
}, origin);
|
||||
std::visit(
|
||||
overloaded{
|
||||
[&](const std::monostate &) { out << "«none»"; },
|
||||
[&](const Pos::Stdin &) { out << "«stdin»"; },
|
||||
[&](const Pos::String & s) { out << "«string»"; },
|
||||
[&](const SourcePath & path) { out << path; }},
|
||||
origin);
|
||||
out << ":";
|
||||
}
|
||||
out << line;
|
||||
|
|
@ -107,7 +106,8 @@ void Pos::LinesIterator::bump(bool atFirst)
|
|||
input.remove_prefix(eol);
|
||||
}
|
||||
|
||||
std::optional<std::string> Pos::getSnippetUpTo(const Pos & end) const {
|
||||
std::optional<std::string> Pos::getSnippetUpTo(const Pos & end) const
|
||||
{
|
||||
assert(this->origin == end.origin);
|
||||
|
||||
if (end.line < this->line)
|
||||
|
|
@ -152,5 +152,4 @@ std::optional<std::string> Pos::getSnippetUpTo(const Pos & end) const {
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue