r177842 - Simplify code. No functionality change.
Benjamin Kramer
benny.kra at googlemail.com
Sun Mar 24 09:04:55 PDT 2013
Author: d0k
Date: Sun Mar 24 11:04:55 2013
New Revision: 177842
URL: http://llvm.org/viewvc/llvm-project?rev=177842&view=rev
Log:
Simplify code. No functionality change.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=177842&r1=177841&r2=177842&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sun Mar 24 11:04:55 2013
@@ -331,10 +331,8 @@ static void GenOpenCLArgMetadata(const F
// 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 F
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 F
// 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 F
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));
More information about the cfe-commits
mailing list