[clang] [Clang] Only compare template params of potential overload after checking their decl context (PR #78139)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 15 06:41:24 PST 2024
================
@@ -1259,6 +1259,40 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New,
if ((OldTemplate == nullptr) != (NewTemplate == nullptr))
return true;
+ // Is the function New an overload of the function Old?
+ QualType OldQType = SemaRef.Context.getCanonicalType(Old->getType());
+ QualType NewQType = SemaRef.Context.getCanonicalType(New->getType());
+
+ // Compare the signatures (C++ 1.3.10) of the two functions to
+ // determine whether they are overloads. If we find any mismatch
+ // in the signature, they are overloads.
+
+ // If either of these functions is a K&R-style function (no
+ // prototype), then we consider them to have matching signatures.
+ if (isa<FunctionNoProtoType>(OldQType.getTypePtr()) ||
+ isa<FunctionNoProtoType>(NewQType.getTypePtr()))
+ return false;
+
+ const FunctionProtoType *OldType = cast<FunctionProtoType>(OldQType);
+ const FunctionProtoType *NewType = cast<FunctionProtoType>(NewQType);
----------------
cor3ntin wrote:
Fixed. Note that this code was just moved so it's all preexisting
https://github.com/llvm/llvm-project/pull/78139
More information about the cfe-commits
mailing list