[PATCH] D37042: Teach clang to tolerate the 'p = nullptr + n' idiom used by glibc
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 29 16:57:49 PDT 2017
rsmith added inline comments.
Comment at: lib/Sema/SemaExpr.cpp:8808
+ Context.getTypeSize(pointerType) ==
+ IsGNUIdiom = true;
> efriedma wrote:
> > Please make sure you use exactly the same check in Sema and CodeGen (probably easiest to stick a helper into lib/AST/).
> That's a good idea, but I'm not really familiar enough with the structure of clang to be sure I'm not doing it in a ham-fisted way. Can you clarify? Are you suggesting adding something like ASTContext::isPointeeTypeCharSize() and ASTContext::isIntegerTypePointerSize()? Or maybe a single specialized function somewhere that does both checks like ASTContext::areOperandNullPointerArithmeticCompatible()?
I would suggest something even more specific, such as `isNullPointerPlusIntegerExtension`
More information about the cfe-commits