Fix -Wstring-compare warnings in new OpenMP code
authorReid Kleckner <rnk@google.com>
Fri, 14 Feb 2020 23:23:42 +0000 (15:23 -0800)
committerReid Kleckner <rnk@google.com>
Fri, 14 Feb 2020 23:23:49 +0000 (15:23 -0800)
llvm/lib/Frontend/OpenMP/OMPContext.cpp

index f4c4bdf..244448c 100644 (file)
@@ -411,7 +411,7 @@ bool llvm::omp::isValidTraitPropertyForTraitSetAndSelector(
 std::string llvm::omp::listOpenMPContextTraitSets() {
   std::string S;
 #define OMP_TRAIT_SET(Enum, Str)                                               \
 std::string llvm::omp::listOpenMPContextTraitSets() {
   std::string S;
 #define OMP_TRAIT_SET(Enum, Str)                                               \
-  if (Str != "invalid")                                                        \
+  if (StringRef(Str) != "invalid")                                             \
     S.append("'").append(Str).append("'").append(" ");
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
   S.pop_back();
     S.append("'").append(Str).append("'").append(" ");
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
   S.pop_back();
@@ -421,7 +421,7 @@ std::string llvm::omp::listOpenMPContextTraitSets() {
 std::string llvm::omp::listOpenMPContextTraitSelectors(TraitSet Set) {
   std::string S;
 #define OMP_TRAIT_SELECTOR(Enum, TraitSetEnum, Str, ReqProp)                   \
 std::string llvm::omp::listOpenMPContextTraitSelectors(TraitSet Set) {
   std::string S;
 #define OMP_TRAIT_SELECTOR(Enum, TraitSetEnum, Str, ReqProp)                   \
-  if (TraitSet::TraitSetEnum == Set && Str != "Invalid")                       \
+  if (TraitSet::TraitSetEnum == Set && StringRef(Str) != "Invalid")            \
     S.append("'").append(Str).append("'").append(" ");
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
   S.pop_back();
     S.append("'").append(Str).append("'").append(" ");
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
   S.pop_back();
@@ -434,7 +434,8 @@ llvm::omp::listOpenMPContextTraitProperties(TraitSet Set,
   std::string S;
 #define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str)         \
   if (TraitSet::TraitSetEnum == Set &&                                         \
   std::string S;
 #define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str)         \
   if (TraitSet::TraitSetEnum == Set &&                                         \
-      TraitSelector::TraitSelectorEnum == Selector && Str != "invalid")        \
+      TraitSelector::TraitSelectorEnum == Selector &&                          \
+      StringRef(Str) != "invalid")                                             \
     S.append("'").append(Str).append("'").append(" ");
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
   S.pop_back();
     S.append("'").append(Str).append("'").append(" ");
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
   S.pop_back();