[Modularize] Make Location::operator bool explicit
This unbreaks C++20 buildbot that was broken since402baea0a9. With implicit conversion in C++20 compilation mode the spaceship will unintentionally be based on `operator bool`: ```cpp auto foo(Location L, Location R) { return L <=> R; // Equivalent to the following line due to implicit conversions. // return L.operator bool() <=> R.operator bool(); } ``` The spaceship operator is rarely used explicitly, but its implicit uses in the STL may cause surprising results, as exposed by the use of `std::tie` in402baea0a9, which ended up changing the comparisons results unintentionally.
This commit is contained in:
@@ -395,7 +395,7 @@ struct Location {
|
||||
Column = SM.getColumnNumber(Decomposed.first, Decomposed.second);
|
||||
}
|
||||
|
||||
operator bool() const { return File != nullptr; }
|
||||
explicit operator bool() const { return File != nullptr; }
|
||||
|
||||
friend bool operator==(const Location &X, const Location &Y) {
|
||||
return X.File == Y.File && X.Line == Y.Line && X.Column == Y.Column;
|
||||
|
||||
Reference in New Issue
Block a user