[all-commits] [llvm/llvm-project] ba545c: [Sema] Try 2: Attempt to perform call-size-specifi...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Fri Jan 24 03:44:45 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ba545c814bc19c3b1ec9ce88a7f13575e0e4ce1d
      https://github.com/llvm/llvm-project/commit/ba545c814bc19c3b1ec9ce88a7f13575e0e4ce1d
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-01-24 (Fri, 24 Jan 2020)

  Changed paths:
    M clang/lib/Sema/SemaChecking.cpp
    M clang/test/Sema/alloc-align-attr.c
    M clang/test/SemaCXX/alloc-align-attr.cpp

  Log Message:
  -----------
  [Sema] Try 2: Attempt to perform call-size-specific `__attribute__((alloc_align(param_idx)))` validation

Summary:
`alloc_align` attribute takes parameter number, not the alignment itself,
so given **just** the attribute/function declaration we can't do any
sanity checking for said alignment.

However, at call site, given the actual `Expr` that is passed
into that parameter, we //might// be able to evaluate said `Expr`
as Integer Constant Expression, and perform the sanity checks.
But since there is no requirement for that argument to be an immediate,
we may fail, and that's okay.

However if we did evaluate, we should enforce the same constraints
as with `__builtin_assume_aligned()`/`__attribute__((assume_aligned(imm)))`:
said alignment is a power of two, and is not greater than our magic threshold


This was initially committed in c2a9061ac5166e48fe85ea2b6dbce9457c964958
but reverted in 00756b182398b92abe16559287467079087aa631 because of
suspicious bot failures.

Reviewers: erichkeane, aaron.ballman, hfinkel, rsmith, jdoerfert

Reviewed By: erichkeane

Subscribers: cfe-commits

Tags: #clang

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




More information about the All-commits mailing list