#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Intrinsics.h"
-#include "llvm/iOther.h"
+#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/Debugger/SourceFile.h"
#include "llvm/Debugger/SourceLanguage.h"
#include "Support/FileUtilities.h"
#include "Support/SlowOperationInformer.h"
#include "Support/STLExtras.h"
+#include <iostream>
+
using namespace llvm;
/// getGlobalVariablesUsing - Return all of the global variables which have the
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
if (GV->hasInitializer() && isa<ConstantArray>(GV->getInitializer())) {
ConstantArray *Init = cast<ConstantArray>(GV->getInitializer());
- if (Init->getType()->getElementType() == Type::SByteTy ||
- Init->getType()->getElementType() == Type::UByteTy) {
+ if (Init->isString()) {
std::string Result = Init->getAsString();
if (Offset < Result.size()) {
// If we are pointing INTO The string, erase the beginning...
}
}
} else if (Constant *C = dyn_cast<Constant>(V)) {
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C))
- return getStringValue(CPR->getValue(), Offset);
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(C))
+ return getStringValue(GV, Offset);
else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
if (CE->getOpcode() == Instruction::GetElementPtr) {
// Turn a gep into the specified offset.
if (const ConstantInt *C = dyn_cast<ConstantInt>(CI->getOperand(3)))
CurColNo = C->getRawValue();
const Value *Op = CI->getOperand(4);
- if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Op))
- Op = CPR->getValue();
if ((CurDesc = dyn_cast<GlobalVariable>(Op)) &&
(LineNo < LastLineNo ||
if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Desc->getInitializer()))
if (CS->getNumOperands() > 2) {
// Entry #1 is the file descriptor.
- if (const ConstantPointerRef *CPR =
- dyn_cast<ConstantPointerRef>(CS->getOperand(1)))
- if (const GlobalVariable *GV =
- dyn_cast<GlobalVariable>(CPR->getValue()))
- SourceFile = &PI.getSourceFile(GV);
+ if (const GlobalVariable *GV =
+ dyn_cast<GlobalVariable>(CS->getOperand(1)))
+ SourceFile = &PI.getSourceFile(GV);
// Entry #2 is the function name.
Name = getStringValue(CS->getOperand(2));
if (Desc && Desc->hasInitializer())
if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Desc->getInitializer()))
if (CS->getNumOperands() > 0)
- if (const ConstantPointerRef *CPR =
- dyn_cast<ConstantPointerRef>(CS->getOperand(1)))
- SourceFileDesc = dyn_cast<GlobalVariable>(CPR->getValue());
+ if (const GlobalVariable *GV =
+ dyn_cast<GlobalVariable>(CS->getOperand(1)))
+ SourceFileDesc = GV;
const SourceLanguage &Lang = getSourceFile(SourceFileDesc).getLanguage();
return *(Result = Lang.createSourceFunctionInfo(Desc, *this));