Skip to content

Commit

Permalink
Fix violations of [basic.class.scope]p2.
Browse files Browse the repository at this point in the history
These cases all follow the same pattern:

struct A {
  friend class X;
  //...
  class X {};
};

But 'friend class X;' injects 'X' into the surrounding namespace scope,
rather than introducing a class member. So the second 'class X {}' is a
completely different type, which changes the meaning of the earlier name
'X' from '::X' to 'A::X'.

Additionally, the friend declaration is pointless -- members of a class
don't need to be befriended to be able to access private members.
  • Loading branch information
zygoloid committed Jun 2, 2020
1 parent e51d5bc commit 4ccb6c3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 7 deletions.
2 changes: 0 additions & 2 deletions clang/lib/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ class AddStmtChoice {
///
class LocalScope {
public:
friend class const_iterator;

using AutomaticVarsTy = BumpVector<VarDecl *>;

/// const_iterator - Iterates local scope backwards and jumps to previous
Expand Down
2 changes: 0 additions & 2 deletions clang/utils/TableGen/NeonEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ class Variable {
/// The main grunt class. This represents an instantiation of an intrinsic with
/// a particular typespec and prototype.
class Intrinsic {
friend class DagEmitter;

/// The Record this intrinsic was created from.
Record *R;
/// The unmangled name.
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ class DwarfDebug : public DebugHandlerBase {
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
DIE &Die, const DICompositeType *CTy);

friend class NonTypeUnitContext;
class NonTypeUnitContext {
DwarfDebug *DD;
decltype(DwarfDebug::TypeUnitsUnderConstruction) TypeUnitsUnderConstruction;
Expand Down
2 changes: 0 additions & 2 deletions llvm/lib/CodeGen/InterferenceCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ class LLVM_LIBRARY_VISIBILITY InterferenceCache {
Entry *get(unsigned PhysReg);

public:
friend class Cursor;

InterferenceCache() = default;

~InterferenceCache() {
Expand Down

0 comments on commit 4ccb6c3

Please sign in to comment.