[all-commits] [llvm/llvm-project] 12728e: [C] Support _Generic expressions with a type operand

Aaron Ballman via All-commits all-commits at lists.llvm.org
Mon Jun 5 08:10:18 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 12728e144994efe84715f4e5dbb8c3104e9f0b5a
      https://github.com/llvm/llvm-project/commit/12728e144994efe84715f4e5dbb8c3104e9f0b5a
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2023-06-05 (Mon, 05 Jun 2023)

  Changed paths:
    M clang/docs/LanguageExtensions.rst
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/ASTNodeTraverser.h
    M clang/include/clang/AST/Expr.h
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/include/clang/Basic/DiagnosticParseKinds.td
    M clang/include/clang/Basic/Features.def
    M clang/include/clang/Parse/Parser.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/ASTImporter.cpp
    M clang/lib/AST/ComputeDependence.cpp
    M clang/lib/AST/Expr.cpp
    M clang/lib/AST/StmtPrinter.cpp
    M clang/lib/Analysis/ExprMutationAnalyzer.cpp
    M clang/lib/Parse/ParseExpr.cpp
    M clang/lib/Parse/ParseTentative.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaExprObjC.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/lib/Sema/SemaPseudoObject.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/lib/Serialization/ASTReaderStmt.cpp
    M clang/lib/Serialization/ASTWriterStmt.cpp
    M clang/test/Lexer/has_extension.c
    A clang/test/Parser/generic-selection-type-extension-pedantic.c
    A clang/test/Parser/generic-selection-type-extension.c
    A clang/test/Sema/generic-selection-type-extension.c
    M clang/test/SemaCXX/generic-selection.cpp

  Log Message:
  -----------
  [C] Support _Generic expressions with a type operand

_Generic accepts an expression operand whose type is matched against a
list of associations. The expression operand is unevaluated, but the
type matched is the type after lvalue conversion. This conversion loses
type information, which makes it more difficult to match against
qualified or incomplete types.

This extension allows _Generic to accept a type operand instead of an
expression operand. The type operand form does not undergo any
conversions and is matched directly against the association list.

This extension is also supported in C++ as we already supported
_Generic selection expressions there.

The RFC for this extension can be found at:
https://discourse.llvm.org/t/rfc-generic-selection-expression-with-a-type-operand/70388

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




More information about the All-commits mailing list