<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58220>58220</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] macOS: false positives with CoreFoundation types, e.g. cppcoreguidelines-init-variables, etc.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          H-G-Hristov
      </td>
    </tr>
</table>

<pre>
    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:

![Screenshot 2022-10-07 at 11 20 30](https://user-images.githubusercontent.com/47526411/194507270-421bcced-3a85-48b5-bc3a-b8cc3c24381a.png)
![Screenshot 2022-10-07 at 11 22 23](https://user-images.githubusercontent.com/47526411/194507661-e381f670-d1c9-4493-98f2-bfccf8254152.png)


[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).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztW1GT2jgS_jWeF5UpW7YxPPAwwwzJXGWT1M7d3uOWbMugjLF8lsyE_fXXLRkwhGGYhCFsbSjK2LLcan39dasli0Rmy9GEFYqTSiqhxYIrJ7h2vFvHa48uSasqlTWfNiLjhSi5ckUptLtgtWBJwRVxiSwJlglWCMUzsr61ElFzlrFEFEIv3VSWC15rd87nCa_dvClTLWSpXC1dpZkWqRU453omM0WeZiKdEZamXCliHyK54EW2lj4XKnWbsoGm3YrVDJ7ktep2guu0172-J1CZ_PEwlhl3aKywj1rKQhH-VfNSgT5tu7LRVaMVYUQVYjrTxZJkIs95zUsN3VKsKfQOYg71nejmIa05SJpJTahHqet7rhcTponvQwEJPCe6dehgpnVlIKcT-IJWtSvmbMpVbyr0rEmwBBADpXQvlXOoE8YR7Ye-D6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