[all-commits] [llvm/llvm-project] a0e309: [clang][Tooling] Get rid of a hack in SymbolOccurr...

Mikhail Maltsev via All-commits all-commits at lists.llvm.org
Fri Jan 22 05:02:10 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a0e30914f8c8bb60795a008ce2d9e3c0a4f9b7a2
      https://github.com/llvm/llvm-project/commit/a0e30914f8c8bb60795a008ce2d9e3c0a4f9b7a2
  Author: Mikhail Maltsev <mikhail.maltsev at arm.com>
  Date:   2021-01-22 (Fri, 22 Jan 2021)

  Changed paths:
    M clang/include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
    M clang/lib/Basic/SourceLocation.cpp
    M clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp

  Log Message:
  -----------
  [clang][Tooling] Get rid of a hack in SymbolOccurrences, NFCI

The class `SymbolOccurrences` can store either a single `SourceRange`
in-place or multiple `SourceRanges` on the heap. In the latter case
the number of source ranges is stored in the internal representation
of the beginning `SourceLocation` of the in-place `SourceRange`
object.

This change gets rid of such hack by placing `SourceRange` in a union
which holds either a valid `SourceRange` or an `unsigned int` (a number
of ranges).

The change also adds `static_assert`s that check that `SourceRange` and
`SourceLocation` are trivially destructible (this is required for the
current patch and for D94237 which has already been committed).

Reviewed By: MarkMurrayARM, simon_tatham

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




More information about the All-commits mailing list