summaryrefslogtreecommitdiffstats
path: root/clang/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
commitfc368259af1a580b1843174cae3067d1b3c9aafc (patch)
tree2732d2c5da4cb77df8c39009f0077f78387c6382 /clang/lib/Sema/AnalysisBasedWarnings.cpp
parent362bf98ec68b63f8abcd347e48db2551436de75d (diff)
downloadbcm5719-llvm-fc368259af1a580b1843174cae3067d1b3c9aafc.tar.gz
bcm5719-llvm-fc368259af1a580b1843174cae3067d1b3c9aafc.zip
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. llvm-svn: 189843
Diffstat (limited to 'clang/lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.cpp48
1 files changed, 17 insertions, 31 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 74de09a9566..d4997429edc 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud