|
5 | 5 | import cpp
|
6 | 6 | import codingstandards.cpp.standardlibrary.Exceptions
|
7 | 7 | import codingstandards.cpp.exceptions.ExceptionSpecifications
|
| 8 | +import codingstandards.cpp.exceptions.ExceptionFlowCustomizations |
8 | 9 | import ThirdPartyExceptions
|
9 | 10 |
|
10 | 11 | /*
|
@@ -271,72 +272,6 @@ ExceptionType getAFunctionThrownType(Function f, ThrowingExpr throwingExpr) {
|
271 | 272 | )
|
272 | 273 | }
|
273 | 274 |
|
274 |
| -/** A `ThrowingExpr` which is the origin of a exceptions in the program. */ |
275 |
| -abstract class OriginThrowingExpr extends ThrowingExpr { } |
276 |
| - |
277 |
| -/** An expression which directly throws. */ |
278 |
| -class DirectThrowExprThrowingExpr extends DirectThrowExpr, OriginThrowingExpr { |
279 |
| - override ExceptionType getAnExceptionType() { result = getExceptionType() } |
280 |
| -} |
281 |
| - |
282 |
| -/** An `typeid` expression which may throw `std::bad_typeid`. */ |
283 |
| -class TypeIdThrowingExpr extends TypeidOperator, OriginThrowingExpr { |
284 |
| - override ExceptionType getAnExceptionType() { result instanceof StdBadTypeId } |
285 |
| -} |
286 |
| - |
287 |
| -/** An `new[]` expression which may throw `std::bad_array_new_length`. */ |
288 |
| -class NewThrowingExpr extends NewArrayExpr, OriginThrowingExpr { |
289 |
| - NewThrowingExpr() { |
290 |
| - // If the extent is known to be below 0 at runtime |
291 |
| - getExtent().getValue().toInt() < 0 |
292 |
| - or |
293 |
| - // initializer has more elements than the array size |
294 |
| - getExtent().getValue().toInt() < getInitializer().(ArrayAggregateLiteral).getArraySize() |
295 |
| - } |
296 |
| - |
297 |
| - override ExceptionType getAnExceptionType() { result instanceof StdBadArrayNewLength } |
298 |
| -} |
299 |
| - |
300 |
| -/** A `ReThrowExpr` which throws a previously caught exception. */ |
301 |
| -class ReThrowExprThrowingExpr extends ReThrowExpr, ThrowingExpr { |
302 |
| - predicate rethrows(CatchBlock cb, ExceptionType et, ThrowingExpr te) { |
303 |
| - // Find the nearest CatchBlock |
304 |
| - cb = getNearestCatch(this.getEnclosingStmt()) and |
305 |
| - // Find an `ExceptionType` which is caught by this catch block, and `ThrowingExpr` which throws that exception type |
306 |
| - catches(cb, te, et) |
307 |
| - } |
308 |
| - |
309 |
| - override ExceptionType getAnExceptionType() { rethrows(_, result, _) } |
310 |
| - |
311 |
| - CatchBlock getCatchBlock() { rethrows(result, _, _) } |
312 |
| -} |
313 |
| - |
314 |
| -/** An expression which calls a function which may throw an exception. */ |
315 |
| -class FunctionCallThrowingExpr extends FunctionCall, ThrowingExpr { |
316 |
| - override ExceptionType getAnExceptionType() { |
317 |
| - exists(Function target | |
318 |
| - target = getTarget() and |
319 |
| - result = getAFunctionThrownType(target, _) and |
320 |
| - // [expect.spec] states that throwing an exception type that is prohibited |
321 |
| - // by the specification will result in the program terminating, unless |
322 |
| - // a custom `unexpected_handler` is registered that throws an exception type |
323 |
| - // which is compatible with the dynamic exception specification, or the |
324 |
| - // dynamic exception specification lists `std::bad_exception`, in which case |
325 |
| - // a `std::bad_exception` is thrown. |
326 |
| - // As dynamic exception specifications and the `unexpected_handler` are both |
327 |
| - // deprecated in C++14 and removed in C++17, we assume a default |
328 |
| - // `std::unexpected` handler that calls `std::terminate` and therefore |
329 |
| - // do not propagate such exceptions to the call sites for the function. |
330 |
| - not ( |
331 |
| - hasDynamicExceptionSpecification(target) and |
332 |
| - not result = getAHandledExceptionType(target.getAThrownType()) |
333 |
| - or |
334 |
| - isNoExceptTrue(target) |
335 |
| - ) |
336 |
| - ) |
337 |
| - } |
338 |
| -} |
339 |
| - |
340 | 275 | module ExceptionPathGraph {
|
341 | 276 | /**
|
342 | 277 | * A function for which we want path information.
|
|
0 commit comments