aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Transforms
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-08-12 07:49:36 +0000
committerAlexey Samsonov <samsonov@google.com>2013-08-12 07:49:36 +0000
commitd976d43f23d67e18f097d72fd90923627f334c79 (patch)
treee57f2453743e9921768ce65f7ce5fe5f56ebe26c /include/llvm/Transforms
parent23331c30aefae840f55b52e2ed343117e5599682 (diff)
downloadexternal_llvm-d976d43f23d67e18f097d72fd90923627f334c79.zip
external_llvm-d976d43f23d67e18f097d72fd90923627f334c79.tar.gz
external_llvm-d976d43f23d67e18f097d72fd90923627f334c79.tar.bz2
Introduce factory methods for SpecialCaseList
Summary: Doing work in constructors is bad: this change suggests to call SpecialCaseList::create(Path, Error) instead of "new SpecialCaseList(Path)". Currently the latter may crash with report_fatal_error, which is undesirable - sometimes we want to report the error to user gracefully - for example, if he provides an incorrect file as an argument of Clang's -fsanitize-blacklist flag. Reviewers: pcc Reviewed By: pcc CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1327 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188156 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms')
-rw-r--r--include/llvm/Transforms/Utils/SpecialCaseList.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/llvm/Transforms/Utils/SpecialCaseList.h b/include/llvm/Transforms/Utils/SpecialCaseList.h
index 787ddb0..36ee604 100644
--- a/include/llvm/Transforms/Utils/SpecialCaseList.h
+++ b/include/llvm/Transforms/Utils/SpecialCaseList.h
@@ -57,8 +57,18 @@ class StringRef;
class SpecialCaseList {
public:
+ // FIXME: Switch all users to factories and remove these constructors.
SpecialCaseList(const StringRef Path);
SpecialCaseList(const MemoryBuffer *MB);
+
+ /// Parses the special case list from a file. If Path is empty, returns
+ /// an empty special case list. On failure, returns 0 and writes an error
+ /// message to string.
+ static SpecialCaseList *create(const StringRef Path, std::string &Error);
+ /// Parses the special case list from a memory buffer. On failure, returns
+ /// 0 and writes an error message to string.
+ static SpecialCaseList *create(const MemoryBuffer *MB, std::string &Error);
+
~SpecialCaseList();
/// Returns whether either this function or its source file are listed in the
@@ -89,10 +99,16 @@ class SpecialCaseList {
bool findCategory(const Module &M, StringRef &Category) const;
private:
+ SpecialCaseList(SpecialCaseList const &) LLVM_DELETED_FUNCTION;
+ SpecialCaseList &operator=(SpecialCaseList const &) LLVM_DELETED_FUNCTION;
+
struct Entry;
StringMap<StringMap<Entry> > Entries;
- void init(const MemoryBuffer *MB);
+ SpecialCaseList();
+ /// Parses just-constructed SpecialCaseList entries from a memory buffer.
+ bool parse(const MemoryBuffer *MB, std::string &Error);
+
bool findCategory(const StringRef Section, const StringRef Query,
StringRef &Category) const;
bool inSectionCategory(const StringRef Section, const StringRef Query,