@@ -441,6 +441,8 @@ class ASTVisitor
441
441
return nullptr ;
442
442
}
443
443
444
+ // KRYSTIAN FIXME: something is broken here w.r.t
445
+ // qualified names, but i'm not sure what exactly
444
446
std::unique_ptr<TypeInfo>
445
447
buildTypeInfo (
446
448
QualType qt,
@@ -737,295 +739,6 @@ class ASTVisitor
737
739
}
738
740
}
739
741
740
- #if 0
741
- std::unique_ptr<TypeInfo>
742
- buildTypeInfo_(
743
- QualType qt,
744
- unsigned quals = 0)
745
- {
746
- auto* ptr = qt.getTypePtrOrNull();
747
- if(! ptr)
748
- return nullptr;
749
- return visit(ptr, [&]<typename TypeTy>(
750
- TypeTy* T) -> std::unique_ptr<TypeInfo>
751
- {
752
- constexpr Type::TypeClass kind =
753
- TypeToKind<TypeTy>();
754
-
755
- switch(kind)
756
- {
757
- case Type::Paren:
758
- {
759
- return buildTypeInfo(
760
- T->getInnerType(), quals);
761
- }
762
- // type with __atribute__
763
- case Type::Attributed:
764
- {
765
- return buildTypeInfo(
766
- T->getModifiedType(), quals);
767
- }
768
- // adjusted and decayed types
769
- case Type::Decayed:
770
- case Type::Adjusted:
771
- {
772
- return buildTypeInfo(
773
- T->getOriginalType(), quals);
774
- }
775
- // using declarations
776
- case Type::Using:
777
- {
778
- // look through the using declaration and
779
- // use the the type from the referenced declaration
780
- return buildTypeInfo(
781
- T->getUnderlyingType(), quals);
782
- }
783
- // pointers
784
- case Type::Pointer:
785
- {
786
- auto I = std::make_unique<PointerTypeInfo>();
787
- I->PointeeType = buildTypeInfo(
788
- T->getPointeeType());
789
- I->CVQualifiers = convertToQualifierKind(quals);
790
- return I;
791
- }
792
- // references
793
- case Type::LValueReference:
794
- {
795
- auto I = std::make_unique<LValueReferenceTypeInfo>();
796
- I->PointeeType = buildTypeInfo(
797
- T->getPointeeType());
798
- return I;
799
- }
800
- case Type::RValueReference:
801
- {
802
- auto I = std::make_unique<RValueReferenceTypeInfo>();
803
- I->PointeeType = buildTypeInfo(
804
- T->getPointeeType());
805
- return I;
806
- }
807
- // pointer to members
808
- case Type::MemberPointer:
809
- {
810
- auto I = std::make_unique<MemberPointerTypeInfo>();
811
- I->PointeeType = buildTypeInfo(
812
- T->getPointeeType());
813
- I->ParentType = buildTypeInfo(
814
- QualType(T->getClass(), 0));
815
- I->CVQualifiers = convertToQualifierKind(quals);
816
- return I;
817
- }
818
- // pack expansion
819
- case Type::PackExpansion:
820
- {
821
- auto I = std::make_unique<PackTypeInfo>();
822
- I->PatternType = buildTypeInfo(T->getPattern());
823
- return I;
824
- }
825
- // KRYSTIAN NOTE: we don't handle FunctionNoProto here,
826
- // and it's unclear if we should. we should not encounter
827
- // such types in c++ (but it might be possible?)
828
- // functions
829
- case Type::FunctionProto:
830
- {
831
- auto I = std::make_unique<FunctionTypeInfo>();
832
- I->ReturnType = buildTypeInfo(
833
- T->getReturnType());
834
- for(QualType PT : T->getParamTypes())
835
- I->ParamTypes.emplace_back(
836
- buildTypeInfo(PT));
837
- I->RefQualifier = convertToReferenceKind(
838
- T->getRefQualifier());
839
- I->CVQualifiers = convertToQualifierKind(
840
- T->getMethodQuals().getFastQualifiers());
841
- I->ExceptionSpec = convertToNoexceptKind(
842
- T->getExceptionSpecType());
843
- return I;
844
- }
845
- // KRYSTIAN FIXME: do we handle variables arrays?
846
- // they can only be created within function scope
847
- // arrays
848
- case Type::IncompleteArray:
849
- {
850
- auto I = std::make_unique<ArrayTypeInfo>();
851
- I->ElementType = buildTypeInfo(
852
- T->getElementType());
853
- return I;
854
- }
855
- case Type::ConstantArray:
856
- {
857
- auto I = std::make_unique<ArrayTypeInfo>();
858
- I->ElementType = buildTypeInfo(
859
- T->getElementType());
860
- // KRYSTIAN FIXME: this is broken; cannonical
861
- // constant array types never have a size expression
862
- buildExprInfo(I->Bounds,
863
- T->getSizeExpr(), T->getSize());
864
- return I;
865
- }
866
- case Type::DependentSizedArray:
867
- {
868
- auto I = std::make_unique<ArrayTypeInfo>();
869
- I->ElementType = buildTypeInfo(
870
- T->getElementType());
871
- buildExprInfo(I->Bounds,
872
- T->getSizeExpr());
873
- return I;
874
- }
875
- case Type::Auto:
876
- {
877
- QualType deduced = T->getDeducedType();
878
- // KRYSTIAN NOTE: we don't use isDeduced because it will
879
- // return true if the type is dependent
880
- // if the type has been deduced, use the deduced type
881
- if(! deduced.isNull())
882
- return buildTypeInfo(deduced);
883
- auto I = std::make_unique<BuiltinTypeInfo>();
884
- I->Name = getTypeAsString(
885
- qt.withoutLocalFastQualifiers());
886
- I->CVQualifiers = convertToQualifierKind(quals);
887
- return I;
888
- }
889
- case Type::DeducedTemplateSpecialization:
890
- {
891
- auto* T = cast<DeducedTemplateSpecializationType>(type);
892
- if(T->isDeduced())
893
- return buildTypeInfo(T->getDeducedType());
894
- auto I = makeTypeInfo<TagTypeInfo>(
895
- T->getTemplateName().getAsTemplateDecl(), quals);
896
- return I;
897
- }
898
- // elaborated type specifier or
899
- // type with nested name specifier
900
- case Type::Elaborated:
901
- {
902
- auto* T = cast<ElaboratedType>(type);
903
- auto I = buildTypeInfo(
904
- T->getNamedType(), quals);
905
- // ignore elaborated-type-specifiers
906
- if(auto kw = T->getKeyword();
907
- kw != ElaboratedTypeKeyword::ETK_Typename &&
908
- kw != ElaboratedTypeKeyword::ETK_None)
909
- return I;
910
- switch(I->Kind)
911
- {
912
- case TypeKind::Tag:
913
- static_cast<TagTypeInfo&>(*I).ParentType =
914
- buildTypeInfo(T->getQualifier());
915
- break;
916
- case TypeKind::Specialization:
917
- static_cast<SpecializationTypeInfo&>(*I).ParentType =
918
- buildTypeInfo(T->getQualifier());
919
- break;
920
- case TypeKind::Builtin:
921
- // KRYSTIAN FIXME: is this correct?
922
- break;
923
- default:
924
- MRDOX_UNREACHABLE();
925
- };
926
- return I;
927
- }
928
- // qualified dependent name with template keyword
929
- case Type::DependentTemplateSpecialization:
930
- {
931
- auto* T = cast<DependentTemplateSpecializationType>(type);
932
- auto I = makeTypeInfo<SpecializationTypeInfo>(
933
- T->getIdentifier(), quals);
934
- I->ParentType = buildTypeInfo(
935
- T->getQualifier());
936
- buildTemplateArgs(I->TemplateArgs, T->template_arguments());
937
- return I;
938
- }
939
- // specialization of a class/alias template or
940
- // template template parameter
941
- case Type::TemplateSpecialization:
942
- {
943
- auto* T = cast<TemplateSpecializationType>(type);
944
- auto name = T->getTemplateName();
945
- MRDOX_ASSERT(! name.isNull());
946
- NamedDecl* ND = name.getAsTemplateDecl();
947
- // if this is a specialization of a alias template,
948
- // the canonical type will be the named type. in such cases,
949
- // we will use the template name. otherwise, we use the
950
- // canonical type whenever possible.
951
- if(! T->isTypeAlias())
952
- {
953
- auto* CT = qt.getCanonicalType().getTypePtrOrNull();
954
- if(auto* ICT = dyn_cast_or_null<
955
- InjectedClassNameType>(CT))
956
- {
957
- ND = ICT->getDecl();
958
- }
959
- if(auto* RT = dyn_cast_or_null<
960
- RecordType>(CT))
961
- {
962
- ND = RT->getDecl();
963
- }
964
- }
965
- auto I = makeTypeInfo<SpecializationTypeInfo>(ND, quals);
966
- buildTemplateArgs(I->TemplateArgs, T->template_arguments());
967
- return I;
968
- }
969
- // dependent typename-specifier
970
- case Type::DependentName:
971
- {
972
- auto* T = cast<DependentNameType>(type);
973
- auto I = makeTypeInfo<TagTypeInfo>(
974
- T->getIdentifier(), quals);
975
- I->ParentType = buildTypeInfo(
976
- T->getQualifier());
977
- return I;
978
- }
979
- // record & enum types, as well as injected class names
980
- // within a class template (or specializations thereof)
981
- case Type::InjectedClassName:
982
- case Type::Record:
983
- case Type::Enum:
984
- {
985
- auto I = makeTypeInfo<TagTypeInfo>(
986
- type->getAsTagDecl(), quals);
987
- return I;
988
- }
989
- // typedef/alias type
990
- case Type::Typedef:
991
- {
992
- auto* T = cast<TypedefType>(type);
993
- auto I = makeTypeInfo<TagTypeInfo>(
994
- T->getDecl(), quals);
995
- return I;
996
- }
997
- case Type::TemplateTypeParm:
998
- {
999
- auto* T = cast<TemplateTypeParmType>(type);
1000
- auto I = std::make_unique<BuiltinTypeInfo>();
1001
- if(auto* D = T->getDecl())
1002
- {
1003
- // special case for implicit template parameters
1004
- // resulting from abbreviated function templates
1005
- if(D->isImplicit())
1006
- I->Name = "auto";
1007
- else if(auto* II = D->getIdentifier())
1008
- I->Name = II->getName();
1009
- }
1010
- I->CVQualifiers = convertToQualifierKind(quals);
1011
- return I;
1012
- }
1013
- // builtin/unhandled type
1014
- default:
1015
- {
1016
- auto I = std::make_unique<BuiltinTypeInfo>();
1017
- I->Name = getTypeAsString(
1018
- qt.withoutLocalFastQualifiers());
1019
- I->CVQualifiers = convertToQualifierKind(quals);
1020
- return I;
1021
- }
1022
- }
1023
-
1024
- return nullptr;
1025
- });
1026
- }
1027
- #endif
1028
-
1029
742
/* * Get the user-written `Decl` for a `Decl`
1030
743
1031
744
Given a `Decl` `D`, `getInstantiatedFrom` will return the
@@ -1305,8 +1018,6 @@ class ASTVisitor
1305
1018
QualType QT = P->getDefaultArgument ();
1306
1019
R->Default = buildTemplateArg (
1307
1020
TemplateArgument (QT, QT.isNull (), true ));
1308
- // R->Default = buildTypeInfo(
1309
- // P->getDefaultArgument());
1310
1021
}
1311
1022
return R;
1312
1023
}
@@ -1319,8 +1030,6 @@ class ASTVisitor
1319
1030
{
1320
1031
R->Default = buildTemplateArg (
1321
1032
TemplateArgument (P->getDefaultArgument (), true ));
1322
- // R->Default.emplace(getSourceCode(
1323
- // P->getDefaultArgumentLoc()));
1324
1033
}
1325
1034
return R;
1326
1035
}
@@ -1337,8 +1046,6 @@ class ASTVisitor
1337
1046
{
1338
1047
R->Default = buildTemplateArg (
1339
1048
P->getDefaultArgument ().getArgument ());
1340
- // R->Default.emplace(getSourceCode(
1341
- // P->getDefaultArgumentLoc()));
1342
1049
}
1343
1050
return R;
1344
1051
}
0 commit comments