clang: lib/CodeGen/VarBypassDetector.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H

15#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H

16

18#include "llvm/ADT/DenseMap.h"

19#include "llvm/ADT/DenseSet.h"

20#include "llvm/ADT/SmallVector.h"

21

23

25class Stmt;

26class VarDecl;

27

28namespace CodeGen {

29

30

31

32

33

34

35

36

37

38

40

41

43

45

46 llvm::DenseMap<const Stmt *, unsigned> ToScopes;

47

48 llvm::DenseSet<const VarDecl *> Bypasses;

49

50 bool AlwaysBypassed = false;

51

52public:

54

55

56

58 return AlwaysBypassed || Bypasses.contains(D);

59 }

60

61private:

62 bool BuildScopeInformation(const Decl *D, unsigned &ParentScope);

63 bool BuildScopeInformation(const Stmt *S, unsigned &origParentScope);

64 void Detect();

65 void Detect(unsigned From, unsigned To);

66};

67}

68}

69

70#endif

The class detects jumps which bypass local variables declaration: goto L; int a; L:

bool IsBypassed(const VarDecl *D) const

Returns true if the variable declaration was by bypassed by any goto or switch statement.

Decl - This represents one declaration (or definition), e.g.

Stmt - This represents one statement.

Represents a variable declaration or definition.

@ Decl

The l-value was an access to a declared entity or something equivalently strong, like the address of ...

The JSON file list parser is used to communicate input to InstallAPI.