Results 1 to 4 of 4

Thread: Qt C++ Source Code Analyzer Example

  1. #1
    Join Date
    Jun 2017
    Posts
    19
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Qt C++ Source Code Analyzer Example

    Qt 5.9 has "C++ Source Code Analyzer" Example. It has following project file:

    src_code_analyzer_pro.PNG


    Added after 6 minutes:


    Following is help information about this Source Code Analyzer Example:

    Src_Code_Analyzer_Help.jpg


    Added after 11 minutes:


    I built and ran this example and got following GUI window:

    Src_Code_Analyser_GUI_screen.PNG


    Added after 6 minutes:


    Why this example program is saying: "Could not find the executable, please specify one."?

    How to use this example program please?

    I am expecting this program to be able to open a C++ file.

    What to type in the "Command line arguments" text box?
    Thank you for any information about how to use this example program please?


    Added after 6 minutes:


    Is there a C++ source file(s) this example file is based on?
    What is meant by "TEMPLATE = aux" in this example program's xquery.pro file?

    How to look at this example program's C++ file?
    I want to look at its C++ file and modify it to display all assignment statements in an input C++ text file.

    Is it possible to look at the C++ file of this example program please?
    Thanks
    Last edited by Mike_m; 7th July 2017 at 11:31.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt C++ Source Code Analyzer Example

    The "C++ Source Code Analyzer" example does not build a program. It provides an xquery script that will take the output of the gcc source code analysis XML file and transform it into XML for display in a browser. The dialog box you see is displayed by Qt Creator when it can't find an executable for the project you are trying to run.

    Read all of the "C++ Source Code Analyzer Example" help page you linked to. You need to get the GCC-XML tool from Kitware that is linked to in the help text. After you install it, you need to run it on your source file:

    Qt Code:
    1. gccxml [options] <input-file> -fxml=<output-file>
    To copy to clipboard, switch view to plain text mode 

    as explained on the GCC-XML page.

    Next, you need to run the xmlpatterns program (part of the Qt distribution) on the output XML file:

    Qt Code:
    1. xmlpatterns reportGlobals.xq -param fileToOpen=<output-file>.gccxml -output <html-file>.html
    To copy to clipboard, switch view to plain text mode 

    The xquery in this case is "reportglobals.xq", which will generate a report of all the global declarations in your source code file. This xquery script is in the "globalvariables" subdirectory of the xquery example project.

    If you want any other type of report, you will have to write your own XQuery script to generate it. That's why this is an example, not a complete source code analyzer.

    If you want a real source code analyzer, then you will have to use Google to find one.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jun 2017
    Posts
    19
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Qt C++ Source Code Analyzer Example

    Hello d_stranz,
    Thank you very much for excellent information about "C++ Source Code Analyzer" Qt example.

    I do not need off-the shelf source code analyzer (unless it is a small C++ program less than 1000 or 2000 line and its source code is open source).
    I need this example kind of Qt program so that I can modify it to produce:
    1. List of global variable names of input C++ file and their C++ types
    2. List of local variable names and their C++ types
    3. List of Assignment statements in each function of the input C++ file
    4. List of Function call statements in the input C++ file.

    Using your inputs, I will read and understand the information you have given and develop the example so that it outputs above four kinds of data to an output text file.

    Once I get the above four kinds of information, I need to develop additional features to this example program.

    If there is a similar Qt example that is developed using C++ only, I would have preferred.

    Again, thank you very much for your detailed reply.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt C++ Source Code Analyzer Example

    You will have to modify the "reportglobals.xq" file (or better, write a new xquery file using that as a start) to identify and report the additional features you want. I don't know enough about XQuery to tell you what to do; you'll have to go to the WW3 web site, read the XQuery documentation, and try to teach yourself.

    You are also going to probably have to configure the options for GCC-XML so they match what your compiler does when it builds your source code. For example, any #define / #ifdef preprocessor options have to work the same way. It also has to be able to find all of the system #include files used by your compiler so it finds the definitions for system-level classes and namespaces (like std:: ).

    GCC-XML does not handle code beyond C++99, so any C++11 or later code won't work. For that you will need to use the CastXML tool that has replaced GCC-XML. I would advise you to start with CastXML instead of GCC-XML.

    Personally, I think you would be better off looking around for a real source code analyzer rather than trying to learn all of these new technologies and writing your own.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Source code to *.ui
    By Zergi in forum Qt Tools
    Replies: 3
    Last Post: 28th September 2011, 18:12
  2. no source code
    By banlinhtienphong in forum General Programming
    Replies: 1
    Last Post: 25th July 2011, 17:19
  3. Where is the source code?
    By Fletcher in forum Newbie
    Replies: 1
    Last Post: 10th December 2009, 20:45
  4. Source code
    By afflictedd2 in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2008, 09:04
  5. Qte source code
    By Gaurav vyas in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 1st July 2007, 14:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.