diff options
author | Nick Desaulniers <ndesaulniers@google.com> | 2023-02-16 17:50:34 -0800 |
---|---|---|
committer | Nick Desaulniers <ndesaulniers@google.com> | 2023-02-16 17:58:35 -0800 |
commit | af6656338db365fde6c0b0e53db8f98aa8ed59d4 (patch) | |
tree | 3952c683ad6082a3686649983fb355e34ec6d456 /clang/lib/Analysis/UninitializedValues.cpp | |
parent | 329ef60f3e21fd6845e8e8b0da405cae7eb27267 (diff) | |
download | llvm-af6656338db365fde6c0b0e53db8f98aa8ed59d4.zip llvm-af6656338db365fde6c0b0e53db8f98aa8ed59d4.tar.gz llvm-af6656338db365fde6c0b0e53db8f98aa8ed59d4.tar.bz2 |
[clang] fix -Wuninitialized for asm goto outputs on indirect edges.
Now that we support outputs from asm goto along indirect edges, we can
remove/revert some code that was added to help warn about the previous
limitation that outputs were not supported along indirect edges.
Reverts some code added in:
commit 72aa619a7fe0 ("Warn of uninitialized variables on asm goto's indirect branch")
commit 3a604fdbcd5f ("[Clang][CFG] check children statements of asm goto")
But keeps+updates the tests.
Link: https://github.com/llvm/llvm-project/issues/53562
Reviewed By: void
Differential Revision: https://reviews.llvm.org/D140508
Diffstat (limited to 'clang/lib/Analysis/UninitializedValues.cpp')
-rw-r--r-- | clang/lib/Analysis/UninitializedValues.cpp | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index 2437095..87765db 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/lib/Analysis/UninitializedValues.cpp @@ -586,28 +586,6 @@ public: continue; } - if (AtPredExit == MayUninitialized) { - // If the predecessor's terminator is an "asm goto" that initializes - // the variable, then don't count it as "initialized" on the indirect - // paths. - CFGTerminator term = Pred->getTerminator(); - if (const auto *as = dyn_cast_or_null<GCCAsmStmt>(term.getStmt())) { - const CFGBlock *fallthrough = *Pred->succ_begin(); - if (as->isAsmGoto() && - llvm::any_of(as->outputs(), [&](const Expr *output) { - return vd == findVar(output).getDecl() && - llvm::any_of(as->labels(), - [&](const AddrLabelExpr *label) { - return label->getLabel()->getStmt() == B->Label && - B != fallthrough; - }); - })) { - Use.setUninitAfterDecl(); - continue; - } - } - } - unsigned &SV = SuccsVisited[Pred->getBlockID()]; if (!SV) { // When visiting the first successor of a block, mark all NULL @@ -820,7 +798,8 @@ void TransferFunctions::VisitGCCAsmStmt(GCCAsmStmt *as) { // it's used on an indirect path, where it's not guaranteed to be // defined. if (const VarDecl *VD = findVar(Ex).getDecl()) - vals[VD] = MayUninitialized; + if (vals[VD] != Initialized) + vals[VD] = MayUninitialized; } } |