- Notifications
You must be signed in to change notification settings - Fork14.5k
[Clang] Do not emit -Wmissing-noreturn when [[noreturn]] is present#148552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Fix a false positve warning which was introduced byllvm#146234.
@llvm/pr-subscribers-clang Author: Corentin Jabot (cor3ntin) ChangesFix a false positve warning which was introduced by #146234. Full diff:https://github.com/llvm/llvm-project/pull/148552.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cppindex 7ebb53318702c..72972221d23c5 100644--- a/clang/lib/Sema/SemaDeclAttr.cpp+++ b/clang/lib/Sema/SemaDeclAttr.cpp@@ -1976,7 +1976,7 @@ void clang::inferNoReturnAttr(Sema &S, const Decl *D) { Diags.isIgnored(diag::warn_suggest_noreturn_function, FD->getLocation())) return;- if (!FD->hasAttr<NoReturnAttr>() && !FD->hasAttr<InferredNoReturnAttr>() &&+ if (!FD->isNoReturn() && !FD->hasAttr<InferredNoReturnAttr>() && isKnownToAlwaysThrow(FD)) { NonConstFD->addAttr(InferredNoReturnAttr::CreateImplicit(S.Context));diff --git a/clang/test/SemaCXX/wmissing-noreturn-suggestion.cpp b/clang/test/SemaCXX/wmissing-noreturn-suggestion.cppindex 7548ba8904a71..8beffcd39e85c 100644--- a/clang/test/SemaCXX/wmissing-noreturn-suggestion.cpp+++ b/clang/test/SemaCXX/wmissing-noreturn-suggestion.cpp@@ -21,3 +21,25 @@ int ensureZero(int i) { if (i == 0) return 0; throwError("ERROR"); // no-warning }+++template <typename Ex>+[[noreturn]]+void tpl_throws(Ex const& e) {+ throw e;+}++[[noreturn]]+void tpl_throws_test() {+ tpl_throws(0);+}++[[gnu::noreturn]]+int gnu_throws() {+ throw 0;+}++[[noreturn]]+int cxx11_throws() {+ throw 0;+} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM! Thank you for the fix!
afffa0d
intollvm:mainUh oh!
There was an error while loading.Please reload this page.
LLVM Buildbot has detected a new failure on builder Full details are available at:https://lab.llvm.org/buildbot/#/builders/70/builds/10641 Here is the relevant piece of the build log for the reference
|
Fix a false positve warning which was introduced by#146234.