mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-16 13:08:42 +00:00
Cleanup the style of some of this code prior to functional changes.
I think this moves the code in the desired direction of the new style recommendations (and style conventional in Clang), but if anyone prefers the previous style, or has other suggestions just chime in and I'll follow up. llvm-svn: 128878
This commit is contained in:
parent
7f3654f65c
commit
4e02182a74
@ -379,40 +379,43 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
/// ContainsReference - A visitor class to search for references to
|
||||
/// a particular declaration (the needle) within any evaluated component of an
|
||||
/// expression (recursively).
|
||||
class ContainsReference : public EvaluatedExprVisitor<ContainsReference> {
|
||||
bool containsReference;
|
||||
const DeclRefExpr *dr;
|
||||
bool FoundReference;
|
||||
const DeclRefExpr *Needle;
|
||||
|
||||
public:
|
||||
ContainsReference(ASTContext &context,
|
||||
const DeclRefExpr *dr) :
|
||||
EvaluatedExprVisitor<ContainsReference>(context),
|
||||
containsReference(false), dr(dr) {}
|
||||
|
||||
void VisitExpr(Expr *e) {
|
||||
ContainsReference(ASTContext &Context, const DeclRefExpr *Needle)
|
||||
: EvaluatedExprVisitor<ContainsReference>(Context),
|
||||
FoundReference(false), Needle(Needle) {}
|
||||
|
||||
void VisitExpr(Expr *E) {
|
||||
// Stop evaluating if we already have a reference.
|
||||
if (containsReference)
|
||||
if (FoundReference)
|
||||
return;
|
||||
|
||||
EvaluatedExprVisitor<ContainsReference>::VisitExpr(e);
|
||||
|
||||
EvaluatedExprVisitor<ContainsReference>::VisitExpr(E);
|
||||
}
|
||||
|
||||
void VisitDeclRefExpr(DeclRefExpr *e) {
|
||||
if (e == dr)
|
||||
containsReference = true;
|
||||
else
|
||||
EvaluatedExprVisitor<ContainsReference>::VisitDeclRefExpr(e);
|
||||
|
||||
void VisitDeclRefExpr(DeclRefExpr *E) {
|
||||
if (E == Needle)
|
||||
FoundReference = true;
|
||||
else
|
||||
EvaluatedExprVisitor<ContainsReference>::VisitDeclRefExpr(E);
|
||||
}
|
||||
|
||||
bool doesContainReference() const { return containsReference; }
|
||||
|
||||
bool doesContainReference() const { return FoundReference; }
|
||||
};
|
||||
}
|
||||
|
||||
static bool isSelfInit(ASTContext &context,
|
||||
const VarDecl *vd, const DeclRefExpr *dr) {
|
||||
if (const Expr *exp = vd->getInit()) {
|
||||
ContainsReference contains(context, dr);
|
||||
contains.Visit(const_cast<Expr*>(exp));
|
||||
return contains.doesContainReference();
|
||||
static bool isSelfInit(ASTContext &Context,
|
||||
const VarDecl *VD, const DeclRefExpr *DR) {
|
||||
if (const Expr *E = VD->getInit()) {
|
||||
ContainsReference CR(Context, DR);
|
||||
CR.Visit(const_cast<Expr*>(E));
|
||||
return CR.doesContainReference();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user