[all-commits] [llvm/llvm-project] 2a702c: Driver: Avoid llvm::sys::path::append if resource ...

Peter Collingbourne via All-commits all-commits at lists.llvm.org
Tue Jul 1 20:22:13 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2a702cdc38f96989cb41c0b863d977f0d8f4f325
      https://github.com/llvm/llvm-project/commit/2a702cdc38f96989cb41c0b863d977f0d8f4f325
  Author: Peter Collingbourne <peter at pcc.me.uk>
  Date:   2025-07-01 (Tue, 01 Jul 2025)

  Changed paths:
    M clang/lib/Driver/Driver.cpp
    M llvm/include/llvm/Support/Path.h

  Log Message:
  -----------
  Driver: Avoid llvm::sys::path::append if resource directory absolute.

After #145996 CLANG_RESOURCE_DIR can be an absolute path so we need to
handle it correctly in the driver.

llvm::sys::path::append does not append absolute paths in the way
that I expected (or consistent with other similar APIs such as C++17
std::filesystem::path::append or Python os.path.join); instead, it
effectively discards the leading / and appends the resulting relative path
(e.g. append(P, "/bar") with P = "/foo" sets P to "/foo/bar").

Many tests start failing if I try to align llvm::sys::path::append with
the other APIs because of callers that expect the existing behavior,
so for now let's add a special case here for absolute resource paths,
and document the behavior in Path.h.

Reviewers: MaskRay

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/146449



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list