[clang] 849c605 - PR47792: Include the type of a pointer or reference non-type template

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 11 22:55:34 PDT 2020


On Sun, 11 Oct 2020 at 20:19, Jonas Devlieghere <jonas at devlieghere.com>
wrote:

> I've reverted this in ba2dff0159fcd1d2349bc610331914618ca9bc30 because it
> also caused a build failure when building a stage 2 clang:
>

Thanks!


> http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/24177/console
>
> FAILED: tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o
> /Users/buildslave/jenkins/workspace/lldb-cmake at 2/host-compiler/bin/clang++
> -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/AST
> -I/Users/buildslave/jenkins/workspace/lldb-cmake at 2/llvm-project/clang/lib/AST
> -I/Users/buildslave/jenkins/workspace/lldb-cmake at 2/llvm-project/clang/include
> -Itools/clang/include -Iinclude
> -I/Users/buildslave/jenkins/workspace/lldb-cmake at 2/llvm-project/llvm/include
> -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time
> -Werror=unguarded-availability-new -fmodules
> -fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake at 2/lldb-build/module.cache
> -fcxx-modules -Xclang -fmodules-local-submodule-visibility -Wall -Wextra
> -Wno-unused-parameter -Wwrite-strings -Wcast-qual
> -Wmissing-field-initializers -pedantic -Wno-long-long
> -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type
> -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override
> -Wstring-conversion -fdiagnostics-color -fno-common -Woverloaded-virtual
> -Wno-nested-anon-types -O3 -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
> -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT
> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o -MF
> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o.d -o
> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o -c
> '/Users/buildslave/jenkins/workspace/lldb-cmake at 2/llvm-project/clang/lib/AST/ASTContext.cpp'
> In module 'Clang_AST' imported from
> /Users/buildslave/jenkins/workspace/lldb-cmake at 2/llvm-project/clang/lib/AST/ASTContext.cpp:13:
> /Users/buildslave/jenkins/workspace/lldb-cmake at 2/llvm-project/clang/include/clang/AST/ExternalASTSource.h:409:20:
> error: definition with same mangled name
> '_ZN5clang25LazyGenerationalUpdatePtrIPKNS_4DeclEPS1_XadL_ZNS_17ExternalASTSource19CompleteRedeclChainES3_EEE9makeValueERKNS_10ASTContextES4_'
> as another definition static ValueType makeValue(const ASTContext &Ctx, T
> Value);
>
>
>
> On Sun, Oct 11, 2020 at 6:27 PM Hubert Tong via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> The bots don't seem happy building with a Clang that incorporates this
>> change:
>> ```
>> /b/sanitizer-x86_64-linux-bootstrap/build/llvm-project/clang/lib/ASTMatchers/ASTMatchersInternal.cpp:943:5:
>> error: redefinition of 'hasAnyName' with a different type: 'const
>> VariadicFunction<...>' vs 'const VariadicFunction<...>'
>>     hasAnyName = {};
>>     ^
>> /b/sanitizer-x86_64-linux-bootstrap/build/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h:2771:5:
>> note: previous declaration is here
>>     hasAnyName;
>>     ^
>> ```
>> (from
>> http://lab.llvm.org:8011/#/builders/99/builds/49/steps/2/logs/build_clang_asan
>> )
>>
>> On Sun, Oct 11, 2020 at 7:00 PM Richard Smith via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>>
>>>
>>> Author: Richard Smith
>>> Date: 2020-10-11T15:59:49-07:00
>>> New Revision: 849c60541b630ddf8cabf9179fa771b3f4207ec8
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8.diff
>>>
>>> LOG: PR47792: Include the type of a pointer or reference non-type
>>> template
>>> parameter in its notion of template argument identity.
>>>
>>> We already did this for all the other kinds of non-type template
>>> argument. We're still missing the type from the mangling, so we continue
>>> to be able to see collisions at link time; that's an open ABI issue.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>>     clang/lib/AST/ASTContext.cpp
>>>     clang/lib/AST/TemplateBase.cpp
>>>     clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> ################################################################################
>>> diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
>>> index a82d95461bb9..7c96038629fb 100644
>>> --- a/clang/lib/AST/ASTContext.cpp
>>> +++ b/clang/lib/AST/ASTContext.cpp
>>> @@ -5890,7 +5890,7 @@ ASTContext::getCanonicalTemplateArgument(const
>>> TemplateArgument &Arg) const {
>>>
>>>      case TemplateArgument::Declaration: {
>>>        auto *D = cast<ValueDecl>(Arg.getAsDecl()->getCanonicalDecl());
>>> -      return TemplateArgument(D, Arg.getParamTypeForDecl());
>>> +      return TemplateArgument(D,
>>> getCanonicalType(Arg.getParamTypeForDecl()));
>>>      }
>>>
>>>      case TemplateArgument::NullPtr:
>>>
>>> diff  --git a/clang/lib/AST/TemplateBase.cpp
>>> b/clang/lib/AST/TemplateBase.cpp
>>> index a9113720fd45..e4303fdb7731 100644
>>> --- a/clang/lib/AST/TemplateBase.cpp
>>> +++ b/clang/lib/AST/TemplateBase.cpp
>>> @@ -244,7 +244,8 @@ void
>>> TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
>>>      break;
>>>
>>>    case Declaration:
>>> -    ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() :
>>> nullptr);
>>> +    ID.AddPointer(getAsDecl() ? getAsDecl()->getCanonicalDecl() :
>>> nullptr);
>>> +    getParamTypeForDecl().Profile(ID);
>>>      break;
>>>
>>>    case Template:
>>> @@ -294,7 +295,8 @@ bool TemplateArgument::structurallyEquals(const
>>> TemplateArgument &Other) const {
>>>      return TypeOrValue.V == Other.TypeOrValue.V;
>>>
>>>    case Declaration:
>>> -    return getAsDecl() == Other.getAsDecl();
>>> +    return getAsDecl() == Other.getAsDecl() &&
>>> +           getParamTypeForDecl() == Other.getParamTypeForDecl();
>>>
>>>    case Integral:
>>>      return getIntegralType() == Other.getIntegralType() &&
>>>
>>> diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
>>> b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
>>> index 7538de330902..6949a2eaad48 100644
>>> --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
>>> +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
>>> @@ -459,3 +459,23 @@ namespace PR46637 {
>>>    X<f> y;
>>>    int n = y.call(); // expected-error {{cannot initialize a variable of
>>> type 'int' with an rvalue of type 'void *'}}
>>>  }
>>> +
>>> +namespace PR47792 {
>>> +  using I = int;
>>> +
>>> +  template<decltype(auto)> int a;
>>> +  const int n = 0;
>>> +  const I n2 = 0;
>>> +  static_assert(&a<n> == &a<0>, "both should have type 'int'");
>>> +  static_assert(&a<n2> == &a<0>, "both should have type 'int'");
>>> +
>>> +  // FIXME: We will need to mangle these cases
>>> diff erently too!
>>> +  int m;
>>> +  const int &r1 = m;
>>> +  int &r2 = m;
>>> +  static_assert(&a<r1> != &a<r2>, "should have
>>> diff erent types");
>>> +
>>> +  const I &r3 = m;
>>> +  static_assert(&a<r1> == &a<r3>, "should have
>>> diff erent types");
>>>
>> I think the text of the static_assert string here is a copy-paste error.
>>
>>
>>> +  static_assert(&a<r2> != &a<r3>, "should have
>>> diff erent types");
>>> +}
>>>
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201011/4bbf9c81/attachment.html>


More information about the cfe-commits mailing list