|
LLVM
10.0.0
|
Annotations lets you mark points and ranges inside source code, for tests: More...
#include "llvm/Testing/Support/Annotations.h"
Classes | |
| struct | Range |
| Two offsets pointing to a continuous substring. More... | |
Public Member Functions | |
| Annotations (llvm::StringRef Text) | |
| Parses the annotations from Text. Crashes if it's malformed. More... | |
| llvm::StringRef | code () const |
| The input text with all annotations stripped. More... | |
| size_t | point (llvm::StringRef Name="") const |
| Returns the position of the point marked by ^ (or $name^) in the text. More... | |
| std::vector< size_t > | points (llvm::StringRef Name="") const |
| Returns the position of all points marked by ^ (or $name^) in the text. More... | |
| Range | range (llvm::StringRef Name="") const |
| Returns the location of the range marked by [[ ]] (or $name[[ ]]). More... | |
| std::vector< Range > | ranges (llvm::StringRef Name="") const |
| Returns the location of all ranges marked by [[ ]] (or $name[[ ]]). More... | |
Annotations lets you mark points and ranges inside source code, for tests:
Annotations Example(R"cpp( int complete() { x.pri^ } // ^ indicates a point void err() { [["hello" == 42]]; } // [[this is a range]] $definition^class Foo{}; // points can be named: "definition" $fail[[static_assert(false, "")]] // ranges can be named too: "fail" )cpp");
StringRef Code = Example.code(); // annotations stripped. std::vector<size_t> PP = Example.points(); // all unnamed points size_t P = Example.point(); // there must be exactly one llvm::Range R = Example.range("fail"); // find named ranges
Points/ranges are coordinated into code() which is stripped of annotations.
Ranges may be nested (and points can be inside ranges), but there's no way to define general overlapping ranges.
FIXME: the choice of the marking syntax makes it impossible to represent some of the C++ and Objective C constructs (including common ones like C++ attributes). We can fix this by:
Definition at line 46 of file Annotations.h.
| Annotations::Annotations | ( | llvm::StringRef | Text | ) |
Parses the annotations from Text. Crashes if it's malformed.
Definition at line 26 of file Annotations.cpp.
References llvm::SmallVectorTemplateCommon< T >::back(), llvm::StringRef::consume_front(), llvm::StringRef::drop_front(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorBase::empty(), llvm::StringRef::empty(), llvm::StringRef::front(), llvm::Optional< T >::getValueOr(), llvm::isAlnum(), Name, llvm::None, llvm::SmallVectorTemplateBase< T >::pop_back(), require(), llvm::StringRef::size(), and llvm::StringRef::take_while().
|
inline |
The input text with all annotations stripped.
All points and ranges are relative to this stripped text.
Definition at line 65 of file Annotations.h.
References Name, llvm::RISCVFenceField::O, llvm::operator<<(), point(), points(), range(), and ranges().
| size_t Annotations::point | ( | llvm::StringRef | Name = "" | ) | const |
Returns the position of the point marked by ^ (or $name^) in the text.
Crashes if there isn't exactly one.
Definition at line 67 of file Annotations.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::find(), I, and require().
Referenced by code().
| std::vector< size_t > Annotations::points | ( | llvm::StringRef | Name = "" | ) | const |
Returns the position of all points marked by ^ (or $name^) in the text.
Definition at line 74 of file Annotations.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::lookup(), and P.
Referenced by code().
| Annotations::Range Annotations::range | ( | llvm::StringRef | Name = "" | ) | const |
Returns the location of the range marked by [[ ]] (or $name[[ ]]).
Crashes if there isn't exactly one.
Definition at line 79 of file Annotations.cpp.
Referenced by code().
| std::vector< Annotations::Range > Annotations::ranges | ( | llvm::StringRef | Name = "" | ) | const |
Returns the location of all ranges marked by [[ ]] (or $name[[ ]]).
Definition at line 87 of file Annotations.cpp.
Referenced by code().
1.8.13