summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2019-08-08 01:45:31 +0000
committerRichard Trieu <rtrieu@google.com>2019-08-08 01:45:31 +0000
commit07e6798baf9aee653168fbb281311358eb483928 (patch)
tree291a216b55343d8815f771c2d1b23e330c118458 /clang/lib/Sema/SemaExpr.cpp
parentb78c8a0a35bc2797ba0d25a2140bc8fb8b3b9764 (diff)
downloadbcm5719-llvm-07e6798baf9aee653168fbb281311358eb483928.tar.gz
bcm5719-llvm-07e6798baf9aee653168fbb281311358eb483928.zip
Inline diagnostic text into .td file. NFC.
llvm-svn: 368244
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b407fb3c137..a4f8660ac53 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10174,45 +10174,55 @@ static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc,
// result.
ValueDecl *DL = getCompareDecl(LHSStripped);
ValueDecl *DR = getCompareDecl(RHSStripped);
+
+ // Used for indexing into %select in warn_comparison_always
+ enum {
+ AlwaysConstant,
+ AlwaysTrue,
+ AlwaysFalse,
+ AlwaysEqual, // std::strong_ordering::equal from operator<=>
+ };
if (DL && DR && declaresSameEntity(DL, DR)) {
- StringRef Result;
+ unsigned Result;
switch (Opc) {
case BO_EQ: case BO_LE: case BO_GE:
- Result = "true";
+ Result = AlwaysTrue;
break;
case BO_NE: case BO_LT: case BO_GT:
- Result = "false";
+ Result = AlwaysFalse;
break;
case BO_Cmp:
- Result = "'std::strong_ordering::equal'";
+ Result = AlwaysEqual;
break;
default:
+ Result = AlwaysConstant;
break;
}
S.DiagRuntimeBehavior(Loc, nullptr,
S.PDiag(diag::warn_comparison_always)
- << 0 /*self-comparison*/ << !Result.empty()
+ << 0 /*self-comparison*/
<< Result);
} else if (DL && DR &&
DL->getType()->isArrayType() && DR->getType()->isArrayType() &&
!DL->isWeak() && !DR->isWeak()) {
// What is it always going to evaluate to?
- StringRef Result;
+ unsigned Result;
switch(Opc) {
case BO_EQ: // e.g. array1 == array2
- Result = "false";
+ Result = AlwaysFalse;
break;
case BO_NE: // e.g. array1 != array2
- Result = "true";
+ Result = AlwaysTrue;
break;
default: // e.g. array1 <= array2
// The best we can say is 'a constant'
+ Result = AlwaysConstant;
break;
}
S.DiagRuntimeBehavior(Loc, nullptr,
S.PDiag(diag::warn_comparison_always)
<< 1 /*array comparison*/
- << !Result.empty() << Result);
+ << Result);
}
if (isa<CastExpr>(LHSStripped))
OpenPOWER on IntegriCloud