<div dir="ltr">Thanks!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 15, 2023 at 11:21 AM Ziqing Luo <<a href="mailto:ziqing@udel.edu">ziqing@udel.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>It is, but sorry I didn't realize that I have a pre-commit hook that clang-formats my patch. This is why there are so many differences.<br></div><div>I will revert and re-commit this change.</div><div><br></div><div>-ziqing<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 15, 2023 at 11:11 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Is this patch the right one for the commit message? This doesn't look like "removing an unnecessary const qualifier"</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 12, 2023 at 2:47 PM via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: ziqingluo-90<br>
Date: 2023-05-12T14:46:56-07:00<br>
New Revision: 7a0900fd3e2d34bc1d513a97cf8fbdc1754252d7<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/7a0900fd3e2d34bc1d513a97cf8fbdc1754252d7" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/7a0900fd3e2d34bc1d513a97cf8fbdc1754252d7</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/7a0900fd3e2d34bc1d513a97cf8fbdc1754252d7.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/7a0900fd3e2d34bc1d513a97cf8fbdc1754252d7.diff</a><br>
<br>
LOG: [-Wunsafe-buffer-usage] Remove an unnecessary const-qualifier<br>
<br>
A follow-up change for 6d861d498de1320d22771c329ec69f9419ef06b7:<br>
remove an unnecessary const-qualifier so that the code doesn't have to<br>
remove the qualifier explicitly using `std::remove_const_t`, which<br>
triggers a warning at some bots (e.g.,<br>
<a href="https://lab.llvm.org/buildbot/#/builders/247/builds/4442" rel="noreferrer" target="_blank">https://lab.llvm.org/buildbot/#/builders/247/builds/4442</a>).<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
clang/include/clang/Sema/AnalysisBasedWarnings.h<br>
clang/lib/Sema/AnalysisBasedWarnings.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff --git a/clang/include/clang/Sema/AnalysisBasedWarnings.h b/clang/include/clang/Sema/AnalysisBasedWarnings.h<br>
index c73506894db9d..7d0fa9541c352 100644<br>
--- a/clang/include/clang/Sema/AnalysisBasedWarnings.h<br>
+++ b/clang/include/clang/Sema/AnalysisBasedWarnings.h<br>
@@ -24,7 +24,7 @@ class FunctionDecl;<br>
class QualType;<br>
class Sema;<br>
namespace sema {<br>
- class FunctionScopeInfo;<br>
+class FunctionScopeInfo;<br>
}<br>
<br>
namespace sema {<br>
@@ -38,6 +38,7 @@ class AnalysisBasedWarnings {<br>
unsigned enableCheckUnreachable : 1;<br>
unsigned enableThreadSafetyAnalysis : 1;<br>
unsigned enableConsumedAnalysis : 1;<br>
+<br>
public:<br>
Policy();<br>
void disableCheckFallThrough() { enableCheckFallThrough = 0; }<br>
@@ -51,7 +52,7 @@ class AnalysisBasedWarnings {<br>
std::unique_ptr<InterProceduralData> IPData;<br>
<br>
enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };<br>
- llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;<br>
+ llvm::DenseMap<const FunctionDecl *, VisitFlag> VisitedFD;<br>
<br>
/// \name Statistics<br>
/// @{<br>
@@ -93,11 +94,11 @@ class AnalysisBasedWarnings {<br>
AnalysisBasedWarnings(Sema &s);<br>
~AnalysisBasedWarnings();<br>
<br>
- void IssueWarnings(Policy P, FunctionScopeInfo *fscope,<br>
- const Decl *D, QualType BlockType);<br>
+ void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D,<br>
+ QualType BlockType);<br>
<br>
// Issue warnings that require whole-translation-unit analysis.<br>
- void IssueWarnings(const TranslationUnitDecl *D);<br>
+ void IssueWarnings(TranslationUnitDecl *D);<br>
<br>
Policy getDefaultPolicy() { return DefaultPolicy; }<br>
<br>
<br>
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp<br>
index 4d96f3b9ab32b..c2b6d362d966d 100644<br>
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp<br>
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp<br>
@@ -1,4 +1,5 @@<br>
-//=- AnalysisBasedWarnings.cpp - Sema warnings based on libAnalysis -*- C++ -*-=//<br>
+//=- AnalysisBasedWarnings.cpp - Sema warnings based on libAnalysis -*- C++<br>
+//-*-=//<br>
//<br>
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
// See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
@@ -26,7 +27,6 @@<br>
#include "clang/AST/StmtCXX.h"<br>
#include "clang/AST/StmtObjC.h"<br>
#include "clang/AST/StmtVisitor.h"<br>
-#include "clang/AST/RecursiveASTVisitor.h"<br>
#include "clang/AST/Type.h"<br>
#include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"<br>
#include "clang/Analysis/Analyses/CalledOnceCheck.h"<br>
@@ -64,61 +64,60 @@ using namespace clang;<br>
//===----------------------------------------------------------------------===//<br>
<br>
namespace {<br>
- class UnreachableCodeHandler : public reachable_code::Callback {<br>
- Sema &S;<br>
- SourceRange PreviousSilenceableCondVal;<br>
-<br>
- public:<br>
- UnreachableCodeHandler(Sema &s) : S(s) {}<br>
-<br>
- void HandleUnreachable(reachable_code::UnreachableKind UK, SourceLocation L,<br>
- SourceRange SilenceableCondVal, SourceRange R1,<br>
- SourceRange R2, bool HasFallThroughAttr) override {<br>
- // If the diagnosed code is `[[fallthrough]];` and<br>
- // `-Wunreachable-code-fallthrough` is enabled, suppress `code will never<br>
- // be executed` warning to avoid generating diagnostic twice<br>
- if (HasFallThroughAttr &&<br>
- !S.getDiagnostics().isIgnored(diag::warn_unreachable_fallthrough_attr,<br>
- SourceLocation()))<br>
- return;<br>
-<br>
- // Avoid reporting multiple unreachable code diagnostics that are<br>
- // triggered by the same conditional value.<br>
- if (PreviousSilenceableCondVal.isValid() &&<br>
- SilenceableCondVal.isValid() &&<br>
- PreviousSilenceableCondVal == SilenceableCondVal)<br>
- return;<br>
- PreviousSilenceableCondVal = SilenceableCondVal;<br>
-<br>
- unsigned diag = diag::warn_unreachable;<br>
- switch (UK) {<br>
- case reachable_code::UK_Break:<br>
- diag = diag::warn_unreachable_break;<br>
- break;<br>
- case reachable_code::UK_Return:<br>
- diag = diag::warn_unreachable_return;<br>
- break;<br>
- case reachable_code::UK_Loop_Increment:<br>
- diag = diag::warn_unreachable_loop_increment;<br>
- break;<br>
- case reachable_code::UK_Other:<br>
- break;<br>
- }<br>
+class UnreachableCodeHandler : public reachable_code::Callback {<br>
+ Sema &S;<br>
+ SourceRange PreviousSilenceableCondVal;<br>
+<br>
+public:<br>
+ UnreachableCodeHandler(Sema &s) : S(s) {}<br>
+<br>
+ void HandleUnreachable(reachable_code::UnreachableKind UK, SourceLocation L,<br>
+ SourceRange SilenceableCondVal, SourceRange R1,<br>
+ SourceRange R2, bool HasFallThroughAttr) override {<br>
+ // If the diagnosed code is `[[fallthrough]];` and<br>
+ // `-Wunreachable-code-fallthrough` is enabled, suppress `code will never<br>
+ // be executed` warning to avoid generating diagnostic twice<br>
+ if (HasFallThroughAttr &&<br>
+ !S.getDiagnostics().isIgnored(diag::warn_unreachable_fallthrough_attr,<br>
+ SourceLocation()))<br>
+ return;<br>
+<br>
+ // Avoid reporting multiple unreachable code diagnostics that are<br>
+ // triggered by the same conditional value.<br>
+ if (PreviousSilenceableCondVal.isValid() && SilenceableCondVal.isValid() &&<br>
+ PreviousSilenceableCondVal == SilenceableCondVal)<br>
+ return;<br>
+ PreviousSilenceableCondVal = SilenceableCondVal;<br>
+<br>
+ unsigned diag = diag::warn_unreachable;<br>
+ switch (UK) {<br>
+ case reachable_code::UK_Break:<br>
+ diag = diag::warn_unreachable_break;<br>
+ break;<br>
+ case reachable_code::UK_Return:<br>
+ diag = diag::warn_unreachable_return;<br>
+ break;<br>
+ case reachable_code::UK_Loop_Increment:<br>
+ diag = diag::warn_unreachable_loop_increment;<br>
+ break;<br>
+ case reachable_code::UK_Other:<br>
+ break;<br>
+ }<br>
<br>
- S.Diag(L, diag) << R1 << R2;<br>
+ S.Diag(L, diag) << R1 << R2;<br>
<br>
- SourceLocation Open = SilenceableCondVal.getBegin();<br>
- if (Open.isValid()) {<br>
- SourceLocation Close = SilenceableCondVal.getEnd();<br>
- Close = S.getLocForEndOfToken(Close);<br>
- if (Close.isValid()) {<br>
- S.Diag(Open, diag::note_unreachable_silence)<br>
+ SourceLocation Open = SilenceableCondVal.getBegin();<br>
+ if (Open.isValid()) {<br>
+ SourceLocation Close = SilenceableCondVal.getEnd();<br>
+ Close = S.getLocForEndOfToken(Close);<br>
+ if (Close.isValid()) {<br>
+ S.Diag(Open, diag::note_unreachable_silence)<br>
<< FixItHint::CreateInsertion(Open, "/* DISABLES CODE */ (")<br>
<< FixItHint::CreateInsertion(Close, ")");<br>
- }<br>
}<br>
}<br>
- };<br>
+ }<br>
+};<br>
} // anonymous namespace<br>
<br>
/// CheckUnreachable - Check for unreachable code.<br>
@@ -278,7 +277,8 @@ static void checkRecursiveFunction(Sema &S, const FunctionDecl *FD,<br>
return;<br>
<br>
CFG *cfg = AC.getCFG();<br>
- if (!cfg) return;<br>
+ if (!cfg)<br>
+ return;<br>
<br>
// If the exit block is unreachable, skip processing the function.<br>
if (cfg->getExit().pred_empty())<br>
@@ -314,10 +314,9 @@ static bool throwEscapes(Sema &S, const CXXThrowExpr *E, CFGBlock &ThrowBlock,<br>
if (Succ->getBlockID() == Body->getExit().getBlockID())<br>
return true;<br>
<br>
- if (auto *Catch =<br>
- dyn_cast_or_null<CXXCatchStmt>(Succ->getLabel())) {<br>
+ if (auto *Catch = dyn_cast_or_null<CXXCatchStmt>(Succ->getLabel())) {<br>
QualType Caught = Catch->getCaughtType();<br>
- if (Caught.isNull() || // catch (...) catches everything<br>
+ if (Caught.isNull() || // catch (...) catches everything<br>
!E->getSubExpr() || // throw; is considered cuaght by any handler<br>
S.handlerCanCatch(Caught, E->getSubExpr()->getType()))<br>
// Exception doesn't escape via this path.<br>
@@ -336,7 +335,8 @@ static void visitReachableThrows(<br>
CFG *BodyCFG,<br>
llvm::function_ref<void(const CXXThrowExpr *, CFGBlock &)> Visit) {<br>
llvm::BitVector Reachable(BodyCFG->getNumBlockIDs());<br>
- clang::reachable_code::ScanReachableFromBlock(&BodyCFG->getEntry(), Reachable);<br>
+ clang::reachable_code::ScanReachableFromBlock(&BodyCFG->getEntry(),<br>
+ Reachable);<br>
for (CFGBlock *B : *BodyCFG) {<br>
if (!Reachable[B->getBlockID()])<br>
continue;<br>
@@ -359,8 +359,8 @@ static void EmitDiagForCXXThrowInNonThrowingFunc(Sema &S, SourceLocation OpLoc,<br>
(isa<CXXDestructorDecl>(FD) ||<br>
FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||<br>
FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete)) {<br>
- if (const auto *Ty = FD->getTypeSourceInfo()->getType()-><br>
- getAs<FunctionProtoType>())<br>
+ if (const auto *Ty =<br>
+ FD->getTypeSourceInfo()->getType()->getAs<FunctionProtoType>())<br>
S.Diag(FD->getLocation(), diag::note_throw_in_dtor)<br>
<< !isa<CXXDestructorDecl>(FD) << !Ty->hasExceptionSpec()<br>
<< FD->getExceptionSpecSourceRange();<br>
@@ -377,10 +377,11 @@ static void checkThrowInNonThrowingFunc(Sema &S, const FunctionDecl *FD,<br>
return;<br>
if (BodyCFG->getExit().pred_empty())<br>
return;<br>
- visitReachableThrows(BodyCFG, [&](const CXXThrowExpr *Throw, CFGBlock &Block) {<br>
- if (throwEscapes(S, Throw, Block, BodyCFG))<br>
- EmitDiagForCXXThrowInNonThrowingFunc(S, Throw->getThrowLoc(), FD);<br>
- });<br>
+ visitReachableThrows(<br>
+ BodyCFG, [&](const CXXThrowExpr *Throw, CFGBlock &Block) {<br>
+ if (throwEscapes(S, Throw, Block, BodyCFG))<br>
+ EmitDiagForCXXThrowInNonThrowingFunc(S, Throw->getThrowLoc(), FD);<br>
+ });<br>
}<br>
<br>
static bool isNoexcept(const FunctionDecl *FD) {<br>
@@ -413,13 +414,14 @@ enum ControlFlowKind {<br>
/// will return.<br>
static ControlFlowKind CheckFallThrough(AnalysisDeclContext &AC) {<br>
CFG *cfg = AC.getCFG();<br>
- if (!cfg) return UnknownFallThrough;<br>
+ if (!cfg)<br>
+ return UnknownFallThrough;<br>
<br>
// The CFG leaves in dead things, and we don't want the dead code paths to<br>
// confuse us, so we mark all live things first.<br>
llvm::BitVector live(cfg->getNumBlockIDs());<br>
- unsigned count = reachable_code::ScanReachableFromBlock(&cfg->getEntry(),<br>
- live);<br>
+ unsigned count =<br>
+ reachable_code::ScanReachableFromBlock(&cfg->getEntry(), live);<br>
<br>
bool AddEHEdges = AC.getAddEHEdges();<br>
if (!AddEHEdges && count != cfg->getNumBlockIDs())<br>
@@ -472,7 +474,7 @@ static ControlFlowKind CheckFallThrough(AnalysisDeclContext &AC) {<br>
// statement (if it exists).<br>
CFGBlock::const_reverse_iterator ri = B.rbegin(), re = B.rend();<br>
<br>
- for ( ; ri != re ; ++ri)<br>
+ for (; ri != re; ++ri)<br>
if (ri->getAs<CFGStmt>())<br>
break;<br>
<br>
@@ -546,14 +548,12 @@ struct CheckFallThroughDiagnostics {<br>
static CheckFallThroughDiagnostics MakeForFunction(const Decl *Func) {<br>
CheckFallThroughDiagnostics D;<br>
D.FuncLoc = Func->getLocation();<br>
- D.diag_MaybeFallThrough_HasNoReturn =<br>
- diag::warn_falloff_noreturn_function;<br>
+ D.diag_MaybeFallThrough_HasNoReturn = diag::warn_falloff_noreturn_function;<br>
D.diag_MaybeFallThrough_ReturnsNonVoid =<br>
- diag::warn_maybe_falloff_nonvoid_function;<br>
- D.diag_AlwaysFallThrough_HasNoReturn =<br>
- diag::warn_falloff_noreturn_function;<br>
+ diag::warn_maybe_falloff_nonvoid_function;<br>
+ D.diag_AlwaysFallThrough_HasNoReturn = diag::warn_falloff_noreturn_function;<br>
D.diag_AlwaysFallThrough_ReturnsNonVoid =<br>
- diag::warn_falloff_nonvoid_function;<br>
+ diag::warn_falloff_nonvoid_function;<br>
<br>
// Don't suggest that virtual functions be marked "noreturn", since they<br>
// might be overridden by non-noreturn functions.<br>
@@ -567,8 +567,7 @@ struct CheckFallThroughDiagnostics {<br>
isTemplateInstantiation = Function->isTemplateInstantiation();<br>
<br>
if (!isVirtualMethod && !isTemplateInstantiation)<br>
- D.diag_NeverFallThroughOrReturn =<br>
- diag::warn_suggest_noreturn_function;<br>
+ D.diag_NeverFallThroughOrReturn = diag::warn_suggest_noreturn_function;<br>
else<br>
D.diag_NeverFallThroughOrReturn = 0;<br>
<br>
@@ -593,13 +592,12 @@ struct CheckFallThroughDiagnostics {<br>
static CheckFallThroughDiagnostics MakeForBlock() {<br>
CheckFallThroughDiagnostics D;<br>
D.diag_MaybeFallThrough_HasNoReturn =<br>
- diag::err_noreturn_block_has_return_expr;<br>
+ diag::err_noreturn_block_has_return_expr;<br>
D.diag_MaybeFallThrough_ReturnsNonVoid =<br>
- diag::err_maybe_falloff_nonvoid_block;<br>
+ diag::err_maybe_falloff_nonvoid_block;<br>
D.diag_AlwaysFallThrough_HasNoReturn =<br>
- diag::err_noreturn_block_has_return_expr;<br>
- D.diag_AlwaysFallThrough_ReturnsNonVoid =<br>
- diag::err_falloff_nonvoid_block;<br>
+ diag::err_noreturn_block_has_return_expr;<br>
+ D.diag_AlwaysFallThrough_ReturnsNonVoid = diag::err_falloff_nonvoid_block;<br>
D.diag_NeverFallThroughOrReturn = 0;<br>
D.funMode = Block;<br>
return D;<br>
@@ -608,13 +606,12 @@ struct CheckFallThroughDiagnostics {<br>
static CheckFallThroughDiagnostics MakeForLambda() {<br>
CheckFallThroughDiagnostics D;<br>
D.diag_MaybeFallThrough_HasNoReturn =<br>
- diag::err_noreturn_lambda_has_return_expr;<br>
+ diag::err_noreturn_lambda_has_return_expr;<br>
D.diag_MaybeFallThrough_ReturnsNonVoid =<br>
- diag::warn_maybe_falloff_nonvoid_lambda;<br>
+ diag::warn_maybe_falloff_nonvoid_lambda;<br>
D.diag_AlwaysFallThrough_HasNoReturn =<br>
- diag::err_noreturn_lambda_has_return_expr;<br>
- D.diag_AlwaysFallThrough_ReturnsNonVoid =<br>
- diag::warn_falloff_nonvoid_lambda;<br>
+ diag::err_noreturn_lambda_has_return_expr;<br>
+ D.diag_AlwaysFallThrough_ReturnsNonVoid = diag::warn_falloff_nonvoid_lambda;<br>
D.diag_NeverFallThroughOrReturn = 0;<br>
D.funMode = Lambda;<br>
return D;<br>
@@ -666,14 +663,12 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,<br>
else<br>
ReturnsVoid = FD->getReturnType()->isVoidType();<br>
HasNoReturn = FD->isNoReturn();<br>
- }<br>
- else if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {<br>
+ } else if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {<br>
ReturnsVoid = MD->getReturnType()->isVoidType();<br>
HasNoReturn = MD->hasAttr<NoReturnAttr>();<br>
- }<br>
- else if (isa<BlockDecl>(D)) {<br>
+ } else if (isa<BlockDecl>(D)) {<br>
if (const FunctionType *FT =<br>
- BlockType->getPointeeType()->getAs<FunctionType>()) {<br>
+ BlockType->getPointeeType()->getAs<FunctionType>()) {<br>
if (FT->getReturnType()->isVoidType())<br>
ReturnsVoid = true;<br>
if (FT->getNoReturnAttr())<br>
@@ -685,7 +680,7 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,<br>
<br>
// Short circuit for compilation speed.<br>
if (CD.checkDiagnostics(Diags, ReturnsVoid, HasNoReturn))<br>
- return;<br>
+ return;<br>
SourceLocation LBrace = Body->getBeginLoc(), RBrace = Body->getEndLoc();<br>
auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) {<br>
if (IsCoroutine)<br>
@@ -700,34 +695,34 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,<br>
<br>
// Either in a function body compound statement, or a function-try-block.<br>
switch (CheckFallThrough(AC)) {<br>
- case UnknownFallThrough:<br>
- break;<br>
+ case UnknownFallThrough:<br>
+ break;<br>
<br>
- case MaybeFallThrough:<br>
- if (HasNoReturn)<br>
- EmitDiag(RBrace, CD.diag_MaybeFallThrough_HasNoReturn);<br>
- else if (!ReturnsVoid)<br>
- EmitDiag(RBrace, CD.diag_MaybeFallThrough_ReturnsNonVoid);<br>
- break;<br>
- case AlwaysFallThrough:<br>
- if (HasNoReturn)<br>
- EmitDiag(RBrace, CD.diag_AlwaysFallThrough_HasNoReturn);<br>
- else if (!ReturnsVoid)<br>
- EmitDiag(RBrace, CD.diag_AlwaysFallThrough_ReturnsNonVoid);<br>
- break;<br>
- case NeverFallThroughOrReturn:<br>
- if (ReturnsVoid && !HasNoReturn && CD.diag_NeverFallThroughOrReturn) {<br>
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {<br>
- S.Diag(LBrace, CD.diag_NeverFallThroughOrReturn) << 0 << FD;<br>
- } else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {<br>
- S.Diag(LBrace, CD.diag_NeverFallThroughOrReturn) << 1 << MD;<br>
- } else {<br>
- S.Diag(LBrace, CD.diag_NeverFallThroughOrReturn);<br>
- }<br>
+ case MaybeFallThrough:<br>
+ if (HasNoReturn)<br>
+ EmitDiag(RBrace, CD.diag_MaybeFallThrough_HasNoReturn);<br>
+ else if (!ReturnsVoid)<br>
+ EmitDiag(RBrace, CD.diag_MaybeFallThrough_ReturnsNonVoid);<br>
+ break;<br>
+ case AlwaysFallThrough:<br>
+ if (HasNoReturn)<br>
+ EmitDiag(RBrace, CD.diag_AlwaysFallThrough_HasNoReturn);<br>
+ else if (!ReturnsVoid)<br>
+ EmitDiag(RBrace, CD.diag_AlwaysFallThrough_ReturnsNonVoid);<br>
+ break;<br>
+ case NeverFallThroughOrReturn:<br>
+ if (ReturnsVoid && !HasNoReturn && CD.diag_NeverFallThroughOrReturn) {<br>
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {<br>
+ S.Diag(LBrace, CD.diag_NeverFallThroughOrReturn) << 0 << FD;<br>
+ } else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {<br>
+ S.Diag(LBrace, CD.diag_NeverFallThroughOrReturn) << 1 << MD;<br>
+ } else {<br>
+ S.Diag(LBrace, CD.diag_NeverFallThroughOrReturn);<br>
}<br>
- break;<br>
- case NeverFallThrough:<br>
- break;<br>
+ }<br>
+ break;<br>
+ case NeverFallThrough:<br>
+ break;<br>
}<br>
}<br>
<br>
@@ -747,7 +742,7 @@ class ContainsReference : public ConstEvaluatedExprVisitor<ContainsReference> {<br>
typedef ConstEvaluatedExprVisitor<ContainsReference> Inherited;<br>
<br>
ContainsReference(ASTContext &Context, const DeclRefExpr *Needle)<br>
- : Inherited(Context), FoundReference(false), Needle(Needle) {}<br>
+ : Inherited(Context), FoundReference(false), Needle(Needle) {}<br>
<br>
void VisitExpr(const Expr *E) {<br>
// Stop evaluating if we already have a reference.<br>
@@ -770,8 +765,7 @@ class ContainsReference : public ConstEvaluatedExprVisitor<ContainsReference> {<br>
<br>
static bool SuggestInitializationFixit(Sema &S, const VarDecl *VD) {<br>
QualType VariableTy = VD->getType().getCanonicalType();<br>
- if (VariableTy->isBlockPointerType() &&<br>
- !VD->hasAttr<BlocksAttr>()) {<br>
+ if (VariableTy->isBlockPointerType() && !VD->hasAttr<BlocksAttr>()) {<br>
S.Diag(VD->getLocation(), diag::note_block_var_fixit_add_initialization)<br>
<< VD->getDeclName()<br>
<< FixItHint::CreateInsertion(VD->getLocation(), "__block ");<br>
@@ -793,16 +787,16 @@ static bool SuggestInitializationFixit(Sema &S, const VarDecl *VD) {<br>
if (Init.empty())<br>
return false;<br>
<br>
- S.Diag(Loc, diag::note_var_fixit_add_initialization) << VD->getDeclName()<br>
- << FixItHint::CreateInsertion(Loc, Init);<br>
+ S.Diag(Loc, diag::note_var_fixit_add_initialization)<br>
+ << VD->getDeclName() << FixItHint::CreateInsertion(Loc, Init);<br>
return true;<br>
}<br>
<br>
/// Create a fixit to remove an if-like statement, on the assumption that its<br>
/// condition is CondVal.<br>
static void CreateIfFixit(Sema &S, const Stmt *If, const Stmt *Then,<br>
- const Stmt *Else, bool CondVal,<br>
- FixItHint &Fixit1, FixItHint &Fixit2) {<br>
+ const Stmt *Else, bool CondVal, FixItHint &Fixit1,<br>
+ FixItHint &Fixit2) {<br>
if (CondVal) {<br>
// If condition is always true, remove all but the 'then'.<br>
Fixit1 = FixItHint::CreateRemoval(<br>
@@ -838,10 +832,10 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,<br>
case UninitUse::AfterDecl:<br>
case UninitUse::AfterCall:<br>
S.Diag(VD->getLocation(), diag::warn_sometimes_uninit_var)<br>
- << VD->getDeclName() << IsCapturedByBlock<br>
- << (Use.getKind() == UninitUse::AfterDecl ? 4 : 5)<br>
- << const_cast<DeclContext*>(VD->getLexicalDeclContext())<br>
- << VD->getSourceRange();<br>
+ << VD->getDeclName() << IsCapturedByBlock<br>
+ << (Use.getKind() == UninitUse::AfterDecl ? 4 : 5)<br>
+ << const_cast<DeclContext *>(VD->getLexicalDeclContext())<br>
+ << VD->getSourceRange();<br>
S.Diag(Use.getUser()->getBeginLoc(), diag::note_uninit_var_use)<br>
<< IsCapturedByBlock << Use.getUser()->getSourceRange();<br>
return;<br>
@@ -870,9 +864,9 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,<br>
// For all binary terminators, branch 0 is taken if the condition is true,<br>
// and branch 1 is taken if the condition is false.<br>
int RemoveDiagKind = -1;<br>
- const char *FixitStr =<br>
- S.getLangOpts().CPlusPlus ? (I->Output ? "true" : "false")<br>
- : (I->Output ? "1" : "0");<br>
+ const char *FixitStr = S.getLangOpts().CPlusPlus<br>
+ ? (I->Output ? "true" : "false")<br>
+ : (I->Output ? "1" : "0");<br>
FixItHint Fixit1, Fixit2;<br>
<br>
switch (Term ? Term->getStmtClass() : Stmt::DeclStmtClass) {<br>
@@ -888,8 +882,8 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,<br>
Str = "if";<br>
Range = IS->getCond()->getSourceRange();<br>
RemoveDiagKind = 0;<br>
- CreateIfFixit(S, IS, IS->getThen(), IS->getElse(),<br>
- I->Output, Fixit1, Fixit2);<br>
+ CreateIfFixit(S, IS, IS->getThen(), IS->getElse(), I->Output, Fixit1,<br>
+ Fixit2);<br>
break;<br>
}<br>
case Stmt::ConditionalOperatorClass: {<br>
@@ -898,8 +892,8 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,<br>
Str = "?:";<br>
Range = CO->getCond()->getSourceRange();<br>
RemoveDiagKind = 0;<br>
- CreateIfFixit(S, CO, CO->getTrueExpr(), CO->getFalseExpr(),<br>
- I->Output, Fixit1, Fixit2);<br>
+ CreateIfFixit(S, CO, CO->getTrueExpr(), CO->getFalseExpr(), I->Output,<br>
+ Fixit1, Fixit2);<br>
break;<br>
}<br>
case Stmt::BinaryOperatorClass: {<br>
@@ -974,13 +968,13 @@ static void DiagUninitUse(Sema &S, const VarDecl *VD, const UninitUse &Use,<br>
}<br>
<br>
S.Diag(Range.getBegin(), diag::warn_sometimes_uninit_var)<br>
- << VD->getDeclName() << IsCapturedByBlock << DiagKind<br>
- << Str << I->Output << Range;<br>
+ << VD->getDeclName() << IsCapturedByBlock << DiagKind << Str<br>
+ << I->Output << Range;<br>
S.Diag(User->getBeginLoc(), diag::note_uninit_var_use)<br>
<< IsCapturedByBlock << User->getSourceRange();<br>
if (RemoveDiagKind != -1)<br>
S.Diag(Fixit1.RemoveRange.getBegin(), diag::note_uninit_fixit_remove_cond)<br>
- << RemoveDiagKind << Str << I->Output << Fixit1 << Fixit2;<br>
+ << RemoveDiagKind << Str << I->Output << Fixit1 << Fixit2;<br>
<br>
Diagnosed = true;<br>
}<br>
@@ -1055,81 +1049,77 @@ static bool DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,<br>
}<br>
<br>
namespace {<br>
- class FallthroughMapper : public RecursiveASTVisitor<FallthroughMapper> {<br>
- public:<br>
- FallthroughMapper(Sema &S)<br>
- : FoundSwitchStatements(false),<br>
- S(S) {<br>
- }<br>
+class FallthroughMapper : public RecursiveASTVisitor<FallthroughMapper> {<br>
+public:<br>
+ FallthroughMapper(Sema &S) : FoundSwitchStatements(false), S(S) {}<br>
<br>
- bool foundSwitchStatements() const { return FoundSwitchStatements; }<br>
+ bool foundSwitchStatements() const { return FoundSwitchStatements; }<br>
<br>
- void markFallthroughVisited(const AttributedStmt *Stmt) {<br>
- bool Found = FallthroughStmts.erase(Stmt);<br>
- assert(Found);<br>
- (void)Found;<br>
- }<br>
+ void markFallthroughVisited(const AttributedStmt *Stmt) {<br>
+ bool Found = FallthroughStmts.erase(Stmt);<br>
+ assert(Found);<br>
+ (void)Found;<br>
+ }<br>
+<br>
+ typedef llvm::SmallPtrSet<const AttributedStmt *, 8> AttrStmts;<br>
+<br>
+ const AttrStmts &getFallthroughStmts() const { return FallthroughStmts; }<br>
<br>
- typedef llvm::SmallPtrSet<const AttributedStmt*, 8> AttrStmts;<br>
+ void fillReachableBlocks(CFG *Cfg) {<br>
+ assert(ReachableBlocks.empty() && "ReachableBlocks already filled");<br>
+ std::deque<const CFGBlock *> BlockQueue;<br>
<br>
- const AttrStmts &getFallthroughStmts() const {<br>
- return FallthroughStmts;<br>
+ ReachableBlocks.insert(&Cfg->getEntry());<br>
+ BlockQueue.push_back(&Cfg->getEntry());<br>
+ // Mark all case blocks reachable to avoid problems with switching on<br>
+ // constants, covered enums, etc.<br>
+ // These blocks can contain fall-through annotations, and we don't want to<br>
+ // issue a warn_fallthrough_attr_unreachable for them.<br>
+ for (const auto *B : *Cfg) {<br>
+ const Stmt *L = B->getLabel();<br>
+ if (L && isa<SwitchCase>(L) && ReachableBlocks.insert(B).second)<br>
+ BlockQueue.push_back(B);<br>
}<br>
<br>
- void fillReachableBlocks(CFG *Cfg) {<br>
- assert(ReachableBlocks.empty() && "ReachableBlocks already filled");<br>
- std::deque<const CFGBlock *> BlockQueue;<br>
-<br>
- ReachableBlocks.insert(&Cfg->getEntry());<br>
- BlockQueue.push_back(&Cfg->getEntry());<br>
- // Mark all case blocks reachable to avoid problems with switching on<br>
- // constants, covered enums, etc.<br>
- // These blocks can contain fall-through annotations, and we don't want to<br>
- // issue a warn_fallthrough_attr_unreachable for them.<br>
- for (const auto *B : *Cfg) {<br>
- const Stmt *L = B->getLabel();<br>
- if (L && isa<SwitchCase>(L) && ReachableBlocks.insert(B).second)<br>
+ while (!BlockQueue.empty()) {<br>
+ const CFGBlock *P = BlockQueue.front();<br>
+ BlockQueue.pop_front();<br>
+ for (const CFGBlock *B : P->succs()) {<br>
+ if (B && ReachableBlocks.insert(B).second)<br>
BlockQueue.push_back(B);<br>
}<br>
-<br>
- while (!BlockQueue.empty()) {<br>
- const CFGBlock *P = BlockQueue.front();<br>
- BlockQueue.pop_front();<br>
- for (const CFGBlock *B : P->succs()) {<br>
- if (B && ReachableBlocks.insert(B).second)<br>
- BlockQueue.push_back(B);<br>
- }<br>
- }<br>
}<br>
+ }<br>
<br>
- bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt,<br>
- bool IsTemplateInstantiation) {<br>
- assert(!ReachableBlocks.empty() && "ReachableBlocks empty");<br>
+ bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt,<br>
+ bool IsTemplateInstantiation) {<br>
+ assert(!ReachableBlocks.empty() && "ReachableBlocks empty");<br>
<br>
- int UnannotatedCnt = 0;<br>
- AnnotatedCnt = 0;<br>
+ int UnannotatedCnt = 0;<br>
+ AnnotatedCnt = 0;<br>
<br>
- std::deque<const CFGBlock*> BlockQueue(B.pred_begin(), B.pred_end());<br>
- while (!BlockQueue.empty()) {<br>
- const CFGBlock *P = BlockQueue.front();<br>
- BlockQueue.pop_front();<br>
- if (!P) continue;<br>
+ std::deque<const CFGBlock *> BlockQueue(B.pred_begin(), B.pred_end());<br>
+ while (!BlockQueue.empty()) {<br>
+ const CFGBlock *P = BlockQueue.front();<br>
+ BlockQueue.pop_front();<br>
+ if (!P)<br>
+ continue;<br>
<br>
- const Stmt *Term = P->getTerminatorStmt();<br>
- if (Term && isa<SwitchStmt>(Term))<br>
- continue; // Switch statement, good.<br>
+ const Stmt *Term = P->getTerminatorStmt();<br>
+ if (Term && isa<SwitchStmt>(Term))<br>
+ continue; // Switch statement, good.<br>
<br>
- const SwitchCase *SW = dyn_cast_or_null<SwitchCase>(P->getLabel());<br>
- if (SW && SW->getSubStmt() == B.getLabel() && P->begin() == P->end())<br>
- continue; // Previous case label has no statements, good.<br>
+ const SwitchCase *SW = dyn_cast_or_null<SwitchCase>(P->getLabel());<br>
+ if (SW && SW->getSubStmt() == B.getLabel() && P->begin() == P->end())<br>
+ continue; // Previous case label has no statements, good.<br>
<br>
- const LabelStmt *L = dyn_cast_or_null<LabelStmt>(P->getLabel());<br>
- if (L && L->getSubStmt() == B.getLabel() && P->begin() == P->end())<br>
- continue; // Case label is preceded with a normal label, good.<br>
+ const LabelStmt *L = dyn_cast_or_null<LabelStmt>(P->getLabel());<br>
+ if (L && L->getSubStmt() == B.getLabel() && P->begin() == P->end())<br>
+ continue; // Case label is preceded with a normal label, good.<br>
<br>
- if (!ReachableBlocks.count(P)) {<br>
- for (const CFGElement &Elem : llvm::reverse(*P)) {<br>
- if (std::optional<CFGStmt> CS = Elem.getAs<CFGStmt>()) {<br>
+ if (!ReachableBlocks.count(P)) {<br>
+ for (const CFGElement &Elem : llvm::reverse(*P)) {<br>
+ if (std::optional<CFGStmt> CS = Elem.getAs<CFGStmt>()) {<br>
if (const AttributedStmt *AS = asFallThroughAttr(CS->getStmt())) {<br>
// Don't issue a warning for an unreachable fallthrough<br>
// attribute in template instantiations as it may not be<br>
@@ -1142,110 +1132,109 @@ namespace {<br>
break;<br>
}<br>
// Don't care about other unreachable statements.<br>
- }<br>
}<br>
- // If there are no unreachable statements, this may be a special<br>
- // case in CFG:<br>
- // case X: {<br>
- // A a; // A has a destructor.<br>
- // break;<br>
- // }<br>
- // // <<<< This place is represented by a 'hanging' CFG block.<br>
- // case Y:<br>
- continue;<br>
- }<br>
-<br>
- const Stmt *LastStmt = getLastStmt(*P);<br>
- if (const AttributedStmt *AS = asFallThroughAttr(LastStmt)) {<br>
- markFallthroughVisited(AS);<br>
- ++AnnotatedCnt;<br>
- continue; // Fallthrough annotation, good.<br>
- }<br>
-<br>
- if (!LastStmt) { // This block contains no executable statements.<br>
- // Traverse its predecessors.<br>
- std::copy(P->pred_begin(), P->pred_end(),<br>
- std::back_inserter(BlockQueue));<br>
- continue;<br>
}<br>
+ // If there are no unreachable statements, this may be a special<br>
+ // case in CFG:<br>
+ // case X: {<br>
+ // A a; // A has a destructor.<br>
+ // break;<br>
+ // }<br>
+ // // <<<< This place is represented by a 'hanging' CFG block.<br>
+ // case Y:<br>
+ continue;<br>
+ }<br>
<br>
- ++UnannotatedCnt;<br>
+ const Stmt *LastStmt = getLastStmt(*P);<br>
+ if (const AttributedStmt *AS = asFallThroughAttr(LastStmt)) {<br>
+ markFallthroughVisited(AS);<br>
+ ++AnnotatedCnt;<br>
+ continue; // Fallthrough annotation, good.<br>
}<br>
- return !!UnannotatedCnt;<br>
- }<br>
<br>
- // RecursiveASTVisitor setup.<br>
- bool shouldWalkTypesOfTypeLocs() const { return false; }<br>
+ if (!LastStmt) { // This block contains no executable statements.<br>
+ // Traverse its predecessors.<br>
+ std::copy(P->pred_begin(), P->pred_end(),<br>
+ std::back_inserter(BlockQueue));<br>
+ continue;<br>
+ }<br>
<br>
- bool VisitAttributedStmt(AttributedStmt *S) {<br>
- if (asFallThroughAttr(S))<br>
- FallthroughStmts.insert(S);<br>
- return true;<br>
+ ++UnannotatedCnt;<br>
}<br>
+ return !!UnannotatedCnt;<br>
+ }<br>
<br>
- bool VisitSwitchStmt(SwitchStmt *S) {<br>
- FoundSwitchStatements = true;<br>
- return true;<br>
- }<br>
+ // RecursiveASTVisitor setup.<br>
+ bool shouldWalkTypesOfTypeLocs() const { return false; }<br>
<br>
- // We don't want to traverse local type declarations. We analyze their<br>
- // methods separately.<br>
- bool TraverseDecl(Decl *D) { return true; }<br>
+ bool VisitAttributedStmt(AttributedStmt *S) {<br>
+ if (asFallThroughAttr(S))<br>
+ FallthroughStmts.insert(S);<br>
+ return true;<br>
+ }<br>
<br>
- // We analyze lambda bodies separately. Skip them here.<br>
- bool TraverseLambdaExpr(LambdaExpr *LE) {<br>
- // Traverse the captures, but not the body.<br>
- for (const auto C : zip(LE->captures(), LE->capture_inits()))<br>
- TraverseLambdaCapture(LE, &std::get<0>(C), std::get<1>(C));<br>
- return true;<br>
- }<br>
+ bool VisitSwitchStmt(SwitchStmt *S) {<br>
+ FoundSwitchStatements = true;<br>
+ return true;<br>
+ }<br>
<br>
- private:<br>
+ // We don't want to traverse local type declarations. We analyze their<br>
+ // methods separately.<br>
+ bool TraverseDecl(Decl *D) { return true; }<br>
<br>
- static const AttributedStmt *asFallThroughAttr(const Stmt *S) {<br>
- if (const AttributedStmt *AS = dyn_cast_or_null<AttributedStmt>(S)) {<br>
- if (hasSpecificAttr<FallThroughAttr>(AS->getAttrs()))<br>
- return AS;<br>
- }<br>
- return nullptr;<br>
- }<br>
+ // We analyze lambda bodies separately. Skip them here.<br>
+ bool TraverseLambdaExpr(LambdaExpr *LE) {<br>
+ // Traverse the captures, but not the body.<br>
+ for (const auto C : zip(LE->captures(), LE->capture_inits()))<br>
+ TraverseLambdaCapture(LE, &std::get<0>(C), std::get<1>(C));<br>
+ return true;<br>
+ }<br>
<br>
- static const Stmt *getLastStmt(const CFGBlock &B) {<br>
- if (const Stmt *Term = B.getTerminatorStmt())<br>
- return Term;<br>
- for (const CFGElement &Elem : llvm::reverse(B))<br>
- if (std::optional<CFGStmt> CS = Elem.getAs<CFGStmt>())<br>
- return CS->getStmt();<br>
- // Workaround to detect a statement thrown out by CFGBuilder:<br>
- // case X: {} case Y:<br>
- // case X: ; case Y:<br>
- if (const SwitchCase *SW = dyn_cast_or_null<SwitchCase>(B.getLabel()))<br>
- if (!isa<SwitchCase>(SW->getSubStmt()))<br>
- return SW->getSubStmt();<br>
-<br>
- return nullptr;<br>
+private:<br>
+ static const AttributedStmt *asFallThroughAttr(const Stmt *S) {<br>
+ if (const AttributedStmt *AS = dyn_cast_or_null<AttributedStmt>(S)) {<br>
+ if (hasSpecificAttr<FallThroughAttr>(AS->getAttrs()))<br>
+ return AS;<br>
}<br>
+ return nullptr;<br>
+ }<br>
<br>
- bool FoundSwitchStatements;<br>
- AttrStmts FallthroughStmts;<br>
- Sema &S;<br>
- llvm::SmallPtrSet<const CFGBlock *, 16> ReachableBlocks;<br>
- };<br>
+ static const Stmt *getLastStmt(const CFGBlock &B) {<br>
+ if (const Stmt *Term = B.getTerminatorStmt())<br>
+ return Term;<br>
+ for (const CFGElement &Elem : llvm::reverse(B))<br>
+ if (std::optional<CFGStmt> CS = Elem.getAs<CFGStmt>())<br>
+ return CS->getStmt();<br>
+ // Workaround to detect a statement thrown out by CFGBuilder:<br>
+ // case X: {} case Y:<br>
+ // case X: ; case Y:<br>
+ if (const SwitchCase *SW = dyn_cast_or_null<SwitchCase>(B.getLabel()))<br>
+ if (!isa<SwitchCase>(SW->getSubStmt()))<br>
+ return SW->getSubStmt();<br>
+<br>
+ return nullptr;<br>
+ }<br>
+<br>
+ bool FoundSwitchStatements;<br>
+ AttrStmts FallthroughStmts;<br>
+ Sema &S;<br>
+ llvm::SmallPtrSet<const CFGBlock *, 16> ReachableBlocks;<br>
+};<br>
} // anonymous namespace<br>
<br>
static StringRef getFallthroughAttrSpelling(Preprocessor &PP,<br>
SourceLocation Loc) {<br>
- TokenValue FallthroughTokens[] = {<br>
- tok::l_square, tok::l_square,<br>
- PP.getIdentifierInfo("fallthrough"),<br>
- tok::r_square, tok::r_square<br>
- };<br>
-<br>
- TokenValue ClangFallthroughTokens[] = {<br>
- tok::l_square, tok::l_square, PP.getIdentifierInfo("clang"),<br>
- tok::coloncolon, PP.getIdentifierInfo("fallthrough"),<br>
- tok::r_square, tok::r_square<br>
- };<br>
+ TokenValue FallthroughTokens[] = {tok::l_square, tok::l_square,<br>
+ PP.getIdentifierInfo("fallthrough"),<br>
+ tok::r_square, tok::r_square};<br>
+<br>
+ TokenValue ClangFallthroughTokens[] = {tok::l_square,<br>
+ tok::l_square,<br>
+ PP.getIdentifierInfo("clang"),<br>
+ tok::coloncolon,<br>
+ PP.getIdentifierInfo("fallthrough"),<br>
+ tok::r_square,<br>
+ tok::r_square};<br>
<br>
bool PreferClangAttr = !PP.getLangOpts().CPlusPlus17 && !PP.getLangOpts().C2x;<br>
<br>
@@ -1360,13 +1349,12 @@ static bool isInLoop(const ASTContext &Ctx, const ParentMap &PM,<br>
<br>
static void diagnoseRepeatedUseOfWeak(Sema &S,<br>
const sema::FunctionScopeInfo *CurFn,<br>
- const Decl *D,<br>
- const ParentMap &PM) {<br>
+ const Decl *D, const ParentMap &PM) {<br>
typedef sema::FunctionScopeInfo::WeakObjectProfileTy WeakObjectProfileTy;<br>
typedef sema::FunctionScopeInfo::WeakObjectUseMap WeakObjectUseMap;<br>
typedef sema::FunctionScopeInfo::WeakUseVector WeakUseVector;<br>
typedef std::pair<const Stmt *, WeakObjectUseMap::const_iterator><br>
- StmtUsesPair;<br>
+ StmtUsesPair;<br>
<br>
ASTContext &Ctx = S.getASTContext();<br>
<br>
@@ -1380,7 +1368,7 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,<br>
<br>
// Find the first read of the weak object.<br>
WeakUseVector::const_iterator UI = Uses.begin(), UE = Uses.end();<br>
- for ( ; UI != UE; ++UI) {<br>
+ for (; UI != UE; ++UI) {<br>
if (UI->isUnsafe())<br>
break;<br>
}<br>
@@ -1437,12 +1425,7 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,<br>
// warn_arc_repeated_use_of_weak and warn_arc_possible_repeated_use_of_weak.<br>
// FIXME: Should we use a common classification enum and the same set of<br>
// possibilities all throughout Sema?<br>
- enum {<br>
- Function,<br>
- Method,<br>
- Block,<br>
- Lambda<br>
- } FunctionKind;<br>
+ enum { Function, Method, Block, Lambda } FunctionKind;<br>
<br>
if (isa<sema::BlockScopeInfo>(CurFn))<br>
FunctionKind = Block;<br>
@@ -1473,12 +1456,7 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,<br>
// Classify the weak object being accessed for better warning text.<br>
// This enum should stay in sync with the cases in<br>
// warn_arc_repeated_use_of_weak and warn_arc_possible_repeated_use_of_weak.<br>
- enum {<br>
- Variable,<br>
- Property,<br>
- ImplicitProperty,<br>
- Ivar<br>
- } ObjectKind;<br>
+ enum { Variable, Property, ImplicitProperty, Ivar } ObjectKind;<br>
<br>
const NamedDecl *KeyProp = Key.getProperty();<br>
if (isa<VarDecl>(KeyProp))<br>
@@ -1643,7 +1621,7 @@ class UninitValsDiagReporter : public UninitVariablesHandler {<br>
}<br>
<br>
private:<br>
- static bool hasAlwaysUninitializedUse(const UsesVec* vec) {<br>
+ static bool hasAlwaysUninitializedUse(const UsesVec *vec) {<br>
return llvm::any_of(*vec, [](const UninitUse &U) {<br>
return U.getKind() == UninitUse::Always ||<br>
U.getKind() == UninitUse::AfterCall ||<br>
@@ -1839,10 +1817,10 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {<br>
: getNotes();<br>
}<br>
<br>
- public:<br>
+public:<br>
ThreadSafetyReporter(Sema &S, SourceLocation FL, SourceLocation FEL)<br>
- : S(S), FunLocation(FL), FunEndLocation(FEL),<br>
- CurrentFunction(nullptr), Verbose(false) {}<br>
+ : S(S), FunLocation(FL), FunEndLocation(FEL), CurrentFunction(nullptr),<br>
+ Verbose(false) {}<br>
<br>
void setVerbose(bool b) { Verbose = b; }<br>
<br>
@@ -1904,24 +1882,24 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {<br>
LockErrorKind LEK) override {<br>
unsigned DiagID = 0;<br>
switch (LEK) {<br>
- case LEK_LockedSomePredecessors:<br>
- DiagID = diag::warn_lock_some_predecessors;<br>
- break;<br>
- case LEK_LockedSomeLoopIterations:<br>
- DiagID = diag::warn_expecting_lock_held_on_loop;<br>
- break;<br>
- case LEK_LockedAtEndOfFunction:<br>
- DiagID = diag::warn_no_unlock;<br>
- break;<br>
- case LEK_NotLockedAtEndOfFunction:<br>
- DiagID = diag::warn_expecting_locked;<br>
- break;<br>
+ case LEK_LockedSomePredecessors:<br>
+ DiagID = diag::warn_lock_some_predecessors;<br>
+ break;<br>
+ case LEK_LockedSomeLoopIterations:<br>
+ DiagID = diag::warn_expecting_lock_held_on_loop;<br>
+ break;<br>
+ case LEK_LockedAtEndOfFunction:<br>
+ DiagID = diag::warn_no_unlock;<br>
+ break;<br>
+ case LEK_NotLockedAtEndOfFunction:<br>
+ DiagID = diag::warn_expecting_locked;<br>
+ break;<br>
}<br>
if (LocEndOfScope.isInvalid())<br>
LocEndOfScope = FunEndLocation;<br>
<br>
- PartialDiagnosticAt Warning(LocEndOfScope, S.PDiag(DiagID) << Kind<br>
- << LockName);<br>
+ PartialDiagnosticAt Warning(LocEndOfScope, S.PDiag(DiagID)<br>
+ << Kind << LockName);<br>
Warnings.emplace_back(std::move(Warning),<br>
makeLockedHereNote(LocLocked, Kind));<br>
}<br>
@@ -1941,11 +1919,11 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {<br>
AccessKind AK, SourceLocation Loc) override {<br>
assert((POK == POK_VarAccess || POK == POK_VarDereference) &&<br>
"Only works for variables");<br>
- unsigned DiagID = POK == POK_VarAccess?<br>
- diag::warn_variable_requires_any_lock:<br>
- diag::warn_var_deref_requires_any_lock;<br>
+ unsigned DiagID = POK == POK_VarAccess<br>
+ ? diag::warn_variable_requires_any_lock<br>
+ : diag::warn_var_deref_requires_any_lock;<br>
PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID)<br>
- << D << getLockKindFromAccessKind(AK));<br>
+ << D << getLockKindFromAccessKind(AK));<br>
Warnings.emplace_back(std::move(Warning), getNotes());<br>
}<br>
<br>
@@ -1956,25 +1934,24 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {<br>
unsigned DiagID = 0;<br>
if (PossibleMatch) {<br>
switch (POK) {<br>
- case POK_VarAccess:<br>
- DiagID = diag::warn_variable_requires_lock_precise;<br>
- break;<br>
- case POK_VarDereference:<br>
- DiagID = diag::warn_var_deref_requires_lock_precise;<br>
- break;<br>
- case POK_FunctionCall:<br>
- DiagID = diag::warn_fun_requires_lock_precise;<br>
- break;<br>
- case POK_PassByRef:<br>
- DiagID = diag::warn_guarded_pass_by_reference;<br>
- break;<br>
- case POK_PtPassByRef:<br>
- DiagID = diag::warn_pt_guarded_pass_by_reference;<br>
- break;<br>
+ case POK_VarAccess:<br>
+ DiagID = diag::warn_variable_requires_lock_precise;<br>
+ break;<br>
+ case POK_VarDereference:<br>
+ DiagID = diag::warn_var_deref_requires_lock_precise;<br>
+ break;<br>
+ case POK_FunctionCall:<br>
+ DiagID = diag::warn_fun_requires_lock_precise;<br>
+ break;<br>
+ case POK_PassByRef:<br>
+ DiagID = diag::warn_guarded_pass_by_reference;<br>
+ break;<br>
+ case POK_PtPassByRef:<br>
+ DiagID = diag::warn_pt_guarded_pass_by_reference;<br>
+ break;<br>
}<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID) << Kind<br>
- << D<br>
- << LockName << LK);<br>
+ PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID)<br>
+ << Kind << D << LockName << LK);<br>
PartialDiagnosticAt Note(Loc, S.PDiag(diag::note_found_mutex_near_match)<br>
<< *PossibleMatch);<br>
if (Verbose && POK == POK_VarAccess) {<br>
@@ -1986,25 +1963,24 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {<br>
Warnings.emplace_back(std::move(Warning), getNotes(Note));<br>
} else {<br>
switch (POK) {<br>
- case POK_VarAccess:<br>
- DiagID = diag::warn_variable_requires_lock;<br>
- break;<br>
- case POK_VarDereference:<br>
- DiagID = diag::warn_var_deref_requires_lock;<br>
- break;<br>
- case POK_FunctionCall:<br>
- DiagID = diag::warn_fun_requires_lock;<br>
- break;<br>
- case POK_PassByRef:<br>
- DiagID = diag::warn_guarded_pass_by_reference;<br>
- break;<br>
- case POK_PtPassByRef:<br>
- DiagID = diag::warn_pt_guarded_pass_by_reference;<br>
- break;<br>
+ case POK_VarAccess:<br>
+ DiagID = diag::warn_variable_requires_lock;<br>
+ break;<br>
+ case POK_VarDereference:<br>
+ DiagID = diag::warn_var_deref_requires_lock;<br>
+ break;<br>
+ case POK_FunctionCall:<br>
+ DiagID = diag::warn_fun_requires_lock;<br>
+ break;<br>
+ case POK_PassByRef:<br>
+ DiagID = diag::warn_guarded_pass_by_reference;<br>
+ break;<br>
+ case POK_PtPassByRef:<br>
+ DiagID = diag::warn_pt_guarded_pass_by_reference;<br>
+ break;<br>
}<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID) << Kind<br>
- << D<br>
- << LockName << LK);<br>
+ PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID)<br>
+ << Kind << D << LockName << LK);<br>
if (Verbose && POK == POK_VarAccess) {<br>
PartialDiagnosticAt Note(D->getLocation(),<br>
S.PDiag(diag::note_guarded_by_declared_here));<br>
@@ -2016,9 +1992,9 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {<br>
<br>
void handleNegativeNotHeld(StringRef Kind, Name LockName, Name Neg,<br>
SourceLocation Loc) override {<br>
- PartialDiagnosticAt Warning(Loc,<br>
- S.PDiag(diag::warn_acquire_requires_negative_cap)<br>
- << Kind << LockName << Neg);<br>
+ PartialDiagnosticAt Warning(<br>
+ Loc, S.PDiag(diag::warn_acquire_requires_negative_cap)<br>
+ << Kind << LockName << Neg);<br>
Warnings.emplace_back(std::move(Warning), getNotes());<br>
}<br>
<br>
@@ -2038,22 +2014,20 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {<br>
<br>
void handleLockAcquiredBefore(StringRef Kind, Name L1Name, Name L2Name,<br>
SourceLocation Loc) override {<br>
- PartialDiagnosticAt Warning(Loc,<br>
- S.PDiag(diag::warn_acquired_before) << Kind << L1Name << L2Name);<br>
+ PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_acquired_before)<br>
+ << Kind << L1Name << L2Name);<br>
Warnings.emplace_back(std::move(Warning), getNotes());<br>
}<br>
<br>
void handleBeforeAfterCycle(Name L1Name, SourceLocation Loc) override {<br>
- PartialDiagnosticAt Warning(Loc,<br>
- S.PDiag(diag::warn_acquired_before_after_cycle) << L1Name);<br>
+ PartialDiagnosticAt Warning(<br>
+ Loc, S.PDiag(diag::warn_acquired_before_after_cycle) << L1Name);<br>
Warnings.emplace_back(std::move(Warning), getNotes());<br>
}<br>
<br>
- void enterFunction(const FunctionDecl* FD) override {<br>
- CurrentFunction = FD;<br>
- }<br>
+ void enterFunction(const FunctionDecl *FD) override { CurrentFunction = FD; }<br>
<br>
- void leaveFunction(const FunctionDecl* FD) override {<br>
+ void leaveFunction(const FunctionDecl *FD) override {<br>
CurrentFunction = nullptr;<br>
}<br>
};<br>
@@ -2074,7 +2048,6 @@ class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {<br>
DiagList Warnings;<br>
<br>
public:<br>
-<br>
ConsumedWarningsHandler(Sema &S) : S(S) {}<br>
<br>
void emitDiagnostics() override {<br>
@@ -2088,8 +2061,8 @@ class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {<br>
<br>
void warnLoopStateMismatch(SourceLocation Loc,<br>
StringRef VariableName) override {<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_loop_state_mismatch) <<<br>
- VariableName);<br>
+ PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_loop_state_mismatch)<br>
+ << VariableName);<br>
<br>
Warnings.emplace_back(std::move(Warning), OptionalNotes());<br>
}<br>
@@ -2099,9 +2072,9 @@ class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {<br>
StringRef ExpectedState,<br>
StringRef ObservedState) override {<br>
<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(<br>
- diag::warn_param_return_typestate_mismatch) << VariableName <<<br>
- ExpectedState << ObservedState);<br>
+ PartialDiagnosticAt Warning(<br>
+ Loc, S.PDiag(diag::warn_param_return_typestate_mismatch)<br>
+ << VariableName << ExpectedState << ObservedState);<br>
<br>
Warnings.emplace_back(std::move(Warning), OptionalNotes());<br>
}<br>
@@ -2109,16 +2082,18 @@ class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {<br>
void warnParamTypestateMismatch(SourceLocation Loc, StringRef ExpectedState,<br>
StringRef ObservedState) override {<br>
<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(<br>
- diag::warn_param_typestate_mismatch) << ExpectedState << ObservedState);<br>
+ PartialDiagnosticAt Warning(Loc,<br>
+ S.PDiag(diag::warn_param_typestate_mismatch)<br>
+ << ExpectedState << ObservedState);<br>
<br>
Warnings.emplace_back(std::move(Warning), OptionalNotes());<br>
}<br>
<br>
void warnReturnTypestateForUnconsumableType(SourceLocation Loc,<br>
StringRef TypeName) override {<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(<br>
- diag::warn_return_typestate_for_unconsumable_type) << TypeName);<br>
+ PartialDiagnosticAt Warning(<br>
+ Loc, S.PDiag(diag::warn_return_typestate_for_unconsumable_type)<br>
+ << TypeName);<br>
<br>
Warnings.emplace_back(std::move(Warning), OptionalNotes());<br>
}<br>
@@ -2126,8 +2101,9 @@ class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {<br>
void warnReturnTypestateMismatch(SourceLocation Loc, StringRef ExpectedState,<br>
StringRef ObservedState) override {<br>
<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(<br>
- diag::warn_return_typestate_mismatch) << ExpectedState << ObservedState);<br>
+ PartialDiagnosticAt Warning(Loc,<br>
+ S.PDiag(diag::warn_return_typestate_mismatch)<br>
+ << ExpectedState << ObservedState);<br>
<br>
Warnings.emplace_back(std::move(Warning), OptionalNotes());<br>
}<br>
@@ -2135,8 +2111,9 @@ class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {<br>
void warnUseOfTempInInvalidState(StringRef MethodName, StringRef State,<br>
SourceLocation Loc) override {<br>
<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(<br>
- diag::warn_use_of_temp_in_invalid_state) << MethodName << State);<br>
+ PartialDiagnosticAt Warning(Loc,<br>
+ S.PDiag(diag::warn_use_of_temp_in_invalid_state)<br>
+ << MethodName << State);<br>
<br>
Warnings.emplace_back(std::move(Warning), OptionalNotes());<br>
}<br>
@@ -2144,8 +2121,9 @@ class ConsumedWarningsHandler : public ConsumedWarningsHandlerBase {<br>
void warnUseInInvalidState(StringRef MethodName, StringRef VariableName,<br>
StringRef State, SourceLocation Loc) override {<br>
<br>
- PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_use_in_invalid_state) <<<br>
- MethodName << VariableName << State);<br>
+ PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_use_in_invalid_state)<br>
+ << MethodName << VariableName<br>
+ << State);<br>
<br>
Warnings.emplace_back(std::move(Warning), OptionalNotes());<br>
}<br>
@@ -2340,7 +2318,7 @@ class CallableVisitor : public RecursiveASTVisitor<CallableVisitor> {<br>
};<br>
<br>
void clang::sema::AnalysisBasedWarnings::IssueWarnings(<br>
- const TranslationUnitDecl *TU) {<br>
+ TranslationUnitDecl *TU) {<br>
if (!TU)<br>
return; // This is unexpected, give up quietly.<br>
<br>
@@ -2370,9 +2348,7 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(<br>
// reasoning. Check if any of them is enabled at all before scanning the AST:<br>
if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation, SourceLocation()) ||<br>
!Diags.isIgnored(diag::warn_unsafe_buffer_variable, SourceLocation())) {<br>
- CallableVisitor(CallAnalyzers)<br>
- .TraverseTranslationUnitDecl(<br>
- std::remove_const_t<TranslationUnitDecl *>(TU));<br>
+ CallableVisitor(CallAnalyzers).TraverseTranslationUnitDecl(TU);<br>
}<br>
}<br>
<br>
@@ -2430,16 +2406,15 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(<br>
P.enableConsumedAnalysis) {<br>
// Unreachable code analysis and thread safety require a linearized CFG.<br>
AC.getCFGBuildOptions().setAllAlwaysAdd();<br>
- }<br>
- else {<br>
+ } else {<br>
AC.getCFGBuildOptions()<br>
- .setAlwaysAdd(Stmt::BinaryOperatorClass)<br>
- .setAlwaysAdd(Stmt::CompoundAssignOperatorClass)<br>
- .setAlwaysAdd(Stmt::BlockExprClass)<br>
- .setAlwaysAdd(Stmt::CStyleCastExprClass)<br>
- .setAlwaysAdd(Stmt::DeclRefExprClass)<br>
- .setAlwaysAdd(Stmt::ImplicitCastExprClass)<br>
- .setAlwaysAdd(Stmt::UnaryOperatorClass);<br>
+ .setAlwaysAdd(Stmt::BinaryOperatorClass)<br>
+ .setAlwaysAdd(Stmt::CompoundAssignOperatorClass)<br>
+ .setAlwaysAdd(Stmt::BlockExprClass)<br>
+ .setAlwaysAdd(Stmt::CStyleCastExprClass)<br>
+ .setAlwaysAdd(Stmt::DeclRefExprClass)<br>
+ .setAlwaysAdd(Stmt::ImplicitCastExprClass)<br>
+ .setAlwaysAdd(Stmt::UnaryOperatorClass);<br>
}<br>
<br>
// Install the logical handler.<br>
@@ -2493,15 +2468,14 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(<br>
// Warning: check missing 'return'<br>
if (P.enableCheckFallThrough) {<br>
const CheckFallThroughDiagnostics &CD =<br>
- (isa<BlockDecl>(D)<br>
- ? CheckFallThroughDiagnostics::MakeForBlock()<br>
- : (isa<CXXMethodDecl>(D) &&<br>
- cast<CXXMethodDecl>(D)->getOverloadedOperator() == OO_Call &&<br>
- cast<CXXMethodDecl>(D)->getParent()->isLambda())<br>
- ? CheckFallThroughDiagnostics::MakeForLambda()<br>
- : (fscope->isCoroutine()<br>
- ? CheckFallThroughDiagnostics::MakeForCoroutine(D)<br>
- : CheckFallThroughDiagnostics::MakeForFunction(D)));<br>
+ (isa<BlockDecl>(D) ? CheckFallThroughDiagnostics::MakeForBlock()<br>
+ : (isa<CXXMethodDecl>(D) &&<br>
+ cast<CXXMethodDecl>(D)->getOverloadedOperator() == OO_Call &&<br>
+ cast<CXXMethodDecl>(D)->getParent()->isLambda())<br>
+ ? CheckFallThroughDiagnostics::MakeForLambda()<br>
+ : (fscope->isCoroutine()<br>
+ ? CheckFallThroughDiagnostics::MakeForCoroutine(D)<br>
+ : CheckFallThroughDiagnostics::MakeForFunction(D)));<br>
CheckFallThroughForBody(S, D, Body, BlockType, CD, AC, fscope);<br>
}<br>
<br>
@@ -2555,12 +2529,10 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(<br>
++NumUninitAnalysisFunctions;<br>
NumUninitAnalysisVariables += stats.NumVariablesAnalyzed;<br>
NumUninitAnalysisBlockVisits += stats.NumBlockVisits;<br>
- MaxUninitAnalysisVariablesPerFunction =<br>
- std::max(MaxUninitAnalysisVariablesPerFunction,<br>
- stats.NumVariablesAnalyzed);<br>
- MaxUninitAnalysisBlockVisitsPerFunction =<br>
- std::max(MaxUninitAnalysisBlockVisitsPerFunction,<br>
- stats.NumBlockVisits);<br>
+ MaxUninitAnalysisVariablesPerFunction = std::max(<br>
+ MaxUninitAnalysisVariablesPerFunction, stats.NumVariablesAnalyzed);<br>
+ MaxUninitAnalysisBlockVisitsPerFunction = std::max(<br>
+ MaxUninitAnalysisBlockVisitsPerFunction, stats.NumBlockVisits);<br>
}<br>
}<br>
}<br>
@@ -2589,7 +2561,6 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(<br>
!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, D->getBeginLoc()))<br>
diagnoseRepeatedUseOfWeak(S, fscope, D, AC.getParentMap());<br>
<br>
-<br>
// Check for infinite self-recursion in functions<br>
if (!Diags.isIgnored(diag::warn_infinite_recursive_function,<br>
D->getBeginLoc())) {<br>
@@ -2617,8 +2588,8 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(<br>
// If we successfully built a CFG for this context, record some more<br>
// detail information about it.<br>
NumCFGBlocks += cfg->getNumBlockIDs();<br>
- MaxCFGBlocksPerFunction = std::max(MaxCFGBlocksPerFunction,<br>
- cfg->getNumBlockIDs());<br>
+ MaxCFGBlocksPerFunction =<br>
+ std::max(MaxCFGBlocksPerFunction, cfg->getNumBlockIDs());<br>
} else {<br>
++NumFunctionsWithBadCFGs;<br>
}<br>
@@ -2630,7 +2601,7 @@ void clang::sema::AnalysisBasedWarnings::PrintStats() const {<br>
<br>
unsigned NumCFGsBuilt = NumFunctionsAnalyzed - NumFunctionsWithBadCFGs;<br>
unsigned AvgCFGBlocksPerFunction =<br>
- !NumCFGsBuilt ? 0 : NumCFGBlocks/NumCFGsBuilt;<br>
+ !NumCFGsBuilt ? 0 : NumCFGBlocks / NumCFGsBuilt;<br>
llvm::errs() << NumFunctionsAnalyzed << " functions analyzed ("<br>
<< NumFunctionsWithBadCFGs << " w/o CFGs).\n"<br>
<< " " << NumCFGBlocks << " CFG blocks built.\n"<br>
@@ -2639,10 +2610,14 @@ void clang::sema::AnalysisBasedWarnings::PrintStats() const {<br>
<< " " << MaxCFGBlocksPerFunction<br>
<< " max CFG blocks per function.\n";<br>
<br>
- unsigned AvgUninitVariablesPerFunction = !NumUninitAnalysisFunctions ? 0<br>
- : NumUninitAnalysisVariables/NumUninitAnalysisFunctions;<br>
- unsigned AvgUninitBlockVisitsPerFunction = !NumUninitAnalysisFunctions ? 0<br>
- : NumUninitAnalysisBlockVisits/NumUninitAnalysisFunctions;<br>
+ unsigned AvgUninitVariablesPerFunction =<br>
+ !NumUninitAnalysisFunctions<br>
+ ? 0<br>
+ : NumUninitAnalysisVariables / NumUninitAnalysisFunctions;<br>
+ unsigned AvgUninitBlockVisitsPerFunction =<br>
+ !NumUninitAnalysisFunctions<br>
+ ? 0<br>
+ : NumUninitAnalysisBlockVisits / NumUninitAnalysisFunctions;<br>
llvm::errs() << NumUninitAnalysisFunctions<br>
<< " functions analyzed for uninitialiazed variables\n"<br>
<< " " << NumUninitAnalysisVariables << " variables analyzed.\n"<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</blockquote></div><br clear="all"><br><span>-- </span><br><div dir="ltr"><div dir="ltr"><div>Ziqing Luo, Ph.D.</div><div>Computer & Information Science Department</div><div>Verified Software Lab</div><div>University of Delaware</div></div></div>
</blockquote></div>