@@ -1988,6 +1988,53 @@ static enum CXChildVisitResult PrintDeclAttributes(CXCursor cursor, CXCursor p,
19881988 return CXChildVisit_Continue ;
19891989}
19901990
1991+ /******************************************************************************/
1992+ /* Inline assembly cursor testing */
1993+ /******************************************************************************/
1994+
1995+ static enum CXChildVisitResult
1996+ PrintGCCInlineAssembly (CXCursor cursor , CXCursor p , CXClientData d ) {
1997+ CXString Constraint , Template , Clobber ;
1998+ CXCursor Expr ;
1999+ unsigned hasGoto , i , e ;
2000+ if (clang_getCursorKind (cursor ) != CXCursor_AsmStmt ) {
2001+ return CXChildVisit_Recurse ;
2002+ }
2003+ hasGoto = clang_Cursor_isGCCAssemblyHasGoto (cursor );
2004+ printf ("===ASM TEMPLATE%s===\n" , hasGoto ? " (WITH GOTO)" : "" );
2005+ Template = clang_Cursor_getGCCAssemblyTemplate (cursor );
2006+ printf ("%s" , clang_getCString (Template ));
2007+ clang_disposeString (Template );
2008+ printf ("\n===ASM TEMPLATE END===\n" );
2009+
2010+ printf ("volatile: %s\n" ,
2011+ clang_Cursor_isGCCAssemblyVolatile (cursor ) ? "true" : "false" );
2012+ printf ("simple: %s\n" ,
2013+ clang_Cursor_isGCCAssemblySimple (cursor ) ? "true" : "false" );
2014+
2015+ for (i = 0 , e = clang_Cursor_getGCCAssemblyNumOutputs (cursor ); i < e ; ++ i ) {
2016+ clang_Cursor_getGCCAssemblyOutput (cursor , i , & Constraint , & Expr );
2017+ printf ("Output #%d Constraint (%s): " , i , clang_getCString (Constraint ));
2018+ PrintCursor (Expr , NULL );
2019+ printf ("\n" );
2020+ clang_disposeString (Constraint );
2021+ }
2022+ for (i = 0 , e = clang_Cursor_getGCCAssemblyNumInputs (cursor ); i < e ; ++ i ) {
2023+ clang_Cursor_getGCCAssemblyInput (cursor , i , & Constraint , & Expr );
2024+ printf ("Input #%d Constraint (%s): " , i , clang_getCString (Constraint ));
2025+ PrintCursor (Expr , NULL );
2026+ printf ("\n" );
2027+ clang_disposeString (Constraint );
2028+ }
2029+ for (i = 0 , e = clang_Cursor_getGCCAssemblyNumClobbers (cursor ); i < e ; ++ i ) {
2030+ Clobber = clang_Cursor_getGCCAssemblyClobber (cursor , i );
2031+ printf ("Clobber #%d: %s\n" , i , clang_getCString (Clobber ));
2032+ clang_disposeString (Clobber );
2033+ }
2034+ printf ("===ASM END===\n" );
2035+ return CXChildVisit_Recurse ;
2036+ }
2037+
19912038/******************************************************************************/
19922039/* Target information testing. */
19932040/******************************************************************************/
@@ -5010,6 +5057,7 @@ static void print_usage(void) {
50105057 " c-index-test -test-annotate-tokens=<range> {<args>}*\n"
50115058 " c-index-test -test-inclusion-stack-source {<args>}*\n"
50125059 " c-index-test -test-inclusion-stack-tu <AST file>\n" );
5060+ fprintf (stderr , " c-index-test -test-inline-assembly <AST file>\n" );
50135061 fprintf (stderr ,
50145062 " c-index-test -test-print-linkage-source {<args>}*\n"
50155063 " c-index-test -test-print-visibility {<args>}*\n"
@@ -5167,6 +5215,10 @@ int cindextest_main(int argc, const char **argv) {
51675215 else if (argc > 2 && strstr (argv [1 ], "-single-symbol-sgf-for=" ) == argv [1 ])
51685216 return perform_test_single_symbol_sgf (argv [1 ], argc - 2 , argv + 2 );
51695217
5218+ if (argc > 2 && strstr (argv [1 ], "-test-inline-assembly" ) == argv [1 ])
5219+ return perform_test_load_source (argc - 2 , argv + 2 , "all" ,
5220+ PrintGCCInlineAssembly , NULL );
5221+
51705222 print_usage ();
51715223 return 1 ;
51725224}
0 commit comments