[all-commits] [llvm/llvm-project] adf845: [Sema] Introduce BuiltinAttr, per-declaration buil...

Richard Smith via All-commits all-commits at lists.llvm.org
Mon Dec 14 16:44:25 PST 2020


  Branch: refs/heads/release/11.x
  Home:   https://github.com/llvm/llvm-project
  Commit: adf845300c9cc023d386d97b6ebeb1e82bd97763
      https://github.com/llvm/llvm-project/commit/adf845300c9cc023d386d97b6ebeb1e82bd97763
  Author: Raul Tambre <raul at tambre.ee>
  Date:   2020-12-14 (Mon, 14 Dec 2020)

  Changed paths:
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/Builtins.def
    M clang/include/clang/Basic/IdentifierTable.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/Decl.cpp
    M clang/lib/Headers/intrin.h
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaLookup.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/test/AST/ast-dump-attr.cpp
    A clang/test/CodeGen/builtin-redeclaration.c
    M clang/test/CodeGen/callback_pthread_create.c
    M clang/test/CodeGenCXX/builtins.cpp
    M clang/test/Sema/implicit-builtin-decl.c
    M clang/test/Sema/warn-fortify-source.c
    M clang/test/SemaCXX/cxx11-compat.cpp
    M clang/test/SemaCXX/warn-unused-local-typedef.cpp

  Log Message:
  -----------
  [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

Instead of relying on whether a certain identifier is a builtin, introduce BuiltinAttr to specify a declaration as having builtin semantics.

This fixes incompatible redeclarations of builtins, as reverting the identifier as being builtin due to one incompatible redeclaration would have broken rest of the builtin calls.
Mostly-compatible redeclarations of builtins also no longer have builtin semantics. They don't call the builtin nor inherit their attributes.
A long-standing FIXME regarding builtins inside a namespace enclosed in extern "C" not being recognized is also addressed.

Due to the more correct handling attributes for builtin functions are added in more places, resulting in more useful warnings.
Tests are updated to reflect that.

Intrinsics without an inline definition in intrin.h had `inline` and `static` removed as they had no effect and caused them to no longer be recognized as builtins otherwise.

A pthread_create() related test is XFAIL-ed, as it relied on it being recognized as a builtin based on its name.
The builtin declaration syntax is too restrictive and doesn't allow custom structs, function pointers, etc.
It seems to be the only case and fixing this would require reworking the current builtin syntax, so this seems acceptable.

Fixes PR45410.

Reviewed By: rsmith, yutsumi

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


  Commit: fdab756331f322a9818c1bdf14d23d9cd6036c81
      https://github.com/llvm/llvm-project/commit/fdab756331f322a9818c1bdf14d23d9cd6036c81
  Author: Raul Tambre <raul.tambre at cleveron.com>
  Date:   2020-12-14 (Mon, 14 Dec 2020)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    A clang/test/SemaObjCXX/builtin-objcsuper.mm

  Log Message:
  -----------
  [Sema] Handle objc_super special lookup when checking builtin compatibility

objc_super is special and needs LookupPredefedObjCSuperType() called before performing builtin type comparisons.
This fixes an error when compiling macOS headers. A test is added.

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


  Commit: 0312bec0d7573b0549a222fb5d0a695fcf819dc3
      https://github.com/llvm/llvm-project/commit/0312bec0d7573b0549a222fb5d0a695fcf819dc3
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2020-12-14 (Mon, 14 Dec 2020)

  Changed paths:
    M clang/include/clang/Basic/Builtins.def
    M clang/include/clang/Basic/Builtins.h
    M clang/lib/Sema/SemaDecl.cpp
    A clang/test/CodeGen/setjmp.c
    M clang/test/Sema/builtin-setjmp.c
    M clang/test/Sema/implicit-builtin-decl.c

  Log Message:
  -----------
  Recognize setjmp and friends as builtins even if jmp_buf is not declared yet.

This happens in glibc's headers. It's important that we recognize these
functions so that we can mark them as returns_twice.

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


  Commit: 98f575ff55bff1e4128ffaeef4d05c356d996ab9
      https://github.com/llvm/llvm-project/commit/98f575ff55bff1e4128ffaeef4d05c356d996ab9
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2020-12-14 (Mon, 14 Dec 2020)

  Changed paths:
    M clang/include/clang/Basic/Builtins.def
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/Sema/SemaChecking.cpp
    M clang/test/Sema/builtin-setjmp.c

  Log Message:
  -----------
  Don't reject calls to MinGW's unusual _setjmp declaration.

We now recognize this function as a builtin despite it having an
unexpected number of parameters; make sure we don't enforce that it has
only 1 argument for its 2 parameters.


Compare: https://github.com/llvm/llvm-project/compare/200eb1abe2a1...98f575ff55bf


More information about the All-commits mailing list