[all-commits] [llvm/llvm-project] 227078: [ADT, Support] Move operator<< to raw_ostream.h (NFC)

kazutakahirata via All-commits all-commits at lists.llvm.org
Tue Dec 6 09:10:39 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 227078b7136c09f6505dab7972d7b65d5210209d
      https://github.com/llvm/llvm-project/commit/227078b7136c09f6505dab7972d7b65d5210209d
  Author: Kazu Hirata <kazu at google.com>
  Date:   2022-12-06 (Tue, 06 Dec 2022)

  Changed paths:
    M llvm/include/llvm/ADT/Optional.h
    M llvm/include/llvm/Support/raw_ostream.h

  Log Message:
  -----------
  [ADT, Support] Move operator<< to raw_ostream.h (NFC)

Without this patch, operator<< for Optional<T> and std::optional<T>
are in Optional.h.  This means that a C++ source file must include
Optional.h even if it just needs to stream std::optional<T> and has
nothing to do with Optional<T>, which is counter-intuitive.

This patch moves the operator<< to raw_ostream.h.

As a bonus, we get to resolve a circular dependency.  Optional.h no
longer needs to forward-declare raw_ostream.  That is, raw_ostream.h
depends on Optional.h, not vice versa.

As a preparation for this patch, I've checked in
77609717410372e8c43aca49a268511378f58297 to forward-declare
raw_ostream in those header files that were relying on the forward
declaration of raw_ostream in Optional.h.

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




More information about the All-commits mailing list