Skip to content

[NFC] Make 'Triple&' param a 'const&' instead #110628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

Sirraide
Copy link
Member

@Sirraide Sirraide commented Oct 1, 2024

There isn’t really a reason for it not to be a const& (afaict), and it is a bit annoying because some APIs (e.g. TargetMachine::getTargetTriple()) return a const Triple&.

@Sirraide Sirraide added the llvm Umbrella label for LLVM issues label Oct 1, 2024
@Sirraide Sirraide requested review from nikic and cjacek October 1, 2024 05:52
@llvmbot
Copy link
Member

llvmbot commented Oct 1, 2024

@llvm/pr-subscribers-llvm-binary-utilities

Author: None (Sirraide)

Changes

There isn’t really a reason for it not to be a const& (afaict), and it is a bit annoying because some APIs (e.g. TargetMachine::getTargetTriple()) return a const Triple&.


Full diff: https://github.com/llvm/llvm-project/pull/110628.diff

2 Files Affected:

  • (modified) llvm/include/llvm/Object/Archive.h (+1-1)
  • (modified) llvm/lib/Object/Archive.cpp (+1-1)
diff --git a/llvm/include/llvm/Object/Archive.h b/llvm/include/llvm/Object/Archive.h
index a3165c3235e0ed..b2dd970b00c056 100644
--- a/llvm/include/llvm/Object/Archive.h
+++ b/llvm/include/llvm/Object/Archive.h
@@ -339,7 +339,7 @@ class Archive : public Binary {
   Kind kind() const { return (Kind)Format; }
   bool isThin() const { return IsThin; }
   static object::Archive::Kind getDefaultKind();
-  static object::Archive::Kind getDefaultKindForTriple(Triple &T);
+  static object::Archive::Kind getDefaultKindForTriple(const Triple &T);
 
   child_iterator child_begin(Error &Err, bool SkipInternal = true) const;
   child_iterator child_end() const;
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index e798bbdd16f143..9857eb0de7a80d 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -969,7 +969,7 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
   Err = Error::success();
 }
 
-object::Archive::Kind Archive::getDefaultKindForTriple(Triple &T) {
+object::Archive::Kind Archive::getDefaultKindForTriple(const Triple &T) {
   if (T.isOSDarwin())
     return object::Archive::K_DARWIN;
   if (T.isOSAIX())

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sirraide
Copy link
Member Author

Sirraide commented Oct 1, 2024

CI errors seem to be because of something in Bolt; I’m gonna go ahead and assume that that’s unrelated and that I just need to update my fork again because I candidly don’t see how this could possibly cause those...

@Sirraide Sirraide merged commit 9c28432 into llvm:main Oct 1, 2024
9 of 11 checks passed
@Sirraide Sirraide deleted the archive-const-triple branch October 1, 2024 19:16
Sterling-Augustine pushed a commit to Sterling-Augustine/llvm-project that referenced this pull request Oct 3, 2024
There isn’t really a reason for it not to be a `const&` (afaict), and it
is a bit annoying because some APIs (e.g. `TargetMachine::getTargetTriple()`) 
return a `const Triple&`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:binary-utilities llvm Umbrella label for LLVM issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants