[llvm-branch-commits] [clang-tools-extra] 54b68d5 - [clang-tidy] Fix crash in readability-identifier-naming check

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 15 11:24:04 PST 2021


Author: Nathan James
Date: 2021-02-15T11:23:15-08:00
New Revision: 54b68d56dc957457b54c700af8e24a2c86539cc3

URL: https://github.com/llvm/llvm-project/commit/54b68d56dc957457b54c700af8e24a2c86539cc3
DIFF: https://github.com/llvm/llvm-project/commit/54b68d56dc957457b54c700af8e24a2c86539cc3.diff

LOG: [clang-tidy] Fix crash in readability-identifier-naming check

`isParamInMainLikeFunction` didn't check if the function had an identifer name before calling getName() which could lead to an assert.

(cherry picked from commit c97592c5df09850404a9ddbfb614c7df271d1dfe)

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index d33040a00e15..867b074ca6db 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -352,6 +352,10 @@ static bool isParamInMainLikeFunction(const ParmVarDecl &ParmDecl,
     return false;
   if (FDecl->getAccess() != AS_public && FDecl->getAccess() != AS_none)
     return false;
+  // If the function doesn't have a name thats an identifier, can occur of the
+  // function is an operator overload, bail out early.
+  if (!FDecl->getDeclName().isIdentifier())
+    return false;
   enum MainType { None, Main, WMain };
   auto IsCharPtrPtr = [](QualType QType) -> MainType {
     if (QType.isNull())


        


More information about the llvm-branch-commits mailing list