Can you tell me How it return "A" by getBase() and return "4" by getIdx().

If I've understood the question properly, getBase() returns the
pointer operand and getIdx() returns the integral one regardless of
which is outside the brackets. So even if you'd written "4[A]" the
type of A must be a pointer and getBase can tell which it is.

Thanks for your respose.You seem the type of return for getLHS() is Expr
*,How can you get A form A[4].As far as I know ,I
cann't get a std::string form such type as Expr *.

I can do it ,the codes as follows:for A[4]
Expr *rhs=Decl2->getRHS();
if(ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(rhs))
{
Curr=ICE->getSubExpr();
if(DeclRefExpr *ICE1 = dyn_cast<DeclRefExpr>(Curr))
De=ICE1->getNameInfo();
// llvm::errs()<<De.getAsString()<<"\n";
}
This is get "A"and
Expr *lhs=Decl2->getLHS();
if(ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(lhs))
{
Curr=ICE->getSubExpr();
if(DeclRefExpr *ICE1 = dyn_cast<DeclRefExpr>(Curr))
De=ICE1->getNameInfo();
// llvm::errs()<<De.getAsString()<<"\n";
}
This is get 4.
Thank your for your reply again.

I can do it ,the codes as follows:for A[4]
Expr *rhs=Decl2->getRHS();
if(ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(rhs))
{
Curr=ICE->getSubExpr();
if(DeclRefExpr *ICE1 = dyn_cast<DeclRefExpr>(Curr))
De=ICE1->getNameInfo();
// llvm::errs()<<De.getAsString()<<"\n";
}
This is get "A"and Expr *lhs=Decl2->getLHS();
if(ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(lhs))
{
Curr=ICE->getSubExpr();
if(DeclRefExpr *ICE1 = dyn_cast<DeclRefExpr>(Curr))
De=ICE1->getNameInfo();
// llvm::errs()<<De.getAsString()<<"\n";
}
This is get 4.

A couple of member functions of Expr would be helpful to you -

As far as I know,IgnoreImpCasts, IgnoreParens, IgnoreParenCasts don't help to
my question. http://a6128786ad6c6ad61b66ad4ddf09b1bd8
<http://a6128786ad6c6ad61b66ad4ddf09b1bd8> this link show us that
"IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return its
subexpression. If that subexpression is also a ParenExpr, then this method
recursively returns its subexpression, and so forth. Otherwise, the method
returns the current Expr. "I doubt your solution exactly.

As far as I know,IgnoreImpCasts, IgnoreParens, IgnoreParenCasts don't help to
my question. http://a6128786ad6c6ad61b66ad4ddf09b1bd8
<http://a6128786ad6c6ad61b66ad4ddf09b1bd8> this link show us that
"IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return its
subexpression. If that subexpression is also a ParenExpr, then this method
recursively returns its subexpression, and so forth. Otherwise, the method
returns the current Expr. "I doubt your solution exactly.

I meant that often you don't need to explicitly dyn_cast an Expr to ImplicitCastExpr. Instead, you can use IgnoreXXX function to strip off casts and/or parentheses. For example, your code was: