summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2015-10-27 00:06:21 +0000
committerEric Christopher <echristo@gmail.com>2015-10-27 00:06:21 +0000
commit4a4367534b533c1d0064f7e192bb5ef099a994db (patch)
tree2e32f05ed55c495e7292c511158adc033d8dfd58 /clang/lib/CodeGen
parent28d1598e5bae8af21a11837d89b1ea7db8811c6b (diff)
downloadbcm5719-llvm-4a4367534b533c1d0064f7e192bb5ef099a994db.tar.gz
bcm5719-llvm-4a4367534b533c1d0064f7e192bb5ef099a994db.zip
Use early exits to reduce indentation.
llvm-svn: 251371
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp94
1 files changed, 48 insertions, 46 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f9ee711b90a..c3fd54e7b22 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -296,53 +296,55 @@ bool CodeGenFunction::checkBuiltinTargetFeatures(
if (!TargetDecl)
return true;
- // Get the current enclosing function if it exists.
- if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl)) {
- unsigned BuiltinID = TargetDecl->getBuiltinID();
- const char *FeatureList =
- CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
- if (FeatureList && StringRef(FeatureList) != "") {
- StringRef TargetCPU = Target.getTargetOpts().CPU;
- llvm::StringMap<bool> FeatureMap;
-
- if (const auto *TD = FD->getAttr<TargetAttr>()) {
- // If we have a TargetAttr build up the feature map based on that.
- TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
-
- // Make a copy of the features as passed on the command line into the
- // beginning of the additional features from the function to override.
- ParsedAttr.first.insert(
- ParsedAttr.first.begin(),
- Target.getTargetOpts().FeaturesAsWritten.begin(),
- Target.getTargetOpts().FeaturesAsWritten.end());
-
- if (ParsedAttr.second != "")
- TargetCPU = ParsedAttr.second;
-
- // Now populate the feature map, first with the TargetCPU which is
- // either
- // the default or a new one from the target attribute string. Then we'll
- // use the passed in features (FeaturesAsWritten) along with the new
- // ones
- // from the attribute.
- Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
- ParsedAttr.first);
- } else {
- Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
- Target.getTargetOpts().Features);
- }
+ // Get the current enclosing function if it exists. If it doesn't
+ // we can't check the target features anyhow.
+ const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl);
+ if (!FD) return true;
- // If we have at least one of the features in the feature list return
- // true, otherwise return false.
- SmallVector<StringRef, 1> AttrFeatures;
- StringRef(FeatureList).split(AttrFeatures, ",");
- for (const auto &Feature : AttrFeatures)
- if (FeatureMap[Feature])
- return true;
- return false;
- }
- }
- return true;
+ unsigned BuiltinID = TargetDecl->getBuiltinID();
+ const char *FeatureList =
+ CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
+
+ if (!FeatureList || StringRef(FeatureList) == "")
+ return true;
+
+ StringRef TargetCPU = Target.getTargetOpts().CPU;
+ llvm::StringMap<bool> FeatureMap;
+
+ if (const auto *TD = FD->getAttr<TargetAttr>()) {
+ // If we have a TargetAttr build up the feature map based on that.
+ TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
+
+ // Make a copy of the features as passed on the command line into the
+ // beginning of the additional features from the function to override.
+ ParsedAttr.first.insert(ParsedAttr.first.begin(),
+ Target.getTargetOpts().FeaturesAsWritten.begin(),
+ Target.getTargetOpts().FeaturesAsWritten.end());
+
+ if (ParsedAttr.second != "")
+ TargetCPU = ParsedAttr.second;
+
+ // Now populate the feature map, first with the TargetCPU which is
+ // either
+ // the default or a new one from the target attribute string. Then we'll
+ // use the passed in features (FeaturesAsWritten) along with the new
+ // ones
+ // from the attribute.
+ Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
+ ParsedAttr.first);
+ } else {
+ Target.initFeatureMap(FeatureMap, CGM.getDiags(), TargetCPU,
+ Target.getTargetOpts().Features);
+ }
+
+ // If we have at least one of the features in the feature list return
+ // true, otherwise return false.
+ SmallVector<StringRef, 1> AttrFeatures;
+ StringRef(FeatureList).split(AttrFeatures, ",");
+ for (const auto &Feature : AttrFeatures)
+ if (FeatureMap[Feature])
+ return true;
+ return false;
}
RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
OpenPOWER on IntegriCloud