AST, Sema, Serialization: keep track of cudaConfigureCall
llvm-svn: 125216
This commit is contained in:
parent
fd3e83953f
commit
9e2c81f00a
|
@ -210,6 +210,9 @@ class ASTContext {
|
|||
/// \brief Type for the Block descriptor for Blocks CodeGen.
|
||||
mutable RecordDecl *BlockDescriptorExtendedType;
|
||||
|
||||
/// \brief Declaration for the CUDA cudaConfigureCall function.
|
||||
FunctionDecl *cudaConfigureCallDecl;
|
||||
|
||||
TypeSourceInfo NullTypeSourceInfo;
|
||||
|
||||
/// \brief Keeps track of all declaration attributes.
|
||||
|
@ -541,6 +544,13 @@ public:
|
|||
return QualType();
|
||||
}
|
||||
|
||||
void setcudaConfigureCallDecl(FunctionDecl *FD) {
|
||||
cudaConfigureCallDecl = FD;
|
||||
}
|
||||
FunctionDecl *getcudaConfigureCallDecl() {
|
||||
return cudaConfigureCallDecl;
|
||||
}
|
||||
|
||||
/// This gets the struct used to keep track of pointer to blocks, complete
|
||||
/// with captured variables.
|
||||
QualType getBlockParmType(bool BlockHasCopyDispose,
|
||||
|
|
|
@ -3049,6 +3049,8 @@ def err_deleted_function_use : Error<"attempt to use a deleted function">;
|
|||
|
||||
def err_kern_type_not_void_return : Error<
|
||||
"kernel function type %0 must have void return type">;
|
||||
def err_config_scalar_return : Error<
|
||||
"CUDA special function 'cudaConfigureCall' must have scalar return type">;
|
||||
|
||||
|
||||
def err_cannot_pass_objc_interface_to_vararg : Error<
|
||||
|
|
|
@ -347,7 +347,10 @@ namespace clang {
|
|||
CXX_BASE_SPECIFIER_OFFSETS = 37,
|
||||
|
||||
/// \brief Record code for #pragma diagnostic mappings.
|
||||
DIAG_PRAGMA_MAPPINGS = 38
|
||||
DIAG_PRAGMA_MAPPINGS = 38,
|
||||
|
||||
/// \brief Record code for special CUDA declarations.
|
||||
CUDA_SPECIAL_DECL_REFS = 39
|
||||
};
|
||||
|
||||
/// \brief Record types used within a source manager block.
|
||||
|
|
|
@ -575,6 +575,12 @@ private:
|
|||
/// The AST context tracks a few important types, such as va_list, directly.
|
||||
llvm::SmallVector<uint64_t, 16> SpecialTypes;
|
||||
|
||||
/// \brief The IDs of CUDA-specific declarations ASTContext stores directly.
|
||||
///
|
||||
/// The AST context tracks a few important decls, currently cudaConfigureCall,
|
||||
/// directly.
|
||||
llvm::SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
|
||||
|
||||
//@}
|
||||
|
||||
/// \brief Diagnostic IDs and their mappings that the user changed.
|
||||
|
|
|
@ -197,6 +197,7 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
|
|||
CFConstantStringTypeDecl(0), NSConstantStringTypeDecl(0),
|
||||
ObjCFastEnumerationStateTypeDecl(0), FILEDecl(0), jmp_bufDecl(0),
|
||||
sigjmp_bufDecl(0), BlockDescriptorType(0), BlockDescriptorExtendedType(0),
|
||||
cudaConfigureCallDecl(0),
|
||||
NullTypeSourceInfo(QualType()),
|
||||
SourceMgr(SM), LangOpts(LOpts), ABI(createCXXABI(t)), Target(t),
|
||||
Idents(idents), Selectors(sels),
|
||||
|
|
|
@ -4110,6 +4110,19 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
|||
}
|
||||
|
||||
MarkUnusedFileScopedDecl(NewFD);
|
||||
|
||||
if (getLangOptions().CUDA)
|
||||
if (IdentifierInfo *II = NewFD->getIdentifier())
|
||||
if (!NewFD->isInvalidDecl() &&
|
||||
NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
|
||||
if (II->isStr("cudaConfigureCall")) {
|
||||
if (!R->getAs<FunctionType>()->getResultType()->isScalarType())
|
||||
Diag(NewFD->getLocation(), diag::err_config_scalar_return);
|
||||
|
||||
Context.setcudaConfigureCallDecl(NewFD);
|
||||
}
|
||||
}
|
||||
|
||||
return NewFD;
|
||||
}
|
||||
|
||||
|
|
|
@ -2152,6 +2152,11 @@ ASTReader::ReadASTBlock(PerFileData &F) {
|
|||
PragmaDiagMappings.insert(PragmaDiagMappings.end(),
|
||||
Record.begin(), Record.end());
|
||||
break;
|
||||
|
||||
case CUDA_SPECIAL_DECL_REFS:
|
||||
// Later tables overwrite earlier ones.
|
||||
CUDASpecialDeclRefs.swap(Record);
|
||||
break;
|
||||
}
|
||||
First = false;
|
||||
}
|
||||
|
@ -2496,6 +2501,13 @@ void ASTReader::InitializeContext(ASTContext &Ctx) {
|
|||
Context->setInt128Installed();
|
||||
|
||||
ReadPragmaDiagnosticMappings(Context->getDiagnostics());
|
||||
|
||||
// If there were any CUDA special declarations, deserialize them.
|
||||
if (!CUDASpecialDeclRefs.empty()) {
|
||||
assert(CUDASpecialDeclRefs.size() == 1 && "More decl refs than expected!");
|
||||
Context->setcudaConfigureCallDecl(
|
||||
cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Retrieve the name of the original source file name
|
||||
|
|
|
@ -2545,6 +2545,11 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
|||
AddDeclRef(SemaRef.getStdBadAlloc(), SemaDeclRefs);
|
||||
}
|
||||
|
||||
RecordData CUDASpecialDeclRefs;
|
||||
if (Context.getcudaConfigureCallDecl()) {
|
||||
AddDeclRef(Context.getcudaConfigureCallDecl(), CUDASpecialDeclRefs);
|
||||
}
|
||||
|
||||
// Write the remaining AST contents.
|
||||
RecordData Record;
|
||||
Stream.EnterSubblock(AST_BLOCK_ID, 5);
|
||||
|
@ -2659,6 +2664,10 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
|||
if (!SemaDeclRefs.empty())
|
||||
Stream.EmitRecord(SEMA_DECL_REFS, SemaDeclRefs);
|
||||
|
||||
// Write the record containing CUDA-specific declaration references.
|
||||
if (!CUDASpecialDeclRefs.empty())
|
||||
Stream.EmitRecord(CUDA_SPECIAL_DECL_REFS, CUDASpecialDeclRefs);
|
||||
|
||||
// Some simple statistics
|
||||
Record.clear();
|
||||
Record.push_back(NumStatements);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
void cudaConfigureCall(unsigned gridSize, unsigned blockSize); // expected-error {{must have scalar return type}}
|
Loading…
Reference in New Issue