aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2008-04-19 04:17:09 +0000
committerNate Begeman <natebegeman@mac.com>2008-04-19 04:17:09 +0000
commit8bd4afeb876fd0015bb808eb2f3de1fe709658a7 (patch)
tree362833f12587d36e36f3a338bbb2a7be316fd346 /lib/CodeGen/CGDecl.cpp
parent532485cc6c078d9e51b517c6bbd8984deb17f0fe (diff)
Generate code for annotation attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49951 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index e186bb69eb..df5882c217 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -14,6 +14,7 @@
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/AST.h"
+#include "clang/Basic/SourceManager.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Type.h"
using namespace clang;
@@ -82,19 +83,26 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
}
assert(Init && "Unable to create initialiser for static decl");
-
+
std::string ContextName;
if (const FunctionDecl * FD = dyn_cast<FunctionDecl>(CurFuncDecl))
ContextName = FD->getName();
else
assert(0 && "Unknown context for block var decl"); // FIXME Handle objc.
-
- DMEntry =
- new llvm::GlobalVariable(LTy, false,
- llvm::GlobalValue::InternalLinkage,
+
+ llvm::GlobalValue *GV =
+ new llvm::GlobalVariable(LTy, false, llvm::GlobalValue::InternalLinkage,
Init, ContextName + "." + D.getName(),
- &CGM.getModule(), 0,
- Ty.getAddressSpace());
+ &CGM.getModule(), 0, Ty.getAddressSpace());
+
+ if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) {
+ SourceManager &SM = CGM.getContext().getSourceManager();
+ llvm::Constant *Ann =
+ CGM.EmitAnnotateAttr(GV, AA, SM.getLogicalLineNumber(D.getLocation()));
+ CGM.AddAnnotation(Ann);
+ }
+
+ DMEntry = GV;
}
/// EmitLocalBlockVarDecl - Emit code and set up an entry in LocalDeclMap for a