Weak.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- UnresolvedSet.h - Unresolved sets of declarations ------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the WeakInfo class, which is used to store
  15. // information about the target of a #pragma weak directive.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_SEMA_WEAK_H
  19. #define LLVM_CLANG_SEMA_WEAK_H
  20. #include "clang/Basic/SourceLocation.h"
  21. namespace clang {
  22. class IdentifierInfo;
  23. /// Captures information about a \#pragma weak directive.
  24. class WeakInfo {
  25. IdentifierInfo *alias; // alias (optional)
  26. SourceLocation loc; // for diagnostics
  27. bool used; // identifier later declared?
  28. public:
  29. WeakInfo()
  30. : alias(nullptr), loc(SourceLocation()), used(false) {}
  31. WeakInfo(IdentifierInfo *Alias, SourceLocation Loc)
  32. : alias(Alias), loc(Loc), used(false) {}
  33. inline IdentifierInfo * getAlias() const { return alias; }
  34. inline SourceLocation getLocation() const { return loc; }
  35. void setUsed(bool Used=true) { used = Used; }
  36. inline bool getUsed() { return used; }
  37. bool operator==(WeakInfo RHS) const {
  38. return alias == RHS.getAlias() && loc == RHS.getLocation();
  39. }
  40. bool operator!=(WeakInfo RHS) const { return !(*this == RHS); }
  41. };
  42. } // end namespace clang
  43. #endif // LLVM_CLANG_SEMA_WEAK_H
  44. #ifdef __GNUC__
  45. #pragma GCC diagnostic pop
  46. #endif