summaryrefslogtreecommitdiffstats
path: root/lib/Sema/AnalysisBasedWarnings.cpp
diff options
context:
space:
mode:
authorDeLesley Hutchins <delesley@google.com>2013-09-03 20:11:38 +0000
committerDeLesley Hutchins <delesley@google.com>2013-09-03 20:11:38 +0000
commit0e8534efc3c536795ede0128aed86a6b8ad53ab7 (patch)
tree3704fe6b5f8ed5c1712122085805dc3ff3ff92d5 /lib/Sema/AnalysisBasedWarnings.cpp
parent5c62d575a179ef26fb93a95c297431c08daccd19 (diff)
Consumed analysis: add return_typestate attribute.
Patch by chris.wailes@gmail.com Functions can now declare what state the consumable type the are returning will be in. This is then used on the caller side and checked on the callee side. Constructors now use this attribute instead of the 'consumes' attribute. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp48
1 files changed, 17 insertions, 31 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 74de09a956..d4997429ed 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1445,11 +1445,23 @@ public:
}
}
- /// Warn about unnecessary-test errors.
- /// \param VariableName -- The name of the variable that holds the unique
- /// value.
- ///
- /// \param Loc -- The SourceLocation of the unnecessary test.
+ void warnReturnTypestateForUnconsumableType(SourceLocation Loc,
+ StringRef TypeName) {
+ PartialDiagnosticAt Warning(Loc, S.PDiag(
+ diag::warn_return_typestate_for_unconsumable_type) << TypeName);
+
+ Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
+ }
+
+ void warnReturnTypestateMismatch(SourceLocation Loc, StringRef ExpectedState,
+ StringRef ObservedState) {
+
+ PartialDiagnosticAt Warning(Loc, S.PDiag(
+ diag::warn_return_typestate_mismatch) << ExpectedState << ObservedState);
+
+ Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
+ }
+
void warnUnnecessaryTest(StringRef VariableName, StringRef VariableState,
SourceLocation Loc) {
@@ -1459,11 +1471,6 @@ public:
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
}
- /// Warn about use-while-consumed errors.
- /// \param MethodName -- The name of the method that was incorrectly
- /// invoked.
- ///
- /// \param Loc -- The SourceLocation of the method invocation.
void warnUseOfTempWhileConsumed(StringRef MethodName, SourceLocation Loc) {
PartialDiagnosticAt Warning(Loc, S.PDiag(
@@ -1472,11 +1479,6 @@ public:
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
}
- /// Warn about use-in-unknown-state errors.
- /// \param MethodName -- The name of the method that was incorrectly
- /// invoked.
- ///
- /// \param Loc -- The SourceLocation of the method invocation.
void warnUseOfTempInUnknownState(StringRef MethodName, SourceLocation Loc) {
PartialDiagnosticAt Warning(Loc, S.PDiag(
@@ -1485,14 +1487,6 @@ public:
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
}
- /// Warn about use-while-consumed errors.
- /// \param MethodName -- The name of the method that was incorrectly
- /// invoked.
- ///
- /// \param VariableName -- The name of the variable that holds the unique
- /// value.
- ///
- /// \param Loc -- The SourceLocation of the method invocation.
void warnUseWhileConsumed(StringRef MethodName, StringRef VariableName,
SourceLocation Loc) {
@@ -1502,14 +1496,6 @@ public:
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
}
- /// Warn about use-in-unknown-state errors.
- /// \param MethodName -- The name of the method that was incorrectly
- /// invoked.
- ///
- /// \param VariableName -- The name of the variable that holds the unique
- /// value.
- ///
- /// \param Loc -- The SourceLocation of the method invocation.
void warnUseInUnknownState(StringRef MethodName, StringRef VariableName,
SourceLocation Loc) {