Split tests files into noexcept and throw().
This is preparation for a C++20 support in this check.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp | ||
---|---|---|
267 | I run into this often as well. If you don't want to get push back during review because of this I advice you to disable the automatic trailing whitespace removal for this project. Regular source code will be fixed via clang-format anyway. Alternatively you will be asked to fix it in (another) NFC patch :) I personally don't mind a couple or two such fixes, but here there's a lot of them and really create noise, distracting from the actual patch. | |
555–558 | Why this change? |
Formating fixes
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp | ||
---|---|---|
5 | it is align, comment is for function, not for throw. |
Do we really want to split these two functions apart to different test files? Is this really NFC?
The way ExceptionEscapeCheck works is that it creates an ExceptionAnalyzer upon instantiation.
By the way upon looking at the constructor of the check I see that std::bad_alloc is always ignored.
Maybe we want to turn this into an option, so that users can enable it if they want.
ExceptionAnalyzer caches functions based on their FunctionDecl * in
std::map<const FunctionDecl *, ExceptionInfo> FunctionCache;.
The FunctionDecl lives in the AST of the translation unit, so the same function declaration in two
different translation units will have different FunctionDecl *s. Maybe ODRHash would be more
suitable to be used as key in the map.
By moving throwing functions into a different TU than non-throwing functions, I think the correctness
of the caching inside ExceptionAnalyzer no longer will be tested properly. Maybe this is something
we want to preserve.
Yes, throw specifier is removed in C++17, split allows to support C++17 and above in main test file
And ? This has nothing to do with test split.
Not a scope of this change, please raise an issue on github if you want such feature, or implement it your self. I personally don't see an use-case for it.
ExceptionAnalyzer caches functions based on their FunctionDecl * in
std::map<const FunctionDecl *, ExceptionInfo> FunctionCache;.The FunctionDecl lives in the AST of the translation unit, so the same function declaration in two
different translation units will have different FunctionDecl *s. Maybe ODRHash would be more
suitable to be used as key in the map.By moving throwing functions into a different TU than non-throwing functions, I think the correctness
of the caching inside ExceptionAnalyzer no longer will be tested properly. Maybe this is something
we want to preserve.
Those tests never tested caching (not failing if you disable cache), and here cache will be executed on things
like recursion_helper anyway. I see no issue here.
Yes, throw specifier is removed in C++17, split allows to support C++17 and above in main test file
A lot of our test files uses macros to differentiate between specific C++ standards, why not do that here too?
There are only a few occurences of functions with throw().
#if __cplusplus < 201703L // put functions with throw() here #endif
Those tests never tested caching (not failing if you disable cache)
They weren't tested explicitly, but it still happened in the background by default.
@isuckatcs
Ifdefs are ugly, to avoid messing with multiple runs in same unit test, I decided to split into 2 test files (C++11 and above, and C++11,C++14).
And to be honest this change does nothing for caching (zero impact), let me explain:
super_throws_again alone won't be tested, because its not noexcept, it will be tested only once (no cache hit) when testing sub_throws_again.
Same goes for throwing_throw_nothing, its not called from anywhere, so there will be no hit into cache.
Simply code that were moved into new file didn't utilize cache before and now.
LGTM!
A lot of our test files uses macros to differentiate between specific C++ standards, why not do that here too?
It's not that easy, because the #ifdef lines do not remove the // CHECK comments, so to work around that it gets messy very easily. Splitting into 2 files seems to be common practice in other tests for easier maintenance and readability.
Please align comments