LLVM Discussion Forums

Silence warning "must resolve to a function declared within the llvm namespace`

Hello!

I am using clangd 11 together with the Emacs lsp package. Basically it works, but I am getting tons of warnings like:

[something] must resolve to a function declared within the '__llvm_libc' namespace"

The source of this message is clang-tidy, the location is a c++ stl file, like shared_ptr_base.h. Still, the warning is shown in my code.

How can I silence the warning? I tried adding -llvmlibc-* to Checks in my projects .clang-tidy and also tried InheritParentConfig: true, both with no effect. Complete .clang-tidy see below.

clangd version is:
Ubuntu clangd version 11.0.0-++20201008094836+176249bd673-1~exp1~20201008080315.114

Thanks a lot!

complete lsp log:

[Trace - 10:20:20 AM] Sending request 'textDocument/codeAction - (109)'.
Params: {
  "textDocument": {
    "uri": "file:///myproject/file.cpp"
  },
  "range": {
    "start": {
      "line": 46,
      "character": 14
    },
    "end": {
      "line": 46,
      "character": 14
    }
  },
  "context": {
    "diagnostics": [
      {
        "source": "clang-tidy",
        "severity": 2,
        "relatedInformation": [
          {
            "message": "Resolves to this declaration",
            "location": {
              "uri": "file:///usr/include/c%2B%2B/7/bits/shared_ptr_base.h",
              "range": {
                "start": {
                  "line": 965,
                  "character": 6
                },
                "end": {
                  "line": 965,
                  "character": 14
                }
              }
            }
          }
        ],
        "range": {
          "start": {
            "line": 46,
            "character": 13
          },
          "end": {
            "line": 46,
            "character": 15
          }
        },
        "message": "'operator->' must resolve to a function declared within the '__llvm_libc' namespace",
        "code": "llvmlibc-callee-namespace"
      }
    ]
  }
}

complete .clang-tidy:

Checks:
'*,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-type-vararg,
-fuchsia-*,
-google-readability-todo,
-google-runtime-references,
-hicpp-braces-around-statements,
-hicpp-no-array-decay,
-hicpp-vararg,
-modernize-use-trailing-return-type,
-readability-avoid-const-params-in-decls,
-readability-simplify-boolean-expr,
-llvmlibc-*
'

InheritParentConfig: true

CheckOptions:
  - { key: readability-identifier-naming.NamespaceCase,                value: lower_case }
  - { key: readability-identifier-naming.ClassCase,                    value: CamelCase  }
  - { key: readability-identifier-naming.StructCase,                   value: CamelCase  }
  - { key: readability-identifier-naming.TemplateParameterCase,        value: CamelCase  }
  - { key: readability-identifier-naming.TemplateParameterSuffix,      value: 'T'  }
  - { key: readability-identifier-naming.ValueTemplateParameterCase,   value: CamelCase  }
  - { key: readability-identifier-naming.ValueTemplateParameterPrefix, value: 'k'  }
  - { key: readability-identifier-naming.ValueTemplateParameterSuffix, value: 'T'  }
  - { key: readability-identifier-naming.TypedefCase,                  value: CamelCase  }
  - { key: readability-identifier-naming.TypeAliasCase,                value: CamelCase  }
  - { key: readability-identifier-naming.EnumCase,                     value: CamelCase  }
  - { key: readability-identifier-naming.VariableCase,                 value: lower_case }
  - { key: readability-identifier-naming.ParameterCase,                value: lower_case }
  - { key: readability-identifier-naming.PrivateMemberPrefix,          value: 'm_' }
  - { key: readability-identifier-naming.ProtectedMemberPrefix,        value: 'm_' }
  - { key: readability-identifier-naming.GlobalVariablePrefix,         value: 'g_' }
  - { key: readability-identifier-naming.StaticVariableCase,           value: CamelCase }
  - { key: readability-identifier-naming.StaticVariablePrefix,         value: 's_' }
  - { key: readability-identifier-naming.StaticConstantCase,           value: CamelCase }
  - { key: readability-identifier-naming.StaticConstantPrefix,         value: 'k' }
  - { key: readability-identifier-naming.GlobalConstantCase,           value: CamelCase }
  - { key: readability-identifier-naming.GlobalConstantPrefix,         value: 'k' }
  - { key: readability-identifier-naming.EnumConstantCase,             value: CamelCase }
  - { key: readability-identifier-naming.EnumConstantPrefix,           value: 'k' }
  - { key: readability-identifier-naming.FunctionCase,                 value: camelBack }
  - { key: readability-identifier-naming.TsmRotationCase,              value: target_T_source }
  - { key: readability-identifier-naming.TsmIsometryCase,              value: target_T_source }
  - { key: readability-identifier-naming.TsmJacobianCase,              value: target_J_source }
  - { key: readability-identifier-naming.TsmIndexStructCase,           value: UPPER_CASE }
  - { key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1 } # structs are allowed
  
FormatStyle: file # use .clang-format from the project dir for fixes

I don’t think you can have arbitrary newlines in your Checks line. Can you try after putting all of the Checks string in a single line? i.e:

Checks: '*, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-type-vararg, -fuchsia-*, -google-readability-todo, -google-runtime-references, -hicpp-braces-around-statements, -hicpp-no-array-decay, -hicpp-vararg, -modernize-use-trailing-return-type, -readability-avoid-const-params-in-decls, -readability-simplify-boolean-expr, -llvmlibc-*'

Ok, right now it seems that this issue is solved. Deleting the ~/.cache/clangd directory and reindexing, together with -llvmlibc* in clang-tidy did the trick.