could you give me some advice ?

excuse me for bother you again .
a little supplement

Constant* c = findValue(m,"E1$entry");
Constant* c2 = findValue(m,"E1$str");

I can get string object from c2
string s = cast<ConstantArray>(c2)->getAsString();

but it is not applicable for c
string s= cast<ConstantArray>(c)->getAsString(); // Assert Fail

because c is ConstantExpr::GetElementPtr actually , not ConstantArray
so I have to get string object like this :
GlobalVariable* gv = cast<GlobalVariable>(c->getOperand(0));
ConstantArray* ca = cast<ConstantArray>(gv->getOperand(0));
std::string str = ca->getAsString();
I feel this code a little awkward .
I wonder whether it should to be improved ?
thanks again

but it is not applicable for c
string s= cast<ConstantArray>(c)->getAsString(); // Assert Fail

because c is ConstantExpr::GetElementPtr actually , not ConstantArray

Exactly.

so I have to get string object like this :
GlobalVariable* gv = cast<GlobalVariable>(c->getOperand(0));
ConstantArray* ca = cast<ConstantArray>(gv->getOperand(0));
std::string str = ca->getAsString();
I feel this code a little awkward .
I wonder whether it should to be improved ?

You have the right approach, there is nothing better that you can do, other than writing helper functions for yourself.

The issue is that LLVM has no notion of a 'string'. It only has global variables that are constant arrays, which happen to be initialized with byte values that can be interpreted in a string-like way.

The ConstantArray::getAsString method is a nice convenience method, but it doesn't make sense for GlobalVariable's to have this.

-Chris