[PATCH] D112059: Fix inline builtin handling in case of redefinition

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 26 15:46:46 PDT 2021


nickdesaulniers added a comment.

Actually, it looks like:

  diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
  index 69d2ef631872..8e77cdef2ed5 100644
  --- a/clang/lib/Sema/SemaDecl.cpp
  +++ b/clang/lib/Sema/SemaDecl.cpp
  @@ -10927,6 +10927,10 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
     }
   
     if (Redeclaration) {
  +    if (cast<FunctionDecl>(OldDecl)->isInlineBuiltinDeclaration() && !NewFD->isInlineBuiltinDeclaration()) {
  +      // Set a flag on NewFD that it's a shadowed gnu_inline that should be
  +      // emitted, or on OldDecl that it should not be emitted?
  +    }
       // NewFD and OldDecl represent declarations that need to be
       // merged.
       if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {

might detect what you need.  Can we perhaps use those checks there (when we have already detected a redeclaration) to perhaps set new members (to be added) on `FunctionDecl` that they shouldn't be emitted or not because they are this weird case? Then `CodeGenFunction::GenerateCode` can simply check that flag, then erase the existing function (or not generate it in the first place by setting a flag on `OldDecl` perhaps?).  No redecl walking for every FunctionDecl required.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112059/new/

https://reviews.llvm.org/D112059



More information about the cfe-commits mailing list