From 6fd5cdde30cfaac0c7be1d601efe745d6f5b5cff Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 4 Mar 2014 19:31:42 +0000 Subject: [PATCH] Pass llvm::Triple objects by const reference. Copying isn't cheap as it contains a std::string. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202880 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/AttributeList.h | 2 +- lib/AST/Mangle.cpp | 2 +- lib/Driver/ToolChains.cpp | 2 +- lib/Driver/Tools.cpp | 4 ++-- lib/Parse/ParseStmt.cpp | 2 +- lib/Sema/AttributeList.cpp | 4 ++-- utils/TableGen/ClangAttrEmitter.cpp | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/clang/Sema/AttributeList.h b/include/clang/Sema/AttributeList.h index 6d48e38e3e..6a326f2a4d 100644 --- a/include/clang/Sema/AttributeList.h +++ b/include/clang/Sema/AttributeList.h @@ -493,7 +493,7 @@ public: unsigned getMaxArgs() const; bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const; bool diagnoseLangOpts(class Sema &S) const; - bool existsInTarget(llvm::Triple T) const; + bool existsInTarget(const llvm::Triple &T) const; bool isKnownToGCC() const; /// \brief If the parsed attribute has a semantic equivalent, and it would diff --git a/lib/AST/Mangle.cpp b/lib/AST/Mangle.cpp index 6ab2406079..96e844746c 100644 --- a/lib/AST/Mangle.cpp +++ b/lib/AST/Mangle.cpp @@ -64,7 +64,7 @@ static bool isExternC(const NamedDecl *ND) { static StdOrFastCC getStdOrFastCallMangling(const ASTContext &Context, const NamedDecl *ND) { const TargetInfo &TI = Context.getTargetInfo(); - llvm::Triple Triple = TI.getTriple(); + const llvm::Triple &Triple = TI.getTriple(); if (!Triple.isOSWindows() || Triple.getArch() != llvm::Triple::x86) return SOF_OTHER; diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 83ba05b47f..9232a5d4b0 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -2757,7 +2757,7 @@ static Distro DetectDistro(llvm::Triple::ArchType Arch) { /// a target-triple directory in the library and header search paths. /// Unfortunately, this triple does not align with the vanilla target triple, /// so we provide a rough mapping here. -static std::string getMultiarchTriple(const llvm::Triple TargetTriple, +static std::string getMultiarchTriple(const llvm::Triple &TargetTriple, StringRef SysRoot) { // For most architectures, just use whatever we have rather than trying to be // clever. diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 911b6a02ae..abc8f7dc9a 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -5983,7 +5983,7 @@ void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, } else if (getToolChain().getArch() == llvm::Triple::arm || getToolChain().getArch() == llvm::Triple::thumb) { const Driver &D = getToolChain().getDriver(); - llvm::Triple Triple = getToolChain().getTriple(); + const llvm::Triple &Triple = getToolChain().getTriple(); StringRef FloatABI = arm::getARMFloatABI(D, Args, Triple); if (FloatABI == "hard") { @@ -6591,7 +6591,7 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, SplitDebugName(Args, Inputs)); } -static void AddLibgcc(llvm::Triple Triple, const Driver &D, +static void AddLibgcc(const llvm::Triple &Triple, const Driver &D, ArgStringList &CmdArgs, const ArgList &Args) { bool isAndroid = Triple.getEnvironment() == llvm::Triple::Android; bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 0be14f07ae..87074cc09f 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -2132,7 +2132,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) { SmallVector ClobberRefs; // We need an actual supported target. - llvm::Triple TheTriple = Actions.Context.getTargetInfo().getTriple(); + const llvm::Triple &TheTriple = Actions.Context.getTargetInfo().getTriple(); llvm::Triple::ArchType ArchTy = TheTriple.getArch(); const std::string &TT = TheTriple.getTriple(); const llvm::Target *TheTarget = 0; diff --git a/lib/Sema/AttributeList.cpp b/lib/Sema/AttributeList.cpp index 7258b37ffe..c4c1b805c1 100644 --- a/lib/Sema/AttributeList.cpp +++ b/lib/Sema/AttributeList.cpp @@ -155,7 +155,7 @@ struct ParsedAttrInfo { bool (*DiagAppertainsToDecl)(Sema &S, const AttributeList &Attr, const Decl *); bool (*DiagLangOpts)(Sema &S, const AttributeList &Attr); - bool (*ExistsInTarget)(llvm::Triple T); + bool (*ExistsInTarget)(const llvm::Triple &T); unsigned (*SpellingIndexToSemanticSpelling)(const AttributeList &Attr); }; @@ -195,7 +195,7 @@ bool AttributeList::isTypeAttr() const { return getInfo(*this).IsType; } -bool AttributeList::existsInTarget(llvm::Triple T) const { +bool AttributeList::existsInTarget(const llvm::Triple &T) const { return getInfo(*this).ExistsInTarget(T); } diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index 44f14229f7..b073760414 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -2237,7 +2237,7 @@ static std::string GenerateLangOptRequirements(const Record &R, } static void GenerateDefaultTargetRequirements(raw_ostream &OS) { - OS << "static bool defaultTargetRequirements(llvm::Triple) {\n"; + OS << "static bool defaultTargetRequirements(const llvm::Triple &) {\n"; OS << " return true;\n"; OS << "}\n\n"; } @@ -2313,7 +2313,7 @@ static std::string GenerateTargetRequirements(const Record &Attr, if (I != CustomTargetSet.end()) return *I; - OS << "static bool " << FnName << "(llvm::Triple T) {\n"; + OS << "static bool " << FnName << "(const llvm::Triple &T) {\n"; OS << " llvm::Triple::ArchType Arch = T.getArch();\n"; if (UsesOS) OS << " llvm::Triple::OSType OS = T.getOS();\n"; -- 2.40.0