diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/UninitializedValues.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 23 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 10 |
3 files changed, 43 insertions, 11 deletions
diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index da4d072807c..ef2cf36f3ca 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/lib/Analysis/UninitializedValues.cpp @@ -300,13 +300,28 @@ void ClassifyRefs::classify(const Expr *E, Class C) { // The result of a ?: could also be an lvalue. E = E->IgnoreParens(); if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) { - const Expr *TrueExpr = CO->getTrueExpr(); - if (!isa<OpaqueValueExpr>(TrueExpr)) - classify(TrueExpr, C); + classify(CO->getTrueExpr(), C); classify(CO->getFalseExpr(), C); return; } + if (const BinaryConditionalOperator *BCO = + dyn_cast<BinaryConditionalOperator>(E)) { + classify(BCO->getFalseExpr(), C); + return; + } + + if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) { + classify(OVE->getSourceExpr(), C); + return; + } + + if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) { + if (BO->getOpcode() == BO_Comma) + classify(BO->getRHS(), C); + return; + } + FindVarResult Var = findVar(E, DC); if (const DeclRefExpr *DRE = Var.getDeclRefExpr()) Classification[DRE] = std::max(Classification[DRE], C); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2d2f97316de..c7af3b488c4 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8211,7 +8211,7 @@ namespace { void HandleValue(Expr *E) { if (isReferenceType) return; - E = E->IgnoreParenImpCasts(); + E = E->IgnoreParens(); if (DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) { HandleDeclRefExpr(DRE); return; @@ -8223,6 +8223,23 @@ namespace { return; } + if (BinaryConditionalOperator *BCO = + dyn_cast<BinaryConditionalOperator>(E)) { + HandleValue(BCO->getFalseExpr()); + return; + } + + if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) { + HandleValue(OVE->getSourceExpr()); + return; + } + + if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) { + if (BO->getOpcode() == BO_Comma) + HandleValue(BO->getRHS()); + return; + } + if (isa<MemberExpr>(E)) { Expr *Base = E->IgnoreParenImpCasts(); while (MemberExpr *ME = dyn_cast<MemberExpr>(Base)) { @@ -8313,9 +8330,7 @@ namespace { if (E->getNumArgs() == 1) { if (FunctionDecl *FD = E->getDirectCallee()) { if (FD->getIdentifier() && FD->getIdentifier()->isStr("move")) { - if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->getArg(0))) { - HandleDeclRefExpr(DRE); - } + HandleValue(E->getArg(0)); } } } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 1332eac840b..081d91e0506 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2279,11 +2279,15 @@ namespace { if (BinaryConditionalOperator *BCO = dyn_cast<BinaryConditionalOperator>(E)) { - HandleValue(BCO->getCommon()); HandleValue(BCO->getFalseExpr()); return; } + if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) { + HandleValue(OVE->getSourceExpr()); + return; + } + if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) { switch (BO->getOpcode()) { default: @@ -2342,9 +2346,7 @@ namespace { if (E->getNumArgs() == 1) { if (FunctionDecl *FD = E->getDirectCallee()) { if (FD->getIdentifier() && FD->getIdentifier()->isStr("move")) { - if (MemberExpr *ME = dyn_cast<MemberExpr>(E->getArg(0))) { - HandleMemberExpr(ME, false /*CheckReferenceOnly*/); - } + HandleValue(E->getArg(0)); } } } |