Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: src/IceGlobalInits.h

Issue 1221643012: Subzero: Add -Wshadow to the build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- C++ -*-===// 1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
11 /// This file declares the representation of function declarations, 11 /// This file declares the representation of function declarations,
12 /// global variable declarations, and the corresponding variable 12 /// global variable declarations, and the corresponding variable
13 /// initializers in Subzero. Global variable initializers are 13 /// initializers in Subzero. Global variable initializers are
14 /// represented as a sequence of simple initializers. 14 /// represented as a sequence of simple initializers.
15 /// 15 ///
16 //===----------------------------------------------------------------------===// 16 //===----------------------------------------------------------------------===//
17 17
18 #ifndef SUBZERO_SRC_ICEGLOBALINITS_H 18 #ifndef SUBZERO_SRC_ICEGLOBALINITS_H
19 #define SUBZERO_SRC_ICEGLOBALINITS_H 19 #define SUBZERO_SRC_ICEGLOBALINITS_H
20 20
21 #include "IceDefs.h" 21 #include "IceDefs.h"
22 #include "IceGlobalContext.h" 22 #include "IceGlobalContext.h"
23 #include "IceTypes.h" 23 #include "IceTypes.h"
24 24
25 #pragma clang diagnostic push 25 #pragma clang diagnostic push
26 #pragma clang diagnostic ignored "-Wunused-parameter" 26 #pragma clang diagnostic ignored "-Wunused-parameter"
27 #pragma clang diagnostic ignored "-Wshadow"
27 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" // for NaClBitcodeRecord. 28 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" // for NaClBitcodeRecord.
28 #include "llvm/IR/CallingConv.h" 29 #include "llvm/IR/CallingConv.h"
29 #include "llvm/IR/GlobalValue.h" // for GlobalValue::LinkageTypes. 30 #include "llvm/IR/GlobalValue.h" // for GlobalValue::LinkageTypes.
30 #pragma clang diagnostic pop 31 #pragma clang diagnostic pop
31 32
32 #include <memory> 33 #include <memory>
33 #include <utility> 34 #include <utility>
34 35
35 // TODO(kschimpf): Remove ourselves from using LLVM representation for calling 36 // TODO(kschimpf): Remove ourselves from using LLVM representation for calling
36 // conventions and linkage types. 37 // conventions and linkage types.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 /// Returns true if when emitting names, we should suppress mangling. 81 /// Returns true if when emitting names, we should suppress mangling.
81 virtual bool getSuppressMangling() const = 0; 82 virtual bool getSuppressMangling() const = 0;
82 83
83 /// Mangles name for cross tests, unless external and not defined locally 84 /// Mangles name for cross tests, unless external and not defined locally
84 /// (so that relocations accross pnacl-sz and pnacl-llc will work). 85 /// (so that relocations accross pnacl-sz and pnacl-llc will work).
85 virtual IceString mangleName(GlobalContext *Ctx) const { 86 virtual IceString mangleName(GlobalContext *Ctx) const {
86 return getSuppressMangling() ? Name : Ctx->mangleName(Name); 87 return getSuppressMangling() ? Name : Ctx->mangleName(Name);
87 } 88 }
88 89
89 protected: 90 protected:
90 GlobalDeclaration(GlobalDeclarationKind Kind, 91 GlobalDeclaration(GlobalDeclarationKind MyKind,
91 llvm::GlobalValue::LinkageTypes Linkage) 92 llvm::GlobalValue::LinkageTypes MyLinkage)
92 : Kind(Kind), Linkage(Linkage) {} 93 : Kind(MyKind), Linkage(MyLinkage) {}
93 94
94 const GlobalDeclarationKind Kind; 95 const GlobalDeclarationKind Kind;
95 IceString Name; 96 IceString Name;
96 llvm::GlobalValue::LinkageTypes Linkage; 97 llvm::GlobalValue::LinkageTypes Linkage;
97 }; 98 };
98 99
99 /// Models a function declaration. This includes the type signature of 100 /// Models a function declaration. This includes the type signature of
100 /// the function, its calling conventions, and its linkage. 101 /// the function, its calling conventions, and its linkage.
101 class FunctionDeclaration : public GlobalDeclaration { 102 class FunctionDeclaration : public GlobalDeclaration {
102 FunctionDeclaration() = delete; 103 FunctionDeclaration() = delete;
(...skipping 18 matching lines...) Expand all
121 } 122 }
122 void dumpType(Ostream &Stream) const final; 123 void dumpType(Ostream &Stream) const final;
123 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 124 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
124 bool getSuppressMangling() const final { return isExternal() && IsProto; } 125 bool getSuppressMangling() const final { return isExternal() && IsProto; }
125 126
126 private: 127 private:
127 const Ice::FuncSigType Signature; 128 const Ice::FuncSigType Signature;
128 llvm::CallingConv::ID CallingConv; 129 llvm::CallingConv::ID CallingConv;
129 bool IsProto; 130 bool IsProto;
130 131
131 FunctionDeclaration(const FuncSigType &Signature, 132 FunctionDeclaration(const FuncSigType &MySignature,
132 llvm::CallingConv::ID CallingConv, 133 llvm::CallingConv::ID MyCallingConv,
133 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) 134 llvm::GlobalValue::LinkageTypes Linkage, bool MyIsProto)
134 : GlobalDeclaration(FunctionDeclarationKind, Linkage), 135 : GlobalDeclaration(FunctionDeclarationKind, Linkage),
135 Signature(Signature), CallingConv(CallingConv), IsProto(IsProto) {} 136 Signature(MySignature), CallingConv(MyCallingConv), IsProto(MyIsProto) {
137 }
136 }; 138 };
137 139
138 /// Models a global variable declaration, and its initializers. 140 /// Models a global variable declaration, and its initializers.
139 class VariableDeclaration : public GlobalDeclaration { 141 class VariableDeclaration : public GlobalDeclaration {
140 VariableDeclaration(const VariableDeclaration &) = delete; 142 VariableDeclaration(const VariableDeclaration &) = delete;
141 VariableDeclaration &operator=(const VariableDeclaration &) = delete; 143 VariableDeclaration &operator=(const VariableDeclaration &) = delete;
142 144
143 public: 145 public:
144 /// Base class for a global variable initializer. 146 /// Base class for a global variable initializer.
145 class Initializer { 147 class Initializer {
(...skipping 11 matching lines...) Expand all
157 virtual ~Initializer() = default; 159 virtual ~Initializer() = default;
158 virtual SizeT getNumBytes() const = 0; 160 virtual SizeT getNumBytes() const = 0;
159 virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0; 161 virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
160 void dump(Ostream &Stream) const { 162 void dump(Ostream &Stream) const {
161 if (BuildDefs::dump()) 163 if (BuildDefs::dump())
162 dump(nullptr, Stream); 164 dump(nullptr, Stream);
163 } 165 }
164 virtual void dumpType(Ostream &Stream) const; 166 virtual void dumpType(Ostream &Stream) const;
165 167
166 protected: 168 protected:
167 explicit Initializer(InitializerKind Kind) : Kind(Kind) {} 169 explicit Initializer(InitializerKind MyKind) : Kind(MyKind) {}
168 170
169 private: 171 private:
170 const InitializerKind Kind; 172 const InitializerKind Kind;
171 }; 173 };
172 174
173 /// Models the data in a data initializer. 175 /// Models the data in a data initializer.
174 typedef std::vector<char> DataVecType; 176 typedef std::vector<char> DataVecType;
175 177
176 /// Defines a sequence of byte values as a data initializer. 178 /// Defines a sequence of byte values as a data initializer.
177 class DataInitializer : public Initializer { 179 class DataInitializer : public Initializer {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 223 }
222 SizeT getNumBytes() const final { return Size; } 224 SizeT getNumBytes() const final { return Size; }
223 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 225 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
224 static bool classof(const Initializer *Z) { 226 static bool classof(const Initializer *Z) {
225 return Z->getKind() == ZeroInitializerKind; 227 return Z->getKind() == ZeroInitializerKind;
226 } 228 }
227 229
228 private: 230 private:
229 ENABLE_MAKE_UNIQUE; 231 ENABLE_MAKE_UNIQUE;
230 232
231 explicit ZeroInitializer(SizeT Size) 233 explicit ZeroInitializer(SizeT MySize)
232 : Initializer(ZeroInitializerKind), Size(Size) {} 234 : Initializer(ZeroInitializerKind), Size(MySize) {}
233 235
234 /// The number of bytes to be zero initialized. 236 /// The number of bytes to be zero initialized.
235 SizeT Size; 237 SizeT Size;
236 }; 238 };
237 239
238 /// Defines the relocation value of another global declaration. 240 /// Defines the relocation value of another global declaration.
239 class RelocInitializer : public Initializer { 241 class RelocInitializer : public Initializer {
240 RelocInitializer(const RelocInitializer &) = delete; 242 RelocInitializer(const RelocInitializer &) = delete;
241 RelocInitializer &operator=(const RelocInitializer &) = delete; 243 RelocInitializer &operator=(const RelocInitializer &) = delete;
242 244
243 public: 245 public:
244 static std::unique_ptr<RelocInitializer> 246 static std::unique_ptr<RelocInitializer>
245 create(const GlobalDeclaration *Declaration, RelocOffsetT Offset) { 247 create(const GlobalDeclaration *Declaration, RelocOffsetT Offset) {
246 return makeUnique<RelocInitializer>(Declaration, Offset); 248 return makeUnique<RelocInitializer>(Declaration, Offset);
247 } 249 }
248 250
249 RelocOffsetT getOffset() const { return Offset; } 251 RelocOffsetT getOffset() const { return Offset; }
250 const GlobalDeclaration *getDeclaration() const { return Declaration; } 252 const GlobalDeclaration *getDeclaration() const { return Declaration; }
251 SizeT getNumBytes() const final { return RelocAddrSize; } 253 SizeT getNumBytes() const final { return RelocAddrSize; }
252 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 254 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
253 void dumpType(Ostream &Stream) const final; 255 void dumpType(Ostream &Stream) const final;
254 static bool classof(const Initializer *R) { 256 static bool classof(const Initializer *R) {
255 return R->getKind() == RelocInitializerKind; 257 return R->getKind() == RelocInitializerKind;
256 } 258 }
257 259
258 private: 260 private:
259 ENABLE_MAKE_UNIQUE; 261 ENABLE_MAKE_UNIQUE;
260 262
261 RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset) 263 RelocInitializer(const GlobalDeclaration *MyDeclaration,
262 : Initializer(RelocInitializerKind), Declaration(Declaration), 264 RelocOffsetT MyOffset)
263 Offset(Offset) {} // The global declaration used in the relocation. 265 : Initializer(RelocInitializerKind), Declaration(MyDeclaration),
266 Offset(MyOffset) {} // The global declaration used in the relocation.
264 267
265 const GlobalDeclaration *Declaration; 268 const GlobalDeclaration *Declaration;
266 /// The offset to add to the relocation. 269 /// The offset to add to the relocation.
267 const RelocOffsetT Offset; 270 const RelocOffsetT Offset;
268 }; 271 };
269 272
270 /// Models the list of initializers. 273 /// Models the list of initializers.
271 typedef std::vector<std::unique_ptr<Initializer>> InitializerListType; 274 typedef std::vector<std::unique_ptr<Initializer>> InitializerListType;
272 275
273 static VariableDeclaration *create(GlobalContext *Context) { 276 static VariableDeclaration *create(GlobalContext *Context) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 template <class StreamType> 355 template <class StreamType>
353 inline StreamType &operator<<(StreamType &Stream, 356 inline StreamType &operator<<(StreamType &Stream,
354 const GlobalDeclaration &Addr) { 357 const GlobalDeclaration &Addr) {
355 Addr.dump(Stream); 358 Addr.dump(Stream);
356 return Stream; 359 return Stream;
357 } 360 }
358 361
359 } // end of namespace Ice 362 } // end of namespace Ice
360 363
361 #endif // SUBZERO_SRC_ICEGLOBALINITS_H 364 #endif // SUBZERO_SRC_ICEGLOBALINITS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698