[clang-tools-extra] c97592c - [clang-tidy] Fix crash in readability-identifier-naming check

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 2 21:12:04 PST 2021


Author: Nathan James
Date: 2021-02-03T05:11:56Z
New Revision: c97592c5df09850404a9ddbfb614c7df271d1dfe

URL: https://github.com/llvm/llvm-project/commit/c97592c5df09850404a9ddbfb614c7df271d1dfe
DIFF: https://github.com/llvm/llvm-project/commit/c97592c5df09850404a9ddbfb614c7df271d1dfe.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.

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 b862efe5f104..57ee992e64ba 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 cfe-commits mailing list