[all-commits] [llvm/llvm-project] 507bbc: [AST][NFC] Silence GCC warning about broken strict...

llvmbot via All-commits all-commits at lists.llvm.org
Fri Dec 4 06:40:08 PST 2020


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 507bbc45bba90fab3f1a2b42e94ae4fbebdd6498
      https://github.com/llvm/llvm-project/commit/507bbc45bba90fab3f1a2b42e94ae4fbebdd6498
  Author: Thomas Preud'homme <thomasp at graphcore.ai>
  Date:   2020-12-04 (Fri, 04 Dec 2020)

  Changed paths:
    M clang/include/clang/AST/Attr.h

  Log Message:
  -----------
  [AST][NFC] Silence GCC warning about broken strict aliasing rules

The deserialize() method would trigger the following warning on GCC <7:

   warning: dereferencing type-punned pointer will break
       strict-aliasing rules [-Wstrict-aliasing]

       ParamIdx P(*reinterpret_cast<ParamIdx *>(&S));
                                                  ^

&S was previously reinterpret_casted from a ParamIdx into a SerialType,
it is therefore safe to cast back into a ParamIdx. Similar to what was
done in D50608, we replace it with two static_cast via void * which
silences the warning and presumably makes GCC understand that no
strict-aliasing violation is happening.

No functional change intended.

Reviewed By: aaron.ballman

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




More information about the All-commits mailing list