]> granicus.if.org Git - clang/commit
[CodeGen] Always use string computed in Sema for PredefinedExpr
authorEli Friedman <efriedma@codeaurora.org>
Tue, 22 Jan 2019 00:11:17 +0000 (00:11 +0000)
committerEli Friedman <efriedma@codeaurora.org>
Tue, 22 Jan 2019 00:11:17 +0000 (00:11 +0000)
commit12ab032c299151930251e64b550bc1eaf7770e46
treea19c68b42f8eaf04ab24ba94708a7d091330bc69
parent7f77c0c9a77506be62cd0c96fbfc1c0c8b3d5220
[CodeGen] Always use string computed in Sema for PredefinedExpr

We can't use any other string, anyway, because its type wouldn't
match the type of the PredefinedExpr.

With this change, we don't compute a "nice" name for the __func__ global
when it's used in the initializer for a constant. This doesn't seem like
a great loss, and I'm not sure how to fix it without either storing more
information in the AST, or somehow threading through the information
from ExprConstant.cpp.

This could break some situations involving BlockDecl; currently,
CodeGenFunction::EmitPredefinedLValue has some logic to intentionally
emit a string different from what Sema computed.  This code skips that
logic... but that logic can't work correctly in general anyway.  (For
example, sizeof(__func__) returns the wrong result.) Hopefully this
doesn't affect practical code.

Fixes https://bugs.llvm.org/show_bug.cgi?id=40313 .

Differential Revision: https://reviews.llvm.org/D56821

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351766 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExprConstant.cpp
test/CodeGen/const-init.c
test/CodeGenCXX/predefined-expr-cxx14.cpp