r219050 - -ms-extensions: Allow __super in return stements.
Nikola Smiljanic
popizdeh at gmail.com
Sat Oct 4 03:17:58 PDT 2014
Author: nikola
Date: Sat Oct 4 05:17:57 2014
New Revision: 219050
URL: http://llvm.org/viewvc/llvm-project?rev=219050&view=rev
Log:
-ms-extensions: Allow __super in return stements.
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/MicrosoftSuper.cpp
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=219050&r1=219049&r2=219050&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Oct 4 05:17:57 2014
@@ -2616,7 +2616,7 @@ public:
ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc,
RedeclarationKind Redecl
= NotForRedeclaration);
- void LookupInSuper(LookupResult &R, CXXRecordDecl *Class);
+ bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class);
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
QualType T1, QualType T2,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=219050&r1=219049&r2=219050&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Oct 4 05:17:57 2014
@@ -702,11 +702,7 @@ Sema::NameClassification Sema::ClassifyN
}
LookupResult Result(*this, Name, NameLoc, LookupOrdinaryName);
- NestedNameSpecifier *NNS = SS.getScopeRep();
- if (NNS && NNS->getKind() == NestedNameSpecifier::Super)
- LookupInSuper(Result, NNS->getAsRecordDecl());
- else
- LookupParsedName(Result, S, &SS, !CurMethod);
+ LookupParsedName(Result, S, &SS, !CurMethod);
// For unqualified lookup in a class template in MSVC mode, look into
// dependent base classes where the primary class template is known.
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=219050&r1=219049&r2=219050&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Sat Oct 4 05:17:57 2014
@@ -1782,7 +1782,8 @@ bool Sema::LookupQualifiedName(LookupRes
/// contexts that receive a name and an optional C++ scope specifier
/// (e.g., "N::M::x"). It will then perform either qualified or
/// unqualified name lookup (with LookupQualifiedName or LookupName,
-/// respectively) on the given name and return those results.
+/// respectively) on the given name and return those results. It will
+/// perform a special type of lookup for "__super::" scope specifier.
///
/// @param S The scope from which unqualified name lookup will
/// begin.
@@ -1802,6 +1803,10 @@ bool Sema::LookupParsedName(LookupResult
}
if (SS && SS->isSet()) {
+ NestedNameSpecifier *NNS = SS->getScopeRep();
+ if (NNS->getKind() == NestedNameSpecifier::Super)
+ return LookupInSuper(R, NNS->getAsRecordDecl());
+
if (DeclContext *DC = computeDeclContext(*SS, EnteringContext)) {
// We have resolved the scope specifier to a particular declaration
// contex, and will perform name lookup in that context.
@@ -1831,7 +1836,9 @@ bool Sema::LookupParsedName(LookupResult
///
/// \param Class The context in which qualified name lookup will
/// search. Name lookup will search in all base classes merging the results.
-void Sema::LookupInSuper(LookupResult &R, CXXRecordDecl *Class) {
+///
+/// @returns True if any decls were found (but possibly ambiguous)
+bool Sema::LookupInSuper(LookupResult &R, CXXRecordDecl *Class) {
for (const auto &BaseSpec : Class->bases()) {
CXXRecordDecl *RD = cast<CXXRecordDecl>(
BaseSpec.getType()->castAs<RecordType>()->getDecl());
@@ -1843,6 +1850,8 @@ void Sema::LookupInSuper(LookupResult &R
}
R.resolveKind();
+
+ return !R.empty();
}
/// \brief Produce a diagnostic describing the ambiguity that resulted
Modified: cfe/trunk/test/SemaCXX/MicrosoftSuper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftSuper.cpp?rev=219050&r1=219049&r2=219050&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftSuper.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftSuper.cpp Sat Oct 4 05:17:57 2014
@@ -29,12 +29,14 @@ struct Derived : Base1 {
X = sizeof(__super::XXX)
};
- void foo(int i) {
- __super::foo(i);
+ void foo() {
+ __super::foo(1);
- if (i == 0) {
- __super::foo(i);
+ if (true) {
+ __super::foo(1);
}
+
+ return __super::foo(1);
}
static void bar() {
More information about the cfe-commits
mailing list