Skip to content

[llvm] Triple string has inconsistency in the object format component when the value equals to the default #144579

@royitaqi

Description

@royitaqi

Read this code.

Repro steps:

  1. Create a Triple: "arch-vendor-os-env".
  2. Call triple.SetObjectFormat() to set it to the default format (the one that would be returned by getDefaultFormat()). The object format component would be added.
  3. Call triple.SetEnvironment() to set the same environment. The object format component would be removed.
  4. One can then repeat step 2 and 3 to add/remove the object format component while it has always been the same object format.

The above can be verified by the following test:

TEST_F(TempTest, TempTest1) {
  // Initial triple, without object format component
  llvm::Triple triple("arm64-apple-ios-simulator");
  ASSERT_EQ(triple.str(), "arm64-apple-ios-simulator");
  ASSERT_EQ(triple.getObjectFormat(), llvm::Triple::MachO);

  // Explicitly set the same object format.
  // This adds the object format component to the triple string.
  triple.setObjectFormat(llvm::Triple::MachO);
  ASSERT_EQ(triple.str(), "arm64-apple-ios-simulator-macho");
  ASSERT_EQ(triple.getObjectFormat(), llvm::Triple::MachO);

  // Explicitly set the same environment.
  // This removes the object format component from the triple string.
  triple.setEnvironmentName("simulator");
  ASSERT_EQ(triple.str(), "arm64-apple-ios-simulator");
  ASSERT_EQ(triple.getObjectFormat(), llvm::Triple::MachO);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvmUmbrella label for LLVM issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions