[PATCH] D96777: [clang][driver] Set the input type to Fortran when reading from stdin

2021-02-22 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a subscriber: hans.
awarzynski added a comment.

In D96777#2578153 , @SouraVX wrote:

> Thanks! for the patch.
> This code touches some of the `clang` part, Anyway changes are pretty 
> self-explanatory. I'll leave this one to you, if you want land it or wait 
> from someone from `clang` community to take a look :)

Thank you for reviewing!

Git history tells me that @hans touched this bit most recently - in 2014 :) 
Added as a reviewer - I will wait another day or two before merging.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96777/new/

https://reviews.llvm.org/D96777

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96950: [clang][CodeComplete] Ensure there are no crashes when completing with ParenListExprs as LHS

2021-02-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf10137399a3c: [clang][CodeComplete] Ensure there are no 
crashes when completing with… (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96950/new/

https://reviews.llvm.org/D96950

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5245,6 +5245,19 @@
   return Unresolved;
 }
 
+// If \p Base is ParenListExpr, assume a chain of comma operators and pick the
+// last expr. We expect other ParenListExprs to be resolved to e.g. constructor
+// calls before here. (So the ParenListExpr should be nonempty, but check just
+// in case)
+Expr *unwrapParenList(Expr *Base) {
+  if (auto *PLE = llvm::dyn_cast_or_null(Base)) {
+if (PLE->getNumExprs() == 0)
+  return nullptr;
+Base = PLE->getExpr(PLE->getNumExprs() - 1);
+  }
+  return Base;
+}
+
 } // namespace
 
 void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
@@ -5252,18 +5265,11 @@
SourceLocation OpLoc, bool IsArrow,
bool IsBaseExprStatement,
QualType PreferredType) {
+  Base = unwrapParenList(Base);
+  OtherOpBase = unwrapParenList(OtherOpBase);
   if (!Base || !CodeCompleter)
 return;
 
-  // Peel off the ParenListExpr by chosing the last one, as they don't have a
-  // predefined type.
-  if (auto *PLE = llvm::dyn_cast(Base))
-Base = PLE->getExpr(PLE->getNumExprs() - 1);
-  if (OtherOpBase) {
-if (auto *PLE = llvm::dyn_cast(OtherOpBase))
-  OtherOpBase = PLE->getExpr(PLE->getNumExprs() - 1);
-  }
-
   ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
   if (ConvertedBase.isInvalid())
 return;
@@ -5693,14 +5699,10 @@
 QualType Sema::ProduceCallSignatureHelp(Scope *S, Expr *Fn,
 ArrayRef Args,
 SourceLocation OpenParLoc) {
+  Fn = unwrapParenList(Fn);
   if (!CodeCompleter || !Fn)
 return QualType();
 
-  // If we have a ParenListExpr for LHS, peel it off by chosing the last expr.
-  // As ParenListExprs don't have a predefined type.
-  if (auto *PLE = llvm::dyn_cast(Fn))
-Fn = PLE->getExpr(PLE->getNumExprs() - 1);
-
   // FIXME: Provide support for variadic template functions.
   // Ignore type-dependent call expressions entirely.
   if (Fn->isTypeDependent() || anyNullArguments(Args))


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5245,6 +5245,19 @@
   return Unresolved;
 }
 
+// If \p Base is ParenListExpr, assume a chain of comma operators and pick the
+// last expr. We expect other ParenListExprs to be resolved to e.g. constructor
+// calls before here. (So the ParenListExpr should be nonempty, but check just
+// in case)
+Expr *unwrapParenList(Expr *Base) {
+  if (auto *PLE = llvm::dyn_cast_or_null(Base)) {
+if (PLE->getNumExprs() == 0)
+  return nullptr;
+Base = PLE->getExpr(PLE->getNumExprs() - 1);
+  }
+  return Base;
+}
+
 } // namespace
 
 void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
@@ -5252,18 +5265,11 @@
SourceLocation OpLoc, bool IsArrow,
bool IsBaseExprStatement,
QualType PreferredType) {
+  Base = unwrapParenList(Base);
+  OtherOpBase = unwrapParenList(OtherOpBase);
   if (!Base || !CodeCompleter)
 return;
 
-  // Peel off the ParenListExpr by chosing the last one, as they don't have a
-  // predefined type.
-  if (auto *PLE = llvm::dyn_cast(Base))
-Base = PLE->getExpr(PLE->getNumExprs() - 1);
-  if (OtherOpBase) {
-if (auto *PLE = llvm::dyn_cast(OtherOpBase))
-  OtherOpBase = PLE->getExpr(PLE->getNumExprs() - 1);
-  }
-
   ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
   if (ConvertedBase.isInvalid())
 return;
@@ -5693,14 +5699,10 @@
 QualType Sema::ProduceCallSignatureHelp(Scope *S, Expr *Fn,
 ArrayRef Args,
 SourceLocation OpenParLoc) {
+  Fn = unwrapParenList(Fn);
   if (!CodeCompleter || !Fn)
 return QualType();
 
-  // If we have a ParenListExpr for LHS, peel it off by chosing the last expr.
-  // As ParenListExprs don't have a predefined type.
-  if (auto *PLE = llvm::dyn_cast(Fn))
-Fn = PLE->getExpr(PLE->getNumExprs() - 1);
-
   // FIXME: Provide support for variadic template functions.
   // Ignore type-depend

[clang] f101373 - [clang][CodeComplete] Ensure there are no crashes when completing with ParenListExprs as LHS

2021-02-22 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-02-22T10:01:22+01:00
New Revision: f10137399a3c9239a6acd1d3df12a40766b64759

URL: 
https://github.com/llvm/llvm-project/commit/f10137399a3c9239a6acd1d3df12a40766b64759
DIFF: 
https://github.com/llvm/llvm-project/commit/f10137399a3c9239a6acd1d3df12a40766b64759.diff

LOG: [clang][CodeComplete] Ensure there are no crashes when completing with 
ParenListExprs as LHS

Differential Revision: https://reviews.llvm.org/D96950

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 1e4d5dd62aa0..2feb02bbe4ed 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -5245,6 +5245,19 @@ QualType getApproximateType(const Expr *E) {
   return Unresolved;
 }
 
+// If \p Base is ParenListExpr, assume a chain of comma operators and pick the
+// last expr. We expect other ParenListExprs to be resolved to e.g. constructor
+// calls before here. (So the ParenListExpr should be nonempty, but check just
+// in case)
+Expr *unwrapParenList(Expr *Base) {
+  if (auto *PLE = llvm::dyn_cast_or_null(Base)) {
+if (PLE->getNumExprs() == 0)
+  return nullptr;
+Base = PLE->getExpr(PLE->getNumExprs() - 1);
+  }
+  return Base;
+}
+
 } // namespace
 
 void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
@@ -5252,18 +5265,11 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, 
Expr *Base,
SourceLocation OpLoc, bool IsArrow,
bool IsBaseExprStatement,
QualType PreferredType) {
+  Base = unwrapParenList(Base);
+  OtherOpBase = unwrapParenList(OtherOpBase);
   if (!Base || !CodeCompleter)
 return;
 
-  // Peel off the ParenListExpr by chosing the last one, as they don't have a
-  // predefined type.
-  if (auto *PLE = llvm::dyn_cast(Base))
-Base = PLE->getExpr(PLE->getNumExprs() - 1);
-  if (OtherOpBase) {
-if (auto *PLE = llvm::dyn_cast(OtherOpBase))
-  OtherOpBase = PLE->getExpr(PLE->getNumExprs() - 1);
-  }
-
   ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
   if (ConvertedBase.isInvalid())
 return;
@@ -5693,14 +5699,10 @@ ProduceSignatureHelp(Sema &SemaRef, Scope *S,
 QualType Sema::ProduceCallSignatureHelp(Scope *S, Expr *Fn,
 ArrayRef Args,
 SourceLocation OpenParLoc) {
+  Fn = unwrapParenList(Fn);
   if (!CodeCompleter || !Fn)
 return QualType();
 
-  // If we have a ParenListExpr for LHS, peel it off by chosing the last expr.
-  // As ParenListExprs don't have a predefined type.
-  if (auto *PLE = llvm::dyn_cast(Fn))
-Fn = PLE->getExpr(PLE->getNumExprs() - 1);
-
   // FIXME: Provide support for variadic template functions.
   // Ignore type-dependent call expressions entirely.
   if (Fn->isTypeDependent() || anyNullArguments(Args))



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97041: [clang][cli] Pass '-Wspir-compat' to cc1 from driver

2021-02-22 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG820e0c49fc48: [clang][cli] Pass '-Wspir-compat' to 
cc1 from driver (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97041/new/

https://reviews.llvm.org/D97041

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/opencl.cl
  clang/test/SemaOpenCL/sampler_t.cl


Index: clang/test/SemaOpenCL/sampler_t.cl
===
--- clang/test/SemaOpenCL/sampler_t.cl
+++ clang/test/SemaOpenCL/sampler_t.cl
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE 
-Wspir-compat -triple amdgcn--amdhsa
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE 
-Wspir-compat -triple spir-unknown-unknown
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only 
-DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only 
-DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only 
-DCHECK_SAMPLER_VALUE -Wspir-compat -triple spir-unknown-unknown
 
 #define CLK_ADDRESS_CLAMP_TO_EDGE   2
 #define CLK_NORMALIZED_COORDS_TRUE  1
Index: clang/test/Driver/opencl.cl
===
--- clang/test/Driver/opencl.cl
+++ clang/test/Driver/opencl.cl
@@ -19,6 +19,8 @@
 // RUN: %clang -S -### -cl-uniform-work-group-size %s 2>&1 | FileCheck 
--check-prefix=CHECK-UNIFORM-WG %s
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
+// RUN: %clang -S -### -target spir-unknown-unknown %s 2>&1 | FileCheck 
--check-prefix=CHECK-W-SPIR-COMPAT %s
+// RUN: %clang -S -### -target amdgcn-amd-amdhsa-opencl %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-W-SPIR-COMPAT %s
 
 // CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
 // CHECK-CL10: "-cc1" {{.*}} "-cl-std=CL1.0"
@@ -45,4 +47,7 @@
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
+// CHECK-W-SPIR-COMPAT: "-Wspir-compat"
+// CHECK-NO-W-SPIR-COMPAT-NOT: "-Wspir-compat"
+
 kernel void func(void);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4628,10 +4628,6 @@
 Success = false;
   }
 
-  // Turn on -Wspir-compat for SPIR target.
-  if (T.isSPIR())
-Res.getDiagnosticOpts().Warnings.push_back("spir-compat");
-
   // If sanitizer is enabled, disable OPT_ffine_grained_bitfield_accesses.
   if (Res.getCodeGenOpts().FineGrainedBitfieldAccesses &&
   !Res.getLangOpts()->Sanitize.empty()) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4264,6 +4264,10 @@
   // are provided.
   TC.addClangWarningOptions(CmdArgs);
 
+  // FIXME: Subclass ToolChain for SPIR and move this to 
addClangWarningOptions.
+  if (Triple.isSPIR())
+CmdArgs.push_back("-Wspir-compat");
+
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;
 


Index: clang/test/SemaOpenCL/sampler_t.cl
===
--- clang/test/SemaOpenCL/sampler_t.cl
+++ clang/test/SemaOpenCL/sampler_t.cl
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple spir-unknown-unknown
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple spir-unknown-unknown
 
 #define CLK_ADDRESS_CLAMP_TO_EDGE   2
 #define CLK_NORMALIZED_COORDS_TRUE  1
Index: clang/test/Drive

[clang] 820e0c4 - [clang][cli] Pass '-Wspir-compat' to cc1 from driver

2021-02-22 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-22T09:54:44+01:00
New Revision: 820e0c49fc48024d8b426f4b10b50b5b5659a705

URL: 
https://github.com/llvm/llvm-project/commit/820e0c49fc48024d8b426f4b10b50b5b5659a705
DIFF: 
https://github.com/llvm/llvm-project/commit/820e0c49fc48024d8b426f4b10b50b5b5659a705.diff

LOG: [clang][cli] Pass '-Wspir-compat' to cc1 from driver

This patch moves the creation of the '-Wspir-compat' argument from cc1 to the 
driver.

Without this change, generating command line arguments from 
`CompilerInvocation` cannot be done reliably: there's no way to distinguish 
whether '-Wspir-compat' was passed to cc1 on the command line (should be 
generated), or if it was created within `CompilerInvocation::CreateFromArgs` 
(should not be generated).

This is also in line with how other '-W' flags are handled.

(This was introduced in D21567.)

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D97041

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/opencl.cl
clang/test/SemaOpenCL/sampler_t.cl

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 180d9cfec225..386bec831175 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4264,6 +4264,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // are provided.
   TC.addClangWarningOptions(CmdArgs);
 
+  // FIXME: Subclass ToolChain for SPIR and move this to 
addClangWarningOptions.
+  if (Triple.isSPIR())
+CmdArgs.push_back("-Wspir-compat");
+
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 45fb4f60a396..a870940ac110 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4628,10 +4628,6 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 Success = false;
   }
 
-  // Turn on -Wspir-compat for SPIR target.
-  if (T.isSPIR())
-Res.getDiagnosticOpts().Warnings.push_back("spir-compat");
-
   // If sanitizer is enabled, disable OPT_ffine_grained_bitfield_accesses.
   if (Res.getCodeGenOpts().FineGrainedBitfieldAccesses &&
   !Res.getLangOpts()->Sanitize.empty()) {

diff  --git a/clang/test/Driver/opencl.cl b/clang/test/Driver/opencl.cl
index 44ae12330662..b6a9b8a32448 100644
--- a/clang/test/Driver/opencl.cl
+++ b/clang/test/Driver/opencl.cl
@@ -19,6 +19,8 @@
 // RUN: %clang -S -### -cl-uniform-work-group-size %s 2>&1 | FileCheck 
--check-prefix=CHECK-UNIFORM-WG %s
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
+// RUN: %clang -S -### -target spir-unknown-unknown %s 2>&1 | FileCheck 
--check-prefix=CHECK-W-SPIR-COMPAT %s
+// RUN: %clang -S -### -target amdgcn-amd-amdhsa-opencl %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-W-SPIR-COMPAT %s
 
 // CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
 // CHECK-CL10: "-cc1" {{.*}} "-cl-std=CL1.0"
@@ -45,4 +47,7 @@
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
+// CHECK-W-SPIR-COMPAT: "-Wspir-compat"
+// CHECK-NO-W-SPIR-COMPAT-NOT: "-Wspir-compat"
+
 kernel void func(void);

diff  --git a/clang/test/SemaOpenCL/sampler_t.cl 
b/clang/test/SemaOpenCL/sampler_t.cl
index 888e973cc31d..a9fcab7faf06 100644
--- a/clang/test/SemaOpenCL/sampler_t.cl
+++ b/clang/test/SemaOpenCL/sampler_t.cl
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE 
-Wspir-compat -triple amdgcn--amdhsa
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE 
-Wspir-compat -triple spir-unknown-unknown
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only 
-DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only 
-DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only 
-DCHECK_SAMPLER_VALUE -Wspir-compat -triple spir-unknown-unknown
 
 #define CLK_ADDRESS_CLAMP_TO_EDGE   2
 #define CLK_NORMALIZED_COORDS_TRUE  1



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97042: [clang][cli] Stop creating '-Wno-stdlibcxx-not-found' in cc1

2021-02-22 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf15697e9b66: [clang][cli] Stop creating 
'-Wno-stdlibcxx-not-found' in cc1 (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97042/new/

https://reviews.llvm.org/D97042

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4588,12 +4588,6 @@
  Res.getPreprocessorOpts().Includes, Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
-if (T.isOSDarwin() && DashX.isPreprocessed()) {
-  // Supress the darwin-specific 'stdlibcxx-not-found' diagnostic for
-  // preprocessed input as we don't expect it to be used with -std=libc++
-  // anyway.
-  Res.getDiagnosticOpts().Warnings.push_back("no-stdlibcxx-not-found");
-}
   }
 
   if (LangOpts.CUDA) {


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4588,12 +4588,6 @@
  Res.getPreprocessorOpts().Includes, Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
-if (T.isOSDarwin() && DashX.isPreprocessed()) {
-  // Supress the darwin-specific 'stdlibcxx-not-found' diagnostic for
-  // preprocessed input as we don't expect it to be used with -std=libc++
-  // anyway.
-  Res.getDiagnosticOpts().Warnings.push_back("no-stdlibcxx-not-found");
-}
   }
 
   if (LangOpts.CUDA) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bf15697 - [clang][cli] Stop creating '-Wno-stdlibcxx-not-found' in cc1

2021-02-22 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-22T09:53:25+01:00
New Revision: bf15697e9b66b8f7e6f3f7c510a259651810bd29

URL: 
https://github.com/llvm/llvm-project/commit/bf15697e9b66b8f7e6f3f7c510a259651810bd29
DIFF: 
https://github.com/llvm/llvm-project/commit/bf15697e9b66b8f7e6f3f7c510a259651810bd29.diff

LOG: [clang][cli] Stop creating '-Wno-stdlibcxx-not-found' in cc1

This patch stops creating the '-Wno-stdlibcxx-not-found' argument in 
`CompilerInvocation::CreateFromArgs`.

The code was added in 2e7ab55e657f (a follow-up to D48297). However, D61963 
removes relevant tests and starts explicitly passing '-Wno-stdlibcxx-not-found' 
to the driver. I think it's fair to assume this is a dead code.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D97042

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a49c97860324..45fb4f60a396 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4588,12 +4588,6 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
  Res.getPreprocessorOpts().Includes, Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
   LangOpts.ObjCExceptions = 1;
-if (T.isOSDarwin() && DashX.isPreprocessed()) {
-  // Supress the darwin-specific 'stdlibcxx-not-found' diagnostic for
-  // preprocessed input as we don't expect it to be used with -std=libc++
-  // anyway.
-  Res.getDiagnosticOpts().Warnings.push_back("no-stdlibcxx-not-found");
-}
   }
 
   if (LangOpts.CUDA) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-02-22 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

@NoQ, @vsavchenko could you please review this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97183/new/

https://reviews.llvm.org/D97183

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-02-22 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD created this revision.
RedDocMD added reviewers: NoQ, vsavchenko, dcoughlin.
Herald added subscribers: steakhal, ASDenysPetrov, martong, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
RedDocMD requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Removed a TODO by adding a note-tag to explain where the
raw pointer came from.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97183

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp


Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -306,7 +306,7 @@
 };
 
 void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
-  A *RP = P.get();
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
   if (!RP) { // expected-note {{Assuming 'RP' is null}}
 // expected-note@-1 {{Taking true branch}}
 P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -457,8 +457,15 @@
 
   State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
   InnerPointerVal);
-  // TODO: Add NoteTag, for how the raw pointer got using 'get' method.
-  C.addTransition(State);
+
+  C.addTransition(State, C.getNoteTag([ThisRegion](PathSensitiveBugReport &BR,
+   llvm::raw_ostream &OS) {
+if (&BR.getBugType() != smartptr::getNullDereferenceBugType() ||
+!BR.isInteresting(ThisRegion))
+  return;
+OS << "Obtained null inner pointer from";
+checkAndPrettyPrintRegion(OS, ThisRegion);
+  }));
 }
 
 bool SmartPtrModeling::handleAssignOp(const CallEvent &Call,


Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -306,7 +306,7 @@
 };
 
 void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
-  A *RP = P.get();
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
   if (!RP) { // expected-note {{Assuming 'RP' is null}}
 // expected-note@-1 {{Taking true branch}}
 P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -457,8 +457,15 @@
 
   State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
   InnerPointerVal);
-  // TODO: Add NoteTag, for how the raw pointer got using 'get' method.
-  C.addTransition(State);
+
+  C.addTransition(State, C.getNoteTag([ThisRegion](PathSensitiveBugReport &BR,
+   llvm::raw_ostream &OS) {
+if (&BR.getBugType() != smartptr::getNullDereferenceBugType() ||
+!BR.isInteresting(ThisRegion))
+  return;
+OS << "Obtained null inner pointer from";
+checkAndPrettyPrintRegion(OS, ThisRegion);
+  }));
 }
 
 bool SmartPtrModeling::handleAssignOp(const CallEvent &Call,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94376: [MemCpyOpt] Enable MemorySSA by default

2021-02-22 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

I ran into a crash in memcpyopt with this patch.
Running

  opt -S -o - bbi-53212.ll -memcpyopt

yields

  opt: ../include/llvm/Support/Casting.h:104: static bool 
llvm::isa_impl_cl::doit(const 
From *) [To = llvm::MemoryUse, From = const llvm::MemoryUseOrDef *]: Assertion 
`Val && "isa<> used on a null pointer"' failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
  Stack dump:
  0.Program arguments: /data/repo/master/llvm/build-all/bin/opt -S -o - 
bbi-53212.ll -memcpyopt
   #0 0x029461e3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/data/repo/master/llvm/build-all/bin/opt+0x29461e3)
   #1 0x02943e9e llvm::sys::RunSignalHandlers() 
(/data/repo/master/llvm/build-all/bin/opt+0x2943e9e)
   #2 0x029466a6 SignalHandler(int) Signals.cpp:0:0
   #3 0x7ff087446980 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
   #4 0x7ff084517fb7 raise 
/build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
   #5 0x7ff084519921 abort 
/build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
   #6 0x7ff08450948a __assert_fail_base 
/build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
   #7 0x7ff084509502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
   #8 0x019f8722 llvm::MemoryUseOrDef::getDefiningAccess() const 
(/data/repo/master/llvm/build-all/bin/opt+0x19f8722)
   #9 0x02766c6d 
llvm::MemCpyOptPass::processByValArgument(llvm::CallBase&, unsigned int) 
(/data/repo/master/llvm/build-all/bin/opt+0x2766c6d)
  #10 0x02767810 
llvm::MemCpyOptPass::iterateOnFunction(llvm::Function&) 
(/data/repo/master/llvm/build-all/bin/opt+0x2767810)
  #11 0x02768280 llvm::MemCpyOptPass::runImpl(llvm::Function&, 
llvm::MemoryDependenceResults*, llvm::TargetLibraryInfo*, llvm::AAResults*, 
llvm::AssumptionCache*, llvm::DominatorTree*, llvm::MemorySSA*) 
(/data/repo/master/llvm/build-all/bin/opt+0x2768280)
  #12 0x02767c69 llvm::MemCpyOptPass::run(llvm::Function&, 
llvm::AnalysisManager&) 
(/data/repo/master/llvm/build-all/bin/opt+0x2767c69)
  #13 0x02bf031d llvm::detail::PassModel >::run(llvm::Function&, 
llvm::AnalysisManager&) 
(/data/repo/master/llvm/build-all/bin/opt+0x2bf031d)
  #14 0x021720c9 llvm::PassManager >::run(llvm::Function&, 
llvm::AnalysisManager&) 
(/data/repo/master/llvm/build-all/bin/opt+0x21720c9)
  #15 0x00a7cbfd llvm::detail::PassModel >, 
llvm::PreservedAnalyses, llvm::AnalysisManager 
>::run(llvm::Function&, llvm::AnalysisManager&) 
(/data/repo/master/llvm/build-all/bin/opt+0xa7cbfd)
  #16 0x021768b6 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, 
llvm::AnalysisManager&) 
(/data/repo/master/llvm/build-all/bin/opt+0x21768b6)
  #17 0x0076c61d llvm::detail::PassModel >::run(llvm::Module&, 
llvm::AnalysisManager&) 
(/data/repo/master/llvm/build-all/bin/opt+0x76c61d)
  #18 0x02170f2b llvm::PassManager >::run(llvm::Module&, 
llvm::AnalysisManager&) 
(/data/repo/master/llvm/build-all/bin/opt+0x2170f2b)
  #19 0x00764fe1 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, 
llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, 
llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, 
llvm::ArrayRef, llvm::opt_tool::OutputKind, 
llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) 
(/data/repo/master/llvm/build-all/bin/opt+0x764fe1)
  #20 0x00776b32 main 
(/data/repo/master/llvm/build-all/bin/opt+0x776b32)
  #21 0x7ff0844fabf7 __libc_start_main 
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
  #22 0x0075e76a _start 
(/data/repo/master/llvm/build-all/bin/opt+0x75e76a)

F15612676: bbi-53212.ll 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94376/new/

https://reviews.llvm.org/D94376

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

> I have documented the behaviors in clang/include/clang/Basic/AttrDocs.td. Do 
> you have suggestions on the wording?

Included; please let me know what you think.




Comment at: clang/include/clang/Basic/AttrDocs.td:63-76
+The attribute, when attached to a function definition, causes the function to
+be emitted even if it appears that the function is not referenced and can
+otherwise be omitted.
+
+The attribute, when attached to a variable definition with static storage,
+causes the variable to be emitted even if it appears that the variable is not
+referenced.





Comment at: clang/include/clang/Basic/AttrDocs.td:83-91
+This attribute only has effects on ELF targets that support SHF_GNU_RETAIN.
+The attribute, when attached to a function or variable definition, if the
+function or variable is emitted, causes the function or variable to be emitted
+in a unique section with SHF_GNU_RETAIN flag.  This ELF section flag prevents
+garbage collection of the section by supported linkers (GNU ld and gold from
+binutils 2.36 onwards, LLD 13 or newer).
+




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96838/new/

https://reviews.llvm.org/D96838

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


<    1   2   3