@@ -464,16 +464,15 @@ void ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() {
464464 else
465465 Behaviour = State::Throwing;
466466}
467- ExceptionAnalyzer::ExceptionInfo
468- ExceptionAnalyzer::throwsException (const FunctionDecl *Func,
469- const ExceptionInfo::Throwables &Caught,
470- CallStack &CallStack) {
467+ ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException (
468+ const FunctionDecl *Func, const ExceptionInfo::Throwables &Caught,
469+ CallStack &CallStack, SourceLocation CallLoc) {
471470 if (!Func || CallStack.contains (Func) ||
472471 (!CallStack.empty () && !canThrow (Func)))
473472 return ExceptionInfo::createNonThrowing ();
474473
475474 if (const Stmt *Body = Func->getBody ()) {
476- CallStack.insert (Func);
475+ CallStack.insert ({ Func, CallLoc} );
477476 ExceptionInfo Result = throwsException (Body, Caught, CallStack);
478477
479478 // For a constructor, we also have to check the initializers.
@@ -485,18 +484,18 @@ ExceptionAnalyzer::throwsException(const FunctionDecl *Func,
485484 }
486485 }
487486
488- CallStack.remove (Func);
487+ CallStack.erase (Func);
489488 return Result;
490489 }
491490
492491 auto Result = ExceptionInfo::createUnknown ();
493492 if (const auto *FPT = Func->getType ()->getAs <FunctionProtoType>()) {
494493 for (const QualType &Ex : FPT->exceptions ()) {
495- CallStack.insert (Func);
494+ CallStack.insert ({ Func, CallLoc} );
496495 Result.registerException (
497496 Ex.getTypePtr (),
498497 {Func->getExceptionSpecSourceRange ().getBegin (), CallStack});
499- CallStack.remove (Func);
498+ CallStack.erase (Func);
500499 }
501500 }
502501 return Result;
@@ -566,12 +565,13 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
566565 Results.merge (Uncaught);
567566 } else if (const auto *Call = dyn_cast<CallExpr>(St)) {
568567 if (const FunctionDecl *Func = Call->getDirectCallee ()) {
569- ExceptionInfo Excs = throwsException (Func, Caught, CallStack);
568+ ExceptionInfo Excs =
569+ throwsException (Func, Caught, CallStack, Call->getBeginLoc ());
570570 Results.merge (Excs);
571571 }
572572 } else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) {
573- ExceptionInfo Excs =
574- throwsException ( Construct->getConstructor (), Caught, CallStack );
573+ ExceptionInfo Excs = throwsException (Construct-> getConstructor (), Caught,
574+ CallStack, Construct->getBeginLoc () );
575575 Results.merge (Excs);
576576 } else if (const auto *DefaultInit = dyn_cast<CXXDefaultInitExpr>(St)) {
577577 ExceptionInfo Excs =
@@ -590,8 +590,8 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
590590 for (const auto &Exception : Excs.getExceptions ()) {
591591 const Type *ExcType = Exception.getFirst ();
592592 if (const CXXRecordDecl *ThrowableRec = ExcType->getAsCXXRecordDecl ()) {
593- ExceptionInfo DestructorExcs =
594- throwsException ( ThrowableRec->getDestructor (), Caught, CallStack);
593+ ExceptionInfo DestructorExcs = throwsException (
594+ ThrowableRec->getDestructor (), Caught, CallStack, SourceLocation{} );
595595 Results.merge (DestructorExcs);
596596 }
597597 }
@@ -612,8 +612,8 @@ ExceptionAnalyzer::analyzeImpl(const FunctionDecl *Func) {
612612 const auto CacheEntry = FunctionCache.find (Func);
613613 if (CacheEntry == FunctionCache.end ()) {
614614 CallStack CallStack;
615- ExceptionList =
616- throwsException (Func, ExceptionInfo::Throwables (), CallStack );
615+ ExceptionList = throwsException (Func, ExceptionInfo::Throwables (),
616+ CallStack, Func-> getLocation () );
617617
618618 // Cache the result of the analysis. This is done prior to filtering
619619 // because it is best to keep as much information as possible.
0 commit comments