Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT][analyzer][NFC] clang-format our folders #82599

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
400 changes: 200 additions & 200 deletions clang/include/clang/Analysis/Analyses/Consumed.h

Large diffs are not rendered by default.

50 changes: 19 additions & 31 deletions clang/include/clang/Analysis/Analyses/Dominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator.h"
#include "llvm/Support/GenericIteratedDominanceFrontier.h"
#include "llvm/Support/GenericDomTree.h"
#include "llvm/Support/GenericDomTreeConstruction.h"
#include "llvm/Support/GenericIteratedDominanceFrontier.h"
#include "llvm/Support/raw_ostream.h"

// FIXME: There is no good reason for the domtree to require a print method
Expand All @@ -38,18 +38,15 @@ namespace clang {
using DomTreeNode = llvm::DomTreeNodeBase<CFGBlock>;

/// Dominator tree builder for Clang's CFG based on llvm::DominatorTreeBase.
template <bool IsPostDom>
class CFGDominatorTreeImpl : public ManagedAnalysis {
template <bool IsPostDom> class CFGDominatorTreeImpl : public ManagedAnalysis {
virtual void anchor();

public:
using DominatorTreeBase = llvm::DominatorTreeBase<CFGBlock, IsPostDom>;

CFGDominatorTreeImpl() = default;

CFGDominatorTreeImpl(CFG *cfg) {
buildDominatorTree(cfg);
}
CFGDominatorTreeImpl(CFG *cfg) { buildDominatorTree(cfg); }

~CFGDominatorTreeImpl() override = default;

Expand All @@ -58,14 +55,10 @@ class CFGDominatorTreeImpl : public ManagedAnalysis {
CFG *getCFG() { return cfg; }

/// \returns the root CFGBlock of the dominators tree.
CFGBlock *getRoot() const {
return DT.getRoot();
}
CFGBlock *getRoot() const { return DT.getRoot(); }

/// \returns the root DomTreeNode, which is the wrapper for CFGBlock.
DomTreeNode *getRootNode() {
return DT.getRootNode();
}
DomTreeNode *getRootNode() { return DT.getRootNode(); }

/// Compares two dominator trees.
/// \returns false if the other dominator tree matches this dominator tree,
Expand Down Expand Up @@ -94,19 +87,16 @@ class CFGDominatorTreeImpl : public ManagedAnalysis {
void dump() {
llvm::errs() << "Immediate " << (IsPostDom ? "post " : "")
<< "dominance tree (Node#,IDom#):\n";
for (CFG::const_iterator I = cfg->begin(),
E = cfg->end(); I != E; ++I) {
for (CFG::const_iterator I = cfg->begin(), E = cfg->end(); I != E; ++I) {

assert(*I &&
"LLVM's Dominator tree builder uses nullpointers to signify the "
"virtual root!");

DomTreeNode *IDom = DT.getNode(*I)->getIDom();
if (IDom && IDom->getBlock())
llvm::errs() << "(" << (*I)->getBlockID()
<< ","
<< IDom->getBlock()->getBlockID()
<< ")\n";
llvm::errs() << "(" << (*I)->getBlockID() << ","
<< IDom->getBlock()->getBlockID() << ")\n";
else {
bool IsEntryBlock = *I == &(*I)->getParent()->getEntry();
bool IsExitBlock = *I == &(*I)->getParent()->getExit();
Expand All @@ -125,8 +115,8 @@ class CFGDominatorTreeImpl : public ManagedAnalysis {
(void)IsDomTreeRoot;
(void)IsPostDomTreeRoot;

llvm::errs() << "(" << (*I)->getBlockID()
<< "," << (*I)->getBlockID() << ")\n";
llvm::errs() << "(" << (*I)->getBlockID() << "," << (*I)->getBlockID()
<< ")\n";
}
}
}
Expand Down Expand Up @@ -170,7 +160,7 @@ class CFGDominatorTreeImpl : public ManagedAnalysis {
virtual void releaseMemory() { DT.reset(); }

/// Converts the dominator tree to human readable form.
virtual void print(raw_ostream &OS, const llvm::Module* M= nullptr) const {
virtual void print(raw_ostream &OS, const llvm::Module *M = nullptr) const {
DT.print(OS);
}

Expand All @@ -182,17 +172,16 @@ class CFGDominatorTreeImpl : public ManagedAnalysis {
using CFGDomTree = CFGDominatorTreeImpl</*IsPostDom*/ false>;
using CFGPostDomTree = CFGDominatorTreeImpl</*IsPostDom*/ true>;

template<> void CFGDominatorTreeImpl<true>::anchor();
template<> void CFGDominatorTreeImpl<false>::anchor();
template <> void CFGDominatorTreeImpl<true>::anchor();
template <> void CFGDominatorTreeImpl<false>::anchor();

} // end of namespace clang

namespace llvm {
namespace IDFCalculatorDetail {

/// Specialize ChildrenGetterTy to skip nullpointer successors.
template <bool IsPostDom>
struct ChildrenGetterTy<clang::CFGBlock, IsPostDom> {
template <bool IsPostDom> struct ChildrenGetterTy<clang::CFGBlock, IsPostDom> {
using NodeRef = typename GraphTraits<clang::CFGBlock *>::NodeRef;
using ChildrenTy = SmallVector<NodeRef, 8>;

Expand Down Expand Up @@ -224,7 +213,7 @@ class ControlDependencyCalculator : public ManagedAnalysis {

public:
ControlDependencyCalculator(CFG *cfg)
: PostDomTree(cfg), IDFCalc(PostDomTree.getBase()) {}
: PostDomTree(cfg), IDFCalc(PostDomTree.getBase()) {}

const CFGPostDomTree &getCFGPostDomTree() const { return PostDomTree; }

Expand Down Expand Up @@ -261,10 +250,8 @@ class ControlDependencyCalculator : public ManagedAnalysis {
"virtual root!");

for (CFGBlock *isControlDependency : getControlDependencies(BB))
llvm::errs() << "(" << BB->getBlockID()
<< ","
<< isControlDependency->getBlockID()
<< ")\n";
llvm::errs() << "(" << BB->getBlockID() << ","
<< isControlDependency->getBlockID() << ")\n";
}
}
};
Expand Down Expand Up @@ -297,7 +284,8 @@ template <> struct GraphTraits<clang::DomTreeNode *> {
}
};

template <> struct GraphTraits<clang::CFGDomTree *>
template <>
struct GraphTraits<clang::CFGDomTree *>
: public GraphTraits<clang::DomTreeNode *> {
static NodeRef getEntryNode(clang::CFGDomTree *DT) {
return DT->getRootNode();
Expand Down
9 changes: 4 additions & 5 deletions clang/include/clang/Analysis/Analyses/LiveVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ class LiveVariables : public ManagedAnalysis {
public:
class LivenessValues {
public:

llvm::ImmutableSet<const Expr *> liveExprs;
llvm::ImmutableSet<const VarDecl *> liveDecls;
llvm::ImmutableSet<const BindingDecl *> liveBindings;

bool equals(const LivenessValues &V) const;

LivenessValues()
: liveExprs(nullptr), liveDecls(nullptr), liveBindings(nullptr) {}
: liveExprs(nullptr), liveDecls(nullptr), liveBindings(nullptr) {}

LivenessValues(llvm::ImmutableSet<const Expr *> liveExprs,
llvm::ImmutableSet<const VarDecl *> LiveDecls,
Expand All @@ -53,14 +52,14 @@ class LiveVariables : public ManagedAnalysis {

class Observer {
virtual void anchor();

public:
virtual ~Observer() {}

/// A callback invoked right before invoking the
/// liveness transfer function on the given statement.
virtual void observeStmt(const Stmt *S,
const CFGBlock *currentBlock,
const LivenessValues& V) {}
virtual void observeStmt(const Stmt *S, const CFGBlock *currentBlock,
const LivenessValues &V) {}

/// Called when the live variables analysis registers
/// that a variable is killed.
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class PostOrderCFGView : public ManagedAnalysis {
public:
// po_iterator requires this iterator, but the only interface needed is the
// value_type type.
struct iterator { using value_type = const CFGBlock *; };
struct iterator {
using value_type = const CFGBlock *;
};

CFGBlockSet() = default;
CFGBlockSet(const CFG *G) : VisitedBlockIDs(G->getNumBlockIDs(), false) {}
Expand Down Expand Up @@ -135,9 +137,7 @@ class PostOrderCFGView : public ManagedAnalysis {
bool operator()(const CFGBlock *b1, const CFGBlock *b2) const;
};

BlockOrderCompare getComparator() const {
return BlockOrderCompare(*this);
}
BlockOrderCompare getComparator() const { return BlockOrderCompare(*this); }

// Used by AnalyisContext to construct this object.
static const void *getTag();
Expand Down
21 changes: 9 additions & 12 deletions clang/include/clang/Analysis/Analyses/ReachableCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
//===----------------------------------------------------------------------===//

namespace llvm {
class BitVector;
class BitVector;
}

namespace clang {
class AnalysisDeclContext;
class CFGBlock;
class Preprocessor;
}
class AnalysisDeclContext;
class CFGBlock;
class Preprocessor;
} // namespace clang

//===----------------------------------------------------------------------===//
// API.
Expand All @@ -37,15 +37,11 @@ namespace clang {
namespace reachable_code {

/// Classifications of unreachable code.
enum UnreachableKind {
UK_Return,
UK_Break,
UK_Loop_Increment,
UK_Other
};
enum UnreachableKind { UK_Return, UK_Break, UK_Loop_Increment, UK_Other };

class Callback {
virtual void anchor();

public:
virtual ~Callback() {}
virtual void HandleUnreachable(UnreachableKind UK, SourceLocation L,
Expand All @@ -61,6 +57,7 @@ unsigned ScanReachableFromBlock(const CFGBlock *Start,
void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP,
Callback &CB);

}} // end namespace clang::reachable_code
} // namespace reachable_code
} // namespace clang

#endif
6 changes: 3 additions & 3 deletions clang/include/clang/Analysis/Analyses/ThreadSafety.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
// A intra-procedural analysis for thread safety (e.g. deadlocks and race
// conditions), based off of an annotation system.
//
// See http://clang.llvm.org/docs/LanguageExtensions.html#thread-safety-annotation-checking
// See
// http://clang.llvm.org/docs/LanguageExtensions.html#thread-safety-annotation-checking
// for more information.
//
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -250,8 +251,7 @@ class ThreadSafetyHandler {
/// at the end of each block, and issue warnings for thread safety violations.
/// Each block in the CFG is traversed exactly once.
void runThreadSafetyAnalysis(AnalysisDeclContext &AC,
ThreadSafetyHandler &Handler,
BeforeSet **Bset);
ThreadSafetyHandler &Handler, BeforeSet **Bset);

void threadSafetyCleanup(BeforeSet *Cache);

Expand Down
30 changes: 14 additions & 16 deletions clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ inline std::string toString(const til::SExpr *E) {
return ss.str();
}

} // namespace sx
} // namespace sx

// This class defines the interface of a clang CFG Visitor.
// CFGWalker will invoke the following methods.
Expand Down Expand Up @@ -168,8 +168,7 @@ class CFGWalker {
}

// Traverse the CFG, calling methods on V as appropriate.
template <class Visitor>
void walk(Visitor &V) {
template <class Visitor> void walk(Visitor &V) {
PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);

V.enterCFG(CFGraph, getDecl(), &CFGraph->getEntry());
Expand All @@ -181,7 +180,7 @@ class CFGWalker {

// Process predecessors, handling back edges last
if (V.visitPredecessors()) {
SmallVector<CFGBlock*, 4> BackEdges;
SmallVector<CFGBlock *, 4> BackEdges;
// Process successors
for (CFGBlock::const_pred_iterator SI = CurrBlock->pred_begin(),
SE = CurrBlock->pred_end();
Expand Down Expand Up @@ -226,7 +225,7 @@ class CFGWalker {

// Process successors, handling back edges first.
if (V.visitSuccessors()) {
SmallVector<CFGBlock*, 8> ForwardEdges;
SmallVector<CFGBlock *, 8> ForwardEdges;

// Process successors
for (CFGBlock::const_succ_iterator SI = CurrBlock->succ_begin(),
Expand Down Expand Up @@ -312,7 +311,7 @@ class CapabilityExpr {
sx::partiallyMatches(sexpr(), other.sexpr());
}

const ValueDecl* valueDecl() const {
const ValueDecl *valueDecl() const {
if (negative() || sexpr() == nullptr)
return nullptr;
if (const auto *P = dyn_cast<til::Project>(sexpr()))
Expand Down Expand Up @@ -349,7 +348,7 @@ class SExprBuilder {
/// by the lock_returned attribute.
struct CallingContext {
// The previous context; or 0 if none.
CallingContext *Prev;
CallingContext *Prev;

// The decl to which the attr is attached.
const NamedDecl *AttrDecl;
Expand Down Expand Up @@ -395,7 +394,7 @@ class SExprBuilder {
// Also performs substitution of variables; Ctx provides the context.
// Dispatches on the type of S.
til::SExpr *translate(const Stmt *S, CallingContext *Ctx);
til::SCFG *buildCFG(CFGWalker &Walker);
til::SCFG *buildCFG(CFGWalker &Walker);

til::SExpr *lookupStmt(const Stmt *S);

Expand All @@ -410,8 +409,7 @@ class SExprBuilder {
// We implement the CFGVisitor API
friend class CFGWalker;

til::SExpr *translateDeclRefExpr(const DeclRefExpr *DRE,
CallingContext *Ctx) ;
til::SExpr *translateDeclRefExpr(const DeclRefExpr *DRE, CallingContext *Ctx);
til::SExpr *translateCXXThisExpr(const CXXThisExpr *TE, CallingContext *Ctx);
til::SExpr *translateMemberExpr(const MemberExpr *ME, CallingContext *Ctx);
til::SExpr *translateObjCIVarRefExpr(const ObjCIvarRefExpr *IVRE,
Expand All @@ -424,19 +422,19 @@ class SExprBuilder {
CallingContext *Ctx);
til::SExpr *translateUnaryOperator(const UnaryOperator *UO,
CallingContext *Ctx);
til::SExpr *translateBinOp(til::TIL_BinaryOpcode Op,
const BinaryOperator *BO,
til::SExpr *translateBinOp(til::TIL_BinaryOpcode Op, const BinaryOperator *BO,
CallingContext *Ctx, bool Reverse = false);
til::SExpr *translateBinAssign(til::TIL_BinaryOpcode Op,
const BinaryOperator *BO,
CallingContext *Ctx, bool Assign = false);
const BinaryOperator *BO, CallingContext *Ctx,
bool Assign = false);
til::SExpr *translateBinaryOperator(const BinaryOperator *BO,
CallingContext *Ctx);
til::SExpr *translateCastExpr(const CastExpr *CE, CallingContext *Ctx);
til::SExpr *translateArraySubscriptExpr(const ArraySubscriptExpr *E,
CallingContext *Ctx);
til::SExpr *translateAbstractConditionalOperator(
const AbstractConditionalOperator *C, CallingContext *Ctx);
til::SExpr *
translateAbstractConditionalOperator(const AbstractConditionalOperator *C,
CallingContext *Ctx);

til::SExpr *translateDeclStmt(const DeclStmt *S, CallingContext *Ctx);

Expand Down
Loading
Loading