llvm-project/clang/unittests
Duncan P. N. Exon Smith ac49500cd0 Reapply "FileManager: Improve the FileEntryRef API and customize its OptionalStorage"
This reverts commit 940d0a310d,
effectively reapplying 84e8257937, after
working around the compile errors on the bots that I wasn't seeing
locally. I removed the `constexpr` from `OptionalStorage<FileEntryRef>`
that I had cargo-culted from the generic version, since `FileEntryRef`
isn't relevant in `constexpr` contexts anyway.

The original commit message follows:

Make a few changes to the `FileEntryRef` API in preparation for
propagating it enough to remove `FileEntry::getName()`.

- Allow `FileEntryRef` to degrade implicitly to `const FileEntry*`. This
  allows functions currently returning `const FileEntry *` to be updated
  to return `FileEntryRef` without requiring all callers to be updated
  in the same patch. This helps avoid both (a) massive patches where
  many fields and locals are updated simultaneously and (b) noisy
  incremental patches where the first patch adds `getFileEntry()` at
  call sites and the second patch removes it. (Once `FileEntryRef` is
  everywhere, we should remove this API.)
- Change `operator==` to compare the underlying `FileEntry*`, ignoring
  any difference in the spelling of the filename. There were 0 users of
  the existing function because it's not useful.  In case comparing the
  exact named reference becomes important, add/test `isSameRef`.
- Add `==` comparisons between `FileEntryRef` and `const FileEntry *`
  (compares the `FileEntry*`).
- Customize `OptionalStorage<FileEntryRef>` to be pointer-sized. Add
  a private constructor that initializes with `nullptr` and specialize
  `OptionalStorage` to use it. This unblocks updating fields in
  size-sensitive data structures that currently use `const FileEntry *`.
- Add `OptionalFileEntryRefDegradesToFileEntryPtr`, a wrapper around
  `Optional<FileEntryRef>` that degrades to `const FileEntry*`. This
  facilitates future incremental patches, like the same operator on
  `FileEntryRef`. (Once `FileEntryRef` is everywhere, we should remove
  this class.)
- Remove the unncessary `const` from the by-value return of
  `FileEntryRef::getName`.
- Delete the unused function `FileEntry::isOpenForTests`.

Note that there are still `FileEntry` APIs that aren't wrapped and I
plan to deal with these separately / incrementally, as they are needed.

Differential Revision: https://reviews.llvm.org/D89834
2020-10-30 15:06:01 -04:00
..
AST [AST] Fix traversal over CXXConstructExpr in Syntactic mode 2020-10-30 12:14:41 +00:00
ASTMatchers [AST] Fix traversal over CXXConstructExpr in Syntactic mode 2020-10-30 12:14:41 +00:00
Analysis [clang] improve accuracy of ExprMutAnalyzer 2020-10-09 13:45:32 +02:00
Basic Reapply "FileManager: Improve the FileEntryRef API and customize its OptionalStorage" 2020-10-30 15:06:01 -04:00
CodeGen Support complex target features combinations 2020-10-30 10:32:53 +08:00
CrossTU [clang][NFC] Add a missing 'override' 2020-07-17 17:35:59 -07:00
DirectoryWatcher Revert "DirectoryWatcher: add an implementation for Windows" 2020-10-13 12:35:22 -07:00
Driver [Driver] Add output file to properties of Command 2020-10-08 18:23:39 +07:00
Format Fix use-after-scope introduced in 850325348a 2020-10-27 14:26:23 +00:00
Frontend [clang][Frontend] Add missing error handling 2020-10-22 14:14:19 -07:00
Index [clang] Do not consider the template arguments of bases to be bases themselves 2020-09-01 19:18:03 -04:00
Lex [clang] Make sure argument expansion locations are correct in presence of predefined buffer 2020-04-22 21:01:52 +02:00
Rename [OpenMP] "UnFix" layering problem with FrontendOpenMP 2020-04-07 14:41:18 -05:00
Rewrite [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug 2019-08-15 21:17:48 +00:00
Sema Use libClangTesting in the unittest for AST matchers 2020-06-04 17:40:39 +02:00
Serialization Revert "[modules] Do not cache invalid state for modules that we attempted to load." 2020-03-10 10:59:26 -07:00
StaticAnalyzer [Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers 2020-09-25 13:28:22 +02:00
Tooling [Syntax] Add iterators over children of syntax trees. 2020-10-28 12:37:57 +01:00
libclang [libclang] Add CXRewriter to libclang API 2020-09-04 14:17:03 -07:00
CMakeLists.txt Use INTERFACE_COMPILE_OPTIONS to disable -Wsuggest-override for any target that links to gtest 2020-07-27 08:37:01 -07:00