Skip to content

Commit c43bc83

Browse files
authored
[SYCLomatic] Remove unused code for vector type in base specifiers (#562)
Signed-off-by: Ziran Zhang <[email protected]>
1 parent 3003497 commit c43bc83

File tree

2 files changed

+8
-61
lines changed

2 files changed

+8
-61
lines changed

clang/include/clang/AST/DeclCXX.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ class CXXBaseSpecifier {
195195
return BaseTypeInfo->getTypeLoc().getBeginLoc();
196196
}
197197

198-
#ifdef SYCLomatic_CUSTOMIZATION
199-
TypeSourceInfo* getBaseTypeInfo() const { return BaseTypeInfo; }
200-
#endif // SYCLomatic_CUSTOMIZATION
201-
202198
/// Determines whether the base class is a virtual base class (or not).
203199
bool isVirtual() const { return Virtual; }
204200

clang/lib/DPCT/ASTTraversal.cpp

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,10 +2938,12 @@ void VectorTypeNamespaceRule::registerMatcher(MatchFinder &MF) {
29382938
.bind("vectorTypeTL"),
29392939
this);
29402940

2941-
MF.addMatcher(
2942-
cxxRecordDecl(isDirectlyDerivedFrom(hasAnyName(SUPPORTEDVECTORTYPENAMES)))
2943-
.bind("inheritanceType"),
2944-
this);
2941+
MF.addMatcher(cxxRecordDecl(isDirectlyDerivedFrom(hasAnyName(
2942+
"char1", "uchar1", "short1", "ushort1",
2943+
"int1", "uint1", "long1", "ulong1", "float1",
2944+
"longlong1", "ulonglong1", "double1")))
2945+
.bind("inherit"),
2946+
this);
29452947
}
29462948

29472949
void VectorTypeNamespaceRule::runRule(const MatchFinder::MatchResult &Result) {
@@ -3056,60 +3058,9 @@ void VectorTypeNamespaceRule::runRule(const MatchFinder::MatchResult &Result) {
30563058
}
30573059
}
30583060
}
3059-
if (auto CRD = getNodeAsType<CXXRecordDecl>(Result, "inheritanceType")) {
3060-
const auto *Base = CRD->bases_begin();
3061-
std::string TypeName = Base->getBaseTypeInfo()->getType().getAsString();
3062-
if (MapNames::SupportedVectorTypes.find(TypeName) ==
3063-
MapNames::SupportedVectorTypes.end())
3064-
return;
3065-
auto Begin = Base->getSourceRange().getBegin();
3066-
auto End = Base->getSourceRange().getEnd();
3067-
if (Begin.isInvalid()) {
3068-
return;
3069-
}
3070-
if (*(TypeName.end() - 1) == '1') {
3071-
if (Begin.isMacroID() &&
3072-
(SM->isWrittenInScratchSpace(SM->getSpellingLoc(Begin)) ||
3073-
SM->isWrittenInScratchSpace(SM->getSpellingLoc(End)))) {
3074-
// Macro concatenate --> use immediateExpansion
3075-
// Make (Begin, End) be the range of "##1"
3076-
Begin = SM->getImmediateExpansionRange(Begin).getBegin();
3077-
End = SM->getImmediateExpansionRange(End).getEnd();
3078-
Begin = SM->getSpellingLoc(Begin);
3079-
End = SM->getSpellingLoc(End);
3080-
Begin = Begin.getLocWithOffset(Lexer::MeasureTokenLength(
3081-
Begin, *SM, DpctGlobalInfo::getContext().getLangOpts()));
3082-
End = End.getLocWithOffset(Lexer::MeasureTokenLength(
3083-
End, *SM, DpctGlobalInfo::getContext().getLangOpts()));
3084-
report(Begin, Comments::VECTYPE_INHERITATED, false);
3085-
} else {
3086-
// Make (Begin, End) be the range of "1"
3087-
Begin = SM->getSpellingLoc(Begin);
3088-
End = SM->getSpellingLoc(End);
3089-
Begin = Begin.getLocWithOffset(
3090-
Lexer::MeasureTokenLength(
3091-
Begin, *SM, DpctGlobalInfo::getContext().getLangOpts()) -
3092-
1);
3093-
End = End.getLocWithOffset(Lexer::MeasureTokenLength(
3094-
End, *SM, DpctGlobalInfo::getContext().getLangOpts()));
3095-
}
3096-
auto Length = SM->getFileOffset(End) - SM->getFileOffset(Begin);
3097-
return emplaceTransformation(new ReplaceText(Begin, Length, ""));
3098-
}
3099-
3100-
if (Begin.isInvalid())
3101-
return;
31023061

3103-
if (Begin.isMacroID()) {
3104-
// Macro concatenate --> use immediateExpansion
3105-
// Make Begin being the begin of "MACROARG##1"
3106-
if (SM->isWrittenInScratchSpace(SM->getSpellingLoc(Begin))) {
3107-
Begin = SM->getImmediateExpansionRange(Begin).getBegin();
3108-
}
3109-
Begin = SM->getSpellingLoc(Begin);
3110-
}
3111-
return emplaceTransformation(
3112-
new InsertText(Begin, MapNames::getClNamespace()));
3062+
if (auto RD = getNodeAsType<CXXRecordDecl>(Result, "inherit")) {
3063+
report(RD->getBeginLoc(), Diagnostics::VECTYPE_INHERITATED, false);
31133064
}
31143065
}
31153066

0 commit comments

Comments
 (0)