protze.joachim created this revision.
protze.joachim added reviewers: jdoerfert, aaron.ballman, hokein.
protze.joachim added projects: clang, clang-tools-extra.
Herald added subscribers: usaxena95, kadircet, arphaman, hiraditya.
protze.joachim requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits.
Herald added a project: LLVM.

The warnings for some of the generated and included files can quickly fill 
pages and might hide serious issues. The macro purposely performs tautological 
comparison to filter those cases. Filtering the warning for the respective code 
regions seems a reasonable approach.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103885

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  llvm/lib/Frontend/OpenMP/OMPContext.cpp


Index: llvm/lib/Frontend/OpenMP/OMPContext.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -58,6 +58,10 @@
     break;
   }
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+  // The generated code is expected to generate tautological comparison
+
   // Add the appropriate device architecture trait based on the triple.
 #define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str)         
\
   if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch) {        
\
@@ -68,6 +72,7 @@
       ActiveTraits.set(unsigned(TraitProperty::Enum));                         
\
   }
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
+#pragma clang diagnostic pop
 
   // TODO: What exactly do we want to see as device ISA trait?
   //       The discussion on the list did not seem to have come to an agreed
Index: clang/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -6227,12 +6227,17 @@
                         &ResultBuilder::IsType);
   Results.EnterNewScope();
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+  // The generated code is expected to generate tautological comparison
+
   // Add the names of overloadable operators. Note that OO_Conditional is not
   // actually overloadable.
 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly)  
\
   if (OO_##Name != OO_Conditional)                                             
\
     Results.AddResult(Result(Spelling));
 #include "clang/Basic/OperatorKinds.def"
+#pragma clang diagnostic pop
 
   // Add any type names visible from the current scope
   Results.allowNestedNameSpecifiers();
Index: clang-tools-extra/clangd/CompileCommands.cpp
===================================================================
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -352,6 +352,10 @@
     };
     // Also grab prefixes for each option, these are not fully exposed.
     const char *const *Prefixes[DriverID::LastOption] = {nullptr};
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+    // the generated code is expected to generate tautological comparison
 #define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  
\
                HELP, METAVAR, VALUES)                                          
\
@@ -361,6 +365,7 @@
 #include "clang/Driver/Options.inc"
 #undef OPTION
 #undef PREFIX
+#pragma clang diagnostic pop
 
     auto Result = std::make_unique<TableTy>();
     // Iterate over distinct options (represented by the canonical alias).


Index: llvm/lib/Frontend/OpenMP/OMPContext.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -58,6 +58,10 @@
     break;
   }
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+  // The generated code is expected to generate tautological comparison
+
   // Add the appropriate device architecture trait based on the triple.
 #define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str)         \
   if (TraitSelector::TraitSelectorEnum == TraitSelector::device_arch) {        \
@@ -68,6 +72,7 @@
       ActiveTraits.set(unsigned(TraitProperty::Enum));                         \
   }
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
+#pragma clang diagnostic pop
 
   // TODO: What exactly do we want to see as device ISA trait?
   //       The discussion on the list did not seem to have come to an agreed
Index: clang/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -6227,12 +6227,17 @@
                         &ResultBuilder::IsType);
   Results.EnterNewScope();
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+  // The generated code is expected to generate tautological comparison
+
   // Add the names of overloadable operators. Note that OO_Conditional is not
   // actually overloadable.
 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly)  \
   if (OO_##Name != OO_Conditional)                                             \
     Results.AddResult(Result(Spelling));
 #include "clang/Basic/OperatorKinds.def"
+#pragma clang diagnostic pop
 
   // Add any type names visible from the current scope
   Results.allowNestedNameSpecifiers();
Index: clang-tools-extra/clangd/CompileCommands.cpp
===================================================================
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -352,6 +352,10 @@
     };
     // Also grab prefixes for each option, these are not fully exposed.
     const char *const *Prefixes[DriverID::LastOption] = {nullptr};
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+    // the generated code is expected to generate tautological comparison
 #define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
                HELP, METAVAR, VALUES)                                          \
@@ -361,6 +365,7 @@
 #include "clang/Driver/Options.inc"
 #undef OPTION
 #undef PREFIX
+#pragma clang diagnostic pop
 
     auto Result = std::make_unique<TableTy>();
     // Iterate over distinct options (represented by the canonical alias).
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to