[PATCH] D87983: [Sema] Split special builtin type lookups into a separate function
Raul Tambre via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 09:12:45 PDT 2020
This revision was automatically updated to reflect the committed changes.
tambre marked an inline comment as done.
Closed by commit rGf91f28c350df: [Sema] Split special builtin type lookups into a separate function (authored by tambre).
Changed prior to commit:
https://reviews.llvm.org/D87983?vs=293008&id=293193#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87983/new/
https://reviews.llvm.org/D87983
Files:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaLookup.cpp
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -907,6 +907,24 @@
return false;
}
+/// Looks up the declaration of "struct objc_super" and
+/// saves it for later use in building builtin declaration of
+/// objc_msgSendSuper and objc_msgSendSuper_stret.
+static void LookupPredefedObjCSuperType(Sema &Sema, Scope *S) {
+ ASTContext &Context = Sema.Context;
+ LookupResult Result(Sema, &Context.Idents.get("objc_super"), SourceLocation(),
+ Sema::LookupTagName);
+ Sema.LookupName(Result, S);
+ if (Result.getResultKind() == LookupResult::Found)
+ if (const TagDecl *TD = Result.getAsSingle<TagDecl>())
+ Context.setObjCSuperType(Context.getTagDeclType(TD));
+}
+
+void Sema::LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID) {
+ if (ID == Builtin::BIobjc_msgSendSuper)
+ LookupPredefedObjCSuperType(*this, S);
+}
+
/// Determine whether we can declare a special member function within
/// the class at this point.
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class) {
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2035,24 +2035,6 @@
return S;
}
-/// Looks up the declaration of "struct objc_super" and
-/// saves it for later use in building builtin declaration of
-/// objc_msgSendSuper and objc_msgSendSuper_stret. If no such
-/// pre-existing declaration exists no action takes place.
-static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S,
- IdentifierInfo *II) {
- if (!II->isStr("objc_msgSendSuper"))
- return;
- ASTContext &Context = ThisSema.Context;
-
- LookupResult Result(ThisSema, &Context.Idents.get("objc_super"),
- SourceLocation(), Sema::LookupTagName);
- ThisSema.LookupName(Result, S);
- if (Result.getResultKind() == LookupResult::Found)
- if (const TagDecl *TD = Result.getAsSingle<TagDecl>())
- Context.setObjCSuperType(Context.getTagDeclType(TD));
-}
-
static StringRef getHeaderName(Builtin::Context &BuiltinInfo, unsigned ID,
ASTContext::GetBuiltinTypeError Error) {
switch (Error) {
@@ -2113,7 +2095,7 @@
NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
Scope *S, bool ForRedeclaration,
SourceLocation Loc) {
- LookupPredefedObjCSuperType(*this, S, II);
+ LookupNecessaryTypesForBuiltin(S, ID);
ASTContext::GetBuiltinTypeError Error;
QualType R = Context.GetBuiltinType(ID, Error);
@@ -9671,7 +9653,7 @@
NewFD->addAttr(BuiltinAttr::CreateImplicit(Context, BuiltinID));
} else {
ASTContext::GetBuiltinTypeError Error;
- LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
+ LookupNecessaryTypesForBuiltin(S, BuiltinID);
QualType BuiltinType = Context.GetBuiltinType(BuiltinID, Error);
if (!Error && !BuiltinType.isNull() &&
@@ -10880,7 +10862,7 @@
// declaration against the expected type for the builtin.
if (unsigned BuiltinID = NewFD->getBuiltinID()) {
ASTContext::GetBuiltinTypeError Error;
- LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
+ LookupNecessaryTypesForBuiltin(S, BuiltinID);
QualType T = Context.GetBuiltinType(BuiltinID, Error);
// If the type of the builtin differs only in its exception
// specification, that's OK.
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3813,6 +3813,7 @@
RedeclarationKind Redecl
= NotForRedeclaration);
bool LookupBuiltin(LookupResult &R);
+ void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
bool LookupName(LookupResult &R, Scope *S,
bool AllowBuiltinCreation = false);
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87983.293193.patch
Type: text/x-patch
Size: 4269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200921/98708acc/attachment.bin>
More information about the cfe-commits
mailing list