} else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
return LValue::MakeAddr(CGM.GetAddrOfFunctionDecl(FD, false));
} else if (const FileVarDecl *FVD = dyn_cast<FileVarDecl>(D)) {
- return LValue::MakeAddr(CGM.GetAddrOfFileVarDecl(FVD, false));
+ return LValue::MakeAddr(CGM.GetAddrOfGlobalVar(FVD, false));
}
assert(0 && "Unimp declref");
//an invalid LValue, but the assert will
return Entry = NewFn;
}
-llvm::Constant *CodeGenModule::GetAddrOfFileVarDecl(const FileVarDecl *D,
- bool isDefinition) {
+llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
+ bool isDefinition) {
+ assert(D->hasGlobalStorage() && "Not a global variable");
+
// See if it is already in the map.
llvm::Constant *&Entry = GlobalDeclMap[D];
if (Entry) return Entry;
// The only thing that can have array type like this is a
// DeclRefExpr(FileVarDecl)?
const DeclRefExpr *DRE = cast<DeclRefExpr>(ICExpr->getSubExpr());
- const FileVarDecl *FVD = cast<FileVarDecl>(DRE->getDecl());
- llvm::Constant *C = CGM.GetAddrOfFileVarDecl(FVD, false);
+ const VarDecl *VD = cast<VarDecl>(DRE->getDecl());
+ llvm::Constant *C = CGM.GetAddrOfGlobalVar(VD, false);
assert(isa<llvm::PointerType>(C->getType()) &&
isa<llvm::ArrayType>(cast<llvm::PointerType>(C->getType())
->getElementType()));
// Get the global, forcing it to be a direct reference.
llvm::GlobalVariable *GV =
- cast<llvm::GlobalVariable>(GetAddrOfFileVarDecl(D, true));
+ cast<llvm::GlobalVariable>(GetAddrOfGlobalVar(D, true));
// Convert the initializer, or use zero if appropriate.
llvm::Constant *Init = 0;
class Expr;
class Stmt;
class ValueDecl;
+ class VarDecl;
class FileVarDecl;
struct LangOptions;
class Diagnostic;
llvm::Constant *GetAddrOfFunctionDecl(const FunctionDecl *D,
bool isDefinition);
- llvm::Constant *GetAddrOfFileVarDecl(const FileVarDecl *D,
- bool isDefinition);
+ llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D, bool isDefinition);
/// getBuiltinLibFunction - Given a builtin id for a function like