Skip to content

Commit d2fd8ca

Browse files
sdkrystianalandefreitas
authored andcommitted
feat: add isInline and isAnonymous to NamespaceInfo
closes cppalliance#199
1 parent 2d12f60 commit d2fd8ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+291
-66
lines changed

include/mrdox/Metadata/Namespace.hpp

+11
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,20 @@
1414

1515
#include <mrdox/Platform.hpp>
1616
#include <mrdox/Metadata/Info.hpp>
17+
#include <mrdox/ADT/BitField.hpp>
1718
#include <vector>
1819

1920
namespace clang {
2021
namespace mrdox {
2122

23+
union NamespaceFlags
24+
{
25+
BitFieldFullValue raw{.value=0u};
26+
27+
BitFlag<0> isInline;
28+
BitFlag<1> isAnonymous;
29+
};
30+
2231
/** Describes a namespace.
2332
*/
2433
struct NamespaceInfo
@@ -27,6 +36,8 @@ struct NamespaceInfo
2736
std::vector<SymbolID> Members;
2837
std::vector<SymbolID> Specializations;
2938

39+
NamespaceFlags specs;
40+
3041
//--------------------------------------------
3142

3243
explicit

mrdox.rnc

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ grammar
2929
Namespace =
3030
element namespace
3131
{
32-
Name,
32+
Name?,
3333
ID?,
34+
attribute is-inline { "1" }?,
35+
attribute is-anonymous { "1" }?,
3436
Javadoc?,
3537
Scope
3638
}

source/-XML/XMLWriter.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,10 @@ operator()(
200200
if constexpr(T::isNamespace())
201201
{
202202
tags_.open(namespaceTagName, {
203-
{ "name", I.Name },
204-
{ I.id }
203+
{ "name", I.Name, ! I.Name.empty() },
204+
{ I.id },
205+
{ "is-anonymous", "1", I.specs.isAnonymous},
206+
{ "is-inline", "1", I.specs.isInline}
205207
});
206208
writeJavadoc(I.javadoc);
207209
corpus_.traverse(I, *this);

source/AST/ASTVisitor.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,9 @@ buildNamespace(
11971197
{
11981198
if(! extractInfo(I, D))
11991199
return;
1200-
if(D->isAnonymousNamespace())
1201-
I.Name = "@nonymous_namespace"; // VFALCO BAD!
1200+
1201+
I.specs.isAnonymous = D->isAnonymousNamespace();
1202+
I.specs.isInline = D->isInline();
12021203

12031204
bool member_spec = getParentNamespaces(I.Namespace, D);
12041205

source/AST/AnyBlock.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,8 @@ class NamespaceBlock
969969
return decodeRecord(R, I->Members, Blob);
970970
case NAMESPACE_SPECIALIZATIONS:
971971
return decodeRecord(R, I->Specializations, Blob);
972+
case NAMESPACE_BITS:
973+
return decodeRecord(R, {&I->specs.raw}, Blob);
972974
default:
973975
return TopLevelBlock::parseRecord(R, ID, Blob);
974976
}

source/AST/BitcodeIDs.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ enum RecordID
9393
SOURCE_INFO_LOC,
9494
NAMESPACE_MEMBERS,
9595
NAMESPACE_SPECIALIZATIONS,
96+
NAMESPACE_BITS,
9697
TYPEINFO_KIND,
9798
TYPEINFO_ID,
9899
TYPEINFO_NAME,

source/AST/BitcodeWriter.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ RecordIDNameMap = []()
276276
{JAVADOC_PARAM_DIRECTION, {"JavadocParamDirection", &Integer32Abbrev}},
277277
{NAMESPACE_MEMBERS, {"NamespaceMembers", &SymbolIDsAbbrev}},
278278
{NAMESPACE_SPECIALIZATIONS, {"NamespaceSpecializations", &SymbolIDsAbbrev}},
279+
{NAMESPACE_BITS, {"NamespaceBits", &Integer32ArrayAbbrev}},
279280
{RECORD_KEY_KIND, {"KeyKind", &Integer32Abbrev}},
280281
{RECORD_IS_TYPE_DEF, {"IsTypeDef", &BoolAbbrev}},
281282
{RECORD_BITS, {"Bits", &Integer32ArrayAbbrev}},
@@ -359,7 +360,7 @@ RecordsByBlock{
359360
JAVADOC_NODE_ADMONISH, JAVADOC_PARAM_DIRECTION}},
360361
// NamespaceInfo
361362
{BI_NAMESPACE_BLOCK_ID,
362-
{NAMESPACE_MEMBERS, NAMESPACE_SPECIALIZATIONS}},
363+
{NAMESPACE_MEMBERS, NAMESPACE_SPECIALIZATIONS, NAMESPACE_BITS}},
363364
// RecordInfo
364365
{BI_RECORD_BLOCK_ID,
365366
{RECORD_KEY_KIND, RECORD_IS_TYPE_DEF, RECORD_BITS,
@@ -1003,6 +1004,7 @@ emitBlock(
10031004
emitInfoPart(I);
10041005
emitRecord(I.Members, NAMESPACE_MEMBERS);
10051006
emitRecord(I.Specializations, NAMESPACE_SPECIALIZATIONS);
1007+
emitRecord({I.specs.raw}, NAMESPACE_BITS);
10061008
}
10071009

10081010
void

source/Metadata/Reduce.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ reduceSpecializedMembers(
162162
void merge(NamespaceInfo& I, NamespaceInfo&& Other)
163163
{
164164
MRDOX_ASSERT(canMerge(I, Other));
165+
I.specs.raw.value |= Other.specs.raw.value;
165166
reduceSymbolIDs(I.Members, std::move(Other.Members));
166167
reduceSymbolIDs(I.Specializations, std::move(Other.Specializations));
167168
mergeInfo(I, std::move(Other));

test-files/old-tests/alias-template.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<template>
66
<tparam name="T" class="type"/>
77
<struct name="A" id="5tUSuMtQqtYE49jBjSYSWp0DJAM=">

test-files/old-tests/attributes_1.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
66
<file path="attributes_1.cpp" line="2"/>
77
<attr id="nodiscard"/>

test-files/old-tests/brief-1.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<function name="f5" id="RnDTZyCZuSqydMEPutN0yG4E/xg=">
66
<file path="brief-1.cpp" line="30"/>
77
<doc>

test-files/old-tests/brief-2.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<function name="f1" id="CnO51rIKTzfiVKHkR3TdPa0eo+8=">
66
<file path="brief-2.cpp" line="5"/>
77
<doc>

test-files/old-tests/canonical_1.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="B" id="3JsK1DO0O+wZhv+0meptQrbs3fY=">
66
<file path="canonical_1.cpp" line="2" class="def"/>
77
</struct>

test-files/old-tests/class-template-partial-spec.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<template>
66
<tparam name="T" class="type"/>
77
<struct name="A" id="5tUSuMtQqtYE49jBjSYSWp0DJAM=">

test-files/old-tests/class-template-spec.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<template>
66
<tparam name="T" class="type"/>
77
<struct name="A" id="5tUSuMtQqtYE49jBjSYSWp0DJAM=">

test-files/old-tests/class-template.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="S" id="pOYGF6pLJlICuiGO0Xj0daDb/to=">
66
<file path="class-template.cpp" line="1" class="def"/>
77
</struct>

test-files/old-tests/commands.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<function name="f1" id="CnO51rIKTzfiVKHkR3TdPa0eo+8=">
66
<file path="commands.cpp" line="8"/>
77
<doc>

test-files/old-tests/duplicate-jdoc.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<function name="f0" id="e1UQQek5v3C9OClW5cGf57XvwQo=">
66
<file path="duplicate-jdoc.cpp" line="5" class="def"/>
77
<return>

test-files/old-tests/explicit-conv-operator.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="Explicit" id="bonobNKGOblPVcRjxpiPan4nYnc=">
66
<file path="explicit-conv-operator.cpp" line="3" class="def"/>
77
<function name="operator bool" id="64zY8rVu+TzEUayzMrnV65i9nFc=">

test-files/old-tests/explicit-ctor.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="Explicit" id="bonobNKGOblPVcRjxpiPan4nYnc=">
66
<file path="explicit-ctor.cpp" line="3" class="def"/>
77
<function name="Explicit" id="JPrjQsrkg+QoApI2wln2eGwCGP4=">

test-files/old-tests/explicit-deduct-guide.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<template>
66
<tparam class="non-type" type="int"/>
77
<struct name="X" id="7wllQWhGGsbbeoZVa3gh4d7bcq8=">

test-files/old-tests/friend-1.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
66
<file path="friend-1.cpp" line="1" class="def"/>
77
<friend id="s6nsa+zVhpzzrN+yUVPP5rvdXqs="/>

test-files/old-tests/friend-2.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
66
<file path="friend-2.cpp" line="1" class="def"/>
77
<friend id="s6nsa+zVhpzzrN+yUVPP5rvdXqs="/>

test-files/old-tests/friend-3.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
66
<file path="friend-3.cpp" line="1" class="def"/>
77
<friend id="s6nsa+zVhpzzrN+yUVPP5rvdXqs="/>

test-files/old-tests/friend-4.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
66
<file path="friend-4.cpp" line="1" class="def"/>
77
<friend id="s6nsa+zVhpzzrN+yUVPP5rvdXqs="/>

test-files/old-tests/friend-5.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
66
<file path="friend-5.cpp" line="1" class="def"/>
77
<friend id="s6nsa+zVhpzzrN+yUVPP5rvdXqs="/>

test-files/old-tests/function-parm-decay.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<function name="f" id="ackjGh57CJQLwtO8PihiSPPKIBY=">
66
<file path="function-parm-decay.cpp" line="3"/>
77
<file path="function-parm-decay.cpp" line="4"/>

test-files/old-tests/function-template.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<template>
66
<tparam name="T" class="type"/>
77
<function name="f0" id="G5Gycl5fXkd7l6yntSV6MMQr5ec=">

test-files/old-tests/function-tparm-decay.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<template>
66
<tparam name="x" class="non-type" type="int"/>
77
<function name="f" id="eqMdBnxdb22zO3kokXFKlz9ktqg=">

test-files/old-tests/mem-fn.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<mrdox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdox/raw/develop/mrdox.rnc">
4-
<namespace name="">
4+
<namespace>
55
<struct name="T01" id="O2UBDeG42PMrk1up8f8PGVFhIGk=">
66
<file path="mem-fn.cpp" line="3" class="def"/>
77
<function name="f" id="dmtEtFE6EVKE6hWuugP9vFuib6Y=">

test-files/old-tests/namespace.cpp

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
namespace A
2+
{
3+
void f0();
4+
5+
namespace B
6+
{
7+
void f1();
8+
}
9+
10+
inline namespace C
11+
{
12+
void f2();
13+
}
14+
15+
namespace
16+
{
17+
void f3();
18+
}
19+
}
20+
21+
inline namespace D
22+
{
23+
void f5();
24+
25+
namespace E
26+
{
27+
void f6();
28+
}
29+
30+
inline namespace F
31+
{
32+
void f7();
33+
}
34+
35+
namespace
36+
{
37+
void f8();
38+
}
39+
}
40+
41+
namespace
42+
{
43+
void f10();
44+
45+
namespace G
46+
{
47+
void f11();
48+
}
49+
50+
inline namespace H
51+
{
52+
void f12();
53+
}
54+
55+
#if 0
56+
namespace
57+
{
58+
void f13();
59+
}
60+
#endif
61+
}
62+
63+
namespace I
64+
{
65+
inline namespace
66+
{
67+
void f14();
68+
}
69+
}

0 commit comments

Comments
 (0)