[cfe-commits] r135128 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/FixIt/typo-crash.cpp
Douglas Gregor
dgregor at apple.com
Wed Jul 13 21:54:23 PDT 2011
Author: dgregor
Date: Wed Jul 13 23:54:23 2011
New Revision: 135128
URL: http://llvm.org/viewvc/llvm-project?rev=135128&view=rev
Log:
Add a hackaround to avoid the crash in PR10355. However, our recovery
is still terrible here because typo correction is not behaving well in
the presence of overloaded functions.
Added:
cfe/trunk/test/FixIt/typo-crash.cpp (with props)
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=135128&r1=135127&r2=135128&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jul 13 23:54:23 2011
@@ -515,6 +515,7 @@
// Perform typo correction to determine if there is another name that is
// close to this name.
if (!SecondTry) {
+ SecondTry = true;
if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(),
Result.getLookupKind(), S, &SS)) {
unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
@@ -560,8 +561,9 @@
if (Corrected.isKeyword())
return Corrected.getCorrectionAsIdentifierInfo();
- Diag(FirstDecl->getLocation(), diag::note_previous_decl)
- << CorrectedQuotedStr;
+ if (FirstDecl)
+ Diag(FirstDecl->getLocation(), diag::note_previous_decl)
+ << CorrectedQuotedStr;
// If we found an Objective-C instance variable, let
// LookupInObjCMethod build the appropriate expression to
Added: cfe/trunk/test/FixIt/typo-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo-crash.cpp?rev=135128&view=auto
==============================================================================
--- cfe/trunk/test/FixIt/typo-crash.cpp (added)
+++ cfe/trunk/test/FixIt/typo-crash.cpp Wed Jul 13 23:54:23 2011
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: The diagnostics and recovery here are very, very poor.
+
+// PR10355
+template<typename T> void template_id1() {
+ template_id2<> t; // expected-error 2{{use of undeclared identifier 'template_id2'; did you mean 'template_id1'?}} \
+ // expected-error{{expected expression}} \
+ // expected-error{{use of undeclared identifier 't'}}
+ }
+
Propchange: cfe/trunk/test/FixIt/typo-crash.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/FixIt/typo-crash.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/FixIt/typo-crash.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list