This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Disable macro redefinition warnings in expression wrapper
ClosedPublic

Authored by teemperor on Dec 9 2022, 12:59 PM.

Details

Summary

GCC emits macro definitions into debug info when compiling with -g3.
LLDB is translating this information into #define directives which are injected into the
source code of user expressions. While this mechanism itself works fine, it can lead to
spurious "... macro redefined" warnings when the defined macro is also a builtin Clang macro:

warning: <lldb wrapper prefix>:46:9: '__VERSION__' macro redefined
#define __VERSION__ "12.1.0"
        ^
<built-in>:19:9: previous definition is here
#define __VERSION__ "Clang 14.0.6"
[repeated about a 100 more times for every builtin macro]

This patch just disables the diagnostic when parsing LLDB's generated list of
macros definitions.

Diff Detail

Event Timeline

teemperor created this revision.Dec 9 2022, 12:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 12:59 PM
teemperor requested review of this revision.Dec 9 2022, 12:59 PM
Michael137 accepted this revision.Dec 10 2022, 8:48 AM

LGTM thanks!

This revision is now accepted and ready to land.Dec 10 2022, 8:48 AM
Michael137 added inline comments.Dec 10 2022, 9:00 AM
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
150

You might want to also add -Wbuiltin-macro-redefined

Just tried this change on my Ubuntu VM with gcc-11 and it gets rid of most diagnostics apart from one:

(lldb) p alksjdh                                                                                          
error: expression failed to parse:                                                                        
warning: <lldb wrapper prefix>:252:9: redefining builtin macro                         
#define __FLT_EVAL_METHOD__ 0                                                                             
        ^                                                                                                 
error: <user expression 0>:1:1: use of undeclared identifier 'alksjdh'                                    
alksjdh                                                                                                   
^
teemperor updated this revision to Diff 497440.Feb 14 2023, 2:20 PM
  • Address builtin redefining (Thanks Michael!)
This revision was landed with ongoing or failed builds.Feb 14 2023, 2:21 PM
This revision was automatically updated to reflect the committed changes.