-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][NFC] Remove const_casts from diagnostic emissions #161211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesThis is apparently not necessary anymore. Not sure when exactly it changed though. Full diff: https://github.com/llvm/llvm-project/pull/161211.diff 3 Files Affected:
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 1b66d83df5171..8606227152a84 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -983,10 +983,9 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,
case UninitUse::AfterDecl:
case UninitUse::AfterCall:
S.Diag(VD->getLocation(), diag::warn_sometimes_uninit_var)
- << VD->getDeclName() << IsCapturedByBlock
- << (Use.getKind() == UninitUse::AfterDecl ? 4 : 5)
- << const_cast<DeclContext*>(VD->getLexicalDeclContext())
- << VD->getSourceRange();
+ << VD->getDeclName() << IsCapturedByBlock
+ << (Use.getKind() == UninitUse::AfterDecl ? 4 : 5)
+ << VD->getLexicalDeclContext() << VD->getSourceRange();
S.Diag(Use.getUser()->getBeginLoc(), diag::note_uninit_var_use)
<< IsCapturedByBlock << Use.getUser()->getSourceRange();
return;
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index d238b7916a330..dc6d232d9a525 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -193,7 +193,7 @@ DiagRecursiveConstraintEval(Sema &S, llvm::FoldingSetNodeID &ID,
// Sema::InstantiatingTemplate::isAlreadyBeingInstantiated function.
if (S.SatisfactionStackContains(Templ, ID)) {
S.Diag(E->getExprLoc(), diag::err_constraint_depends_on_self)
- << const_cast<Expr *>(E) << E->getSourceRange();
+ << E << E->getSourceRange();
return true;
}
diff --git a/clang/lib/Sema/SemaOpenACCAtomic.cpp b/clang/lib/Sema/SemaOpenACCAtomic.cpp
index a9319dce6c586..ad21129d30c15 100644
--- a/clang/lib/Sema/SemaOpenACCAtomic.cpp
+++ b/clang/lib/Sema/SemaOpenACCAtomic.cpp
@@ -454,9 +454,7 @@ class AtomicOperandChecker {
// If nothing matches, error out.
DiagnoseInvalidAtomic(BinInf->FoundExpr->getExprLoc(),
SemaRef.PDiag(diag::note_acc_atomic_mismatch_operand)
- << const_cast<Expr *>(AssignInf.LHS)
- << const_cast<Expr *>(BinInf->LHS)
- << const_cast<Expr *>(BinInf->RHS));
+ << AssignInf.LHS << BinInf->LHS << BinInf->RHS);
return IDACInfo::Fail();
}
@@ -592,8 +590,7 @@ class AtomicOperandChecker {
PartialDiagnostic PD =
SemaRef.PDiag(diag::note_acc_atomic_mismatch_compound_operand)
- << FirstKind << const_cast<Expr *>(FirstX) << SecondKind
- << const_cast<Expr *>(SecondX);
+ << FirstKind << FirstX << SecondKind << SecondX;
return DiagnoseInvalidAtomic(SecondX->getExprLoc(), PD);
}
|
This is apparently not necessary anymore. Not sure when exactly it changed though.
S.Diag(VD->getLocation(), diag::warn_sometimes_uninit_var) | ||
<< VD->getDeclName() << IsCapturedByBlock | ||
<< (Use.getKind() == UninitUse::AfterDecl ? 4 : 5) | ||
<< const_cast<DeclContext*>(VD->getLexicalDeclContext()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IT looks like this one goes back to 2013, so I am guessing it used to be const and that changed and this was just missed. The git archeology is not that hard it just requires a few --ignore-rev
's. It would of course be nice if this actually worked on github instead of timing out.
This is apparently not necessary anymore. Not sure when exactly it changed though.