]> granicus.if.org Git - clang/commitdiff
Fix some direct checks of expressions which might be surrounded by parentheses.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 8 Dec 2009 02:09:46 +0000 (02:09 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 8 Dec 2009 02:09:46 +0000 (02:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90825 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/member-call-parens.cpp [new file with mode: 0644]

index c5c5693818bfd8a98394e6688c2f0b9d19e5f18f..0b77584dd93c2f96df9c865812d01308eb548090 100644 (file)
@@ -241,10 +241,10 @@ static bool canDevirtualizeMemberFunctionCalls(const Expr *Base) {
 }
 
 RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
-  if (isa<BinaryOperator>(CE->getCallee())) 
+  if (isa<BinaryOperator>(CE->getCallee()->IgnoreParens())) 
     return EmitCXXMemberPointerCallExpr(CE);
       
-  const MemberExpr *ME = cast<MemberExpr>(CE->getCallee());
+  const MemberExpr *ME = cast<MemberExpr>(CE->getCallee()->IgnoreParens());
   const CXXMethodDecl *MD = cast<CXXMethodDecl>(ME->getMemberDecl());
 
   if (MD->isStatic()) {
@@ -307,7 +307,8 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
 
 RValue
 CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E) {
-  const BinaryOperator *BO = cast<BinaryOperator>(E->getCallee());
+  const BinaryOperator *BO =
+      cast<BinaryOperator>(E->getCallee()->IgnoreParens());
   const Expr *BaseExpr = BO->getLHS();
   const Expr *MemFnExpr = BO->getRHS();
   
index 8d1d05dc01ed32b95b9e7963cc673bcfc8cf1d36..87f53e876b49c2236aa824b12b6190c72e955976 100644 (file)
@@ -1408,7 +1408,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) {
     if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(TargetDecl))
       return EmitCXXOperatorMemberCallExpr(CE, MD);
 
-  if (isa<CXXPseudoDestructorExpr>(E->getCallee())) {
+  if (isa<CXXPseudoDestructorExpr>(E->getCallee()->IgnoreParens())) {
     // C++ [expr.pseudo]p1:
     //   The result shall only be used as the operand for the function call
     //   operator (), and the result of such a call has type void. The only
diff --git a/test/CodeGenCXX/member-call-parens.cpp b/test/CodeGenCXX/member-call-parens.cpp
new file mode 100644 (file)
index 0000000..0b808e0
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: clang-cc -emit-llvm-only -verify %s
+
+struct A { int a(); };
+typedef int B;
+void a() {
+  A x;
+  ((x.a))();
+  ((x.*&A::a))();
+  B y;
+  // FIXME: Sema doesn't like this for some reason...
+  //(y.~B)();
+}