Skip to content

Commit 11e1562

Browse files
committed
refine code
Signed-off-by: chenwei.sun <chenwei.sun@intel.com>
1 parent b17b6ee commit 11e1562

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

clang/lib/DPCT/AnalysisInfo.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,11 +1487,11 @@ std::string DpctGlobalInfo::getStringForRegexReplacement(StringRef MatchedStr) {
14871487
HelperFuncType::HFT_DefaultQueuePtr, Index);
14881488
case 'E': {
14891489
auto &Vec = DpctGlobalInfo::getInstance().getCSourceFileList();
1490-
SourceProcessType FileType = GetSourceFileType(Vec[Index]);
1490+
SourceProcessType FileType = GetSourceFileType(Vec[Index].first);
14911491

1492-
const bool HasCUDASyntax = DpctGlobalInfo::hasCUDASyntax(Vec[Index]);
1492+
const bool HasCUDASyntax = DpctGlobalInfo::hasCUDASyntax(Vec[Index].first);
14931493
const bool IsCppSource = (FileType & SPT_CppSource);
1494-
const auto Extention = Vec[Index + 1];
1494+
const auto Extention = Vec[Index].second;
14951495

14961496
if (Extention == ".cc") {
14971497
return (HasCUDASyntax && IsCppSource)
@@ -2532,7 +2532,9 @@ bool DpctGlobalInfo::CVersionCUDALaunchUsedFlag = false;
25322532
unsigned int DpctGlobalInfo::ColorOption = 1;
25332533
std::unordered_map<int, std::shared_ptr<DeviceFunctionInfo>>
25342534
DpctGlobalInfo::CubPlaceholderIndexMap;
2535-
std::vector<tooling::UnifiedPath> DpctGlobalInfo::CSourceFileList;
2535+
std::vector<std::pair<tooling::UnifiedPath /*including filename*/,
2536+
std::string /*extention name*/>>
2537+
DpctGlobalInfo::CSourceFileList;
25362538
bool DpctGlobalInfo::OptimizeMigrationFlag = false;
25372539
std::unordered_map<std::string, std::shared_ptr<PriorityReplInfo>>
25382540
DpctGlobalInfo::PriorityReplInfoMap;

clang/lib/DPCT/AnalysisInfo.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,9 @@ class DpctGlobalInfo {
14501450
getCubPlaceholderIndexMap() {
14511451
return CubPlaceholderIndexMap;
14521452
}
1453-
std::vector<tooling::UnifiedPath> &getCSourceFileList() {
1453+
std::vector<std::pair<tooling::UnifiedPath /*including filename*/,
1454+
std::string /*extention name*/>> &
1455+
getCSourceFileList() {
14541456
return CSourceFileList;
14551457
}
14561458
static std::unordered_map<std::string, std::shared_ptr<PriorityReplInfo>> &
@@ -1703,7 +1705,9 @@ class DpctGlobalInfo {
17031705
static unsigned int ColorOption;
17041706
static std::unordered_map<int, std::shared_ptr<DeviceFunctionInfo>>
17051707
CubPlaceholderIndexMap;
1706-
static std::vector<tooling::UnifiedPath> CSourceFileList;
1708+
static std::vector<std::pair<tooling::UnifiedPath /*including filename*/,
1709+
std::string /*extention name*/>>
1710+
CSourceFileList;
17071711
static bool OptimizeMigrationFlag;
17081712
static std::unordered_map<std::string, std::shared_ptr<PriorityReplInfo>>
17091713
PriorityReplInfoMap;

clang/lib/DPCT/RulesInclude/InclusionHeaders.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "PreProcessor.h"
1111
#include "UserDefinedRules/UserDefinedRules.h"
1212
#include <optional>
13+
#include <string>
1314

1415
namespace clang {
1516
namespace dpct {
@@ -179,8 +180,8 @@ void IncludesCallbacks::InclusionDirective(
179180
auto &Vec = DpctGlobalInfo::getInstance().getCSourceFileList();
180181
path::replace_extension(
181182
NewFileName, "{{NEEDREPLACEE" + std::to_string(Vec.size()) + "}}");
182-
Vec.push_back(IncludedFile);
183-
Vec.push_back(Extension);
183+
Vec.push_back(std::pair<tooling::UnifiedPath, std::string>(IncludedFile,
184+
Extension));
184185
} else {
185186
clang::tooling::UnifiedPath NewFilePath = FileName;
186187
rewriteFileName(NewFilePath, IncludedFile);

0 commit comments

Comments
 (0)