[llvm] 4ccb6c3 - Fix violations of [basic.class.scope]p2.
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 1 23:22:14 PDT 2020
On Tue, Jun 2, 2020 at 8:03 AM Richard Smith via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Richard Smith
> Date: 2020-06-01T22:03:05-07:00
> New Revision: 4ccb6c36a9159809f4b98176325ae202753fe136
>
> URL: https://github.com/llvm/llvm-project/commit/4ccb6c36a9159809f4b98176325ae202753fe136
> DIFF: https://github.com/llvm/llvm-project/commit/4ccb6c36a9159809f4b98176325ae202753fe136.diff
>
> LOG: Fix violations of [basic.class.scope]p2.
>
> 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.
Should there be a clang diagnostic for such a situation?
Roman
> Added:
>
>
> Modified:
> clang/lib/Analysis/CFG.cpp
> clang/utils/TableGen/NeonEmitter.cpp
> llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
> llvm/lib/CodeGen/InterferenceCache.h
>
> Removed:
>
>
>
> ################################################################################
> diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
> index bedc8455366f..fc74226951a4 100644
> --- a/clang/lib/Analysis/CFG.cpp
> +++ b/clang/lib/Analysis/CFG.cpp
> @@ -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
>
> diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
> index 9166e7a718ec..625954fe8a04 100644
> --- a/clang/utils/TableGen/NeonEmitter.cpp
> +++ b/clang/utils/TableGen/NeonEmitter.cpp
> @@ -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.
>
> diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
> index df0899930a80..bb0f550b9654 100644
> --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
> +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
> @@ -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;
>
> diff --git a/llvm/lib/CodeGen/InterferenceCache.h b/llvm/lib/CodeGen/InterferenceCache.h
> index 50c6ac62d194..9019e9f61fa0 100644
> --- a/llvm/lib/CodeGen/InterferenceCache.h
> +++ b/llvm/lib/CodeGen/InterferenceCache.h
> @@ -157,8 +157,6 @@ class LLVM_LIBRARY_VISIBILITY InterferenceCache {
> Entry *get(unsigned PhysReg);
>
> public:
> - friend class Cursor;
> -
> InterferenceCache() = default;
>
> ~InterferenceCache() {
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list