jeudi 20 août 2020

Get location of defination of imported entites through a SRCML file

Is there a way by which I can get information that where is the definition of a : 

  • an inherited class 
  • class whose object is created. 
  • method call which is not defined in the current unit Specially in case of C++

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<unit xmlns="http://www.srcML.org/srcML/src" revision="1.0.0" url="temp/STL/stl/src/">

<unit xmlns:cpp="http://www.srcML.org/srcML/cpp" revision="1.0.0" language="C++" filename="../temp/STL/stl/src/StlCompareStringA.cpp" hash="e0f96dbf757dc31aecdca67e74455e0fb8f9bfcf"><comment type="line">// Copyright (c) Microsoft Corporation.</comment>
<comment type="line">// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception</comment>

<cpp:include>#<cpp:directive>include</cpp:directive> <cpp:file>&lt;crtdbg.h&gt;</cpp:file></cpp:include>
<cpp:include>#<cpp:directive>include</cpp:directive> <cpp:file>&lt;internal_shared.h&gt;</cpp:file></cpp:include>
<cpp:include>#<cpp:directive>include</cpp:directive> <cpp:file>&lt;string.h&gt;</cpp:file></cpp:include>

<cpp:include>#<cpp:directive>include</cpp:directive> <cpp:file>&lt;Windows.h&gt;</cpp:file></cpp:include>

<cpp:include>#<cpp:directive>include</cpp:directive> <cpp:file>"awint.hpp"</cpp:file></cpp:include>


<comment type="line">// int __cdecl __crtCompareStringA - Get type information about an ANSI string.</comment>
<comment type="line">//</comment>
<comment type="line">// Purpose:</comment>
<comment type="line">//        Internal support function. Assumes info in ANSI string format. Tries</comment>
<comment type="line">//        to use NLS API call CompareStringA if available and uses CompareStringW</comment>
<comment type="line">//        if it must. If neither is available it fails and returns 0.</comment>
<comment type="line">//</comment>
<comment type="line">// Entry:</comment>
<comment type="line">//        LPCWSTR LocaleName  - locale context for the comparison.</comment>
<comment type="line">//        DWORD   dwCmpFlags  - see docs.microsoft.com</comment>
<comment type="line">//        LPCSTR  lpStringn   - multibyte string to be compared</comment>
<comment type="line">//        int     cchCountn   - char (byte) count (NOT including null terminator)</comment>
<comment type="line">//                              (-1 if null terminated)</comment>
<comment type="line">//        int     code_page   - for MB/WC conversion. If 0, use __lc_codepage</comment>
<comment type="line">//</comment>
<comment type="line">// Exit:</comment>
<comment type="line">//        Success: 1 - if lpString1 &lt;  lpString2</comment>
<comment type="line">//                 2 - if lpString1 == lpString2</comment>
<comment type="line">//                 3 - if lpString1 &gt;  lpString2</comment>
<comment type="line">//        Failure: 0</comment>
<extern>extern <literal type="string">"C"</literal> <function><type><name>int</name> <name>__cdecl</name></type> <name>__crtCompareStringA</name><parameter_list>(<parameter><decl><type><name>LPCWSTR</name></type> <name>LocaleName</name></decl></parameter>, <parameter><decl><type><name>DWORD</name></type> <name>dwCmpFlags</name></decl></parameter>, <parameter><decl><type><name>LPCSTR</name></type> <name>lpString1</name></decl></parameter>, <parameter><decl><type><name>int</name></type> <name>cchCount1</name></decl></parameter>,
    <parameter><decl><type><name>LPCSTR</name></type> <name>lpString2</name></decl></parameter>, <parameter><decl><type><name>int</name></type> <name>cchCount2</name></decl></parameter>, <parameter><decl><type><name>int</name></type> <name>code_page</name></decl></parameter>)</parameter_list> <block>{<block_content>
    <comment type="line">// CompareString will compare past null terminator. Must find null terminator if in string before cchCountn chars.</comment>
    <if_stmt><if>if <condition>(<expr><name>cchCount1</name> <operator>&gt;</operator> <literal type="number">0</literal></expr>)</condition> <block>{<block_content>
        <expr_stmt><expr><name>cchCount1</name> <operator>=</operator> <cast type="static">static_cast<argument_list type="generic">&lt;<argument><expr><name>int</name></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><call><name>__strncnt</name><argument_list>(<argument><expr><name>lpString1</name></expr></argument>, <argument><expr><name>cchCount1</name></expr></argument>)</argument_list></call></expr></argument>)</argument_list></cast></expr>;</expr_stmt>
    </block_content>}</block></if> <if type="elseif">else if <condition>(<expr><name>cchCount1</name> <operator>&lt;</operator> <operator>-</operator><literal type="number">1</literal></expr>)</condition> <block>{<block_content>
        <return>return <expr><name>FALSE</name></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <if_stmt><if>if <condition>(<expr><name>cchCount2</name> <operator>&gt;</operator> <literal type="number">0</literal></expr>)</condition> <block>{<block_content>
        <expr_stmt><expr><name>cchCount2</name> <operator>=</operator> <cast type="static">static_cast<argument_list type="generic">&lt;<argument><expr><name>int</name></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><call><name>__strncnt</name><argument_list>(<argument><expr><name>lpString2</name></expr></argument>, <argument><expr><name>cchCount2</name></expr></argument>)</argument_list></call></expr></argument>)</argument_list></cast></expr>;</expr_stmt>
    </block_content>}</block></if> <if type="elseif">else if <condition>(<expr><name>cchCount2</name> <operator>&lt;</operator> <operator>-</operator><literal type="number">1</literal></expr>)</condition> <block>{<block_content>
        <return>return <expr><name>FALSE</name></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <comment type="line">// Special case: at least one count is zero</comment>
    <if_stmt><if>if <condition>(<expr><operator>!</operator><name>cchCount1</name> <operator>||</operator> <operator>!</operator><name>cchCount2</name></expr>)</condition> <block>{<block_content>
        <comment type="line">// both strings zero</comment>
        <if_stmt><if>if <condition>(<expr><name>cchCount1</name> <operator>==</operator> <name>cchCount2</name></expr>)</condition> <block>{<block_content>
            <return>return <expr><literal type="number">2</literal></expr>;</return>
        </block_content>}</block></if></if_stmt>

        <comment type="line">// string 1 greater</comment>
        <if_stmt><if>if <condition>(<expr><name>cchCount2</name> <operator>&gt;</operator> <literal type="number">1</literal></expr>)</condition> <block>{<block_content>
            <return>return <expr><literal type="number">1</literal></expr>;</return>
        </block_content>}</block></if></if_stmt>

        <comment type="line">// string 2 greater</comment>
        <if_stmt><if>if <condition>(<expr><name>cchCount1</name> <operator>&gt;</operator> <literal type="number">1</literal></expr>)</condition> <block>{<block_content>
            <return>return <expr><literal type="number">3</literal></expr>;</return>
        </block_content>}</block></if></if_stmt>

        <comment type="line">// one has zero count, the other has a count of one</comment>
        <comment type="line">// - if the one count is a naked lead byte, the strings are equal</comment>
        <comment type="line">// - otherwise it is a single character and they are unequal</comment>
        <decl_stmt><decl><type><name>CPINFO</name></type> <name>cpInfo</name></decl>;</decl_stmt>
        <if_stmt><if>if <condition>(<expr><call><name>GetCPInfo</name><argument_list>(<argument><expr><name>code_page</name></expr></argument>, <argument><expr><operator>&amp;</operator><name>cpInfo</name></expr></argument>)</argument_list></call> <operator>==</operator> <name>FALSE</name></expr>)</condition> <block>{<block_content>
            <return>return <expr><literal type="number">0</literal></expr>;</return>
        </block_content>}</block></if></if_stmt>

        <expr_stmt><expr><call><name>_ASSERTE</name><argument_list>(<argument><expr><operator>(</operator><name>cchCount1</name> <operator>==</operator> <literal type="number">0</literal> <operator>&amp;&amp;</operator> <name>cchCount2</name> <operator>==</operator> <literal type="number">1</literal><operator>)</operator> <operator>||</operator> <operator>(</operator><name>cchCount1</name> <operator>==</operator> <literal type="number">1</literal> <operator>&amp;&amp;</operator> <name>cchCount2</name> <operator>==</operator> <literal type="number">0</literal><operator>)</operator></expr></argument>)</argument_list></call></expr>;</expr_stmt>

        <comment type="line">// string 1 has count of 1</comment>
        <if_stmt><if>if <condition>(<expr><name>cchCount1</name> <operator>&gt;</operator> <literal type="number">0</literal></expr>)</condition> <block>{<block_content>
            <if_stmt><if>if <condition>(<expr><name><name>cpInfo</name><operator>.</operator><name>MaxCharSize</name></name> <operator>&lt;</operator> <literal type="number">2</literal></expr>)</condition> <block>{<block_content>
                <return>return <expr><literal type="number">3</literal></expr>;</return>
            </block_content>}</block></if></if_stmt>

            <for>for <control>(<init><decl><type><name>auto</name></type> <name>cp</name> <init>= <expr><operator>&amp;</operator><name><name>cpInfo</name><operator>.</operator><name>LeadByte</name><index>[<expr><literal type="number">0</literal></expr>]</index></name></expr></init></decl>;</init> <condition><expr><name><name>cp</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>&amp;&amp;</operator> <name><name>cp</name><index>[<expr><literal type="number">1</literal></expr>]</index></name></expr>;</condition> <incr><expr><name>cp</name> <operator>+=</operator> <literal type="number">2</literal></expr></incr>)</control> <block>{<block_content>
                <decl_stmt><decl><type><specifier>const</specifier> <specifier>auto</specifier></type> <name>ch</name> <init>= <expr><cast type="static">static_cast<argument_list type="generic">&lt;<argument><expr><name>unsigned</name> <name>char</name></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><operator>*</operator><name>lpString1</name></expr></argument>)</argument_list></cast></expr></init></decl>;</decl_stmt>
                <if_stmt><if>if <condition>(<expr><name>ch</name> <operator>&gt;=</operator> <name><name>cp</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>&amp;&amp;</operator> <name>ch</name> <operator>&lt;=</operator> <name><name>cp</name><index>[<expr><literal type="number">1</literal></expr>]</index></name></expr>)</condition> <block>{<block_content>
                    <return>return <expr><literal type="number">2</literal></expr>;</return>
                </block_content>}</block></if></if_stmt>
            </block_content>}</block></for>

            <return>return <expr><literal type="number">3</literal></expr>;</return>
        </block_content>}</block></if></if_stmt>

        <comment type="line">// string 2 has count of 1</comment>
        <if_stmt><if>if <condition>(<expr><name>cchCount2</name> <operator>&gt;</operator> <literal type="number">0</literal></expr>)</condition> <block>{<block_content>
            <if_stmt><if>if <condition>(<expr><name><name>cpInfo</name><operator>.</operator><name>MaxCharSize</name></name> <operator>&lt;</operator> <literal type="number">2</literal></expr>)</condition> <block>{<block_content>
                <return>return <expr><literal type="number">1</literal></expr>;</return>
            </block_content>}</block></if></if_stmt>

            <for>for <control>(<init><decl><type><name>auto</name></type> <name>cp</name> <init>= <expr><operator>&amp;</operator><name><name>cpInfo</name><operator>.</operator><name>LeadByte</name><index>[<expr><literal type="number">0</literal></expr>]</index></name></expr></init></decl>;</init> <condition><expr><name><name>cp</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>&amp;&amp;</operator> <name><name>cp</name><index>[<expr><literal type="number">1</literal></expr>]</index></name></expr>;</condition> <incr><expr><name>cp</name> <operator>+=</operator> <literal type="number">2</literal></expr></incr>)</control> <block>{<block_content>
                <decl_stmt><decl><type><specifier>const</specifier> <specifier>auto</specifier></type> <name>ch</name> <init>= <expr><cast type="static">static_cast<argument_list type="generic">&lt;<argument><expr><name>unsigned</name> <name>char</name></expr></argument>&gt;</argument_list><argument_list>(<argument><expr><operator>*</operator><name>lpString2</name></expr></argument>)</argument_list></cast></expr></init></decl>;</decl_stmt>
                <if_stmt><if>if <condition>(<expr><name>ch</name> <operator>&gt;=</operator> <name><name>cp</name><index>[<expr><literal type="number">0</literal></expr>]</index></name> <operator>&amp;&amp;</operator> <name>ch</name> <operator>&lt;=</operator> <name><name>cp</name><index>[<expr><literal type="number">1</literal></expr>]</index></name></expr>)</condition> <block>{<block_content>
                    <return>return <expr><literal type="number">2</literal></expr>;</return>
                </block_content>}</block></if></if_stmt>
            </block_content>}</block></for>

            <return>return <expr><literal type="number">1</literal></expr>;</return>
        </block_content>}</block></if></if_stmt>
    </block_content>}</block></if></if_stmt>

    <comment type="line">// Convert strings and return the requested information.</comment>

    <comment type="line">// find out how big a buffer we need (includes null terminator if any)</comment>
    <decl_stmt><decl><type><specifier>const</specifier> <name>int</name></type> <name>buff_size1</name> <init>=
        <expr><call><name>MultiByteToWideChar</name><argument_list>(<argument><expr><name>code_page</name></expr></argument>, <argument><expr><name>MB_PRECOMPOSED</name> <operator>|</operator> <name>MB_ERR_INVALID_CHARS</name></expr></argument>, <argument><expr><name>lpString1</name></expr></argument>, <argument><expr><name>cchCount1</name></expr></argument>, <argument><expr><literal type="null">nullptr</literal></expr></argument>, <argument><expr><literal type="number">0</literal></expr></argument>)</argument_list></call></expr></init></decl>;</decl_stmt>
    <if_stmt><if>if <condition>(<expr><literal type="number">0</literal> <operator>==</operator> <name>buff_size1</name></expr>)</condition> <block>{<block_content>
        <return>return <expr><literal type="number">0</literal></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <comment type="line">// allocate enough space for chars</comment>
    <decl_stmt><decl><type><name><name>__crt_scoped_stack_ptr</name><argument_list type="generic">&lt;<argument><expr><name>wchar_t</name></expr></argument>&gt;</argument_list></name></type> <name>wbuffer1</name><argument_list>(<argument><expr><call><name>_malloca_crt_t</name><argument_list>(<argument><expr><name>wchar_t</name></expr></argument>, <argument><expr><name>buff_size1</name></expr></argument>)</argument_list></call></expr></argument>)</argument_list></decl>;</decl_stmt>
    <if_stmt><if>if <condition>(<expr><call><name><name>wbuffer1</name><operator>.</operator><name>get</name></name><argument_list>()</argument_list></call> <operator>==</operator> <literal type="null">nullptr</literal></expr>)</condition> <block>{<block_content>
        <return>return <expr><literal type="number">0</literal></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <comment type="line">// do the conversion</comment>
    <if_stmt><if>if <condition>(<expr><literal type="number">0</literal> <operator>==</operator> <call><name>MultiByteToWideChar</name><argument_list>(<argument><expr><name>code_page</name></expr></argument>, <argument><expr><name>MB_PRECOMPOSED</name></expr></argument>, <argument><expr><name>lpString1</name></expr></argument>, <argument><expr><name>cchCount1</name></expr></argument>, <argument><expr><call><name><name>wbuffer1</name><operator>.</operator><name>get</name></name><argument_list>()</argument_list></call></expr></argument>, <argument><expr><name>buff_size1</name></expr></argument>)</argument_list></call></expr>)</condition> <block>{<block_content>
        <return>return <expr><literal type="number">0</literal></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <comment type="line">// find out how big a buffer we need (includes null terminator if any)</comment>
    <decl_stmt><decl><type><specifier>const</specifier> <name>int</name></type> <name>buff_size2</name> <init>=
        <expr><call><name>MultiByteToWideChar</name><argument_list>(<argument><expr><name>code_page</name></expr></argument>, <argument><expr><name>MB_PRECOMPOSED</name> <operator>|</operator> <name>MB_ERR_INVALID_CHARS</name></expr></argument>, <argument><expr><name>lpString2</name></expr></argument>, <argument><expr><name>cchCount2</name></expr></argument>, <argument><expr><literal type="null">nullptr</literal></expr></argument>, <argument><expr><literal type="number">0</literal></expr></argument>)</argument_list></call></expr></init></decl>;</decl_stmt>
    <if_stmt><if>if <condition>(<expr><literal type="number">0</literal> <operator>==</operator> <name>buff_size2</name></expr>)</condition> <block>{<block_content>
        <return>return <expr><literal type="number">0</literal></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <comment type="line">// allocate enough space for chars</comment>
    <decl_stmt><decl><type><specifier>const</specifier> <name><name>__crt_scoped_stack_ptr</name><argument_list type="generic">&lt;<argument><expr><name>wchar_t</name></expr></argument>&gt;</argument_list></name></type> <name>wbuffer2</name><argument_list>(<argument><expr><call><name>_malloca_crt_t</name><argument_list>(<argument><expr><name>wchar_t</name></expr></argument>, <argument><expr><name>buff_size2</name></expr></argument>)</argument_list></call></expr></argument>)</argument_list></decl>;</decl_stmt>
    <if_stmt><if>if <condition>(<expr><call><name><name>wbuffer2</name><operator>.</operator><name>get</name></name><argument_list>()</argument_list></call> <operator>==</operator> <literal type="null">nullptr</literal></expr>)</condition> <block>{<block_content>
        <return>return <expr><literal type="number">0</literal></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <decl_stmt><decl><type><specifier>const</specifier> <name>int</name></type> <name>actual_size</name> <init>=
        <expr><call><name>MultiByteToWideChar</name><argument_list>(<argument><expr><name>code_page</name></expr></argument>, <argument><expr><name>MB_PRECOMPOSED</name></expr></argument>, <argument><expr><name>lpString2</name></expr></argument>, <argument><expr><name>cchCount2</name></expr></argument>, <argument><expr><call><name><name>wbuffer2</name><operator>.</operator><name>get</name></name><argument_list>()</argument_list></call></expr></argument>, <argument><expr><name>buff_size2</name></expr></argument>)</argument_list></call></expr></init></decl>;</decl_stmt>
    <if_stmt><if>if <condition>(<expr><name>actual_size</name> <operator>==</operator> <literal type="number">0</literal></expr>)</condition> <block>{<block_content>
        <return>return <expr><literal type="number">0</literal></expr>;</return>
    </block_content>}</block></if></if_stmt>

    <return>return <expr><call><name>__crtCompareStringEx</name><argument_list>(<argument><expr><name>LocaleName</name></expr></argument>, <argument><expr><name>dwCmpFlags</name></expr></argument>, <argument><expr><call><name><name>wbuffer1</name><operator>.</operator><name>get</name></name><argument_list>()</argument_list></call></expr></argument>, <argument><expr><name>buff_size1</name></expr></argument>, <argument><expr><call><name><name>wbuffer2</name><operator>.</operator><name>get</name></name><argument_list>()</argument_list></call></expr></argument>, <argument><expr><name>buff_size2</name></expr></argument>)</argument_list></call></expr>;</return>
</block_content>}</block></function></extern>
</unit>

Aucun commentaire:

Enregistrer un commentaire