arphaman marked an inline comment as done. arphaman added inline comments.
================ Comment at: tools/libclang/CIndex.cpp:3892-3922 CXEvalResult clang_Cursor_Evaluate(CXCursor C) { - const Decl *D = getCursorDecl(C); - if (D) { - const Expr *expr = nullptr; - if (auto *Var = dyn_cast<VarDecl>(D)) { - expr = Var->getInit(); - } else if (auto *Field = dyn_cast<FieldDecl>(D)) { - expr = Field->getInClassInitializer(); + if (clang_isDeclaration(C.kind)) { + const Decl *D = getCursorDecl(C); + if (D) { + const Expr *expr = nullptr; + if (auto *Var = dyn_cast<VarDecl>(D)) { + expr = Var->getInit(); ---------------- dexonsmith wrote: > There's unfortunate nesting here. It would be nice if, either pre-commit or > post-commit, you could refactor this to be more straightline using early > returns. E.g.: > ``` > static CXEvalResult evaluateDeclExpr(const Decl *D) { > if (!D) > return nullptr; > // ... > } > static CXEvalResult evaluateCompoundStmtExpr(const CompoundStmt *CS) { > if (!CS) > return nullptr; > // ... > } > CXEvalResult clang_Cursor_Evaluate(CXCursor C) { > if (clang_isDeclaration(C.kind)) { > return evaluateDeclExpr(getCursorDecl(C)); > return evaluateCompoundStmtExpr( > dyn_cast_or_null<CompoundStmt>(getCursorStmt(C))); > } > ``` Thanks, will do post commit. Repository: rC Clang https://reviews.llvm.org/D49051 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits