I tried to run trunk Clang-tidy readability-redundant-smartptr-get for LLDB code (source/Target/Target.cpp) (as of r255174) and this check doesn't report get usage in conditions like: if (m_process_sp.get()) if (m_source_manager_ap.get() == NULL) if (rhs.m_thread_spec_ap.get() != NULL) Such cases should be handled as http://en.cppreference.com/w/cpp/memory/shared_ptr/operator_bool.
Please provide a self-contained repro (system #includes are fine).
Created attachment 15433 [details] Simple test case
The cases that are missing are: - Explicit bool conversion contexts, like 'if (ptr.get())' - Comparison with NULL. (comparison with nullptr already work).
(In reply to comment #3) > The cases that are missing are: > - Explicit bool conversion contexts, like 'if (ptr.get())' > - Comparison with NULL. (comparison with nullptr already work). I tried Clang-tidy trunk version on attached example and comaprison with nullptr are not reported.
Are you using libc++? It might be that the check is not working properly with libc++.
This seems to be related with how libc++ deals with ABI compatibility. Instead of defining types in std, it defines them in std::_LIBCPP_NAMESPACE where _LIBCPP_NAMESPACE is an inline namespace. The clang-tidy checks are specifically matching against "::std::xxx" and that is failing because the names are actually "::std::_LIBCPP_NAMESPACE::xxx". We could try to fix hasName() to understand inline namespaces, or we could fix the checks to match the name differently.
(In reply to comment #5) > Are you using libc++? > It might be that the check is not working properly with libc++. Yes, I used libc++. Just in case complete compile command line parameters: -Weverything -std=c++11 -m64 -stdlib=libc++ -lc++abi -lc++ SmartPtrGet.cpp -o SmartPtrGet.exe
Fixing hasName to deal with inline namespaces seems like a better idea to me. Littering every STL specific checks with library implementation details might result in hard to maintain code.
Sent http://reviews.llvm.org/D15506 for review
Fixed in r259898.
I run this check through LLDB code and next cases still not detected: * Explicit bool conversion contexts, like 'if (ptr.get())' * Comparison with NULL. (comparison with nullptr already work).
I'm not treating this as a 3.8 blocker.
D24893 up for review.
Fixed in r282386.
Thank you for help, Kirill!