Skip to content

Commit 1c923dd

Browse files
author
git apple-llvm automerger
committed
Merge commit 'adf845300c9c' from llvm.org/release/11.x into apple/stable/20200714
2 parents 2ddc39c + adf8453 commit 1c923dd

19 files changed

+193
-216
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3594,3 +3594,11 @@ def ReleaseHandle : InheritableParamAttr {
35943594
let Subjects = SubjectList<[ParmVar]>;
35953595
let Documentation = [ReleaseHandleDocs];
35963596
}
3597+
3598+
def Builtin : InheritableAttr {
3599+
let Spellings = [];
3600+
let Args = [UnsignedArgument<"ID">];
3601+
let Subjects = SubjectList<[Function]>;
3602+
let SemaHandler = 0;
3603+
let Documentation = [Undocumented];
3604+
}

clang/include/clang/Basic/Builtins.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ LIBBUILTIN(strncasecmp, "icC*cC*z", "f", "strings.h", ALL_GNU_LANGUAGES)
10171017
LIBBUILTIN(_exit, "vi", "fr", "unistd.h", ALL_GNU_LANGUAGES)
10181018
LIBBUILTIN(vfork, "p", "fj", "unistd.h", ALL_LANGUAGES)
10191019
// POSIX pthread.h
1020+
// FIXME: Should specify argument types.
10201021
LIBBUILTIN(pthread_create, "", "fC<2,3>", "pthread.h", ALL_GNU_LANGUAGES)
10211022

10221023
// POSIX setjmp.h

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,6 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
221221
}
222222
void setObjCKeywordID(tok::ObjCKeywordKind ID) { ObjCOrBuiltinID = ID; }
223223

224-
/// True if setNotBuiltin() was called.
225-
bool hasRevertedBuiltin() const {
226-
return ObjCOrBuiltinID == tok::NUM_OBJC_KEYWORDS;
227-
}
228-
229-
/// Revert the identifier to a non-builtin identifier. We do this if
230-
/// the name of a known builtin library function is used to declare that
231-
/// function, but an unexpected type is specified.
232-
void revertBuiltin() {
233-
setBuiltinID(0);
234-
}
235-
236224
/// Return a value indicating whether this is a builtin function.
237225
///
238226
/// 0 is not-built-in. 1+ are specific builtin functions.

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3990,6 +3990,8 @@ class Sema final {
39903990
ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
39913991
SourceLocation IdLoc,
39923992
bool TypoCorrection = false);
3993+
FunctionDecl *CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID,
3994+
SourceLocation Loc);
39933995
NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
39943996
Scope *S, bool ForRedeclaration,
39953997
SourceLocation Loc);

clang/lib/AST/Decl.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,44 +3163,24 @@ FunctionDecl *FunctionDecl::getCanonicalDecl() { return getFirstDecl(); }
31633163
/// functions as their wrapped builtins. This shouldn't be done in general, but
31643164
/// it's useful in Sema to diagnose calls to wrappers based on their semantics.
31653165
unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const {
3166-
unsigned BuiltinID;
3166+
unsigned BuiltinID = 0;
31673167

31683168
if (const auto *ABAA = getAttr<ArmBuiltinAliasAttr>()) {
31693169
BuiltinID = ABAA->getBuiltinName()->getBuiltinID();
3170-
} else {
3171-
if (!getIdentifier())
3172-
return 0;
3173-
3174-
BuiltinID = getIdentifier()->getBuiltinID();
3170+
} else if (const auto *A = getAttr<BuiltinAttr>()) {
3171+
BuiltinID = A->getID();
31753172
}
31763173

31773174
if (!BuiltinID)
31783175
return 0;
31793176

3180-
ASTContext &Context = getASTContext();
3181-
if (Context.getLangOpts().CPlusPlus) {
3182-
const auto *LinkageDecl =
3183-
dyn_cast<LinkageSpecDecl>(getFirstDecl()->getDeclContext());
3184-
// In C++, the first declaration of a builtin is always inside an implicit
3185-
// extern "C".
3186-
// FIXME: A recognised library function may not be directly in an extern "C"
3187-
// declaration, for instance "extern "C" { namespace std { decl } }".
3188-
if (!LinkageDecl) {
3189-
if (BuiltinID == Builtin::BI__GetExceptionInfo &&
3190-
Context.getTargetInfo().getCXXABI().isMicrosoft())
3191-
return Builtin::BI__GetExceptionInfo;
3192-
return 0;
3193-
}
3194-
if (LinkageDecl->getLanguage() != LinkageSpecDecl::lang_c)
3195-
return 0;
3196-
}
3197-
31983177
// If the function is marked "overloadable", it has a different mangled name
31993178
// and is not the C library function.
32003179
if (!ConsiderWrapperFunctions && hasAttr<OverloadableAttr>() &&
32013180
!hasAttr<ArmBuiltinAliasAttr>())
32023181
return 0;
32033182

3183+
ASTContext &Context = getASTContext();
32043184
if (!Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
32053185
return BuiltinID;
32063186

0 commit comments

Comments
 (0)