summaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d56c5980237c..0ed51de0cc13 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -739,6 +739,18 @@ static void GetOpenCLBuiltinFctOverloads(
}
}
+/// Add extensions to the function declaration.
+/// \param S (in/out) The Sema instance.
+/// \param BIDecl (in) Description of the builtin.
+/// \param FDecl (in/out) FunctionDecl instance.
+static void AddOpenCLExtensions(Sema &S, const OpenCLBuiltinStruct &BIDecl,
+ FunctionDecl *FDecl) {
+ // Fetch extension associated with a function prototype.
+ StringRef E = FunctionExtensionTable[BIDecl.Extension];
+ if (E != "")
+ S.setOpenCLExtensionForDecl(FDecl, E);
+}
+
/// When trying to resolve a function name, if isOpenCLBuiltin() returns a
/// non-null <Index, Len> pair, then the name is referencing an OpenCL
/// builtin function. Add all candidate signatures to the LookUpResult.
@@ -765,10 +777,13 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
ASTContext &Context = S.Context;
// Ignore this BIF if its version does not match the language options.
- if (Context.getLangOpts().OpenCLVersion < OpenCLBuiltin.MinVersion)
+ unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
+ if (Context.getLangOpts().OpenCLCPlusPlus)
+ OpenCLVersion = 200;
+ if (OpenCLVersion < OpenCLBuiltin.MinVersion)
continue;
if ((OpenCLBuiltin.MaxVersion != 0) &&
- (Context.getLangOpts().OpenCLVersion >= OpenCLBuiltin.MaxVersion))
+ (OpenCLVersion >= OpenCLBuiltin.MaxVersion))
continue;
SmallVector<QualType, 1> RetTypes;
@@ -812,9 +827,20 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
}
NewOpenCLBuiltin->setParams(ParmList);
}
- if (!S.getLangOpts().OpenCLCPlusPlus) {
+
+ // Add function attributes.
+ if (OpenCLBuiltin.IsPure)
+ NewOpenCLBuiltin->addAttr(PureAttr::CreateImplicit(Context));
+ if (OpenCLBuiltin.IsConst)
+ NewOpenCLBuiltin->addAttr(ConstAttr::CreateImplicit(Context));
+ if (OpenCLBuiltin.IsConv)
+ NewOpenCLBuiltin->addAttr(ConvergentAttr::CreateImplicit(Context));
+
+ if (!S.getLangOpts().OpenCLCPlusPlus)
NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context));
- }
+
+ AddOpenCLExtensions(S, OpenCLBuiltin, NewOpenCLBuiltin);
+
LR.addDecl(NewOpenCLBuiltin);
}
}
@@ -3101,11 +3127,10 @@ Sema::SpecialMemberOverloadResult Sema::LookupSpecialMember(CXXRecordDecl *RD,
});
}
CXXDestructorDecl *DD = RD->getDestructor();
- assert(DD && "record without a destructor");
Result->setMethod(DD);
- Result->setKind(DD->isDeleted() ?
- SpecialMemberOverloadResult::NoMemberOrDeleted :
- SpecialMemberOverloadResult::Success);
+ Result->setKind(DD && !DD->isDeleted()
+ ? SpecialMemberOverloadResult::Success
+ : SpecialMemberOverloadResult::NoMemberOrDeleted);
return *Result;
}