From f4492448a201c352be3d2e1e76220cf7cd499c55 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 24 Mar 2013 16:04:55 +0000 Subject: Simplify code. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177842 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenFunction.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'lib/CodeGen/CodeGenFunction.cpp') diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index a43148cce7..473a1cba76 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -331,10 +331,8 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, // Turn "unsigned type" to "utype" std::string::size_type pos = typeName.find("unsigned"); - if(pos != std::string::npos) { - typeName = typeName.substr(0, pos+1) + - typeName.substr(pos+9, typeName.size()); - } + if (pos != std::string::npos) + typeName.erase(pos+1, 8); argTypeNames.push_back(llvm::MDString::get(Context, typeName)); @@ -343,15 +341,9 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, typeQuals = "restrict"; if (pointeeTy.isConstQualified() || (pointeeTy.getAddressSpace() == LangAS::opencl_constant)) - if (typeQuals != "") - typeQuals += " const"; - else - typeQuals += "const"; + typeQuals += typeQuals.empty() ? "const" : " const"; if (pointeeTy.isVolatileQualified()) - if (typeQuals != "") - typeQuals += " volatile"; - else - typeQuals += "volatile"; + typeQuals += typeQuals.empty() ? "volatile" : " volatile"; } else { addressQuals.push_back(Builder.getInt32(0)); @@ -360,10 +352,8 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, // Turn "unsigned type" to "utype" std::string::size_type pos = typeName.find("unsigned"); - if(pos != std::string::npos) { - typeName = typeName.substr(0, pos+1) + - typeName.substr(pos+9, typeName.size()); - } + if (pos != std::string::npos) + typeName.erase(pos+1, 8); argTypeNames.push_back(llvm::MDString::get(Context, typeName)); @@ -371,10 +361,7 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, if (ty.isConstQualified()) typeQuals = "const"; if (ty.isVolatileQualified()) - if (typeQuals != "") - typeQuals += " volatile"; - else - typeQuals += "volatile"; + typeQuals += typeQuals.empty() ? "volatile" : " volatile"; } argTypeQuals.push_back(llvm::MDString::get(Context, typeQuals)); -- cgit v1.2.3-18-g5258