Simplify code to use castAs rather than getAs + assert.
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 21 Feb 2013 23:35:06 +0000 (23:35 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 21 Feb 2013 23:35:06 +0000 (23:35 +0000)
Post commit review feedback on r175812 from Jordan Rose.

llvm-svn: 175826

clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

index b27a80f..8c6eaec 100644 (file)
@@ -993,11 +993,10 @@ StackHintGenerator::~StackHintGenerator() {}
 
 std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){
   ProgramPoint P = N->getLocation();
-  Optional<CallExitEnd> CExit = P.getAs<CallExitEnd>();
-  assert(CExit && "Stack Hints should be constructed at CallExitEnd points.");
+  CallExitEnd CExit = P.castAs<CallExitEnd>();
 
   // FIXME: Use CallEvent to abstract this over all calls.
-  const Stmt *CallSite = CExit->getCalleeContext()->getCallSite();
+  const Stmt *CallSite = CExit.getCalleeContext()->getCallSite();
   const CallExpr *CE = dyn_cast_or_null<CallExpr>(CallSite);
   if (!CE)
     return "";