-
Notifications
You must be signed in to change notification settings - Fork 93
[SYCLomatic] If viewed from the translation unit, the header file <bits/stdc++.h> is included before SYCL header file, then insert the SYCL header file at the beginning of the main source file of the translation unit. #2790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
d1ac5e3
dbc7aa9
b150eee
8265304
20bd285
69e0cdf
5bd35d6
0132fb9
e3d50ff
7f27890
9e2651a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1392,6 +1392,12 @@ class DpctGlobalInfo { | |
getHeaderInsertedBitMap() { | ||
return HeaderInsertedBitMap; | ||
} | ||
static bool &getIsAfterBitsStdcxxStatus() { return IsAfterBitsStdcxx; } | ||
static std::map<clang::tooling::UnifiedPath, | ||
std::set<clang::tooling::UnifiedPath>> & | ||
getAfterBitsStdcxxFilesMap() { | ||
return AfterBitsStdcxxFiles; | ||
} | ||
std::shared_ptr<DpctFileInfo> | ||
insertFile(const clang::tooling::UnifiedPath &FilePath) { | ||
return insertObject(FileMap, FilePath); | ||
|
@@ -1401,7 +1407,10 @@ class DpctGlobalInfo { | |
return findObject(FileMap, FilePath); | ||
} | ||
std::shared_ptr<DpctFileInfo> getMainFile() const { return MainFile; } | ||
void setMainFile(std::shared_ptr<DpctFileInfo> Main) { MainFile = Main; } | ||
void setMainFile(std::shared_ptr<DpctFileInfo> Main) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] It would be helpful to add a brief comment in setMainFile explaining why the IsAfterBitsStdcxx flag is reset when a new main file is set, to clarify the logic for future maintainers. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
getIsAfterBitsStdcxxStatus() = false; | ||
MainFile = Main; | ||
} | ||
void recordIncludingRelationship( | ||
const clang::tooling::UnifiedPath &CurrentFileName, | ||
const clang::tooling::UnifiedPath &IncludedFileName); | ||
|
@@ -1719,6 +1728,10 @@ class DpctGlobalInfo { | |
static std::unordered_set<std::string> CustomHelperFunctionAddtionalIncludes; | ||
static std::unordered_map<clang::tooling::UnifiedPath, std::bitset<32>> | ||
HeaderInsertedBitMap; | ||
static bool IsAfterBitsStdcxx; | ||
static std::map<clang::tooling::UnifiedPath /*MainFile*/, | ||
std::set<clang::tooling::UnifiedPath>> | ||
AfterBitsStdcxxFiles; | ||
}; | ||
|
||
/// Generate mangle name of FunctionDecl as key of DeviceFunctionInfo. | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -132,6 +132,10 @@ void IncludesCallbacks::InclusionDirective( | |||||
FileInfo->setFirstIncludeOffset(LocInfo.second); | ||||||
LastInclusionLocationUpdater Updater(FileInfo, FilenameRange.getEnd()); | ||||||
|
||||||
if (FileName == "bits/stdc++.h") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Consider extracting the literal "bits/stdc++.h" into a named constant to improve maintainability and reduce the chances of typos in future modifications.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
DpctGlobalInfo::getInstance().getIsAfterBitsStdcxxStatus() = true; | ||||||
} | ||||||
|
||||||
clang::tooling::UnifiedPath IncludedFile; | ||||||
if (auto OptionalAbs = Global.getAbsolutePath(*File)) | ||||||
IncludedFile = OptionalAbs.value(); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: dpct --out-root %T/ %s --cuda-include-path="%cuda-path/include" | ||
// RUN: FileCheck --input-file %T/a.cpp --match-full-lines %s | ||
|
||
// CHECK: #include "h1.h" | ||
#include "h1.h" | ||
|
||
int main() { | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
#include <vector> | ||
#include <numeric> | ||
#include "h2.h" | ||
#include "h3.h" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
// <bits/stdc++.h> is not included | ||
//#include <bits/stdc++.h> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <cudnn.h> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: dpct --out-root %T/ %s --cuda-include-path="%cuda-path/include" | ||
// RUN: FileCheck --input-file %T/a.cpp --match-full-lines %s | ||
|
||
// CHECK: #include "h1.h" | ||
#include "h1.h" | ||
|
||
int main() { | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
#include <vector> | ||
#include <numeric> | ||
#include "h2.h" | ||
#include "h3.h" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <cudnn.h> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
// <bits/stdc++.h> is included after sycl.hpp | ||
#include <bits/stdc++.h> |
Uh oh!
There was an error while loading. Please reload this page.