diff options
author | Eric Christopher <echristo@gmail.com> | 2015-11-14 02:38:37 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-11-14 02:38:37 +0000 |
commit | ce836776664802fa636a579012e4addb02f996af (patch) | |
tree | 27da9d19d0098260b9fe3dc0b58835c7947229b3 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 7f5ff2175f68859e71ba2324190c8f0c8c3942e7 (diff) | |
download | bcm5719-llvm-ce836776664802fa636a579012e4addb02f996af.tar.gz bcm5719-llvm-ce836776664802fa636a579012e4addb02f996af.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index b5812c8d314..a425c3e229a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -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; } } |