[all-commits] [llvm/llvm-project] 325c4c: [clang] Add test cases for multiversion function o...

Tom Honermann via All-commits all-commits at lists.llvm.org
Mon Mar 21 10:40:06 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 325c4c29d68c3bd25984797414b0e5e11ac505f1
      https://github.com/llvm/llvm-project/commit/325c4c29d68c3bd25984797414b0e5e11ac505f1
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/test/Sema/attr-cpuspecific.c
    M clang/test/Sema/attr-target-clones.c
    M clang/test/Sema/attr-target-mv.c

  Log Message:
  -----------
  [clang] Add test cases for multiversion function overload scenarios in C.

This change adds test cases to validate diagnostics for overloaded sets
that contain declarations of multiversion functions. Many of the added test
cases exercise declarations that are intended to be valid. Others are
intended to be valid if and when restrictions on multiversion functions
being declared with the overloadable attribute are lifted.

Several of the new test cases currently trigger the following assertion
failure in SemaDecl.cpp; the relevant test is therefore marked as an
expected failure pending a fix.
```
Assertion `(Previous.empty() || llvm::any_of(Previous, [](const NamedDecl *ND) { return ND->hasAttr(); })) && "Non-redecls shouldn't happen without overloadable present"' failed.
```

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D121954


  Commit: 77472a659e2535607e8150f122ae2448aec67e62
      https://github.com/llvm/llvm-project/commit/77472a659e2535607e8150f122ae2448aec67e62
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp

  Log Message:
  -----------
  [clang] NFC: Dead code removal in SemaDecl.cpp, CheckMultiVersionFunction().

This change removes dead code in the definition of CheckMultiVersionFunction()
in clang/lib/Sema/SemaDecl.cpp. The removed code was made dead by commit
fc53eb69c26cdd7efa6b629c187d04326f0448ca: "Reapply 'Implement target_clones multiversioning'".
See the added code just above the code being deleted; it contains the same
return statement with the previous condition now distributed across an if
statement and a switch statement.

Reviewed By: erichkeane, aaron.ballman

Differential Revision: https://reviews.llvm.org/D121955


  Commit: 01b2e0567c549ef5b7be9026b6a602590d9c3568
      https://github.com/llvm/llvm-project/commit/01b2e0567c549ef5b7be9026b6a602590d9c3568
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp

  Log Message:
  -----------
  [clang] NFC: Redundant code removal in SemaDecl.cpp, CheckTargetCausesMultiVersioning().

This change removes redundant code in the definition of
CheckTargetCausesMultiVersioning() in SemaDecl.cpp. The removed code checked
for multiversion function support. The code immediately following the removed
code is a call to CheckMultiVersionAdditionalRules(); that function performs
the same check on entry. In both cases, the consequences of missing multiversion
function support results in the same diagnostic message being issued and the
applicable function declaration being marked as invalid.

Reviewed By: erichkeane, aaron.ballman

Differential Revision: https://reviews.llvm.org/D121957


  Commit: 42e4c5b2610d0008d52f2ebf08961e8ae0adb58b
      https://github.com/llvm/llvm-project/commit/42e4c5b2610d0008d52f2ebf08961e8ae0adb58b
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp

  Log Message:
  -----------
  [clang] NFC: Remove forced type merging in multiversion function checks.

Checking of multiversion function declarations performed by various functions
in clang/lib/Sema/SemaDecl.cpp previously forced the valus of a passed in
'MergeTypeWithPrevious' reference argument in several scenarios. This was
unnecessary and possibly incorrect in the one case that the value
was forced to 'true' (though seemingly unobservably so).

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D121958


  Commit: 8b6f1cbb21c58e255156aa32ac55530c807055a9
      https://github.com/llvm/llvm-project/commit/8b6f1cbb21c58e255156aa32ac55530c807055a9
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/Sema/attr-cpuspecific.c
    M clang/test/Sema/attr-target-clones.c
    M clang/test/Sema/attr-target-mv.c

  Log Message:
  -----------
  [clang] Add missing diagnostics for invalid overloads of multiversion functions in C.

Previously, an attempt to declare an overload of a multiversion function
in C was not properly diagnosed. In some cases, diagnostics were simply
missing. In other cases the following assertion failure occured...
```
Assertion `(Previous.empty() || llvm::any_of(Previous, [](const NamedDecl *ND) { return ND->hasAttr(); })) && "Non-redecls shouldn't happen without overloadable present"' failed.
```
... or the following diagnostic was spuriously issued.
```
error: at most one overload for a given name may lack the 'overloadable' attribute
```

The diagnostics issued in some cases could be improved. When the function
type of a redeclaration does not match the prior declaration, it would be
preferable to diagnose the type mismatch before diagnosing mismatched
attributes. Diagnostics are also missing for some cases.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D121959


  Commit: 58c202a3d83dab0c4abeb19c3eeff27d83f6c2b5
      https://github.com/llvm/llvm-project/commit/58c202a3d83dab0c4abeb19c3eeff27d83f6c2b5
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp

  Log Message:
  -----------
  [clang] NFC: Rename 'MVType' variables to 'MVKind' for consistency with their type.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121960


  Commit: 0cceee755992820362d5df5698da8bce762b9fe3
      https://github.com/llvm/llvm-project/commit/0cceee755992820362d5df5698da8bce762b9fe3
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/lib/AST/TextNodeDumper.cpp
    A clang/test/AST/ast-dump-funcs-multiversion.c

  Log Message:
  -----------
  [clang] Produce a "multiversion" annotation in textual AST output.

This change adds a "multiversion" annotation to textual AST output.
For example:
  FunctionDecl 0xb6628b0 <t.c:1:1, col:13> col:5 multiversion foo 'int (void)'

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121961


  Commit: 8ff8c3ac0dd675319d779a1aa0087e8a0d5a81b2
      https://github.com/llvm/llvm-project/commit/8ff8c3ac0dd675319d779a1aa0087e8a0d5a81b2
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/test/OpenMP/declare_variant_messages.c

  Log Message:
  -----------
  [clang] [OpenMP] Extend OpenMP variant declaration tests.

This change extends the existing diagnostic tests for OpenMP variant
declarations to cover diagnostics for declarations that include
multiversion function attributes. The new tests demonstrate a missing
check for the 'target_clones' attribute.

Reviewed By: erichkeane, jdoerfert

Differential Revision: https://reviews.llvm.org/D121962


  Commit: 059a953d8819b361b33205c109b5e903801613a2
      https://github.com/llvm/llvm-project/commit/059a953d8819b361b33205c109b5e903801613a2
  Author: Tom Honermann <tom.honermann at intel.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaOpenMP.cpp
    M clang/test/OpenMP/declare_variant_messages.c

  Log Message:
  -----------
  [clang] [OpenMP] Diagnose use of 'target_clones' in OpenMP variant declarations.

Previously, OpenMP variant declarations for a function declaration that included
the 'cpu_dispatch', 'cpu_specific', or 'target' attributes was diagnosed, but
one with the 'target_clones' attribute was not. Now fixed.

Reviewed By: erichkeane, jdoerfert

Differential Revision: https://reviews.llvm.org/D121963


Compare: https://github.com/llvm/llvm-project/compare/86f970e595f4...059a953d8819


More information about the All-commits mailing list