r240571 - [Preprocessor] Iterating over all macros should include those from modules.

Jordan Rose jordan_rose at apple.com
Thu Jun 25 12:53:14 PDT 2015


> On Jun 25, 2015, at 11:54, Justin Bogner <mail at justinbogner.com> wrote:
> 
> Jordan Rose <jordan_rose at apple.com> writes:
>> Author: jrose
>> Date: Wed Jun 24 14:27:02 2015
>> New Revision: 240571
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=240571&view=rev
>> Log:
>> [Preprocessor] Iterating over all macros should include those from modules.
>> 
>> So, iterate over the list of macros mentioned in modules, and make sure those
>> are in the master table.
> 
> This introduces a null dereference in Preprocessor::findDirectiveAtLoc.
> It triggers in clang/test/Modules/crashes.m, so you can find it by
> adding an assert next to the very relevant sounding FIXME like so:
> 
> --- a/include/clang/Lex/Preprocessor.h
> +++ b/include/clang/Lex/Preprocessor.h
> @@ -454,6 +454,7 @@ class Preprocessor : public RefCountedBase<Preprocessor> {
>     MacroDirective::DefInfo findDirectiveAtLoc(SourceLocation Loc,
>                                                SourceManager &SourceMgr) const {
>       // FIXME: Incorporate module macros into the result of this.
> +      assert(getLatest() != nullptr);
>       return getLatest()->findDirectiveAtLoc(Loc, SourceMgr);
>     }
> 
> I found this with ubsan, but I still need a couple of clang patches
> reviewed before I can make a bot to catch such things. For anyone
> interested:
> 
>  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131431.html
>  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131432.html
>  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131433.html <http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/131433.html>

Hm, thanks. I'm not sure whether this means we/I should be more circumspect about what gets added to the Macros table, or whether findDirectiveAtLoc should not assume that everything in the Macros table is currently valid.

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150625/dfa27a32/attachment.html>


More information about the cfe-commits mailing list