clang  6.0.0svn
CallAndMessageChecker.cpp
Go to the documentation of this file.
1 //===--- CallAndMessageChecker.cpp ------------------------------*- C++ -*--==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This defines CallAndMessageChecker, a builtin checker that checks for various
11 // errors of call and objc message expressions.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "ClangSACheckers.h"
16 #include "clang/AST/ParentMap.h"
17 #include "clang/Basic/TargetInfo.h"
23 #include "llvm/ADT/SmallString.h"
24 #include "llvm/ADT/StringExtras.h"
25 #include "llvm/Support/raw_ostream.h"
26 
27 using namespace clang;
28 using namespace ento;
29 
30 namespace {
31 
32 struct ChecksFilter {
33  DefaultBool Check_CallAndMessageUnInitRefArg;
34  DefaultBool Check_CallAndMessageChecker;
35 
36  CheckName CheckName_CallAndMessageUnInitRefArg;
37  CheckName CheckName_CallAndMessageChecker;
38 };
39 
40 class CallAndMessageChecker
41  : public Checker< check::PreStmt<CallExpr>,
42  check::PreStmt<CXXDeleteExpr>,
43  check::PreObjCMessage,
44  check::ObjCMessageNil,
45  check::PreCall > {
46  mutable std::unique_ptr<BugType> BT_call_null;
47  mutable std::unique_ptr<BugType> BT_call_undef;
48  mutable std::unique_ptr<BugType> BT_cxx_call_null;
49  mutable std::unique_ptr<BugType> BT_cxx_call_undef;
50  mutable std::unique_ptr<BugType> BT_call_arg;
51  mutable std::unique_ptr<BugType> BT_cxx_delete_undef;
52  mutable std::unique_ptr<BugType> BT_msg_undef;
53  mutable std::unique_ptr<BugType> BT_objc_prop_undef;
54  mutable std::unique_ptr<BugType> BT_objc_subscript_undef;
55  mutable std::unique_ptr<BugType> BT_msg_arg;
56  mutable std::unique_ptr<BugType> BT_msg_ret;
57  mutable std::unique_ptr<BugType> BT_call_few_args;
58 
59 public:
60  ChecksFilter Filter;
61 
62  void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
63  void checkPreStmt(const CXXDeleteExpr *DE, CheckerContext &C) const;
64  void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const;
65 
66  /// Fill in the return value that results from messaging nil based on the
67  /// return type and architecture and diagnose if the return value will be
68  /// garbage.
69  void checkObjCMessageNil(const ObjCMethodCall &msg, CheckerContext &C) const;
70 
71  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
72 
73 private:
74  bool PreVisitProcessArg(CheckerContext &C, SVal V, SourceRange ArgRange,
75  const Expr *ArgEx, int ArgumentNumber,
76  bool CheckUninitFields, const CallEvent &Call,
77  std::unique_ptr<BugType> &BT,
78  const ParmVarDecl *ParamDecl) const;
79 
80  static void emitBadCall(BugType *BT, CheckerContext &C, const Expr *BadE);
81  void emitNilReceiverBug(CheckerContext &C, const ObjCMethodCall &msg,
82  ExplodedNode *N) const;
83 
84  void HandleNilReceiver(CheckerContext &C,
86  const ObjCMethodCall &msg) const;
87 
88  void LazyInit_BT(const char *desc, std::unique_ptr<BugType> &BT) const {
89  if (!BT)
90  BT.reset(new BuiltinBug(this, desc));
91  }
92  bool uninitRefOrPointer(CheckerContext &C, const SVal &V,
93  SourceRange ArgRange, const Expr *ArgEx,
94  std::unique_ptr<BugType> &BT,
95  const ParmVarDecl *ParamDecl, const char *BD,
96  int ArgumentNumber) const;
97 };
98 } // end anonymous namespace
99 
100 void CallAndMessageChecker::emitBadCall(BugType *BT, CheckerContext &C,
101  const Expr *BadE) {
103  if (!N)
104  return;
105 
106  auto R = llvm::make_unique<BugReport>(*BT, BT->getName(), N);
107  if (BadE) {
108  R->addRange(BadE->getSourceRange());
109  if (BadE->isGLValue())
110  BadE = bugreporter::getDerefExpr(BadE);
112  }
113  C.emitReport(std::move(R));
114 }
115 
117  int ArgumentNumber,
118  llvm::raw_svector_ostream &Os) {
119  switch (Call.getKind()) {
120  case CE_ObjCMessage: {
121  const ObjCMethodCall &Msg = cast<ObjCMethodCall>(Call);
122  switch (Msg.getMessageKind()) {
123  case OCM_Message:
124  Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
125  << " argument in message expression is an uninitialized value";
126  return;
127  case OCM_PropertyAccess:
128  assert(Msg.isSetter() && "Getters have no args");
129  Os << "Argument for property setter is an uninitialized value";
130  return;
131  case OCM_Subscript:
132  if (Msg.isSetter() && (ArgumentNumber == 0))
133  Os << "Argument for subscript setter is an uninitialized value";
134  else
135  Os << "Subscript index is an uninitialized value";
136  return;
137  }
138  llvm_unreachable("Unknown message kind.");
139  }
140  case CE_Block:
141  Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
142  << " block call argument is an uninitialized value";
143  return;
144  default:
145  Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
146  << " function call argument is an uninitialized value";
147  return;
148  }
149 }
150 
151 bool CallAndMessageChecker::uninitRefOrPointer(
152  CheckerContext &C, const SVal &V, SourceRange ArgRange, const Expr *ArgEx,
153  std::unique_ptr<BugType> &BT, const ParmVarDecl *ParamDecl, const char *BD,
154  int ArgumentNumber) const {
155  if (!Filter.Check_CallAndMessageUnInitRefArg)
156  return false;
157 
158  // No parameter declaration available, i.e. variadic function argument.
159  if(!ParamDecl)
160  return false;
161 
162  // If parameter is declared as pointer to const in function declaration,
163  // then check if corresponding argument in function call is
164  // pointing to undefined symbol value (uninitialized memory).
165  SmallString<200> Buf;
166  llvm::raw_svector_ostream Os(Buf);
167 
168  if (ParamDecl->getType()->isPointerType()) {
169  Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
170  << " function call argument is a pointer to uninitialized value";
171  } else if (ParamDecl->getType()->isReferenceType()) {
172  Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
173  << " function call argument is an uninitialized value";
174  } else
175  return false;
176 
177  if(!ParamDecl->getType()->getPointeeType().isConstQualified())
178  return false;
179 
180  if (const MemRegion *SValMemRegion = V.getAsRegion()) {
181  const ProgramStateRef State = C.getState();
182  const SVal PSV = State->getSVal(SValMemRegion);
183  if (PSV.isUndef()) {
184  if (ExplodedNode *N = C.generateErrorNode()) {
185  LazyInit_BT(BD, BT);
186  auto R = llvm::make_unique<BugReport>(*BT, Os.str(), N);
187  R->addRange(ArgRange);
188  if (ArgEx) {
190  }
191  C.emitReport(std::move(R));
192  }
193  return true;
194  }
195  }
196  return false;
197 }
198 
199 bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
200  SVal V,
201  SourceRange ArgRange,
202  const Expr *ArgEx,
203  int ArgumentNumber,
204  bool CheckUninitFields,
205  const CallEvent &Call,
206  std::unique_ptr<BugType> &BT,
207  const ParmVarDecl *ParamDecl
208  ) const {
209  const char *BD = "Uninitialized argument value";
210 
211  if (uninitRefOrPointer(C, V, ArgRange, ArgEx, BT, ParamDecl, BD,
212  ArgumentNumber))
213  return true;
214 
215  if (V.isUndef()) {
216  if (ExplodedNode *N = C.generateErrorNode()) {
217  LazyInit_BT(BD, BT);
218  // Generate a report for this bug.
219  SmallString<200> Buf;
220  llvm::raw_svector_ostream Os(Buf);
221  describeUninitializedArgumentInCall(Call, ArgumentNumber, Os);
222  auto R = llvm::make_unique<BugReport>(*BT, Os.str(), N);
223 
224  R->addRange(ArgRange);
225  if (ArgEx)
227  C.emitReport(std::move(R));
228  }
229  return true;
230  }
231 
232  if (!CheckUninitFields)
233  return false;
234 
237 
238  class FindUninitializedField {
239  public:
241  private:
242  StoreManager &StoreMgr;
243  MemRegionManager &MrMgr;
244  Store store;
245  public:
246  FindUninitializedField(StoreManager &storeMgr,
247  MemRegionManager &mrMgr, Store s)
248  : StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
249 
250  bool Find(const TypedValueRegion *R) {
251  QualType T = R->getValueType();
252  if (const RecordType *RT = T->getAsStructureType()) {
253  const RecordDecl *RD = RT->getDecl()->getDefinition();
254  assert(RD && "Referred record has no definition");
255  for (const auto *I : RD->fields()) {
256  const FieldRegion *FR = MrMgr.getFieldRegion(I, R);
257  FieldChain.push_back(I);
258  T = I->getType();
259  if (T->getAsStructureType()) {
260  if (Find(FR))
261  return true;
262  }
263  else {
264  const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
265  if (V.isUndef())
266  return true;
267  }
268  FieldChain.pop_back();
269  }
270  }
271 
272  return false;
273  }
274  };
275 
276  const LazyCompoundValData *D = LV->getCVData();
277  FindUninitializedField F(C.getState()->getStateManager().getStoreManager(),
279  D->getStore());
280 
281  if (F.Find(D->getRegion())) {
282  if (ExplodedNode *N = C.generateErrorNode()) {
283  LazyInit_BT(BD, BT);
284  SmallString<512> Str;
285  llvm::raw_svector_ostream os(Str);
286  os << "Passed-by-value struct argument contains uninitialized data";
287 
288  if (F.FieldChain.size() == 1)
289  os << " (e.g., field: '" << *F.FieldChain[0] << "')";
290  else {
291  os << " (e.g., via the field chain: '";
292  bool first = true;
294  DI = F.FieldChain.begin(), DE = F.FieldChain.end(); DI!=DE;++DI){
295  if (first)
296  first = false;
297  else
298  os << '.';
299  os << **DI;
300  }
301  os << "')";
302  }
303 
304  // Generate a report for this bug.
305  auto R = llvm::make_unique<BugReport>(*BT, os.str(), N);
306  R->addRange(ArgRange);
307 
308  // FIXME: enhance track back for uninitialized value for arbitrary
309  // memregions
310  C.emitReport(std::move(R));
311  }
312  return true;
313  }
314  }
315 
316  return false;
317 }
318 
319 void CallAndMessageChecker::checkPreStmt(const CallExpr *CE,
320  CheckerContext &C) const{
321 
322  const Expr *Callee = CE->getCallee()->IgnoreParens();
324  const LocationContext *LCtx = C.getLocationContext();
325  SVal L = State->getSVal(Callee, LCtx);
326 
327  if (L.isUndef()) {
328  if (!BT_call_undef)
329  BT_call_undef.reset(new BuiltinBug(
330  this, "Called function pointer is an uninitialized pointer value"));
331  emitBadCall(BT_call_undef.get(), C, Callee);
332  return;
333  }
334 
335  ProgramStateRef StNonNull, StNull;
336  std::tie(StNonNull, StNull) = State->assume(L.castAs<DefinedOrUnknownSVal>());
337 
338  if (StNull && !StNonNull) {
339  if (!BT_call_null)
340  BT_call_null.reset(new BuiltinBug(
341  this, "Called function pointer is null (null dereference)"));
342  emitBadCall(BT_call_null.get(), C, Callee);
343  return;
344  }
345 
346  C.addTransition(StNonNull);
347 }
348 
349 void CallAndMessageChecker::checkPreStmt(const CXXDeleteExpr *DE,
350  CheckerContext &C) const {
351 
352  SVal Arg = C.getSVal(DE->getArgument());
353  if (Arg.isUndef()) {
354  StringRef Desc;
356  if (!N)
357  return;
358  if (!BT_cxx_delete_undef)
359  BT_cxx_delete_undef.reset(
360  new BuiltinBug(this, "Uninitialized argument value"));
361  if (DE->isArrayFormAsWritten())
362  Desc = "Argument to 'delete[]' is uninitialized";
363  else
364  Desc = "Argument to 'delete' is uninitialized";
365  BugType *BT = BT_cxx_delete_undef.get();
366  auto R = llvm::make_unique<BugReport>(*BT, Desc, N);
368  C.emitReport(std::move(R));
369  return;
370  }
371 }
372 
373 void CallAndMessageChecker::checkPreCall(const CallEvent &Call,
374  CheckerContext &C) const {
376 
377  // If this is a call to a C++ method, check if the callee is null or
378  // undefined.
379  if (const CXXInstanceCall *CC = dyn_cast<CXXInstanceCall>(&Call)) {
380  SVal V = CC->getCXXThisVal();
381  if (V.isUndef()) {
382  if (!BT_cxx_call_undef)
383  BT_cxx_call_undef.reset(
384  new BuiltinBug(this, "Called C++ object pointer is uninitialized"));
385  emitBadCall(BT_cxx_call_undef.get(), C, CC->getCXXThisExpr());
386  return;
387  }
388 
389  ProgramStateRef StNonNull, StNull;
390  std::tie(StNonNull, StNull) =
391  State->assume(V.castAs<DefinedOrUnknownSVal>());
392 
393  if (StNull && !StNonNull) {
394  if (!BT_cxx_call_null)
395  BT_cxx_call_null.reset(
396  new BuiltinBug(this, "Called C++ object pointer is null"));
397  emitBadCall(BT_cxx_call_null.get(), C, CC->getCXXThisExpr());
398  return;
399  }
400 
401  State = StNonNull;
402  }
403 
404  const Decl *D = Call.getDecl();
405  if (D && (isa<FunctionDecl>(D) || isa<BlockDecl>(D))) {
406  // If we have a function or block declaration, we can make sure we pass
407  // enough parameters.
408  unsigned Params = Call.parameters().size();
409  if (Call.getNumArgs() < Params) {
411  if (!N)
412  return;
413 
414  LazyInit_BT("Function call with too few arguments", BT_call_few_args);
415 
416  SmallString<512> Str;
417  llvm::raw_svector_ostream os(Str);
418  if (isa<FunctionDecl>(D)) {
419  os << "Function ";
420  } else {
421  assert(isa<BlockDecl>(D));
422  os << "Block ";
423  }
424  os << "taking " << Params << " argument"
425  << (Params == 1 ? "" : "s") << " is called with fewer ("
426  << Call.getNumArgs() << ")";
427 
428  C.emitReport(
429  llvm::make_unique<BugReport>(*BT_call_few_args, os.str(), N));
430  }
431  }
432 
433  // Don't check for uninitialized field values in arguments if the
434  // caller has a body that is available and we have the chance to inline it.
435  // This is a hack, but is a reasonable compromise betweens sometimes warning
436  // and sometimes not depending on if we decide to inline a function.
437  const bool checkUninitFields =
438  !(C.getAnalysisManager().shouldInlineCall() && (D && D->getBody()));
439 
440  std::unique_ptr<BugType> *BT;
441  if (isa<ObjCMethodCall>(Call))
442  BT = &BT_msg_arg;
443  else
444  BT = &BT_call_arg;
445 
446  const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
447  for (unsigned i = 0, e = Call.getNumArgs(); i != e; ++i) {
448  const ParmVarDecl *ParamDecl = nullptr;
449  if(FD && i < FD->getNumParams())
450  ParamDecl = FD->getParamDecl(i);
451  if (PreVisitProcessArg(C, Call.getArgSVal(i), Call.getArgSourceRange(i),
452  Call.getArgExpr(i), i,
453  checkUninitFields, Call, *BT, ParamDecl))
454  return;
455  }
456 
457  // If we make it here, record our assumptions about the callee.
458  C.addTransition(State);
459 }
460 
461 void CallAndMessageChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
462  CheckerContext &C) const {
463  SVal recVal = msg.getReceiverSVal();
464  if (recVal.isUndef()) {
465  if (ExplodedNode *N = C.generateErrorNode()) {
466  BugType *BT = nullptr;
467  switch (msg.getMessageKind()) {
468  case OCM_Message:
469  if (!BT_msg_undef)
470  BT_msg_undef.reset(new BuiltinBug(this,
471  "Receiver in message expression "
472  "is an uninitialized value"));
473  BT = BT_msg_undef.get();
474  break;
475  case OCM_PropertyAccess:
476  if (!BT_objc_prop_undef)
477  BT_objc_prop_undef.reset(new BuiltinBug(
478  this, "Property access on an uninitialized object pointer"));
479  BT = BT_objc_prop_undef.get();
480  break;
481  case OCM_Subscript:
482  if (!BT_objc_subscript_undef)
483  BT_objc_subscript_undef.reset(new BuiltinBug(
484  this, "Subscript access on an uninitialized object pointer"));
485  BT = BT_objc_subscript_undef.get();
486  break;
487  }
488  assert(BT && "Unknown message kind.");
489 
490  auto R = llvm::make_unique<BugReport>(*BT, BT->getName(), N);
491  const ObjCMessageExpr *ME = msg.getOriginExpr();
492  R->addRange(ME->getReceiverRange());
493 
494  // FIXME: getTrackNullOrUndefValueVisitor can't handle "super" yet.
495  if (const Expr *ReceiverE = ME->getInstanceReceiver())
496  bugreporter::trackNullOrUndefValue(N, ReceiverE, *R);
497  C.emitReport(std::move(R));
498  }
499  return;
500  }
501 }
502 
503 void CallAndMessageChecker::checkObjCMessageNil(const ObjCMethodCall &msg,
504  CheckerContext &C) const {
505  HandleNilReceiver(C, C.getState(), msg);
506 }
507 
508 void CallAndMessageChecker::emitNilReceiverBug(CheckerContext &C,
509  const ObjCMethodCall &msg,
510  ExplodedNode *N) const {
511 
512  if (!BT_msg_ret)
513  BT_msg_ret.reset(
514  new BuiltinBug(this, "Receiver in message expression is 'nil'"));
515 
516  const ObjCMessageExpr *ME = msg.getOriginExpr();
517 
518  QualType ResTy = msg.getResultType();
519 
520  SmallString<200> buf;
521  llvm::raw_svector_ostream os(buf);
522  os << "The receiver of message '";
523  ME->getSelector().print(os);
524  os << "' is nil";
525  if (ResTy->isReferenceType()) {
526  os << ", which results in forming a null reference";
527  } else {
528  os << " and returns a value of type '";
529  msg.getResultType().print(os, C.getLangOpts());
530  os << "' that will be garbage";
531  }
532 
533  auto report = llvm::make_unique<BugReport>(*BT_msg_ret, os.str(), N);
534  report->addRange(ME->getReceiverRange());
535  // FIXME: This won't track "self" in messages to super.
536  if (const Expr *receiver = ME->getInstanceReceiver()) {
537  bugreporter::trackNullOrUndefValue(N, receiver, *report);
538  }
539  C.emitReport(std::move(report));
540 }
541 
542 static bool supportsNilWithFloatRet(const llvm::Triple &triple) {
543  return (triple.getVendor() == llvm::Triple::Apple &&
544  (triple.isiOS() || triple.isWatchOS() ||
545  !triple.isMacOSXVersionLT(10,5)));
546 }
547 
548 void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
550  const ObjCMethodCall &Msg) const {
551  ASTContext &Ctx = C.getASTContext();
552  static CheckerProgramPointTag Tag(this, "NilReceiver");
553 
554  // Check the return type of the message expression. A message to nil will
555  // return different values depending on the return type and the architecture.
556  QualType RetTy = Msg.getResultType();
557  CanQualType CanRetTy = Ctx.getCanonicalType(RetTy);
558  const LocationContext *LCtx = C.getLocationContext();
559 
560  if (CanRetTy->isStructureOrClassType()) {
561  // Structure returns are safe since the compiler zeroes them out.
562  SVal V = C.getSValBuilder().makeZeroVal(RetTy);
563  C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V), &Tag);
564  return;
565  }
566 
567  // Other cases: check if sizeof(return type) > sizeof(void*)
568  if (CanRetTy != Ctx.VoidTy && C.getLocationContext()->getParentMap()
569  .isConsumedExpr(Msg.getOriginExpr())) {
570  // Compute: sizeof(void *) and sizeof(return type)
571  const uint64_t voidPtrSize = Ctx.getTypeSize(Ctx.VoidPtrTy);
572  const uint64_t returnTypeSize = Ctx.getTypeSize(CanRetTy);
573 
574  if (CanRetTy.getTypePtr()->isReferenceType()||
575  (voidPtrSize < returnTypeSize &&
577  (Ctx.FloatTy == CanRetTy ||
578  Ctx.DoubleTy == CanRetTy ||
579  Ctx.LongDoubleTy == CanRetTy ||
580  Ctx.LongLongTy == CanRetTy ||
581  Ctx.UnsignedLongLongTy == CanRetTy)))) {
582  if (ExplodedNode *N = C.generateErrorNode(state, &Tag))
583  emitNilReceiverBug(C, Msg, N);
584  return;
585  }
586 
587  // Handle the safe cases where the return value is 0 if the
588  // receiver is nil.
589  //
590  // FIXME: For now take the conservative approach that we only
591  // return null values if we *know* that the receiver is nil.
592  // This is because we can have surprises like:
593  //
594  // ... = [[NSScreens screens] objectAtIndex:0];
595  //
596  // What can happen is that [... screens] could return nil, but
597  // it most likely isn't nil. We should assume the semantics
598  // of this case unless we have *a lot* more knowledge.
599  //
600  SVal V = C.getSValBuilder().makeZeroVal(RetTy);
601  C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V), &Tag);
602  return;
603  }
604 
605  C.addTransition(state);
606 }
607 
608 #define REGISTER_CHECKER(name) \
609  void ento::register##name(CheckerManager &mgr) { \
610  CallAndMessageChecker *Checker = \
611  mgr.registerChecker<CallAndMessageChecker>(); \
612  Checker->Filter.Check_##name = true; \
613  Checker->Filter.CheckName_##name = mgr.getCurrentCheckName(); \
614  }
615 
616 REGISTER_CHECKER(CallAndMessageUnInitRefArg)
617 REGISTER_CHECKER(CallAndMessageChecker)
SVal getReceiverSVal() const
Returns the value of the receiver at the time of this call.
Definition: CallEvent.cpp:748
CanQualType LongLongTy
Definition: ASTContext.h:973
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1698
TypedValueRegion - An abstract class representing regions having a typed value.
Definition: MemRegion.h:511
const Expr * getDerefExpr(const Stmt *S)
Given that expression S represents a pointer that would be dereferenced, try to find a sub-expression...
CanQualType VoidPtrTy
Definition: ASTContext.h:981
A (possibly-)qualified type.
Definition: Type.h:614
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:79
ExplodedNode * generateErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
Selector getSelector() const
Definition: ExprObjC.cpp:306
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: DeclBase.h:974
bool isArrayFormAsWritten() const
Definition: ExprCXX.h:2027
A helper class which wraps a boolean value set to false by default.
Definition: Checker.h:551
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:435
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:782
ExplodedNode * addTransition(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generates a new transition in the program state graph (ExplodedGraph).
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
virtual QualType getValueType() const =0
const RecordType * getAsStructureType() const
Definition: Type.cpp:451
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
Definition: StoreRef.h:26
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:645
AnalysisManager & getAnalysisManager()
bool isConsumedExpr(Expr *E) const
Definition: ParentMap.cpp:159
virtual SVal getBinding(Store store, Loc loc, QualType T=QualType())=0
Return the value bound to specified location in a given state.
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1514
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3482
MemRegionManager & getRegionManager()
Definition: SValBuilder.h:150
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
LineState State
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
Definition: Decl.h:3603
field_range fields() const
Definition: Decl.h:3613
StringRef getName() const
Definition: BugType.h:47
bool isReferenceType() const
Definition: Type.h:5781
virtual const Expr * getArgExpr(unsigned Index) const
Returns the expression associated with a given argument.
Definition: CallEvent.h:275
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
for(const auto &A :T->param_types())
bool isGLValue() const
Definition: Expr.h:264
Represents any expression that calls an Objective-C method.
Definition: CallEvent.h:870
virtual Kind getKind() const =0
Returns the kind of call this is.
bool isSetter() const
Returns true if this property access or subscript is a setter (has the form of an assignment)...
Definition: CallEvent.h:941
CanQualType LongDoubleTy
Definition: ASTContext.h:976
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition: CanonicalType.h:84
#define REGISTER_CHECKER(name)
Represents a non-static C++ member function call, no matter how it is written.
Definition: CallEvent.h:599
DefinedOrUnknownSVal makeZeroVal(QualType type)
Construct an SVal representing &#39;0&#39; for the specified type.
Definition: SValBuilder.cpp:32
Expr - This represents one expression.
Definition: Expr.h:119
virtual ArrayRef< ParmVarDecl * > parameters() const =0
Return call&#39;s formal parameters.
const FunctionProtoType * T
const Expr * getCallee() const
Definition: Expr.h:2311
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called.
Definition: CallEvent.h:205
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:860
const TypedValueRegion * getRegion() const
ParentMap & getParentMap() const
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
Definition: SVals.h:100
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:5608
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
Expr * getArgument()
Definition: ExprCXX.h:2039
const MemRegion * getAsRegion() const
Definition: SVals.cpp:140
CanQualType FloatTy
Definition: ASTContext.h:976
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2187
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
Definition: SVals.h:63
CanQualType VoidTy
Definition: ASTContext.h:965
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1155
virtual const ObjCMessageExpr * getOriginExpr() const
Definition: CallEvent.h:893
Dataflow Directional Tag Classes.
virtual SourceRange getArgSourceRange(unsigned Index) const
Returns the source range for errors associated with this argument.
Definition: CallEvent.cpp:235
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:1992
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:975
Represents an abstract call to a function or method along a particular path.
Definition: CallEvent.h:140
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
Definition: CallEvent.cpp:808
SourceRange getReceiverRange() const
Source range of the receiver.
Definition: ExprObjC.cpp:290
static bool supportsNilWithFloatRet(const llvm::Triple &triple)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3845
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition: SVals.h:92
const ProgramStateRef & getState() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:1961
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2124
bool trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S, BugReport &R, bool IsArg=false, bool EnableNullFPSuppression=true)
Attempts to add visitors to trace a null or undefined value back to its point of origin, whether it is a symbol constrained to null or an explicit assignment.
virtual unsigned getNumArgs() const =0
Returns the number of arguments (explicit and implicit).
static void describeUninitializedArgumentInCall(const CallEvent &Call, int ArgumentNumber, llvm::raw_svector_ostream &Os)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:265
SValBuilder & getSValBuilder()
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2270
bool isUndef() const
Definition: SVals.h:129
bool isPointerType() const
Definition: Type.h:5772
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
Definition: CallEvent.cpp:228
QualType getType() const
Definition: Decl.h:639
A trivial tuple used to represent a source range.
Tag that can use a checker name as a message provider (see SimpleProgramPointTag).
Definition: Checker.h:493
CanQualType DoubleTy
Definition: ASTContext.h:976
const LocationContext * getLocationContext() const
const LangOptions & getLangOpts() const
const FieldRegion * getFieldRegion(const FieldDecl *fd, const SubRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl...
Definition: MemRegion.cpp:966
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Definition: Expr.cpp:2460