r184762 - Add the global namespace (the "::" namespace specifier) to the list of
Kaelyn Uhrain
rikka at google.com
Mon Jun 24 10:49:04 PDT 2013
Author: rikka
Date: Mon Jun 24 12:49:03 2013
New Revision: 184762
URL: http://llvm.org/viewvc/llvm-project?rev=184762&view=rev
Log:
Add the global namespace (the "::" namespace specifier) to the list of
namespaces to try for potential typo corrections.
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
cfe/trunk/test/FixIt/typo.cpp
cfe/trunk/test/Parser/cxx-using-directive.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=184762&r1=184761&r2=184762&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Jun 24 12:49:03 2013
@@ -3414,7 +3414,7 @@ class NamespaceSpecifierSet {
NamespaceSpecifierSet(ASTContext &Context, DeclContext *CurContext,
CXXScopeSpec *CurScopeSpec)
: Context(Context), CurContextChain(BuildContextChain(CurContext)),
- isSorted(true) {
+ isSorted(false) {
if (CurScopeSpec && CurScopeSpec->getScopeRep())
getNestedNameSpecifierIdentifiers(CurScopeSpec->getScopeRep(),
CurNameSpecifierIdentifiers);
@@ -3427,6 +3427,12 @@ class NamespaceSpecifierSet {
if (NamespaceDecl *ND = dyn_cast_or_null<NamespaceDecl>(*C))
CurContextIdentifiers.push_back(ND->getIdentifier());
}
+
+ // Add the global context as a NestedNameSpecifier
+ Distances.insert(1);
+ DistanceMap[1].push_back(
+ SpecifierInfo(cast<DeclContext>(Context.getTranslationUnitDecl()),
+ NestedNameSpecifier::GlobalSpecifier(Context), 1));
}
/// \brief Add the namespace to the set, computing the corresponding
Modified: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp?rev=184762&r1=184761&r2=184762&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp Mon Jun 24 12:49:03 2013
@@ -3,7 +3,7 @@
// Fun things you can do with inline namespaces:
inline namespace X {
- void f1();
+ void f1(); // expected-note {{'::f1' declared here}}
inline namespace Y {
void f2();
@@ -21,7 +21,7 @@ void foo1() {
f1();
::f1();
X::f1();
- Y::f1(); // expected-error {{no member named 'f1' in namespace 'X::Y'}}
+ Y::f1(); // expected-error {{no member named 'f1' in namespace 'X::Y'; did you mean '::f1'?}}
f2();
::f2();
Modified: cfe/trunk/test/FixIt/typo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo.cpp?rev=184762&r1=184761&r2=184762&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/typo.cpp (original)
+++ cfe/trunk/test/FixIt/typo.cpp Mon Jun 24 12:49:03 2013
@@ -6,7 +6,7 @@
namespace std {
template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}} \
- // expected-note {{'otherstd::basic_string' declared here}}
+ // expected-note {{'::basic_string' declared here}}
public:
int find(const char *substr); // expected-note{{'find' declared here}}
static const int npos = -1; // expected-note{{'npos' declared here}}
@@ -84,8 +84,12 @@ namespace nonstd {
yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
wibble::yarn str5; // expected-error{{no type named 'yarn' in namespace 'otherstd'; did you mean 'nonstd::yarn'?}}
+namespace another {
+ template<typename T> class wide_string {}; // expected-note {{'another::wide_string' declared here}}
+}
int poit() {
- nonstd::basic_string<char> str; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean 'otherstd::basic_string'?}}
+ nonstd::basic_string<char> str; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean '::basic_string'?}}
+ nonstd::wide_string<char> str2; // expected-error{{no template named 'wide_string' in namespace 'nonstd'; did you mean 'another::wide_string'?}}
return wibble::narf; // expected-error{{no member named 'narf' in namespace 'otherstd'; did you mean 'nonstd::narf'?}}
}
Modified: cfe/trunk/test/Parser/cxx-using-directive.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-using-directive.cpp?rev=184762&r1=184761&r2=184762&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-using-directive.cpp (original)
+++ cfe/trunk/test/Parser/cxx-using-directive.cpp Mon Jun 24 12:49:03 2013
@@ -8,7 +8,7 @@ namespace B {
using namespace A ;
}
-namespace C {}
+namespace C {} // expected-note{{namespace '::C' defined here}}
namespace D {
@@ -22,7 +22,8 @@ namespace D {
using namespace C ;
using namespace B::A ; // expected-error{{no namespace named 'A' in namespace 'D::B'; did you mean '::B::A'?}}
using namespace ::B::A ;
- using namespace ::D::C ; // expected-error{{expected namespace name}}
+ using namespace ::D::F ; // expected-error{{expected namespace name}}
+ using namespace ::D::C ; // expected-error{{no namespace named 'C' in namespace 'D'; did you mean '::C'?}}
}
using namespace ! ; // expected-error{{expected namespace name}}
More information about the cfe-commits
mailing list