From d3205bbca3e0002d76282878986993e7e7994779 Mon Sep 17 00:00:00 2001 From: Tyker Date: Mon, 26 Oct 2020 09:58:20 +0100 Subject: [Annotation] Allows annotation to carry some additional constant arguments. This allows using annotation in a much more contexts than it currently has. especially when annotation with template or constexpr. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D88645 --- clang/lib/CodeGen/CodeGenFunction.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 2498e2e..78a40aa 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2234,13 +2234,16 @@ void CodeGenFunction::emitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *CodeGenFunction::EmitAnnotationCall(llvm::Function *AnnotationFn, llvm::Value *AnnotatedVal, StringRef AnnotationStr, - SourceLocation Location) { - llvm::Value *Args[4] = { - AnnotatedVal, - Builder.CreateBitCast(CGM.EmitAnnotationString(AnnotationStr), Int8PtrTy), - Builder.CreateBitCast(CGM.EmitAnnotationUnit(Location), Int8PtrTy), - CGM.EmitAnnotationLineNo(Location) + SourceLocation Location, + const AnnotateAttr *Attr) { + SmallVector Args = { + AnnotatedVal, + Builder.CreateBitCast(CGM.EmitAnnotationString(AnnotationStr), Int8PtrTy), + Builder.CreateBitCast(CGM.EmitAnnotationUnit(Location), Int8PtrTy), + CGM.EmitAnnotationLineNo(Location), }; + if (Attr) + Args.push_back(CGM.EmitAnnotationArgs(Attr)); return Builder.CreateCall(AnnotationFn, Args); } @@ -2251,7 +2254,7 @@ void CodeGenFunction::EmitVarAnnotations(const VarDecl *D, llvm::Value *V) { for (const auto *I : D->specific_attrs()) EmitAnnotationCall(CGM.getIntrinsic(llvm::Intrinsic::var_annotation), Builder.CreateBitCast(V, CGM.Int8PtrTy, V->getName()), - I->getAnnotation(), D->getLocation()); + I->getAnnotation(), D->getLocation(), I); } Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D, @@ -2268,7 +2271,7 @@ Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D, // itself. if (VTy != CGM.Int8PtrTy) V = Builder.CreateBitCast(V, CGM.Int8PtrTy); - V = EmitAnnotationCall(F, V, I->getAnnotation(), D->getLocation()); + V = EmitAnnotationCall(F, V, I->getAnnotation(), D->getLocation(), I); V = Builder.CreateBitCast(V, VTy); } -- cgit v1.1