r200868 - Don't consider records with a NULL identifier as a name for typo correction.
Kaelyn Uhrain
rikka at google.com
Wed Feb 5 10:57:51 PST 2014
Author: rikka
Date: Wed Feb 5 12:57:51 2014
New Revision: 200868
URL: http://llvm.org/viewvc/llvm-project?rev=200868&view=rev
Log:
Don't consider records with a NULL identifier as a name for typo correction.
Because in C++, "anonymous" doesn't mean "nameless" for records. In
other words, RecordDecl::isAnonymousStructOrUnion only returns true if
the record lacks a name *and* is not used as the type in an object's
declaration.
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=200868&r1=200867&r2=200868&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Feb 5 12:57:51 2014
@@ -4216,7 +4216,7 @@ TypoCorrection Sema::CorrectTypo(const D
if (CXXRecordDecl *CD = (*TI)->getAsCXXRecordDecl()) {
CD = CD->getCanonicalDecl();
if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
- !CD->isUnion() &&
+ !CD->isUnion() && CD->getIdentifier() &&
(CD->isBeingDefined() || CD->isCompleteDefinition()))
Namespaces.AddNameSpecifier(CD);
}
Modified: cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp?rev=200868&r1=200867&r2=200868&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-pt2.cpp Wed Feb 5 12:57:51 2014
@@ -199,3 +199,11 @@ template <>
PR18213::WrapperInfo ::PR18213::Wrappable<int>::kWrapperInfo = { 0 }; // expected-error {{no member named 'PR18213' in 'PR18213::WrapperInfo'; did you mean simply 'PR18213'?}} \
// expected-error {{C++ requires a type specifier for all declarations}}
}
+
+namespace PR18651 {
+struct {
+ int x;
+} a, b;
+
+int y = x; // expected-error-re {{use of undeclared identifier 'x'{{$}}}}
+}
More information about the cfe-commits
mailing list