| Issue |
58220
|
| Summary |
[clang-tidy] macOS: false positives with CoreFoundation types, e.g. cppcoreguidelines-init-variables, etc.
|
| Labels |
|
| Assignees |
|
| Reporter |
H-G-Hristov
|
False positives:
- cppcoreguidelines-init-variables - on initialised variables
- readability-convert-member-functions-to-static - on methods which access member fields
- misc-unused-parameters
etc.
I use VSCode's cpptools extension which outputs a slightly different resault:


[Archive.zip](https://github.com/llvm/llvm-project/files/9732031/Archive.zip)
CLI output
> hhhhh@Hristos-MacBook-Pro mylib % clang-tidy -config-file=.clang-tidy '/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp'
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp"
No compilation database found in /Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
54775 warnings and 1 error generated.
Error while processing /Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp.
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:29:21: warning: constructor does not initialize these fields: plistRef [cppcoreguidelines-pro-type-member-init,hicpp-member-init]
class LaunchdPlist::LaunchdPlistImpl
^
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:83:9: warning: parameter 'dictionary' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
const CFDictionaryRef dictionary,
^~~~~~
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:134:1: warning: constructor does not initialize these fields: plistRef [cppcoreguidelines-pro-type-member-init,hicpp-member-init]
LaunchdPlist::LaunchdPlistImpl::LaunchdPlistImpl(const std::string_view content)
^
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:138:38: warning: method 'LoadFromString' can be made static [readability-convert-member-functions-to-static]
void LaunchdPlist::LaunchdPlistImpl::LoadFromString(std::string_view plistStr)
^
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:138:70: warning: parameter 'plistStr' is unused [misc-unused-parameters]
void LaunchdPlist::LaunchdPlistImpl::LoadFromString(std::string_view plistStr)
^~~~~~~~
/*plistStr*/
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:153:38: warning: method 'LoadFromFile' can be made static [readability-convert-member-functions-to-static]
void LaunchdPlist::LaunchdPlistImpl::LoadFromFile(std::string_view filepath)
^
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:153:68: warning: parameter 'filepath' is unused [misc-unused-parameters]
void LaunchdPlist::LaunchdPlistImpl::LoadFromFile(std::string_view filepath)
^~~~~~~~
/*filepath*/
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:196:5: warning: 2 adjacent parameters of 'GetObjectsFromArrayOfDictionariesFor' of similar type are easily swapped by mistake [bugprone-easily-swappable-parameters]
std::string_view keyName, const std::function<T(CFDictionaryRef dictionary)>& MakeObject)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:196:22: note: the first parameter in the range is 'keyName'
std::string_view keyName, const std::function<T(CFDictionaryRef dictionary)>& MakeObject)
^~~~~~~
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:196:83: note: the last parameter in the range is 'MakeObject'
std::string_view keyName, const std::function<T(CFDictionaryRef dictionary)>& MakeObject)
^~~~~~~~~~
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:196:5: note: after resolving type aliases, the common type of 'std::string_view' and 'const int &' is 'int'
std::string_view keyName, const std::function<T(CFDictionaryRef dictionary)>& MakeObject)
^
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:196:31: note: 'std::string_view' and 'const int &' parameters accept and bind the same kind of values
std::string_view keyName, const std::function<T(CFDictionaryRef dictionary)>& MakeObject)
^
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:208:49: warning: variable 'itemsRef' is not initialized [cppcoreguidelines-init-variables]
const ::nblib::types::CFWeakRef<CFArrayRef> itemsRef{CFDictionaryGetValue(plistRef.Get(), keyNameRef.Get())};
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:214:20: warning: variable 'resultItems' is not initialized [cppcoreguidelines-init-variables]
std::vector<T> resultItems;
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:216:19: warning: variable 'itemCount' is not initialized [cppcoreguidelines-init-variables]
const CFIndex itemCount = CFArrayGetCount(itemsRef.Get());
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:217:18: warning: variable 'i' is not initialized [cppcoreguidelines-init-variables]
for (CFIndex i = 0; i < itemCount; i++) {
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:218:58: warning: variable 'item' is not initialized [cppcoreguidelines-init-variables]
const ::nblib::types::CFWeakRef<CFDictionaryRef> item{CFArrayGetValueAtIndex(itemsRef.Get(), i)};
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:241:50: warning: variable 'valueRef' is not initialized [cppcoreguidelines-init-variables]
const ::nblib::types::CFWeakRef<CFNumberRef> valueRef{CFDictionaryGetValue(plistRef.Get(), keyNameRef.Get())};
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:262:49: warning: variable 'itemsRef' is not initialized [cppcoreguidelines-init-variables]
const ::nblib::types::CFWeakRef<CFArrayRef> itemsRef{CFDictionaryGetValue(plistRef.Get(), keyNameRef.Get())};
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:268:19: warning: variable 'itemCount' is not initialized [cppcoreguidelines-init-variables]
const CFIndex itemCount = CFArrayGetCount(itemsRef.Get());
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:269:30: warning: variable 'resultItems' is not initialized [cppcoreguidelines-init-variables]
std::vector<std::string> resultItems;
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:271:18: warning: variable 'i' is not initialized [cppcoreguidelines-init-variables]
for (CFIndex i = 0; i < itemCount; i++) {
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:272:54: warning: variable 'item' is not initialized [cppcoreguidelines-init-variables]
const ::nblib::types::CFWeakRef<CFStringRef> item{CFArrayGetValueAtIndex(itemsRef.Get(), i)};
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:295:50: warning: variable 'valueRef' is not initialized [cppcoreguidelines-init-variables]
const ::nblib::types::CFWeakRef<CFStringRef> valueRef{CFDictionaryGetValue(plistRef.Get(), keyNameRef.Get())};
^
= 0
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.cpp:306:38: warning: variable 'AppendSubkeyValueIfExists' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
void LaunchdPlist::LaunchdPlistImpl::AppendSubkeyValueIfExists(
^
/Users/hhhhh/Projects/GitHub/mylib/src/utilities/src/macos/LaunchdPlist.hpp:5:10: error: 'tl/optional.hpp' file not found [clang-diagnostic-error]
#include <tl/optional.hpp>
^~~~~~~~~~~~~~~~~
Suppressed 54752 warnings (54752 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs