hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hokein requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90459

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Modules/submodules-merge-defs.cpp
  clang/test/Sema/PR28181.c
  clang/test/Sema/typo-correction-ambiguity.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction.c
  clang/test/Sema/var-redecl.c
  clang/test/SemaCXX/enum-scoped.cpp
  clang/test/SemaCXX/nested-name-spec.cpp
  clang/test/SemaCXX/typo-correction-crash.cpp
  clang/test/SemaCXX/typo-correction-cxx11.cpp
  clang/test/SemaCXX/typo-correction-delayed.cpp
  clang/test/SemaObjC/error-outof-scope-property-use.m
  clang/test/SemaObjCXX/block-for-lambda-conversion.mm

Index: clang/test/SemaObjCXX/block-for-lambda-conversion.mm
===================================================================
--- clang/test/SemaObjCXX/block-for-lambda-conversion.mm
+++ clang/test/SemaObjCXX/block-for-lambda-conversion.mm
@@ -8,7 +8,7 @@
   NSEventMaskLeftMouseDown = 1
 };
 
-static const NSEventType NSFlagsChanged = NSEventTypeFlagsChanged;
+static const NSEventType NSFlagsChanged = NSEventTypeFlagsChanged; // expected-note {{declared here}}
 
 @interface NSObject
 @end
@@ -20,7 +20,7 @@
 
 void test(id weakThis) {
   id m_flagsChangedEventMonitor = [NSEvent
-      addMonitor:NSFlagsChangedMask //expected-error {{use of undeclared identifier 'NSFlagsChangedMask'}}
+      addMonitor:NSFlagsChangedMask // expected-error {{use of undeclared identifier 'NSFlagsChangedMask'; did you mean 'NSFlagsChanged'?}}
          handler:[weakThis](NSEvent *flagsChangedEvent) {
              return flagsChangedEvent;
          }];
Index: clang/test/SemaObjC/error-outof-scope-property-use.m
===================================================================
--- clang/test/SemaObjC/error-outof-scope-property-use.m
+++ clang/test/SemaObjC/error-outof-scope-property-use.m
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://13178483
 
-@class NSMutableDictionary; // expected-note {{receiver is instance of class declared here}}
+@class NSMutableDictionary;
 
 @interface LaunchdJobs 
 
@@ -15,8 +15,7 @@
 -(void)job
 {
 
- [uuids_jobs objectForKey]; // expected-error {{use of undeclared identifier 'uuids_jobs'}} \
-                            // expected-warning {{instance method '-objectForKey' not found}}
+ [uuids_jobs objectForKey]; // expected-error {{use of undeclared identifier 'uuids_jobs'}}
 }
 
 
Index: clang/test/SemaCXX/typo-correction-delayed.cpp
===================================================================
--- clang/test/SemaCXX/typo-correction-delayed.cpp
+++ clang/test/SemaCXX/typo-correction-delayed.cpp
@@ -137,13 +137,12 @@
 
 namespace PR21925 {
 struct X {
-  int get() { return 7; }  // expected-note {{'get' declared here}}
+  int get() { return 7; }
 };
 void test() {
   X variable;  // expected-note {{'variable' declared here}}
 
-  // expected-error@+2 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}}
-  // expected-error@+1 {{no member named 'getX' in 'PR21925::X'; did you mean 'get'?}}
+  // expected-error@+1 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}}
   int x = variableX.getX();
 }
 }
@@ -192,10 +191,11 @@
 namespace PR22297 {
 double pow(double x, double y);
 struct TimeTicks {
-  static void Now();  // expected-note {{'Now' declared here}}
+  static void Now();
 };
 void f() {
-  TimeTicks::now();  // expected-error {{no member named 'now' in 'PR22297::TimeTicks'; did you mean 'Now'?}}
+  // FIXME: should correct to Now.
+  TimeTicks::now();  // expected-error {{no member named 'now' in 'PR22297::TimeTicks'}}
 }
 }
 
Index: clang/test/SemaCXX/typo-correction-cxx11.cpp
===================================================================
--- clang/test/SemaCXX/typo-correction-cxx11.cpp
+++ clang/test/SemaCXX/typo-correction-cxx11.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 
 namespace PR23186 {
-decltype(ned);  // expected-error-re {{use of undeclared identifier 'ned'{{$}}}}
+// FIXME: what's going on here? suppress the bogus correction of 'ned' to 'new'
+decltype(ned);  // expected-error {{use of undeclared identifier 'ned'; did you mean 'new'}} expected-warning {{declaration does not declare anything}}
 // The code below was triggering an UNREACHABLE in ASTContext::getTypeInfoImpl
 // once the above code failed to recover properly after making the bogus
 // correction of 'ned' to 'new'.
@@ -54,7 +55,7 @@
 
   auto &annotation = *annotations;
   auto new_it = new_annotations.find(5);
-  auto &new_anotation = new_it.second;  // expected-note {{'new_anotation' declared here}}
-  new_annotation->Swap(&annotation);  // expected-error {{use of undeclared identifier 'new_annotation'; did you mean 'new_anotation'?}}
+  auto &new_anotation = new_it.second;
+  new_annotation->Swap(&annotation);  // expected-error {{use of undeclared identifier 'new_annotation'}}
 }
 }
Index: clang/test/SemaCXX/typo-correction-crash.cpp
===================================================================
--- clang/test/SemaCXX/typo-correction-crash.cpp
+++ clang/test/SemaCXX/typo-correction-crash.cpp
@@ -8,7 +8,6 @@
 auto check2() {
   return "s";
   return tes; // expected-error {{use of undeclared identifier 'tes'; did you mean 'test'?}}
-              // expected-error@-1 {{deduced as 'int' here but deduced as 'const char *' in earlier}}
 }
 
 template <class A, class B> struct is_same { static constexpr bool value = false; };
@@ -19,7 +18,8 @@
 static_assert(is_same<T1, void>::value, "Return statement should be discarded");
 auto L2 = [] { return tes; }; // expected-error {{use of undeclared identifier 'tes'; did you mean 'test'?}}
 using T2 = decltype(L2());
-static_assert(is_same<T2, int>::value, "Return statement was corrected");
+// FIXME: fix the bogus "undeclared identifier 'T2'" diagnostic.
+static_assert(is_same<T2, int>::value, "Return statement was corrected"); // expected-error {{use of undeclared identifier 'T2'}}
 
 namespace BarNamespace {
 namespace NestedNamespace { // expected-note {{'BarNamespace::NestedNamespace' declared here}}
Index: clang/test/SemaCXX/nested-name-spec.cpp
===================================================================
--- clang/test/SemaCXX/nested-name-spec.cpp
+++ clang/test/SemaCXX/nested-name-spec.cpp
@@ -403,7 +403,8 @@
 T1<C2:N1> var_1b;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
 template<int N> int F() {}
 int (*X1)() = (B1::B2 ? F<1> : F<2>);
-int (*X2)() = (B1:B2 ? F<1> : F<2>);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+int (*X2)() = (B1:B2 ? F<1> : F<2>);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}} \
+                                         expected-note{{'PR18587::X2' declared here}}
 
 // Bit fields + templates
 struct S7a {
@@ -439,7 +440,7 @@
 
   int x4 = enumerator_2::ENUMERATOR_2; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}}
   int x5 = enumerator_2::X2; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} \
-                             // expected-error{{no member named 'X2' in 'PR16951::enumerator_2'}}
+                             // expected-error{{no member named 'X2' in 'PR16951::enumerator_2'; did you mean 'PR18587::X2'}}
 
 }
 
Index: clang/test/SemaCXX/enum-scoped.cpp
===================================================================
--- clang/test/SemaCXX/enum-scoped.cpp
+++ clang/test/SemaCXX/enum-scoped.cpp
@@ -155,7 +155,7 @@
   enum E x1 = E::a; // ok
   enum class E x2 = E::a; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}}
 
-  enum F { a, b };
+  enum F { a, b }; // expected-note {{'N2764::a' declared here}}
   enum F y1 = a; // ok
   enum class F y2 = a; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}}
 
@@ -302,7 +302,7 @@
   using E::f; // expected-error {{no member named 'f'}}
 
   using E::a; // expected-error {{using declaration cannot refer to a scoped enumerator}}
-  E b = a; // expected-error {{undeclared}}
+  E b = a; // expected-error {{use of undeclared identifier 'a'; did you mean 'N2764::a'?}}
 }
 
 namespace test11 {
Index: clang/test/Sema/var-redecl.c
===================================================================
--- clang/test/Sema/var-redecl.c
+++ clang/test/Sema/var-redecl.c
@@ -53,8 +53,7 @@
 void g18(void) { // expected-note{{'g18' declared here}}
   extern int g19;
 }
-int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \
-             // expected-warning{{incompatible pointer types}}
+int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}}
 
 // PR3645
 static int a;
Index: clang/test/Sema/typo-correction.c
===================================================================
--- clang/test/Sema/typo-correction.c
+++ clang/test/Sema/typo-correction.c
@@ -15,8 +15,7 @@
 
 int foobar;  // expected-note {{'foobar' declared here}}
 new_a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \
-                      // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
-                      // expected-error {{initializer element is not a compile-time constant}}
+                     // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}}
 
 struct ContainerStuct {
   enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}
@@ -95,22 +94,22 @@
 
 void rdar38642201_callee(int x, int y);
 void rdar38642201_caller() {
-  struct rdar38642201 structVar;
+  struct rdar38642201 structVar; // expected-note 2{{'structVar' declared here}}
   rdar38642201_callee(
-      structVar1.fieldName1.member1, //expected-error{{use of undeclared identifier 'structVar1'}}
-      structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+      structVar1.fieldName1.member1, //expected-error{{use of undeclared identifier 'structVar1'; did you mean 'structVar'}}
+      structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'; did you mean 'structVar'}}
 }
 
 void PR40286_g(int x, int y);
 void PR40286_h(int x, int y, int z);
-void PR40286_1(int the_value) {
-  PR40286_g(the_walue); // expected-error {{use of undeclared identifier 'the_walue'}}
+void PR40286_1(int the_value) { // expected-note {{'the_value' declared here}}
+  PR40286_g(the_walue); // expected-error {{use of undeclared identifier 'the_walue'; did you mean 'the_value'}}
 }
-void PR40286_2(int the_value) {
-  PR40286_h(the_value, the_walue); // expected-error {{use of undeclared identifier 'the_walue'}}
+void PR40286_2(int the_value) { // expected-note {{'the_value' declared here}}
+  PR40286_h(the_value, the_walue); // expected-error {{use of undeclared identifier 'the_walue'; did you mean 'the_value'}}
 }
-void PR40286_3(int the_value) {
-  PR40286_h(the_walue); // expected-error {{use of undeclared identifier 'the_walue'}}
+void PR40286_3(int the_value) { // expected-note {{'the_value' declared here}}
+  PR40286_h(the_walue); // expected-error {{use of undeclared identifier 'the_walue'; did you mean 'the_value'}}
 }
 void PR40286_4(int the_value) { // expected-note {{'the_value' declared here}}
   PR40286_h(the_value, the_value, the_walue); // expected-error {{use of undeclared identifier 'the_walue'; did you mean 'the_value'?}}
Index: clang/test/Sema/typo-correction-no-hang.cpp
===================================================================
--- clang/test/Sema/typo-correction-no-hang.cpp
+++ clang/test/Sema/typo-correction-no-hang.cpp
@@ -8,10 +8,10 @@
 
 void rdar38642201_callee(int x, int y);
 void rdar38642201_caller() {
-  struct rdar38642201 structVar;
+  struct rdar38642201 structVar; // expected-note 2{{'structVar' declared here}}
   rdar38642201_callee(
-      structVar1.fieldName1.member1,  //expected-error{{use of undeclared identifier 'structVar1'}}
-      structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+      structVar1.fieldName1.member1,  //expected-error{{use of undeclared identifier 'structVar1'; did you mean 'structVar'}}
+      structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'; did you mean 'structVar'}}
 }
 
 // Similar reproducer.
Index: clang/test/Sema/typo-correction-ambiguity.cpp
===================================================================
--- clang/test/Sema/typo-correction-ambiguity.cpp
+++ clang/test/Sema/typo-correction-ambiguity.cpp
@@ -18,12 +18,12 @@
 
 namespace MultipleCorrectionsButNotAmbiguous
 {
-  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' declared here}}
+  int PrefixType_Name(int value);
   int PrefixType_MIN();
   int PrefixType_MAX();
 };
 
 int testMultipleCorrectionsButNotAmbiguous() {
-  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // expected-error {{no member named 'PrefixType_Enum' in namespace 'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // expected-error {{no member named 'PrefixType_Enum' in namespace 'MultipleCorrectionsButNotAmbiguous'}}
   return val;
 }
Index: clang/test/Sema/PR28181.c
===================================================================
--- clang/test/Sema/PR28181.c
+++ clang/test/Sema/PR28181.c
@@ -6,8 +6,8 @@
 
 void fn1() {
   audit_skb_queue = (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
-}                           // expected-error@-1 {{assigning to 'struct spinlock_t' from incompatible type '<overloaded function type>'}}
+}
 
 void fn2() {
   audit_skb_queue + (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
-}                           // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
+}
Index: clang/test/Modules/submodules-merge-defs.cpp
===================================================================
--- clang/test/Modules/submodules-merge-defs.cpp
+++ clang/test/Modules/submodules-merge-defs.cpp
@@ -51,7 +51,7 @@
   = G::a; // expected-error +{{must be declared}}
 // expected-note@defs.h:49 +{{here}}
 // expected-note@defs.h:50 +{{here}}
-decltype(G::h) pre_gh = G::h; // expected-error +{{must be declared}} expected-error +{{must be defined}}
+decltype(G::h) pre_gh = G::h; // expected-error +{{must be declared}}
 // expected-note@defs.h:51 +{{here}}
 
 int pre_h = H(); // expected-error +{{must be declared}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7919,6 +7919,12 @@
   else if (SS && !TC.WillReplaceSpecifier())
     NewSS = *SS;
 
+  auto Finish = [&](ExprResult R) {
+    if (!R.get())
+      return R;
+    return SemaRef.CreateRecoveryExpr(R.get()->getBeginLoc(),
+                                      R.get()->getEndLoc(), {R.get()});
+  };
   if (auto *ND = TC.getFoundDecl()) {
     R.setLookupName(ND->getDeclName());
     R.addDecl(ND);
@@ -7950,17 +7956,18 @@
                                 isa<MSPropertyDecl>(ND);
 
       if (MightBeImplicitMember)
-        return SemaRef.BuildPossibleImplicitMemberExpr(
+        return Finish(SemaRef.BuildPossibleImplicitMemberExpr(
             NewSS, /*TemplateKWLoc*/ SourceLocation(), R,
-            /*TemplateArgs*/ nullptr, /*S*/ nullptr);
+            /*TemplateArgs*/ nullptr, /*S*/ nullptr));
     } else if (auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
-      return SemaRef.LookupInObjCMethod(R, Consumer.getScope(),
-                                        Ivar->getIdentifier());
+      return Finish(SemaRef.LookupInObjCMethod(R, Consumer.getScope(),
+                                               Ivar->getIdentifier()));
     }
   }
 
-  return SemaRef.BuildDeclarationNameExpr(NewSS, R, /*NeedsADL*/ false,
-                                          /*AcceptInvalidDecl*/ true);
+  auto RE = SemaRef.BuildDeclarationNameExpr(NewSS, R, /*NeedsADL*/ false,
+                                             /*AcceptInvalidDecl*/ true);
+  return Finish(RE);
 }
 
 namespace {
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19274,9 +19274,6 @@
   if (!Context.getLangOpts().RecoveryAST)
     return ExprError();
 
-  if (isSFINAEContext())
-    return ExprError();
-
   if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
     // We don't know the concrete type, fallback to dependent type.
     T = Context.DependentTy;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to