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

Raul Tambre via All-commits all-commits at lists.llvm.org
Thu Sep 17 09:29:19 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e09107ab80dced55414fa458cf78e6cdfe90da6e
      https://github.com/llvm/llvm-project/commit/e09107ab80dced55414fa458cf78e6cdfe90da6e
  Author: Raul Tambre <raul at tambre.ee>
  Date:   2020-09-17 (Thu, 17 Sep 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




More information about the All-commits mailing list