r240443 - Make the typo resolution in r240441 apply to all function calls.

Kaelyn Takata rikka at google.com
Tue Jun 23 12:13:17 PDT 2015


Author: rikka
Date: Tue Jun 23 14:13:17 2015
New Revision: 240443

URL: http://llvm.org/viewvc/llvm-project?rev=240443&view=rev
Log:
Make the typo resolution in r240441 apply to all function calls.

Regular function calls (such as to cabs()) run into the same problem
with handling dependent exprs, not just builtins with custom type
checking.

Fixes PR23775.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/typo-correction.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=240443&r1=240442&r2=240443&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jun 23 14:13:17 2015
@@ -4937,19 +4937,20 @@ Sema::BuildResolvedCallExpr(Expr *Fn, Na
     TheCall = new (Context) CallExpr(Context, Fn, Args, Context.BoolTy,
                                      VK_RValue, RParenLoc);
 
+  if (!getLangOpts().CPlusPlus) {
+    // C cannot always handle TypoExpr nodes in builtin calls and direct
+    // function calls as their argument checking don't necessarily handle
+    // dependent types properly, so make sure any TypoExprs have been
+    // dealt with.
+    ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
+    if (!Result.isUsable()) return ExprError();
+    TheCall = dyn_cast<CallExpr>(Result.get());
+    if (!TheCall) return Result;
+  }
+
   // Bail out early if calling a builtin with custom typechecking.
-  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
-    if (!getLangOpts().CPlusPlus) {
-      // C cannot handle TypoExpr nodes in the builtin's call expr because it
-      // doesn't handle dependent types properly, so make sure any TypoExprs have
-      // been dealt with.
-      ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
-      if (!Result.isUsable()) return ExprError();
-      TheCall = dyn_cast<CallExpr>(Result.get());
-      if (!TheCall) return Result;
-    }
+  if (BuiltinID && Context.BuiltinInfo.hasCustomTypechecking(BuiltinID))
     return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
-  }
 
  retry:
   const FunctionType *FuncT;

Modified: cfe/trunk/test/Sema/typo-correction.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=240443&r1=240442&r2=240443&view=diff
==============================================================================
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Tue Jun 23 14:13:17 2015
@@ -44,3 +44,8 @@ int PR23101(__m128i __x) {
 void f(long *a, long b) {
       __atomic_or_fetch(a, b, c);  // expected-error {{use of undeclared identifier 'c'}}
 }
+
+extern double cabs(_Complex double z);
+void fn1() {
+  cabs(errij);  // expected-error {{use of undeclared identifier 'errij'}}
+}





More information about the cfe-commits mailing list