[all-commits] [llvm/llvm-project] 17f8c4: [clang] Use SourceLocations in unions [NFCI]

Mikhail Maltsev via All-commits all-commits at lists.llvm.org
Thu Jan 14 03:02:20 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 17f8c458de631c0311828931a5bdf72b1a13c29d
      https://github.com/llvm/llvm-project/commit/17f8c458de631c0311828931a5bdf72b1a13c29d
  Author: Mikhail Maltsev <mikhail.maltsev at arm.com>
  Date:   2021-01-14 (Thu, 14 Jan 2021)

  Changed paths:
    M clang/include/clang/AST/DependentDiagnostic.h
    M clang/include/clang/AST/Expr.h
    M clang/include/clang/AST/TemplateBase.h
    M clang/include/clang/Basic/SourceManager.h
    M clang/include/clang/Sema/DeclSpec.h
    M clang/include/clang/Sema/Designator.h
    M clang/include/clang/Sema/Initialization.h
    M clang/lib/AST/Expr.cpp
    M clang/lib/AST/TemplateBase.cpp
    M clang/lib/Parse/ParseDeclCXX.cpp
    M clang/lib/Sema/DeclSpec.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaType.cpp

  Log Message:
  -----------
  [clang] Use SourceLocations in unions [NFCI]

Currently, there are many instances where `SourceLocation` objects are
converted to raw representation to be stored in structs that are
used as fields of tagged unions.

This is done to make the corresponding structs trivial.
Triviality allows avoiding undefined behavior when implicitly changing
the active member of the union.

However, in most cases, we can explicitly construct an active member
using placement new. This patch adds the required active member
selections and replaces `SourceLocation`-s represented as
`unsigned int` with proper `SourceLocation`-s.

One notable exception is `DeclarationNameLoc`: the objects of this class
are often not properly initialized (so the code currently relies on
its default constructor which uses memset). This class will be fixed
in a separate patch.

Reviewed By: dblaikie

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




More information about the All-commits mailing list