summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-07-18 20:41:02 +0000
committerErich Keane <erich.keane@intel.com>2017-07-18 20:41:02 +0000
commitb109a98a7b6b074d57451d73d630fbaf2ff96074 (patch)
tree92ef39fdeea40cf0425e0888f8c9c515e2e9f36d /include
parentf31a13cc41eac5279fd4e0fd01c3a593ba21d338 (diff)
Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further improvements easier
Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further improvements easier The attribute 'target' parse function previously returned a pair. Convert this to a 'pair' in order to add more functionality, and improve usability. Differential Revision: https://reviews.llvm.org/D35574 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Basic/Attr.td24
1 files changed, 17 insertions, 7 deletions
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
index bc36fd8c82..f13e13b010 100644
--- a/include/clang/Basic/Attr.td
+++ b/include/clang/Basic/Attr.td
@@ -1802,11 +1802,18 @@ def Target : InheritableAttr {
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [TargetDocs];
let AdditionalMembers = [{
- typedef std::pair<std::vector<std::string>, StringRef> ParsedTargetAttr;
+ struct ParsedTargetAttr {
+ std::vector<std::string> Features;
+ StringRef Architecture;
+ bool DuplicateArchitecture = false;
+ };
ParsedTargetAttr parse() const {
+ return parse(getFeaturesStr());
+ }
+ static ParsedTargetAttr parse(StringRef Features) {
ParsedTargetAttr Ret;
SmallVector<StringRef, 1> AttrFeatures;
- getFeaturesStr().split(AttrFeatures, ",");
+ Features.split(AttrFeatures, ",");
// Grab the various features and prepend a "+" to turn on the feature to
// the backend and add them to our existing set of features.
@@ -1823,12 +1830,15 @@ def Target : InheritableAttr {
continue;
// While we're here iterating check for a different target cpu.
- if (Feature.startswith("arch="))
- Ret.second = Feature.split("=").second.trim();
- else if (Feature.startswith("no-"))
- Ret.first.push_back("-" + Feature.split("-").second.str());
+ if (Feature.startswith("arch=")) {
+ if (!Ret.Architecture.empty())
+ Ret.DuplicateArchitecture = true;
+ else
+ Ret.Architecture = Feature.split("=").second.trim();
+ } else if (Feature.startswith("no-"))
+ Ret.Features.push_back("-" + Feature.split("-").second.str());
else
- Ret.first.push_back("+" + Feature.str());
+ Ret.Features.push_back("+" + Feature.str());
}
return Ret;
}