-
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
Implement <source_location> #664
Conversation
Microsoft-internal VSO-778944 tracks |
Hi,
|
Note: I'm not arguing one way or the other for what the column numbers are supposed to be, just explaining my reasons for my expectations. |
Removing the |
Should I remove the test from the |
For a test that works for some compilers but not others, I think the current best way is to For tab characters, we have the ability to exempt files from the "no tabs anywhere" validation (see |
Had to change the header file name test as clang expects
while MSVC would expect
if I'm not mistaken. Or would it be prefered to do an |
I think what you did is fine for now, but I'd recommend filing a bug against Clang, reporting their behavior divergence from MSVC (I think they're the "strange" ones since they're not consistently using Windows' preferred separators in the path). |
Not being all |
* Add top-level const. * Avoid _UglyCamels for function parameters. * Use _NODISCARD_CTOR for the constructor. * Add empty lines to separate non-repetitive code.
Unless clang plans on changing their column number, shouldn't there be |
We'll need to add ifdefs for Clang and EDG when we can activate them. |
Actually, since Clang is going to be self activating would it not make sense to pre-emptively have a function like this to compare against instead? constexpr int get_c(int n)
{
#ifdef __clang__
return n - 17;
#elif defined(__EDG__)
return n + 8;
#else
return n;
#endif
} That way its less work for the PR that updates Clang to a version that defines |
I would prefer to defer any work for Clang until the toolset update that activates Clang - because I want to land this very soon, to meet the 16.10 Preview 2 deadline, and I just finished validating this against the internal and public builds, so resetting testing would add additional headache and risk. Your suggested function sounds like a great idea and I'll try to remember it (since I expect to perform that toolset update). Note that Of the changes that I recently pushed, the notable ones are:
I've mirrored this to internal MSVC-PR-307468 along with the necessary "hack these files" changes to add Please note: Further changes are still possible (e.g. if you notice something, or if final review leads to more feedback that should be addressed before merging), but they must be replicated to the mirror PR in order to avoid codebase divergence. |
Thanks for the super detailed answer as always, Stephan. |
All changes requested in Apr 2020 have been made or resolved
Thanks for implementing this feature far in advance of the compilers being ready! 😹 This will be available in VS 2019 16.10 Preview 2 along with MSVC's support for |
stl/inc/source_location
Outdated
uint_least32_t _InColumn = __builtin_COLUMN(), const char* _InFile = __builtin_FILE(), | ||
const char* _InFunction = __builtin_FUNCTION()) noexcept { | ||
source_location _Result; | ||
_Result._Line = _InLine; | ||
_Result._Column = _InColumn; | ||
_Result._File = _InFile; | ||
_Result._Function = _InFunction; | ||
return _Result; |
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.
@StephanTLavavej [INDENTATION STYLE RANT] Theres some ugly indentation here. I will suggest a lecture by Kevlin Henney: ITT 2016 - Kevlin Henney - Seven Ineffective Coding Habits of Many Programmers https://www.youtube.com/watch?t=1263&v=ZsHMHukIlJY [/INDENTATION STYLE RANT]
The below formatting, I believe I get by using clang-format parameters (https://clang.llvm.org/docs/ClangFormatStyleOptions.html):
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
BinPackArguments: false
BinPackParameters: false
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveDeclarations: AcrossComments
ConstructorInitializerIndentWidth: 6
ContinuationIndentWidth: 6
static constexpr source_location current(uint_least32_t _InLine = __builtin_LINE(),
uint_least32_t _InColumn = __builtin_COLUMN(),
const char* _InFile = __builtin_FILE(),
const char* _InFunction = __builtin_FUNCTION()) noexcept
{
source_location _Result;
_Result._Line = _InLine;
_Result._Column = _InColumn;
_Result._File = _InFile;
_Result._Function = _InFunction;
return _Result;
}
As style is a contentious issue, please feel free to ignore this rant.
Description
This PR is blocked until issues with the compiler builtins are solved (as well as
consteval
?)So after now being able to run the tests there's some more potential oddities I found. Thought may as well open a draft PR as it might be helpful for compiler devs.
So following what I found in #54.
current()
is used as a default argument (i.e. 1stargument
test,sloc
, andlambda
pass)Issues to resolve
consteval
source_location::current()
constexpr
__builtin_FILE()
and__builtin_FUNCTION()
lambda_test()
)sub_member_test()
NTTP testI'm unsure how to test the tab column issue as that would mean this file fails validation, right? Thought maybe put it in a different file with a file extension that could be skipped e.g.
test.tab
?Is using
ends_with
sufficient for the file name tests?Checklist
Be sure you've read README.md and understand the scope of this repo.
If you're unsure about a box, leave it unchecked. A maintainer will help you.
_Ugly
as perhttps://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
verified by an STL maintainer before automated testing is enabled on GitHub,
leave this unchecked for initial submission).
members, adding virtual functions, changing whether a type is an aggregate
or trivially copyable, etc.).
the C++ Working Draft (including any cited standards), other WG21 papers
(excluding reference implementations outside of proposed standard wording),
and LWG issues as reference material. If they were derived from a project
that's already listed in NOTICE.txt, that's fine, but please mention it.
If they were derived from any other project (including Boost and libc++,
which are not yet listed in NOTICE.txt), you must mention it here,
so we can determine whether the license is compatible and what else needs
to be done.