[PATCH] D54047: Check TUScope is valid before use

Tom Rix via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 2 14:04:44 PDT 2018


trixirt created this revision.
trixirt added reviewers: rsmith, stephenkelly.
Herald added a subscriber: cfe-commits.

Include-what-you-use crashes when run against llvm because of late use of TUScope.
The testcase is 
https://github.com/trixirt/include-what-you-use/commit/dfec8cf07015fb5fe2db10df2f0a005250953131

Enabling incremental processing, fixes this problem but causes 3 regression in iwyu.
https://github.com/include-what-you-use/include-what-you-use/pull/586

So the fix is moving to clang.


Repository:
  rC Clang

https://reviews.llvm.org/D54047

Files:
  lib/Sema/SemaExpr.cpp


Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -905,6 +905,10 @@
     UnqualifiedId Name;
     Name.setIdentifier(PP.getIdentifierInfo("__builtin_trap"),
                        E->getBeginLoc());
+
+    if (TUScope == nullptr)
+      return ExprError();
+
     ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
                                           Name, true, false);
     if (TrapFn.isInvalid())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54047.172428.patch
Type: text/x-patch
Size: 525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181102/8d487a3d/attachment-0001.bin>


More information about the cfe-commits mailing list