Skip to content

Commit 93eef7d

Browse files
jhuber6jhuber-ornl
authored andcommitted
[OpenMP][NFC] Fix SourceInfo.h variable names
Summary: Fix the names to use Pascal case to comply with the LLVM coding guidelines. `ident_t` is required for compatibility with the rest of libomp.
1 parent 4eb4f89 commit 93eef7d

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

openmp/libomptarget/include/SourceInfo.h

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include <string>
1717

1818
#ifdef _WIN32
19-
static const bool OS_WINDOWS = true;
19+
constexpr bool OSWindows = true;
2020
#else
21-
static const bool OS_WINDOWS = false;
21+
constexpr bool OSWindows = false;
2222
#endif
2323

2424
/// Type alias for source location information for variable mappings with
@@ -39,72 +39,72 @@ struct ident_t {
3939
/// Struct to hold source individual location information.
4040
class SourceInfo {
4141
/// Underlying string copy of the original source information.
42-
const std::string sourceStr;
42+
const std::string SourceStr;
4343

4444
/// Location fields extracted from the source information string.
45-
const std::string name;
46-
const std::string filename;
47-
const int32_t line;
48-
const int32_t column;
45+
const std::string Name;
46+
const std::string Filename;
47+
const int32_t Line;
48+
const int32_t Column;
4949

50-
std::string initStr(const void *name) {
51-
if (!name)
50+
std::string initStr(const void *Name) {
51+
if (!Name)
5252
return ";unknown;unknown;0;0;;";
5353
else
54-
return std::string(reinterpret_cast<const char *>(name));
54+
return std::string(reinterpret_cast<const char *>(Name));
5555
}
5656

57-
std::string initStr(const ident_t *loc) {
58-
if (!loc)
57+
std::string initStr(const ident_t *Loc) {
58+
if (!Loc)
5959
return ";unknown;unknown;0;0;;";
6060
else
61-
return std::string(reinterpret_cast<const char *>(loc->psource));
61+
return std::string(reinterpret_cast<const char *>(Loc->psource));
6262
}
6363

6464
/// Get n-th substring in an expression separated by ;.
65-
std::string getSubstring(const int n) const {
66-
std::size_t begin = sourceStr.find(';');
67-
std::size_t end = sourceStr.find(';', begin + 1);
68-
for (int i = 0; i < n; i++) {
69-
begin = end;
70-
end = sourceStr.find(';', begin + 1);
65+
std::string getSubstring(const unsigned N) const {
66+
std::size_t Begin = SourceStr.find(';');
67+
std::size_t End = SourceStr.find(';', Begin + 1);
68+
for (unsigned I = 0; I < N; I++) {
69+
Begin = End;
70+
End = SourceStr.find(';', Begin + 1);
7171
}
72-
return sourceStr.substr(begin + 1, end - begin - 1);
72+
return SourceStr.substr(Begin + 1, End - Begin - 1);
7373
};
7474

7575
/// Get the filename from a full path.
76-
std::string removePath(const std::string &path) const {
77-
std::size_t pos = (OS_WINDOWS) ? path.rfind('\\') : path.rfind('/');
78-
return path.substr(pos + 1);
76+
std::string removePath(const std::string &Path) const {
77+
std::size_t Pos = (OSWindows) ? Path.rfind('\\') : Path.rfind('/');
78+
return Path.substr(Pos + 1);
7979
};
8080

8181
public:
82-
SourceInfo(const ident_t *loc)
83-
: sourceStr(initStr(loc)), name(getSubstring(1)),
84-
filename(removePath(getSubstring(0))), line(std::stoi(getSubstring(2))),
85-
column(std::stoi(getSubstring(3))) {}
86-
87-
SourceInfo(const map_var_info_t name)
88-
: sourceStr(initStr(name)), name(getSubstring(0)),
89-
filename(removePath(getSubstring(1))), line(std::stoi(getSubstring(2))),
90-
column(std::stoi(getSubstring(3))) {}
91-
92-
const char *getName() const { return name.c_str(); }
93-
const char *getFilename() const { return filename.c_str(); }
94-
int32_t getLine() const { return line; }
95-
int32_t getColumn() const { return column; }
96-
bool isAvailible() const { return (line || column); }
82+
SourceInfo(const ident_t *Loc)
83+
: SourceStr(initStr(Loc)), Name(getSubstring(1)),
84+
Filename(removePath(getSubstring(0))), Line(std::stoi(getSubstring(2))),
85+
Column(std::stoi(getSubstring(3))) {}
86+
87+
SourceInfo(const map_var_info_t Name)
88+
: SourceStr(initStr(Name)), Name(getSubstring(0)),
89+
Filename(removePath(getSubstring(1))), Line(std::stoi(getSubstring(2))),
90+
Column(std::stoi(getSubstring(3))) {}
91+
92+
const char *getName() const { return Name.c_str(); }
93+
const char *getFilename() const { return Filename.c_str(); }
94+
int32_t getLine() const { return Line; }
95+
int32_t getColumn() const { return Column; }
96+
bool isAvailible() const { return (Line || Column); }
9797
};
9898

9999
/// Standalone function for getting the variable name of a mapping.
100-
static inline std::string getNameFromMapping(const map_var_info_t name) {
101-
if (!name)
100+
static inline std::string getNameFromMapping(const map_var_info_t Name) {
101+
if (!Name)
102102
return "unknown";
103103

104-
const std::string name_str(reinterpret_cast<const char *>(name));
105-
std::size_t begin = name_str.find(';');
106-
std::size_t end = name_str.find(';', begin + 1);
107-
return name_str.substr(begin + 1, end - begin - 1);
104+
const std::string NameStr(reinterpret_cast<const char *>(Name));
105+
std::size_t Begin = NameStr.find(';');
106+
std::size_t End = NameStr.find(';', Begin + 1);
107+
return NameStr.substr(Begin + 1, End - Begin - 1);
108108
}
109109

110110
#endif

0 commit comments

Comments
 (0)