clang: lib/Analysis/CocoaConventions.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

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

19#include "llvm/Support/ErrorHandling.h"

20

21using namespace clang;

22using namespace ento;

23

25 StringRef Name) {

26

28 StringRef TDName = TD->getDecl()->getIdentifier()->getName();

29 if (TDName.starts_with(Prefix) && TDName.ends_with("Ref"))

30 return true;

31

32 if (TDName.starts_with("xpc_"))

33 return false;

34 RetTy = TD->getDecl()->getUnderlyingType();

35 }

36

37 if (Name.empty())

38 return false;

39

40

43 return false;

44

45

46 return Name.starts_with(Prefix);

47}

48

49

50

55}

56

62}

63

64

67 return false;

68

70

71

72 if (!PT)

73 return true;

74

75

76

79 return true;

80

81

82

84

85

86

87 if (!ID->hasDefinition())

88 return true;

89

90 for ( ; ID ; ID = ID->getSuperClass())

91 if (ID->getIdentifier()->getName() == "NSObject")

92 return true;

93

94 return false;

95}

96

98

99

101 if (!ident) return false;

102 StringRef functionName = ident->getName();

103

104 StringRef::iterator it = functionName.begin();

105 StringRef::iterator start = it;

106 StringRef::iterator endI = functionName.end();

107

108 while (true) {

109

110 for ( ; it != endI ; ++it) {

111

112 char ch = *it;

113 if (ch == 'C' || ch == 'c') {

114

115 if (ch == 'c' && it != start && isLetter(*(it - 1)))

116 continue;

117

118 ++it;

119 break;

120 }

121 }

122

123

124 if (it == endI)

125 return false;

126

127

128

129 StringRef suffix = functionName.substr(it - start);

130 if (suffix.starts_with("reate")) {

131 it += 5;

132 } else if (suffix.starts_with("opy")) {

133 it += 3;

134 } else {

135

136 continue;

137 }

138

140 return true;

141

142

143

144 }

145}

static bool isDiskArbitrationAPIRefType(QualType T)

Returns true when the passed-in type is a CF-style reference-counted type from the DiskArbitration fr...

C Language Family Type Representation.

Represents a function declaration or definition.

One of these records is kept for each identifier that is lexed.

StringRef getName() const

Return the actual identifier string.

IdentifierInfo * getIdentifier() const

Get the identifier that names this declaration, if there is one.

Represents an ObjC class declaration.

Represents a pointer to an Objective C object.

bool isObjCQualifiedClassType() const

True if this is equivalent to 'Class.

bool isObjCQualifiedIdType() const

True if this is equivalent to 'id.

bool isObjCIdType() const

True if this is equivalent to the 'id' type, i.e.

ObjCInterfaceDecl * getInterfaceDecl() const

If this pointer points to an Objective @interface type, gets the declaration for that interface.

bool isObjCClassType() const

True if this is equivalent to the 'Class' type, i.e.

PointerType - C99 6.7.5.1 - Pointer Declarators.

QualType getPointeeType() const

A (possibly-)qualified type.

QualType getUnqualifiedType() const

Retrieve the unqualified variant of the given type, removing as little sugar as possible.

const T * castAs() const

Member-template castAs.

bool isObjCObjectPointerType() const

const T * getAs() const

Member-template getAs'.

bool isCocoaObjectRef(QualType T)

bool isRefType(QualType RetTy, StringRef Prefix, StringRef Name=StringRef())

bool followsCreateRule(const FunctionDecl *FD)

bool isCFObjectRef(QualType T)

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

LLVM_READONLY bool isLetter(unsigned char c)

Return true if this character is an ASCII letter: [a-zA-Z].

LLVM_READONLY bool isLowercase(unsigned char c)

Return true if this character is a lowercase ASCII letter: [a-z].

const FunctionProtoType * T