[OpenMP] Try to find an existing base for `omp begin/end declare variant`
authorJohannes Doerfert <johannes@jdoerfert.de>
Wed, 1 Apr 2020 22:07:10 +0000 (17:07 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Wed, 8 Apr 2020 04:33:24 +0000 (23:33 -0500)
commit8f0aa3f3a407994314371ee042854a8c79cea462
treee7ee62903c76139c1bc461b2bb0f131449315632
parent3cb1f35df2a560d5a8ce2047b87cba8e3c904170
[OpenMP] Try to find an existing base for `omp begin/end declare variant`

If we have a function definition in `omp begin/end declare variant` it
is a specialization of a base function with the same name and
"compatible" type. Before, we just created a declaration for the base.
With this patch we try to find an existing declaration first and only
create a new one if we did not find any with a compatible type. This is
preferable as we can tolerate slight mismatches, especially if the
specialized version is "more constrained", e.g., constexpr.

Reviewed By: mikerice

Differential Revision: https://reviews.llvm.org/D77252
15 files changed:
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/AST/ast-dump-openmp-begin-declare-variant_10.c [new file with mode: 0644]
clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c [new file with mode: 0644]
clang/test/AST/ast-dump-openmp-begin-declare-variant_12.c [new file with mode: 0644]
clang/test/AST/ast-dump-openmp-begin-declare-variant_2.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_3.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_5.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_6.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_7.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_8.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_9.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_addr_1.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp [new file with mode: 0644]