diff --git a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp --- a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp @@ -52,7 +52,9 @@ if (NS && NS->getName() == "__llvm_libc") return; - if (IgnoredFunctions.contains(FuncDecl->getName())) + const DeclarationName &Name = FuncDecl->getDeclName(); + if (Name.isIdentifier() && + IgnoredFunctions.contains(Name.getAsIdentifierInfo()->getName())) return; diag(UsageSiteExpr->getBeginLoc(), "%0 must resolve to a function declared " diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -136,31 +136,39 @@ Changes in existing checks ^^^^^^^^^^^^^^^^^^^^^^^^^^ -- Improved :doc:`performance-inefficient-vector-operation - ` to work when - the vector is a member of a structure. - -- Fixed a false positive in :doc:`readability-non-const-parameter - ` when the parameter is referenced by an lvalue. - -- Fixed a crash in :doc:`readability-const-return-type - ` when a pure virtual function - overrided has a const return type. Removed the fix for a virtual function. +- Fixed a crash in :doc:`bugprone-sizeof-expression + ` when `sizeof(...)` is + compared against a `__int128_t`. -- Fixed a false positive in :doc:`misc-redundant-expression ` - involving overloaded comparison operators. - -- Fixed a crash in :doc:`bugprone-sizeof-expression ` when - `sizeof(...)` is compared agains a `__int128_t`. - - Improved :doc:`cppcoreguidelines-prefer-member-initializer ` check. Fixed an issue when there was already an initializer in the constructor and the check would try to create another initializer for the same member. -- Fixed a false positive in :doc:`misc-redundant-expression ` - involving assignments in conditions. This fixes `Issue 35853 `_. +- Fixed a crash in :doc:`llvmlibc-callee-namespace + ` when executing for C++ code + that contain calls to advanced constructs, e.g. overloaded operators. + +- Fixed a false positive in :doc:`misc-redundant-expression + ` involving overloaded + comparison operators. + +- Fixed a false positive in :doc:`misc-redundant-expression + ` involving assignments in + conditions. This fixes `Issue 35853 `_. + +- Fixed a crash in :doc:`readability-const-return-type + ` when a pure virtual function + overrided has a const return type. Removed the fix for a virtual function. + +- Fixed a false positive in :doc:`readability-non-const-parameter + ` when the parameter is + referenced by an lvalue. + +- Improved :doc:`performance-inefficient-vector-operation + ` to work when + the vector is a member of a structure. Removed checks ^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp b/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp @@ -5,6 +5,10 @@ void nested_func() {} } // namespace nested void libc_api_func() {} + +struct libc_api_struct { + int operator()() const { return 0; } +}; } // namespace __llvm_libc // Emulate a function from the public headers like string.h @@ -13,6 +17,11 @@ // Emulate a function specifically allowed by the exception list. void malloc() {} +// Emulate a non-trivially named symbol. +struct global_struct { + int operator()() const { return 0; } +}; + namespace __llvm_libc { void Test() { // Allow calls with the fully qualified name. @@ -30,6 +39,9 @@ void (*barePtr)(void) = __llvm_libc::libc_api_func; barePtr(); + // Allow calling entities defined in the namespace. + __llvm_libc::libc_api_struct{}(); + // Disallow calling into global namespace for implemented entrypoints. ::libc_api_func(); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'libc_api_func' must resolve to a function declared within the '__llvm_libc' namespace @@ -43,6 +55,12 @@ // Allow calling into global namespace for specific functions. ::malloc(); + + // Disallow calling on entities that are not in the namespace, but make sure + // no crashes happen. + global_struct{}(); + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'operator()' must resolve to a function declared within the '__llvm_libc' namespace + // CHECK-MESSAGES: :22:7: note: resolves to this declaration } } // namespace __llvm_libc