[PATCH] D129061: [Lex] Diagnose macro in command lines

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 16 16:56:09 PDT 2023


MaskRay added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:664
     HelpText<"Define <macro> to <value> (or 1 if <value> omitted)">;
+def DriverDefine : JoinedOrSeparate<["-"], "driver-define">, Group<Preprocessor_Group>,
+    Flags<[CC1Option, FlangOption, FC1Option]>, MetaVarName<"<macro>=<value>">,
----------------
aaron.ballman wrote:
> jackhong12 wrote:
> > MaskRay wrote:
> > > Make this CC1 only  option `NoDriverOption` by moving it somewhere under `let Flags = [CC1Option, NoDriverOption] in {`
> > > 
> > > Don't add new `Separate` or `JoinedOrSeparate` options. They are legacy.
> > I tried to add `=` behind `driver-define`. But I got the following error messages when I ran `ninja check-all`.
> > ```
> > [416/433] cd /home/zhenhong/ssd/zhenhong/llvm-project/clang/bindings/python && /usr/bin/cmake -E env CLANG_LIBRARY_PATH=/home/zhenhong/ssd/zhenhong/llvm-project/release/lib /usr/bin/python3.8 -m unittest discover                          
> > FAILED: tools/clang/bindings/python/tests/CMakeFiles/check-clang-python                                                                                                                                                                       
> > cd /home/zhenhong/ssd/zhenhong/llvm-project/clang/bindings/python && /usr/bin/cmake -E env CLANG_LIBRARY_PATH=/home/zhenhong/ssd/zhenhong/llvm-project/release/lib /usr/bin/python3.8 -m unittest discover                                    
> > E..........EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...EEEEEEEEEE.EEEEE......EEEE..EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE                                                                                                                
> > ======================================================================                                                                                                                                                                        
> > ERROR: test_access_specifiers (tests.cindex.test_access_specifiers.TestAccessSpecifiers)                                                                                                                                                      
> > Ensure that C++ access specifiers are available on cursors                                                                                                                                                                                    
> > ----------------------------------------------------------------------                                                                                                                                                                        
> > Traceback (most recent call last):                                                                                                                                                                                                            
> >   File "/home/zhenhong/ssd/zhenhong/llvm-project/clang/bindings/python/tests/cindex/test_access_specifiers.py", line 20, in test_access_specifiers                                                                                            
> >     tu = get_tu("""                                                                                                                                                                                                                           
> >   File "/home/zhenhong/ssd/zhenhong/llvm-project/clang/bindings/python/tests/cindex/util.py", line 40, in get_tu                                                                                                                              
> >     return TranslationUnit.from_source(name, args, unsaved_files=[(name,                                                                                                                                                                      
> >   File "/home/zhenhong/ssd/zhenhong/llvm-project/clang/bindings/python/clang/cindex.py", line 2837, in from_source                                                                                                                            
> >     raise TranslationUnitLoadError("Error parsing translation unit.")                                                                                                                                                                         
> > clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
> > 
> > ...
> > ```
> > 
> > I don't know what triggers the crash.
> I've never seen output like that before -- were you able to resolve this crash? @MaskRay do you have ideas?
I suspect that this is a config issue.

This patch now requires some rebase to work. For example, the Flags/CC1Option mechanism has been replaced with `Visibility<[CC1Option]>,`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129061/new/

https://reviews.llvm.org/D129061



More information about the cfe-commits mailing list