Add support for the always_inline + target feature diagnostic to print

out the first missing target feature that's required and reword
the diagnostic accordingly.

llvm-svn: 253121
This commit is contained in:
Eric Christopher
2015-11-14 02:38:37 +00:00
parent 7f5ff2175f
commit ce83677666
4 changed files with 16 additions and 10 deletions

View File

@@ -1852,7 +1852,8 @@ template void CGBuilderInserter<PreserveNames>::InsertHelper(
#undef PreserveNames
static bool hasRequiredFeatures(const SmallVectorImpl<StringRef> &ReqFeatures,
CodeGenModule &CGM, const FunctionDecl *FD) {
CodeGenModule &CGM, const FunctionDecl *FD,
std::string &FirstMissing) {
// If there aren't any required features listed then go ahead and return.
if (ReqFeatures.empty())
return false;
@@ -1870,7 +1871,11 @@ static bool hasRequiredFeatures(const SmallVectorImpl<StringRef> &ReqFeatures,
Feature.split(OrFeatures, "|");
return std::any_of(OrFeatures.begin(), OrFeatures.end(),
[&](StringRef Feature) {
return CallerFeatureMap.lookup(Feature);
if (!CallerFeatureMap.lookup(Feature)) {
FirstMissing = Feature.str();
return false;
}
return true;
});
});
}
@@ -1893,6 +1898,7 @@ void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
// the td file with the default cpu, for an always_inline function this is any
// listed cpu and any listed features.
unsigned BuiltinID = TargetDecl->getBuiltinID();
std::string MissingFeature;
if (BuiltinID) {
SmallVector<StringRef, 1> ReqFeatures;
const char *FeatureList =
@@ -1901,8 +1907,7 @@ void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
if (!FeatureList || StringRef(FeatureList) == "")
return;
StringRef(FeatureList).split(ReqFeatures, ",");
if (!hasRequiredFeatures(ReqFeatures, CGM, FD))
if (!hasRequiredFeatures(ReqFeatures, CGM, FD, MissingFeature))
CGM.getDiags().Report(E->getLocStart(), diag::err_builtin_needs_feature)
<< TargetDecl->getDeclName()
<< CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
@@ -1914,8 +1919,8 @@ void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
CGM.getFunctionFeatureMap(CalleeFeatureMap, TargetDecl);
for (const auto &F : CalleeFeatureMap)
ReqFeatures.push_back(F.getKey());
if (!hasRequiredFeatures(ReqFeatures, CGM, FD))
if (!hasRequiredFeatures(ReqFeatures, CGM, FD, MissingFeature))
CGM.getDiags().Report(E->getLocStart(), diag::err_function_needs_feature)
<< FD->getDeclName() << TargetDecl->getDeclName();
<< FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature;
}
}