summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-09-04 23:19:34 +0000
committerRichard Trieu <rtrieu@google.com>2014-09-04 23:19:34 +0000
commit2a07c96737393f516176916473e958a93a54f398 (patch)
tree6c2f988d0e43aa208c92e4d263410dd985ad54aa /clang/lib/Sema/SemaDecl.cpp
parentc4b4253f7c63de8452eabf0105d87a17ff47748f (diff)
downloadbcm5719-llvm-2a07c96737393f516176916473e958a93a54f398.tar.gz
bcm5719-llvm-2a07c96737393f516176916473e958a93a54f398.zip
Stop double visiting some expressions during self reference checking.
Originally, self reference checking made a double pass over some expressions to handle reference type checking. Now, allow HandleValue to also check reference types, and fallback to Visit for unhandled expressions. llvm-svn: 217203
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f5ba0ea9032..8834705e742 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8207,8 +8207,6 @@ namespace {
// For conditional operators, the cast can be outside the conditional
// operator if both expressions are DeclRefExpr's.
void HandleValue(Expr *E) {
- if (isReferenceType)
- return;
E = E->IgnoreParens();
if (DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
HandleDeclRefExpr(DRE);
@@ -8223,6 +8221,7 @@ namespace {
if (BinaryConditionalOperator *BCO =
dyn_cast<BinaryConditionalOperator>(E)) {
+ Visit(BCO->getCond());
HandleValue(BCO->getFalseExpr());
return;
}
@@ -8250,10 +8249,12 @@ namespace {
HandleDeclRefExpr(DRE);
return;
}
+
+ Visit(E);
}
- // Reference types are handled here since all uses of references are
- // bad, not just r-value uses.
+ // Reference types not handled in HandleValue are handled here since all
+ // uses of references are bad, not just r-value uses.
void VisitDeclRefExpr(DeclRefExpr *E) {
if (isReferenceType)
HandleDeclRefExpr(E);
@@ -8261,8 +8262,10 @@ namespace {
void VisitImplicitCastExpr(ImplicitCastExpr *E) {
if (E->getCastKind() == CK_LValueToRValue ||
- (isRecordType && E->getCastKind() == CK_NoOp))
+ (isRecordType && E->getCastKind() == CK_NoOp)) {
HandleValue(E->getSubExpr());
+ return;
+ }
Inherited::VisitImplicitCastExpr(E);
}
@@ -8329,6 +8332,7 @@ namespace {
if (FunctionDecl *FD = E->getDirectCallee()) {
if (FD->getIdentifier() && FD->getIdentifier()->isStr("move")) {
HandleValue(E->getArg(0));
+ return;
}
}
}
@@ -8336,6 +8340,14 @@ namespace {
Inherited::VisitCallExpr(E);
}
+ // A custom visitor for BinaryConditionalOperator is needed because the
+ // regular visitor would check the condition and true expression separately
+ // but both point to the same place giving duplicate diagnostics.
+ void VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
+ Visit(E->getCond());
+ Visit(E->getFalseExpr());
+ }
+
void HandleDeclRefExpr(DeclRefExpr *DRE) {
Decl* ReferenceDecl = DRE->getDecl();
if (OrigDecl != ReferenceDecl) return;
OpenPOWER on IntegriCloud