[PATCH] D149123: [AArch64][InlineAsm]Add Clang support for flag output constraints

2023-04-24 Thread Mingming Liu via Phabricator via cfe-commits
mingmingl created this revision.
Herald added subscribers: mstorsjo, kristof.beyls.
Herald added a project: All.
mingmingl requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before:

- Clang emits 'invalid output constraint error' 
https://gcc.godbolt.org/z/jWKKr1vrv

After:

- Clang validates and parses flag output constraints to generate LLVM IR.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149123

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/CodeGen/inline-asm-aarch64-flag-output.c
  clang/test/Preprocessor/aarch64_asm_flag_output.c
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/predefined-win-macros.c

Index: clang/test/Preprocessor/predefined-win-macros.c
===
--- clang/test/Preprocessor/predefined-win-macros.c
+++ clang/test/Preprocessor/predefined-win-macros.c
@@ -129,4 +129,5 @@
 // CHECK-ARM64-MINGW: #define WINNT 1
 // CHECK-ARM64-MINGW: #define _WIN32 1
 // CHECK-ARM64-MINGW: #define _WIN64 1
-// CHECK-ARM64-MINGW: #define __aarch64__ 1
+// CHECK-ARM64-MINGW: #define __GCC_ASM_FLAG_OUTPUTS__ 1
+// CHECK-ARM64-MINGW: #define __aarch64__ 1
\ No newline at end of file
Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -106,6 +106,7 @@
 // AARCH64-NEXT: #define __FLT_RADIX__ 2
 // AARCH64-NEXT: #define __FP_FAST_FMA 1
 // AARCH64-NEXT: #define __FP_FAST_FMAF 1
+// AARCH64-NEXT: #define __GCC_ASM_FLAG_OUTPUTS__ 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
Index: clang/test/Preprocessor/aarch64_asm_flag_output.c
===
--- /dev/null
+++ clang/test/Preprocessor/aarch64_asm_flag_output.c
@@ -0,0 +1,3 @@
+// RUN: %clang -target aarch64-unknown-unknown -x c -E -dM -o - %s | FileCheck -match-full-lines %s
+
+// CHECK: #define __GCC_ASM_FLAG_OUTPUTS__ 1
Index: clang/test/CodeGen/inline-asm-aarch64-flag-output.c
===
--- /dev/null
+++ clang/test/CodeGen/inline-asm-aarch64-flag-output.c
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 -O2 -emit-llvm %s -o - -triple aarch64 | FileCheck %s
+
+int test_cceq(int a, int* b) {
+// CHECK-LABEL: @test_cceq
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@cceq},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@cceq"(*b));
+  return a;
+}
+
+int test_ccne(int a, int* b) {
+// CHECK-LABEL: @test_ccne
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@ccne},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@ccne"(*b));
+  return a;
+}
+
+int test_cccs(int a, int* b) {
+// CHECK-LABEL: @test_cccs
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@cccs},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@cccs"(*b));
+  return a;
+}
+
+int test_cchs(int a, int* b) {
+// CHECK-LABEL: @test_cchs
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@cchs},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@cchs"(*b));
+  return a;
+}
+
+int test_(int a, int* b) {
+// CHECK-LABEL: @test_
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@"(*b));
+  return a;
+}
+
+int test_cclo(int a, int* b) {
+// CHECK-LABEL: @test_cclo
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@cclo},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@cclo"(*b));
+  return a;
+}
+
+int test_ccmi(int a, int* b) {
+// CHECK-LABEL: @test_ccmi
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@ccmi},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@ccmi"(*b));
+  return a;
+}
+
+int test_ccpl(int a, int* b) {
+// CHECK-LABEL: @test_ccpl
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@ccpl},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@ccpl"(*b));
+  return a;
+}
+
+int test_ccvs(int a, int* b) {
+// CHECK-LABEL: @test_ccvs
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@ccvs},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@ccvs"(*b));
+  return a;
+}
+
+int test_ccvc(int a, int* b) {
+// CHECK-LABEL: @test_ccvc
+// CHECK: = tail call { i32, i32 } asm "ands ${0:w}, ${0:w}, #3", "=r,={@ccvc},0"(i32 %a)
+  asm("ands %w[a], %w[a], #3"
+  : [a] "+r"(a), "=@ccvc"(*b));
+  return a;
+}
+
+int test_cchi(int a, int* b) {
+// CHECK-LABEL: @test_cchi
+// CHECK: = tail call { 

[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-04-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

LGTM.
About formatting the tests:
Personally, I would have preferred to "clean as you code", but I can see your 
point. Leave it as-is.
Land it, please.


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

https://reviews.llvm.org/D144269

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


[PATCH] D148962: [RISCV] Make Zicntr and Zihpm imply Zicsr.

2023-04-24 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148962

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


[clang] bdbc6c6 - [clang][AST][NFC] Turn some single-line comments into doc comments

2023-04-24 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-04-25T07:17:58+02:00
New Revision: bdbc6c6c325adb6fc55b1e6228fef7c52b3d6731

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

LOG: [clang][AST][NFC] Turn some single-line comments into doc comments

Added: 


Modified: 
clang/include/clang/AST/Expr.h

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index d9b17f8eaf936..0ab778e5d8cd3 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2233,14 +2233,14 @@ class UnaryOperator final
   bool canOverflow() const { return UnaryOperatorBits.CanOverflow; }
   void setCanOverflow(bool C) { UnaryOperatorBits.CanOverflow = C; }
 
-  // Get the FP contractability status of this operator. Only meaningful for
-  // operations on floating point types.
+  /// Get the FP contractability status of this operator. Only meaningful for
+  /// operations on floating point types.
   bool isFPContractableWithinStatement(const LangOptions ) const {
 return getFPFeaturesInEffect(LO).allowFPContractWithinStatement();
   }
 
-  // Get the FENV_ACCESS status of this operator. Only meaningful for
-  // operations on floating point types.
+  /// Get the FENV_ACCESS status of this operator. Only meaningful for
+  /// operations on floating point types.
   bool isFEnvAccessOn(const LangOptions ) const {
 return getFPFeaturesInEffect(LO).getAllowFEnvAccess();
   }
@@ -2325,8 +2325,8 @@ class UnaryOperator final
   void setStoredFPFeatures(FPOptionsOverride F) { getTrailingFPFeatures() = F; 
}
 
 public:
-  // Get the FP features status of this operator. Only meaningful for
-  // operations on floating point types.
+  /// Get the FP features status of this operator. Only meaningful for
+  /// operations on floating point types.
   FPOptions getFPFeaturesInEffect(const LangOptions ) const {
 if (UnaryOperatorBits.HasFPFeatures)
   return getStoredFPFeatures().applyOverrides(LO);
@@ -3082,8 +3082,8 @@ class CallExpr : public Expr {
 *getTrailingFPFeatures() = F;
   }
 
-  // Get the FP features status of this operator. Only meaningful for
-  // operations on floating point types.
+  /// Get the FP features status of this operator. Only meaningful for
+  /// operations on floating point types.
   FPOptions getFPFeaturesInEffect(const LangOptions ) const {
 if (hasStoredFPFeatures())
   return getStoredFPFeatures().applyOverrides(LO);
@@ -3573,8 +3573,8 @@ class CastExpr : public Expr {
 return *getTrailingFPFeatures();
   }
 
-  // Get the FP features status of this operation. Only meaningful for
-  // operations on floating point types.
+  /// Get the FP features status of this operation. Only meaningful for
+  /// operations on floating point types.
   FPOptions getFPFeaturesInEffect(const LangOptions ) const {
 if (hasStoredFPFeatures())
   return getStoredFPFeatures().applyOverrides(LO);
@@ -3971,9 +3971,9 @@ class BinaryOperator : public Expr {
 return isShiftAssignOp(getOpcode());
   }
 
-  // Return true if a binary operator using the specified opcode and operands
-  // would match the 'p = (i8*)nullptr + n' idiom for casting a pointer-sized
-  // integer to a pointer.
+  /// Return true if a binary operator using the specified opcode and operands
+  /// would match the 'p = (i8*)nullptr + n' idiom for casting a pointer-sized
+  /// integer to a pointer.
   static bool isNullPointerArithmeticExtension(ASTContext , Opcode Opc,
const Expr *LHS,
const Expr *RHS);
@@ -4007,8 +4007,8 @@ class BinaryOperator : public Expr {
 *getTrailingFPFeatures() = F;
   }
 
-  // Get the FP features status of this operator. Only meaningful for
-  // operations on floating point types.
+  /// Get the FP features status of this operator. Only meaningful for
+  /// operations on floating point types.
   FPOptions getFPFeaturesInEffect(const LangOptions ) const {
 if (BinaryOperatorBits.HasFPFeatures)
   return getStoredFPFeatures().applyOverrides(LO);
@@ -4022,14 +4022,14 @@ class BinaryOperator : public Expr {
 return FPOptionsOverride();
   }
 
-  // Get the FP contractability status of this operator. Only meaningful for
-  // operations on floating point types.
+  /// Get the FP contractability status of this operator. Only meaningful for
+  /// operations on floating point types.
   bool isFPContractableWithinStatement(const LangOptions ) const {
 return getFPFeaturesInEffect(LO).allowFPContractWithinStatement();
   }
 
-  // Get the FENV_ACCESS status of this operator. Only meaningful for
-  // operations on floating point types.
+  /// Get the FENV_ACCESS status of this operator. Only meaningful for
+  /// 

[PATCH] D143704: [flang] Feature list plugin

2023-04-24 Thread Ethan Luis McDonough 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 rG00d0749f92ec: [flang] Feature list plugin (authored by 
elmcdonough).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

Files:
  flang/examples/CMakeLists.txt
  flang/examples/FeatureList/CMakeLists.txt
  flang/examples/FeatureList/FeatureList.cpp
  flang/test/CMakeLists.txt
  flang/test/Examples/feature-list-class.f90
  flang/test/Examples/feature-list-functions.f90

Index: flang/test/Examples/feature-list-functions.f90
===
--- /dev/null
+++ flang/test/Examples/feature-list-functions.f90
@@ -0,0 +1,76 @@
+! UNSUPPORTED: system-windows
+! REQUIRES: plugins, shell, examples
+
+! RUN: %flang_fc1 -load %llvmshlibdir/flangFeatureList%pluginext \
+! RUN:-plugin feature-list %s 2>&1 | FileCheck %s
+
+program list_features_test
+implicit none
+call test_sub(test_func(2, 3), 4)
+contains
+subroutine test_sub(a, b)
+integer, intent(in) :: a, b
+print "(I0)", a + b
+end subroutine
+
+integer function test_func(a, b)
+integer, intent(in) :: a, b
+test_func = a * b
+end function
+end program list_features_test
+
+! CHECK: Name: 19
+! CHECK-NEXT: Expr: 11
+! CHECK-NEXT: DataRef: 5
+! CHECK-NEXT: Designator: 5
+! CHECK-NEXT: ActualArg: 4
+! CHECK-NEXT: ActualArgSpec: 4
+! CHECK-NEXT: EntityDecl: 4
+! CHECK-NEXT: LiteralConstant: 4
+! CHECK-NEXT: ActionStmt: 3
+! CHECK-NEXT: Block: 3
+! CHECK-NEXT: DeclarationTypeSpec: 3
+! CHECK-NEXT: ExecutableConstruct: 3
+! CHECK-NEXT: ExecutionPart: 3
+! CHECK-NEXT: ExecutionPartConstruct: 3
+! CHECK-NEXT: ImplicitPart: 3
+! CHECK-NEXT: IntLiteralConstant: 3
+! CHECK-NEXT: IntegerTypeSpec: 3
+! CHECK-NEXT: IntrinsicTypeSpec: 3
+! CHECK-NEXT: SpecificationPart: 3
+! CHECK-NEXT: AttrSpec: 2
+! CHECK-NEXT: Call: 2
+! CHECK-NEXT: DeclarationConstruct: 2
+! CHECK-NEXT: DummyArg: 2
+! CHECK-NEXT: IntentSpec: 2
+! CHECK-NEXT: IntentSpec::Intent: 2
+! CHECK-NEXT: InternalSubprogram: 2
+! CHECK-NEXT: ProcedureDesignator: 2
+! CHECK-NEXT: SpecificationConstruct: 2
+! CHECK-NEXT: TypeDeclarationStmt: 2
+! CHECK-NEXT: AssignmentStmt: 1
+! CHECK-NEXT: CallStmt: 1
+! CHECK-NEXT: CharLiteralConstant: 1
+! CHECK-NEXT: ContainsStmt: 1
+! CHECK-NEXT: EndFunctionStmt: 1
+! CHECK-NEXT: EndProgramStmt: 1
+! CHECK-NEXT: EndSubroutineStmt: 1
+! CHECK-NEXT: Expr::Add: 1
+! CHECK-NEXT: Expr::Multiply: 1
+! CHECK-NEXT: Format: 1
+! CHECK-NEXT: FunctionReference: 1
+! CHECK-NEXT: FunctionStmt: 1
+! CHECK-NEXT: FunctionSubprogram: 1
+! CHECK-NEXT: ImplicitPartStmt: 1
+! CHECK-NEXT: ImplicitStmt: 1
+! CHECK-NEXT: InternalSubprogramPart: 1
+! CHECK-NEXT: MainProgram: 1
+! CHECK-NEXT: OutputItem: 1
+! CHECK-NEXT: PrefixSpec: 1
+! CHECK-NEXT: PrintStmt: 1
+! CHECK-NEXT: Program: 1
+! CHECK-NEXT: ProgramStmt: 1
+! CHECK-NEXT: ProgramUnit: 1
+! CHECK-NEXT: SubroutineStmt: 1
+! CHECK-NEXT: SubroutineSubprogram: 1
+! CHECK-NEXT: Variable: 1
Index: flang/test/Examples/feature-list-class.f90
===
--- /dev/null
+++ flang/test/Examples/feature-list-class.f90
@@ -0,0 +1,88 @@
+! UNSUPPORTED: system-windows
+! REQUIRES: plugins, shell, examples
+
+! RUN: %flang_fc1 -load %llvmshlibdir/flangFeatureList%pluginext \
+! RUN:-plugin feature-list %s 2>&1 | FileCheck %s
+
+module list_features_test
+implicit none
+
+type :: test_class_1
+integer :: a
+real :: b
+contains
+procedure :: sum => sum_test_class_1
+procedure :: set => set_values_test_class_1
+end type
+contains
+real function sum_test_class_1(self)
+class(test_class_1), intent(in) :: self
+sum_test_class_1 = self%a + self%b
+end function
+
+subroutine set_values_test_class_1(self, a, b)
+class(test_class_1), intent(out) :: self
+integer, intent(in) :: a, b
+self%a = a
+self%b = b
+end subroutine
+end module list_features_test
+
+! CHECK: Name: 32
+! CHECK-NEXT: DataRef: 11
+! CHECK-NEXT: Designator: 7
+! CHECK-NEXT: DeclarationTypeSpec: 6
+! CHECK-NEXT: Expr: 5
+! CHECK-NEXT: DeclarationConstruct: 4
+! CHECK-NEXT: EntityDecl: 4
+! CHECK-NEXT: IntrinsicTypeSpec: 4
+! CHECK-NEXT: SpecificationConstruct: 4
+! CHECK-NEXT: StructureComponent: 4
+! CHECK-NEXT: ActionStmt: 3
+! CHECK-NEXT: AssignmentStmt: 3
+! CHECK-NEXT: AttrSpec: 3
+! CHECK-NEXT: DummyArg: 3
+! CHECK-NEXT: ExecutableConstruct: 3
+! CHECK-NEXT: ExecutionPartConstruct: 3
+! CHECK-NEXT: ImplicitPart: 3
+! CHECK-NEXT: IntentSpec: 3
+! CHECK-NEXT: IntentSpec::Intent: 3
+! CHECK-NEXT: SpecificationPart: 3
+! CHECK-NEXT: TypeDeclarationStmt: 3
+! CHECK-NEXT: Variable: 3
+! CHECK-NEXT: Block: 2
+! CHECK-NEXT: ComponentDecl: 2
+! CHECK-NEXT: ComponentDefStmt: 2
+! 

[PATCH] D148757: [clang] Follow user-provided order for prefix map

2023-04-24 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

In D148757#4289152 , @MaskRay wrote:

> In D148757#4289076 , @MaskRay wrote:
>
>> I'm creating a patch to change DebugPrefixMap to respect the command line 
>> option order...
>
> Created D148975  to follow GCC's behavior 
> (the last applicable option wins).
>
> In this patch, you may drop the `DebugPrefixMap` 
> (clang/include/clang/Basic/CodeGenOptions.h) change (a no-op without other 
> changes to `DebugPrefixMap` ).

Thanks for you guidance on this @MaskRay, and I removed the changes to 
debuginfo in the new revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

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


[PATCH] D148757: [clang] Follow user-provided order for prefix map

2023-04-24 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem updated this revision to Diff 516616.
gulfem added a comment.

Remove the changes from debuginfo, which is handled in D14897 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/coverage-prefix-map.c


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom 
-fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck 
--check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map==newpath) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map=%/t/root=. 
-fcoverage-prefix-map==newpath -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-ORDER %s
+// COVERAGE-PREFIX-MAP-ORDER: @__llvm_coverage_mapping = 
{{.*"\\02.*newpath.*root.*nested.*coverage-prefix-map\.c}}
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map=%/t/root=.) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map==newpath 
-fcoverage-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-REORDER %s
+// COVERAGE-PREFIX-MAP-REORDER: @__llvm_coverage_mapping =
+// COVERAGE-PREFIX-MAP-REORDER-NOT: newpath
+// COVERAGE-PREFIX-MAP-REORDER-SAME: nested{{.*coverage-prefix-map\.c}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1702,8 +1702,7 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.CoveragePrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.CoveragePrefixMap.emplace_back(Split.first, Split.second);
   }
 
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
Index: clang/lib/CodeGen/CoverageMappingGen.h
===
--- clang/lib/CodeGen/CoverageMappingGen.h
+++ clang/lib/CodeGen/CoverageMappingGen.h
@@ -107,7 +107,10 @@
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionNames;
   std::vector FunctionRecords;
-  std::map CoveragePrefixMap;
+
+  /// Prefix replacement map for coverage.
+  llvm::SmallVector, 0>
+  CoveragePrefixMap;
 
   std::string getCurrentDirname();
   std::string normalizeFilename(StringRef Filename);
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1635,7 +1635,8 @@
 CoverageMappingModuleGen::CoverageMappingModuleGen(
 CodeGenModule , CoverageSourceInfo )
 : CGM(CGM), SourceInfo(SourceInfo) {
-  CoveragePrefixMap = CGM.getCodeGenOpts().CoveragePrefixMap;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().CoveragePrefixMap)
+CoveragePrefixMap.emplace_back(From, To);
 }
 
 std::string CoverageMappingModuleGen::getCurrentDirname() {
@@ -1650,10 +1651,14 @@
 std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  for (const auto  : CoveragePrefixMap) {
-if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
+
+  // Traverse CoveragePrefixMap in reverse order to apply the last provided 
path
+  // prefix replacement when multiple -fcoverage-prefix-map options are
+  // provided.
+  for (const auto &[From, To] : llvm::reverse(CoveragePrefixMap))
+if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
-  }
+
   return Path.str().str();
 }
 
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -207,7 +207,9 @@
   std::string RecordCommandLine;
 

[PATCH] D149009: [Sema]Select correct lexical context during template instantiate

2023-04-24 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 516615.
HerrCai0907 added a comment.

add comment and more test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149009

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/template-friend-definition-in-template.cpp


Index: clang/test/SemaTemplate/template-friend-definition-in-template.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/template-friend-definition-in-template.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  int foo1(F1 X1);
+
+template  struct A {
+  template  friend int foo1(F2 X2) {
+return A1;
+  }
+};
+
+template struct A<1>;
+int main() { 
+  foo1(1.0);
+}
+
+template  int foo2(F1 X1);
+
+template  struct B {
+  template  friend int foo2(F2 X2) {
+return A1;
+  }
+};
+
+template struct B<1>;
+template int foo2(float X1);
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4662,11 +4662,7 @@
   ActiveInstType  = SemaRef.CodeSynthesisContexts.back();
   if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution 
||
   ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
-if (FunctionTemplateDecl *FunTmpl
-  = dyn_cast(ActiveInst.Entity)) {
-  assert(FunTmpl->getTemplatedDecl() == Tmpl &&
- "Deduction from the wrong function template?");
-  (void) FunTmpl;
+if (isa(ActiveInst.Entity)) {
   SemaRef.InstantiatingSpecializations.erase(
   {ActiveInst.Entity->getCanonicalDecl(), ActiveInst.Kind});
   atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef, ActiveInst);
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3591,11 +3591,28 @@
   DeclContext *Owner = FunctionTemplate->getDeclContext();
   if (FunctionTemplate->getFriendObjectKind())
 Owner = FunctionTemplate->getLexicalDeclContext();
+  FunctionDecl *FD = FunctionTemplate->getTemplatedDecl();
+  // additional check for inline friend, 
+  // ```
+  //   template  int foo(F1 X);
+  //   template  struct A {
+  // template  friend int foo(F1 X) { return A1; }
+  //   };
+  //   template struct A<1>;
+  //   int a = foo(1.0);
+  // ```
+  const FunctionDecl *FDFriend;
+  if (FD->getFriendObjectKind() == Decl::FriendObjectKind::FOK_None &&
+  FD->isDefined(FDFriend, true) &&
+  FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) {
+FD = const_cast(FDFriend);
+Owner = FD->getDescribedFunctionTemplate()->getLexicalDeclContext();
+  }
   MultiLevelTemplateArgumentList SubstArgs(
   FunctionTemplate, CanonicalDeducedArgumentList->asArray(),
   /*Final=*/false);
   Specialization = cast_or_null(
-  SubstDecl(FunctionTemplate->getTemplatedDecl(), Owner, SubstArgs));
+  SubstDecl(FD, Owner, SubstArgs));
   if (!Specialization || Specialization->isInvalidDecl())
 return TDK_SubstitutionFailure;
 


Index: clang/test/SemaTemplate/template-friend-definition-in-template.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/template-friend-definition-in-template.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  int foo1(F1 X1);
+
+template  struct A {
+  template  friend int foo1(F2 X2) {
+return A1;
+  }
+};
+
+template struct A<1>;
+int main() { 
+  foo1(1.0);
+}
+
+template  int foo2(F1 X1);
+
+template  struct B {
+  template  friend int foo2(F2 X2) {
+return A1;
+  }
+};
+
+template struct B<1>;
+template int foo2(float X1);
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4662,11 +4662,7 @@
   ActiveInstType  = SemaRef.CodeSynthesisContexts.back();
   if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
   ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
-if (FunctionTemplateDecl *FunTmpl
-  = dyn_cast(ActiveInst.Entity)) {
-  assert(FunTmpl->getTemplatedDecl() == Tmpl &&
- "Deduction from the wrong function template?");
-  (void) FunTmpl;
+if (isa(ActiveInst.Entity)) {
   SemaRef.InstantiatingSpecializations.erase(
   {ActiveInst.Entity->getCanonicalDecl(), ActiveInst.Kind});
   atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef, 

[PATCH] D149119: [CMake] Use llvm-nm to extract symbols for staged LTO builds on Windows

2023-04-24 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: john.brawn, daltenty, jsji, simon_tatham, tmatheson, 
mstorsjo, phosek.
ikudrin added projects: LLVM, clang.
Herald added subscribers: ekilmer, inglorion.
Herald added a project: All.
ikudrin requested review of this revision.

As for now, `extract_symbols.py` uses a predefined set of tools, none of which 
can read bitcode files. The patch makes it possible to override the used tool 
and passes a fresh built `llvm-nm` for that for multi-staged LTO builds. This 
fixes building plugins with LTO builds and subsequently makes 
`clang/test/Frontend/plugin-*` tests pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149119

Files:
  clang/CMakeLists.txt
  llvm/utils/extract_symbols.py

Index: llvm/utils/extract_symbols.py
===
--- llvm/utils/extract_symbols.py
+++ llvm/utils/extract_symbols.py
@@ -29,8 +29,8 @@
 # as, especially on Windows, waiting for the entire output to be ready can take
 # a significant amount of time.
 
-def dumpbin_get_symbols(lib):
-process = subprocess.Popen(['dumpbin','/symbols',lib], bufsize=1,
+def dumpbin_get_symbols(tool, lib):
+process = subprocess.Popen([tool,'/symbols',lib], bufsize=1,
stdout=subprocess.PIPE, stdin=subprocess.PIPE,
universal_newlines=True)
 process.stdin.close()
@@ -41,10 +41,10 @@
 yield (match.group(2), match.group(1) != "UNDEF")
 process.wait()
 
-def nm_get_symbols(lib):
+def nm_get_symbols(tool, lib):
 # -P means the output is in portable format, and -g means we only get global
 # symbols.
-cmd = ['nm','-P','-g']
+cmd = [tool,'-P','-g']
 if sys.platform.startswith('aix'):
 cmd += ['-Xany','-C','-p']
 process = subprocess.Popen(cmd+[lib], bufsize=1,
@@ -68,8 +68,8 @@
 yield (match.group(1), False)
 process.wait()
 
-def readobj_get_symbols(lib):
-process = subprocess.Popen(['llvm-readobj','--symbols',lib], bufsize=1,
+def readobj_get_symbols(tool, lib):
+process = subprocess.Popen([tool,'--symbols',lib], bufsize=1,
stdout=subprocess.PIPE, stdin=subprocess.PIPE,
universal_newlines=True)
 process.stdin.close()
@@ -95,10 +95,10 @@
 # Define functions which determine if the target is 32-bit Windows (as that's
 # where calling convention name decoration happens).
 
-def dumpbin_is_32bit_windows(lib):
+def dumpbin_is_32bit_windows(tool, lib):
 # dumpbin /headers can output a huge amount of data (>100MB in a debug
 # build) so we read only up to the 'machine' line then close the output.
-process = subprocess.Popen(['dumpbin','/headers',lib], bufsize=1,
+process = subprocess.Popen([tool,'/headers',lib], bufsize=1,
stdout=subprocess.PIPE, stdin=subprocess.PIPE,
universal_newlines=True)
 process.stdin.close()
@@ -112,8 +112,8 @@
 process.wait()
 return retval
 
-def objdump_is_32bit_windows(lib):
-output = subprocess.check_output(['objdump','-f',lib],
+def objdump_is_32bit_windows(tool, lib):
+output = subprocess.check_output([tool,'-f',lib],
  universal_newlines=True)
 for line in output.splitlines():
 match = re.match('.+file format (\S+)', line)
@@ -121,8 +121,8 @@
 return (match.group(1) == 'pe-i386')
 return False
 
-def readobj_is_32bit_windows(lib):
-output = subprocess.check_output(['llvm-readobj','--file-header',lib],
+def readobj_is_32bit_windows(tool, lib):
+output = subprocess.check_output([tool,'--file-header',lib],
  universal_newlines=True)
 for line in output.splitlines():
 match = re.match('Format: (\S+)', line)
@@ -132,7 +132,7 @@
 
 # On AIX, there isn't an easy way to detect 32-bit windows objects with the system toolchain,
 # so just assume false.
-def aix_is_32bit_windows(lib):
+def aix_is_32bit_windows(tool, lib):
 return False
 
 # MSVC mangles names to ?@. By examining the
@@ -355,10 +355,10 @@
 return components
 
 def extract_symbols(arg):
-get_symbols, should_keep_symbol, calling_convention_decoration, lib = arg
+get_symbols, get_symbols_tool, should_keep_symbol, calling_convention_decoration, lib = arg
 symbol_defs = dict()
 symbol_refs = set()
-for (symbol, is_def) in get_symbols(lib):
+for (symbol, is_def) in get_symbols(get_symbols_tool, lib):
 symbol = should_keep_symbol(symbol, calling_convention_decoration)
 if symbol:
 if is_def:
@@ -392,8 +392,20 @@
 # Not a template
 return None
 
+def parse_arg_override(parser, val):
+tool, _, path = val.partition('=')
+if not tool in known_tools:
+parser.error(f'Unknown tool: {tool}')
+if not path or not os.path.isfile(path):
+

[PATCH] D147610: [RISCV][MC] Add support for experimental Zfbfmin extension

2023-04-24 Thread Jun Sha via Phabricator via cfe-commits
joshua-arch1 added a comment.

In D147610#4294260 , @craig.topper 
wrote:

> In D147610#4294247 , @joshua-arch1 
> wrote:
>
>> I'm wondering whether it is appropriate to just use FPR16 for the 
>> destination of fcvt.bf16.s? The destination is in BF16 format instead of 
>> simple FP16.  Your implemention looks like just replacing fcvt.h.s with 
>> fcvt.bf16.s. Do we need to define a new register class?
>
> Registers classes only distinguished by the registers in them and what their 
> alignment and spill size are. It doesn't define anything about the format of 
> the register. A BF16 specific register class would be identical in those 
> properties to the FPR16 register class.

Do you have any plan for code generation of these instructions with 
corresponding intrinsics?


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

https://reviews.llvm.org/D147610

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


[PATCH] D148484: [clang-format] Correctly format goto labels followed by blocks

2023-04-24 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

Is this patch accepted or rejected?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148484

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


[clang] e66c2db - -Wframe-larger-than=: improve error with an invalid argument

2023-04-24 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-04-24T20:11:21-07:00
New Revision: e66c2db7996ed0ce8cd27548a623ce62246be33b

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

LOG: -Wframe-larger-than=: improve error with an invalid argument

Remove a FIXME. For simplicity, the error message for the missing argument case
has changed from err_drv_missing_argument to err_drv_invalid_argument_to_option,
which should be fine.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/Wframe-larger-than.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f7544c8f593c8..95ef79416acff 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5230,14 +5230,13 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-// FIXME: Validate the argument here so we don't produce meaningless errors
-// about -fwarn-stack-size=.
-if (v.empty())
-  D.Diag(diag::err_drv_missing_argument) << A->getSpelling() << 1;
+StringRef V = A->getValue(), V1 = V;
+unsigned Size;
+if (V1.consumeInteger(10, Size) || !V1.empty())
+  D.Diag(diag::err_drv_invalid_argument_to_option)
+  << V << A->getOption().getName();
 else
-  CmdArgs.push_back(Args.MakeArgString("-fwarn-stack-size=" + v));
-A->claim();
+  CmdArgs.push_back(Args.MakeArgString("-fwarn-stack-size=" + V));
   }
 
   Args.addOptOutFlag(CmdArgs, options::OPT_fjump_tables,

diff  --git a/clang/test/Driver/Wframe-larger-than.c 
b/clang/test/Driver/Wframe-larger-than.c
index cc5b5d0a2ca1a..768ff4407624b 100644
--- a/clang/test/Driver/Wframe-larger-than.c
+++ b/clang/test/Driver/Wframe-larger-than.c
@@ -8,6 +8,7 @@
 // RUN:   -v -E %s 2>&1 | FileCheck %s --check-prefix=NOARG
 // RUN: not %clang -Wframe-larger-than \
 // RUN:   -v -E %s 2>&1 | FileCheck %s --check-prefix=NOARG
+// RUN: not %clang -Wframe-larger-than=0x2a -E %s 2>&1 | FileCheck %s 
--check-prefix=INVALID
 
 // ENABLE: cc1 {{.*}} -fwarn-stack-size=42 {{.*}} -Wframe-larger-than=42
 // ENABLE: frame-larger-than:
@@ -21,7 +22,8 @@
 // REENABLE: frame-larger-than:
 // REENABLE-SAME: warning
 
-// NOARG: error: argument to '-Wframe-larger-than=' is missing
+// NOARG: error: invalid argument '' to -Wframe-larger-than=
+// INVALID: error: invalid argument '0x2a' to -Wframe-larger-than=
 
 // We need to create some state transitions before the pragma will dump 
anything.
 #pragma clang diagnostic push



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


[PATCH] D148962: [RISCV] Make Zicntr and Zihpm imply Zicsr.

2023-04-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148962

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


[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-04-24 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2408
+
+OperandMatchResultTy RISCVAsmParser::parseZcSpimm(OperandVector ) {
+  if (getLexer().is(AsmToken::Minus))

`parseZcSpimm` -> `parseZcmpSpimm`



Comment at: llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp:477
 
+static DecodeStatus decodeZcRlist(MCInst , unsigned Imm, uint64_t Address,
+  const void *Decoder) {

decodeZcRlist -> decodeZcmpRlist



Comment at: llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp:486
+// spimm is based on rlist now.
+static DecodeStatus decodeZcSpimm(MCInst , unsigned Imm, uint64_t Address,
+  const void *Decoder) {

decodeZcSpimm -> decodeZcmpSpimm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

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


[PATCH] D148223: [SiFive] Support C intrinsics for xsfvcp extension.

2023-04-24 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 516598.
4vtomat added a comment.

Removed unnecessary comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

Files:
  clang/include/clang/Basic/riscv_sifive_vector.td
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp-index-out-of-range.c

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


[PATCH] D147610: [RISCV][MC] Add support for experimental Zfbfmin extension

2023-04-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D147610#4294247 , @joshua-arch1 
wrote:

> I'm wondering whether it is appropriate to just use FPR16 for the destination 
> of fcvt.bf16.s? The destination is in BF16 format instead of simple FP16.  
> Your implemention looks like just replacing fcvt.h.s with fcvt.bf16.s. Do we 
> need to define a new register class?

Registers classes only distinguished by the registers in them and what their 
alignment and spill size are. It doesn't define anything about the format of 
the register. A BF16 specific register class would be identical in those 
properties to the FPR16 register class.


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

https://reviews.llvm.org/D147610

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


[PATCH] D148223: [SiFive] Support C intrinsics for xsfvcp extension.

2023-04-24 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 516596.
4vtomat added a comment.

Resolved Craig's comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

Files:
  clang/include/clang/Basic/riscv_sifive_vector.td
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp-index-out-of-range.c

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


[PATCH] D147610: [RISCV][MC] Add support for experimental Zfbfmin extension

2023-04-24 Thread Jun Sha via Phabricator via cfe-commits
joshua-arch1 added a comment.

I'm wondering whether it is appropriate to just use FPR16 for the destination 
of fcvt.bf16.s? The destination is in BF16 format instead of simple FP16.  Your 
implemention looks like just replacing fcvt.h.s with fcvt.bf16.s. Do we need to 
define a new register class?


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

https://reviews.llvm.org/D147610

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


[PATCH] D148490: [AIX] use system assembler for assembly files

2023-04-24 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:427
+  Assembler.reset(buildAssembler());
+return Assembler.get();
+  }

I saw we have a `ToolChain::getAssemble()` method. Can we use that directly?



Comment at: clang/test/Driver/aix-assembler.s:1
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.

Empty line?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148490

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


[PATCH] D149110: [HIP] Detect HIP for Ubuntu, Mint, Gentoo, etc.

2023-04-24 Thread Cory Bloor via Phabricator via cfe-commits
cgmb created this revision.
cgmb added reviewers: scchan, tra, yaxunl.
Herald added subscribers: kosarev, kerbowa, jvesely.
Herald added a project: All.
cgmb published this revision for review.
cgmb added a comment.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Ubuntu Lunar (23.04) has released, which is the first version of Ubuntu with 
ROCm support in the universe repos. With respect to ROCm, it is basically a 
snapshot of Debian Sid. However, since LLVM detects HIP package differently on 
Ubuntu than on Debian, there are additional flags required on Ubuntu that are 
not needed on Debian. This patch removes the differences in behaviour between 
distros. An alternative approach would be just to add `|| Dist.IsGentoo() || 
Dist.IsUbuntu()` to the existing check, but that may still fail on 
Ubuntu-derived distros such as Linux Mint.


HIP may be installed into /usr or /usr/local on a variety of Linux
operating systems. It may become unwieldy to list them all.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149110

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp


Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -11,7 +11,6 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
@@ -309,13 +308,10 @@
 ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
 /*StrictChecking=*/true);
 
-  Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
-  if (Dist.IsDebian() || Dist.IsRedhat()) {
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
-/*StrictChecking=*/true);
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
-/*StrictChecking=*/true);
-  }
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
+  /*StrictChecking=*/true);
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
+  /*StrictChecking=*/true);
 
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;


Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -11,7 +11,6 @@
 #include "clang/Basic/TargetID.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
@@ -309,13 +308,10 @@
 ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm,
 /*StrictChecking=*/true);
 
-  Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
-  if (Dist.IsDebian() || Dist.IsRedhat()) {
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
-/*StrictChecking=*/true);
-ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
-/*StrictChecking=*/true);
-  }
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local",
+  /*StrictChecking=*/true);
+  ROCmSearchDirs.emplace_back(D.SysRoot + "/usr",
+  /*StrictChecking=*/true);
 
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-04-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 516582.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

- fix typos
- simplify maybeDemangleSymbol in lld COFF
- restore maybeDemangleSymbol


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  lld/COFF/Symbols.cpp
  lld/ELF/SymbolTable.cpp
  lld/ELF/Symbols.cpp
  lld/MachO/Symbols.cpp
  lld/wasm/Symbols.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
  llvm/lib/Demangle/Demangle.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/tools/llvm-objdump/ELFDump.cpp
  llvm/tools/llvm-objdump/XCOFFDump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-readobj/ELFDumper.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp

Index: llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
===
--- llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
+++ llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
@@ -107,7 +107,7 @@
   std::string OutputName = "'";
   OutputName += Name;
   OutputName += "'";
-  std::string DemangledName(demangle(Name.str()));
+  std::string DemangledName(demangle(Name));
   if (Name != DemangledName) {
 OutputName += " aka ";
 OutputName += DemangledName;
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -908,7 +908,7 @@
 }
 
 static std::string maybeDemangle(StringRef Name) {
-  return opts::Demangle ? demangle(std::string(Name)) : Name.str();
+  return opts::Demangle ? demangle(Name) : Name.str();
 }
 
 template 
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1548,7 +1548,7 @@
   if (Demangle) {
 // Fetch the demangled names and store them locally.
 for (const SymbolInfoTy  : SymbolsHere)
-  DemangledSymNamesHere.push_back(demangle(Symbol.Name.str()));
+  DemangledSymNamesHere.push_back(demangle(Symbol.Name));
 // Now we've finished modifying that vector, it's safe to make
 // a vector of StringRefs pointing into it.
 SymNamesHere.insert(SymNamesHere.begin(), DemangledSymNamesHere.begin(),
@@ -1909,9 +1909,8 @@
   if (TargetSym != nullptr) {
 uint64_t TargetAddress = TargetSym->Addr;
 uint64_t Disp = Target - TargetAddress;
-std::string TargetName = TargetSym->Name.str();
-if (Demangle)
-  TargetName = demangle(TargetName);
+std::string TargetName = Demangle ? demangle(TargetSym->Name)
+  : TargetSym->Name.str();
 
 *TargetOS << " <";
 if (!Disp) {
@@ -2511,10 +2510,8 @@
 
 if (NameOrErr) {
   outs() << " (csect:";
-  std::string SymName(NameOrErr.get());
-
-  if (Demangle)
-SymName = demangle(SymName);
+  std::string SymName =
+  Demangle ? demangle(*NameOrErr) : NameOrErr->str();
 
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, *SymRef),
@@ -2568,10 +2565,7 @@
 outs() << " .hidden";
   }
 
-  std::string SymName(Name);
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName = Demangle ? demangle(Name) : Name.str();
   if (O.isXCOFF() && SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, Symbol), SymName);
 
Index: llvm/tools/llvm-objdump/XCOFFDump.cpp
===
--- llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -32,10 +32,8 @@
   if (!SymNameOrErr)
 return SymNameOrErr.takeError();
 
-  std::string SymName = (*SymNameOrErr).str();
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName =
+  Demangle ? demangle(*SymNameOrErr) : SymNameOrErr->str();
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(Obj, *SymI), SymName);
 
Index: llvm/tools/llvm-objdump/ELFDump.cpp
===
--- llvm/tools/llvm-objdump/ELFDump.cpp
+++ llvm/tools/llvm-objdump/ELFDump.cpp
@@ -108,10 +108,7 @@
   Expected SymName = SI->getName();
   if (!SymName)
 return SymName.takeError();
-  if (Demangle)
-Fmt << demangle(std::string(*SymName));
-  else
-Fmt << *SymName;
+  Fmt << (Demangle ? demangle(*SymName) : *SymName);
 }
   } else {
 Fmt << "*ABS*";
Index: 

[clang] b63b2c2 - Reland "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within macros"

2023-04-24 Thread via cfe-commits

Author: MalavikaSamak
Date: 2023-04-24T16:49:13-07:00
New Revision: b63b2c2350ad1af9131fd95bb94c642d912bd4cf

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

LOG: Reland "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations 
for code within macros"

This reverts commit 84ec1f7725d4f4575474b59467e598d7c5528a4e.

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index c53ecb52384d..3b58a51195f8 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1117,42 +1117,44 @@ static std::string getAPIntText(APInt Val) {
 
 // Return the source location of the last character of the AST `Node`.
 template 
-static SourceLocation getEndCharLoc(const NodeTy *Node, const SourceManager 
,
-const LangOptions ) {
+static std::optional
+getEndCharLoc(const NodeTy *Node, const SourceManager ,
+  const LangOptions ) {
   unsigned TkLen = Lexer::MeasureTokenLength(Node->getEndLoc(), SM, LangOpts);
   SourceLocation Loc = Node->getEndLoc().getLocWithOffset(TkLen - 1);
 
-  // We expect `Loc` to be valid. The location is obtained by moving forward
-  // from the beginning of the token 'len(token)-1' characters. The file ID of
-  // the locations within a token must be consistent.
-  assert(Loc.isValid() && "Expected the source location of the last"
-  "character of an AST Node to be always valid");
-  return Loc;
+  if (Loc.isValid())
+return Loc;
+
+  return std::nullopt;
 }
 
 // Return the source location just past the last character of the AST `Node`.
 template 
-static SourceLocation getPastLoc(const NodeTy *Node, const SourceManager ,
- const LangOptions ) {
+static std::optional getPastLoc(const NodeTy *Node,
+const SourceManager ,
+const LangOptions ) {
   SourceLocation Loc =
   Lexer::getLocForEndOfToken(Node->getEndLoc(), 0, SM, LangOpts);
 
-  // We expect `Loc` to be valid as it is either associated to a file ID or
-  //   it must be the end of a macro expansion. (see
-  //   `Lexer::getLocForEndOfToken`)
-  assert(Loc.isValid() && "Expected the source location just past the last "
-  "character of an AST Node to be always valid");
-  return Loc;
+  if (Loc.isValid())
+return Loc;
+
+  return std::nullopt;
 }
 
 // Return text representation of an `Expr`.
-static StringRef getExprText(const Expr *E, const SourceManager ,
- const LangOptions ) {
-  SourceLocation LastCharLoc = getPastLoc(E, SM, LangOpts);
+static std::optional getExprText(const Expr *E,
+const SourceManager ,
+const LangOptions ) {
+  std::optional LastCharLoc = getPastLoc(E, SM, LangOpts);
+
+  if (LastCharLoc)
+return Lexer::getSourceText(
+CharSourceRange::getCharRange(E->getBeginLoc(), *LastCharLoc), SM,
+LangOpts);
 
-  return Lexer::getSourceText(
-  CharSourceRange::getCharRange(E->getBeginLoc(), LastCharLoc), SM,
-  LangOpts);
+  return std::nullopt;
 }
 
 std::optional
@@ -1191,12 +1193,24 @@ DerefSimplePtrArithFixableGadget::getFixits(const 
Strategy ) const {
 CharSourceRange StarWithTrailWhitespace =
 clang::CharSourceRange::getCharRange(DerefOp->getOperatorLoc(),
  LHS->getBeginLoc());
+
+std::optional LHSLocation = getPastLoc(LHS, SM, LangOpts);
+if (!LHSLocation)
+  return std::nullopt;
+
 CharSourceRange PlusWithSurroundingWhitespace =
-clang::CharSourceRange::getCharRange(getPastLoc(LHS, SM, LangOpts),
- RHS->getBeginLoc());
+clang::CharSourceRange::getCharRange(*LHSLocation, RHS->getBeginLoc());
+
+std::optional AddOpLocation =
+getPastLoc(AddOp, SM, LangOpts);
+std::optional DerefOpLocation =
+getPastLoc(DerefOp, SM, LangOpts);
+
+if (!AddOpLocation || !DerefOpLocation)
+  return std::nullopt;
+
 CharSourceRange ClosingParenWithPrecWhitespace =
-clang::CharSourceRange::getCharRange(getPastLoc(AddOp, SM, LangOpts),
- getPastLoc(DerefOp, SM, 
LangOpts));
+clang::CharSourceRange::getCharRange(*AddOpLocation, *DerefOpLocation);
 
 return FixItList{
 {FixItHint::CreateRemoval(StarWithTrailWhitespace),
@@ -1218,12 +1232,12 @@ 

[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-04-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: lld/ELF/Symbols.cpp:50
+std::string root = symName.str();
+return demangle(root);
+  }

MaskRay wrote:
> `return demangle(symName.str());`
> 
> perhaps `return demangle(symName);` works as well?
> perhaps return demangle(symName); works as well?

I saw test failures with that change.  I can keep it as is; wasn't sure if it's 
worth making this more obvious...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

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


[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-04-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: lld/COFF/Symbols.cpp:43
 if (demangled != demangleInput)
-  return prefix + demangle(demangleInput.str());
+  return prefix + demangle(demangleInput);
 return (prefix + prefixless).str();

probably should just be `return prefix + demangled;`



Comment at: llvm/docs/ReleaseNotes.rst:291
+  ``const std::string&``. Be careful passing temporaries into
+  ``llvm::demangle`` that don't outlive the expressing using
+  ``llvm::demangle``.

expression


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

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


[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-04-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: lld/ELF/Symbols.cpp:50
+std::string root = symName.str();
+return demangle(root);
+  }

`return demangle(symName.str());`

perhaps `return demangle(symName);` works as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

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


[clang] 84ec1f7 - Revert "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within macros"

2023-04-24 Thread via cfe-commits

Author: MalavikaSamak
Date: 2023-04-24T16:48:46-07:00
New Revision: 84ec1f7725d4f4575474b59467e598d7c5528a4e

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

LOG: Revert "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations 
for code within macros"

This reverts commit 9bd0db80784e30d40a4a65f1b47109c833f05b54.

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 3b58a51195f8..c53ecb52384d 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1117,44 +1117,42 @@ static std::string getAPIntText(APInt Val) {
 
 // Return the source location of the last character of the AST `Node`.
 template 
-static std::optional
-getEndCharLoc(const NodeTy *Node, const SourceManager ,
-  const LangOptions ) {
+static SourceLocation getEndCharLoc(const NodeTy *Node, const SourceManager 
,
+const LangOptions ) {
   unsigned TkLen = Lexer::MeasureTokenLength(Node->getEndLoc(), SM, LangOpts);
   SourceLocation Loc = Node->getEndLoc().getLocWithOffset(TkLen - 1);
 
-  if (Loc.isValid())
-return Loc;
-
-  return std::nullopt;
+  // We expect `Loc` to be valid. The location is obtained by moving forward
+  // from the beginning of the token 'len(token)-1' characters. The file ID of
+  // the locations within a token must be consistent.
+  assert(Loc.isValid() && "Expected the source location of the last"
+  "character of an AST Node to be always valid");
+  return Loc;
 }
 
 // Return the source location just past the last character of the AST `Node`.
 template 
-static std::optional getPastLoc(const NodeTy *Node,
-const SourceManager ,
-const LangOptions ) {
+static SourceLocation getPastLoc(const NodeTy *Node, const SourceManager ,
+ const LangOptions ) {
   SourceLocation Loc =
   Lexer::getLocForEndOfToken(Node->getEndLoc(), 0, SM, LangOpts);
 
-  if (Loc.isValid())
-return Loc;
-
-  return std::nullopt;
+  // We expect `Loc` to be valid as it is either associated to a file ID or
+  //   it must be the end of a macro expansion. (see
+  //   `Lexer::getLocForEndOfToken`)
+  assert(Loc.isValid() && "Expected the source location just past the last "
+  "character of an AST Node to be always valid");
+  return Loc;
 }
 
 // Return text representation of an `Expr`.
-static std::optional getExprText(const Expr *E,
-const SourceManager ,
-const LangOptions ) {
-  std::optional LastCharLoc = getPastLoc(E, SM, LangOpts);
-
-  if (LastCharLoc)
-return Lexer::getSourceText(
-CharSourceRange::getCharRange(E->getBeginLoc(), *LastCharLoc), SM,
-LangOpts);
+static StringRef getExprText(const Expr *E, const SourceManager ,
+ const LangOptions ) {
+  SourceLocation LastCharLoc = getPastLoc(E, SM, LangOpts);
 
-  return std::nullopt;
+  return Lexer::getSourceText(
+  CharSourceRange::getCharRange(E->getBeginLoc(), LastCharLoc), SM,
+  LangOpts);
 }
 
 std::optional
@@ -1193,24 +1191,12 @@ DerefSimplePtrArithFixableGadget::getFixits(const 
Strategy ) const {
 CharSourceRange StarWithTrailWhitespace =
 clang::CharSourceRange::getCharRange(DerefOp->getOperatorLoc(),
  LHS->getBeginLoc());
-
-std::optional LHSLocation = getPastLoc(LHS, SM, LangOpts);
-if (!LHSLocation)
-  return std::nullopt;
-
 CharSourceRange PlusWithSurroundingWhitespace =
-clang::CharSourceRange::getCharRange(*LHSLocation, RHS->getBeginLoc());
-
-std::optional AddOpLocation =
-getPastLoc(AddOp, SM, LangOpts);
-std::optional DerefOpLocation =
-getPastLoc(DerefOp, SM, LangOpts);
-
-if (!AddOpLocation || !DerefOpLocation)
-  return std::nullopt;
-
+clang::CharSourceRange::getCharRange(getPastLoc(LHS, SM, LangOpts),
+ RHS->getBeginLoc());
 CharSourceRange ClosingParenWithPrecWhitespace =
-clang::CharSourceRange::getCharRange(*AddOpLocation, *DerefOpLocation);
+clang::CharSourceRange::getCharRange(getPastLoc(AddOp, SM, LangOpts),
+ getPastLoc(DerefOp, SM, 
LangOpts));
 
 return FixItList{
 {FixItHint::CreateRemoval(StarWithTrailWhitespace),
@@ -1232,12 +1218,12 @@ 

[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-04-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 516580.
nickdesaulniers marked an inline comment as done.
nickdesaulniers retitled this revision from "[Demangle] use moar 
std::string_view" to "[Demangle] make llvm::demangle take std::string_view 
rather than const std::string&".
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.
Herald added subscribers: cfe-commits, pmatos, asb, aheejin, arichardson, 
sbc100, emaste.
Herald added a reviewer: jhenderson.
Herald added projects: clang, lld-macho.
Herald added a reviewer: lld-macho.

- prefer static linkage to anonymous namespace
- add release notes
- update most callsites


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  lld/COFF/Symbols.cpp
  lld/ELF/SymbolTable.cpp
  lld/ELF/Symbols.cpp
  lld/MachO/Symbols.cpp
  lld/wasm/Symbols.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
  llvm/lib/Demangle/Demangle.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/tools/llvm-objdump/ELFDump.cpp
  llvm/tools/llvm-objdump/XCOFFDump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-readobj/ELFDumper.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp

Index: llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
===
--- llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
+++ llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
@@ -107,7 +107,7 @@
   std::string OutputName = "'";
   OutputName += Name;
   OutputName += "'";
-  std::string DemangledName(demangle(Name.str()));
+  std::string DemangledName(demangle(Name));
   if (Name != DemangledName) {
 OutputName += " aka ";
 OutputName += DemangledName;
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -908,7 +908,7 @@
 }
 
 static std::string maybeDemangle(StringRef Name) {
-  return opts::Demangle ? demangle(std::string(Name)) : Name.str();
+  return opts::Demangle ? demangle(Name) : Name.str();
 }
 
 template 
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1548,7 +1548,7 @@
   if (Demangle) {
 // Fetch the demangled names and store them locally.
 for (const SymbolInfoTy  : SymbolsHere)
-  DemangledSymNamesHere.push_back(demangle(Symbol.Name.str()));
+  DemangledSymNamesHere.push_back(demangle(Symbol.Name));
 // Now we've finished modifying that vector, it's safe to make
 // a vector of StringRefs pointing into it.
 SymNamesHere.insert(SymNamesHere.begin(), DemangledSymNamesHere.begin(),
@@ -1909,9 +1909,8 @@
   if (TargetSym != nullptr) {
 uint64_t TargetAddress = TargetSym->Addr;
 uint64_t Disp = Target - TargetAddress;
-std::string TargetName = TargetSym->Name.str();
-if (Demangle)
-  TargetName = demangle(TargetName);
+std::string TargetName = Demangle ? demangle(TargetSym->Name)
+  : TargetSym->Name.str();
 
 *TargetOS << " <";
 if (!Disp) {
@@ -2511,10 +2510,8 @@
 
 if (NameOrErr) {
   outs() << " (csect:";
-  std::string SymName(NameOrErr.get());
-
-  if (Demangle)
-SymName = demangle(SymName);
+  std::string SymName =
+  Demangle ? demangle(*NameOrErr) : NameOrErr->str();
 
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, *SymRef),
@@ -2568,10 +2565,7 @@
 outs() << " .hidden";
   }
 
-  std::string SymName(Name);
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName = Demangle ? demangle(Name) : Name.str();
   if (O.isXCOFF() && SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, Symbol), SymName);
 
Index: llvm/tools/llvm-objdump/XCOFFDump.cpp
===
--- llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -32,10 +32,8 @@
   if (!SymNameOrErr)
 return SymNameOrErr.takeError();
 
-  std::string SymName = (*SymNameOrErr).str();
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName =
+  Demangle ? demangle(*SymNameOrErr) : SymNameOrErr->str();
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(Obj, *SymI), SymName);
 
Index: llvm/tools/llvm-objdump/ELFDump.cpp

[clang] 1d097ad - [clang] Fix -Wimplicit-fallthrough in UnsafeBufferUsage.cpp [NFC]

2023-04-24 Thread Jie Fu via cfe-commits

Author: Jie Fu
Date: 2023-04-25T07:34:39+08:00
New Revision: 1d097ad73b3fe38ff301f471356d15f093a2dbef

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

LOG: [clang] Fix -Wimplicit-fallthrough in UnsafeBufferUsage.cpp [NFC]

/Users/jiefu/llvm-project/clang/lib/Analysis/UnsafeBufferUsage.cpp:1272:5: 
error: unannotated fall-through between switch labels 
[-Werror,-Wimplicit-fallthrough]
case Strategy::Kind::Wontfix:
^
/Users/jiefu/llvm-project/clang/lib/Analysis/UnsafeBufferUsage.cpp:1272:5: 
note: insert 'LLVM_FALLTHROUGH;' to silence this warning
case Strategy::Kind::Wontfix:
^
LLVM_FALLTHROUGH;
/Users/jiefu/llvm-project/clang/lib/Analysis/UnsafeBufferUsage.cpp:1272:5: 
note: insert 'break;' to avoid fall-through
case Strategy::Kind::Wontfix:
^
break;
1 error generated.

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 037efc9c5d00..3b58a51195f8 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1269,6 +1269,7 @@ std::optional 
UPCStandalonePointerGadget::getFixits(const Strategy 
 return FixItList{{FixItHint::CreateInsertion(
 *EndOfOperand, ".data()")}};
 }
+  [[fallthrough]];
 case Strategy::Kind::Wontfix:
 case Strategy::Kind::Iterator:
 case Strategy::Kind::Array:



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


[PATCH] D148730: [C11] Allow initialization of an atomic-qualified pointer from a null pointer constant

2023-04-24 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

We bisected a build failure on the emscripten waterfall to this change:

https://ci.chromium.org/ui/p/emscripten-releases/builders/try/linux/b878293284529557/overview
https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/878293284529557/+/u/Build_Emscripten__upstream_/stdout

  cache:INFO: generating system library: 
sysroot/lib/wasm32-emscripten/libc-mt.a... (this will be cached in 
"/b/s/w/ir/x/w/install/emscripten/cache/sysroot/lib/wasm32-emscripten/libc-mt.a"
 for subsequent builds)
  /b/s/w/ir/x/w/install/emscripten/system/lib/pthread/emscripten_yield.c:10:26: 
error: cannot compile this static initializer yet
  static _Atomic pthread_t crashed_thread_id = NULL;
   ^
  1 error generated.
  emcc: error: '/b/s/w/ir/x/w/install/bin/clang -target 
wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm 
-combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm 
-disable-lsr -D__EMSCRIPTEN_SHARED_MEMORY__=1 -D__EMSCRIPTEN_WASM_WORKERS__=1 
-Werror=implicit-function-declaration 
--sysroot=/b/s/w/ir/x/w/install/emscripten/cache/sysroot -Xclang 
-iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -O2 -Wall 
-Werror -fno-unroll-loops -std=c99 -D_XOPEN_SOURCE=700 -Wno-unused-result -Os 
-fno-inline-functions -fno-builtin -Wno-ignored-attributes -Wno-macro-redefined 
-Wno-shift-op-parentheses -Wno-string-plus-int -Wno-missing-braces 
-Wno-logical-op-parentheses -Wno-bitwise-op-parentheses 
-Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label 
-Wno-pointer-sign -g3 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/libc/musl/src/internal 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/libc/musl/src/include 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/libc 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/pthread -pthread -DNDEBUG 
-ffile-prefix-map=/b/s/w/ir/x/w/install/emscripten=/emsdk/emscripten 
-fdebug-compilation-dir=/emsdk/emscripten -c -matomics -mbulk-memory 
/b/s/w/ir/x/w/install/emscripten/system/lib/pthread/emscripten_yield.c -o 
/b/s/w/ir/x/w/install/emscripten/cache/build/libc-mt-tmp/emscripten_yield.o' 
failed (returned 1)
  embuilder: error: Subprocess 11/1107 failed (returned 1)! (cmdline: 
/b/s/w/ir/x/w/install/emscripten/emcc -O2 -Wall -Werror -fno-unroll-loops 
-std=c99 -D_XOPEN_SOURCE=700 -Wno-unused-result -Os -fno-inline-functions 
-fno-builtin -Wno-ignored-attributes -Wno-macro-redefined 
-Wno-shift-op-parentheses -Wno-string-plus-int -Wno-missing-braces 
-Wno-logical-op-parentheses -Wno-bitwise-op-parentheses 
-Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label 
-Wno-pointer-sign -g -sSTRICT 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/libc/musl/src/internal 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/libc/musl/src/include 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/libc 
-I/b/s/w/ir/x/w/install/emscripten/system/lib/pthread -pthread -sWASM_WORKERS 
-DNDEBUG -ffile-prefix-map=/b/s/w/ir/x/w/install/emscripten=/emsdk/emscripten 
-fdebug-compilation-dir=/emsdk/emscripten -c 
/b/s/w/ir/x/w/install/emscripten/system/lib/pthread/emscripten_yield.c -o 
/b/s/w/ir/x/w/install/emscripten/cache/build/libc-mt-tmp/emscripten_yield.o)
  Exception thrown in build step.

Prior to this change this code compiled fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148730

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


[PATCH] D146450: [-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within macros.

2023-04-24 Thread Malavika Samak 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 rG9bd0db80784e: [-Wunsafe-buffer-usage] Bug fix: Handles the 
assertion violations for code… (authored by malavikasamak).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146450

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
@@ -2,6 +2,8 @@
 typedef int * Int_ptr_t;
 typedef int Int_t;
 
+#define DEFINE_PTR(X) int* ptr = (X);
+
 void local_array_subscript_simple() {
   int tmp;
   int *p = new int[10];
@@ -222,3 +224,28 @@
   tmp = r[j] + r[k]; // both `j` and `k` are unsigned so they must be non-negative
   tmp = r[(unsigned int)-1]; // a cast-to-unsigned-expression is also non-negative
 }
+
+void all_vars_in_macro() {
+  int* local;
+  DEFINE_PTR(local)
+  ptr[1] = 0;
+}
+
+void few_vars_in_macro() {
+  int* local;
+  DEFINE_PTR(local)
+  ptr[1] = 0;
+  int tmp;
+  ptr[2] = 30;
+  auto p = new int[10];
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span p"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:12-[[@LINE-2]]:12}:"{"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-3]]:23-[[@LINE-3]]:23}:", 10}"
+  tmp = p[5];
+  int val = *p;
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:14}:""
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"[0]"
+  val = *p + 30;
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:10}:""
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:11}:"[0]"
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1117,42 +1117,44 @@
 
 // Return the source location of the last character of the AST `Node`.
 template 
-static SourceLocation getEndCharLoc(const NodeTy *Node, const SourceManager ,
-const LangOptions ) {
+static std::optional
+getEndCharLoc(const NodeTy *Node, const SourceManager ,
+  const LangOptions ) {
   unsigned TkLen = Lexer::MeasureTokenLength(Node->getEndLoc(), SM, LangOpts);
   SourceLocation Loc = Node->getEndLoc().getLocWithOffset(TkLen - 1);
 
-  // We expect `Loc` to be valid. The location is obtained by moving forward
-  // from the beginning of the token 'len(token)-1' characters. The file ID of
-  // the locations within a token must be consistent.
-  assert(Loc.isValid() && "Expected the source location of the last"
-  "character of an AST Node to be always valid");
-  return Loc;
+  if (Loc.isValid())
+return Loc;
+
+  return std::nullopt;
 }
 
 // Return the source location just past the last character of the AST `Node`.
 template 
-static SourceLocation getPastLoc(const NodeTy *Node, const SourceManager ,
- const LangOptions ) {
+static std::optional getPastLoc(const NodeTy *Node,
+const SourceManager ,
+const LangOptions ) {
   SourceLocation Loc =
   Lexer::getLocForEndOfToken(Node->getEndLoc(), 0, SM, LangOpts);
 
-  // We expect `Loc` to be valid as it is either associated to a file ID or
-  //   it must be the end of a macro expansion. (see
-  //   `Lexer::getLocForEndOfToken`)
-  assert(Loc.isValid() && "Expected the source location just past the last "
-  "character of an AST Node to be always valid");
-  return Loc;
+  if (Loc.isValid())
+return Loc;
+
+  return std::nullopt;
 }
 
 // Return text representation of an `Expr`.
-static StringRef getExprText(const Expr *E, const SourceManager ,
- const LangOptions ) {
-  SourceLocation LastCharLoc = getPastLoc(E, SM, LangOpts);
+static std::optional getExprText(const Expr *E,
+const SourceManager ,
+const LangOptions ) {
+  std::optional LastCharLoc = getPastLoc(E, SM, LangOpts);
+
+  if (LastCharLoc)
+return Lexer::getSourceText(
+CharSourceRange::getCharRange(E->getBeginLoc(), *LastCharLoc), SM,
+LangOpts);
 
-  return Lexer::getSourceText(
-  CharSourceRange::getCharRange(E->getBeginLoc(), LastCharLoc), SM,
-  LangOpts);
+  return std::nullopt;
 }
 
 std::optional
@@ -1191,12 +1193,24 @@
 CharSourceRange StarWithTrailWhitespace =
 

[clang] 9bd0db8 - [-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within macros

2023-04-24 Thread via cfe-commits

Author: MalavikaSamak
Date: 2023-04-24T16:10:15-07:00
New Revision: 9bd0db80784e30d40a4a65f1b47109c833f05b54

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

LOG: [-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code 
within macros

When macros get expanded, the source location for the expanded code received by 
the Fixable
gadgets is invalid. We do not want to emit fixits for macro expanded code and 
it currently
crashes the analysis. This patch fixes the assertion violations that were 
introduced for
handling code with such invalid locations.

Reviewed by: NoQ, ziqingluo-90, jkorous

Differential revision: https://reviews.llvm.org/D146450

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 7a432ea5323a4..037efc9c5d009 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1117,42 +1117,44 @@ static std::string getAPIntText(APInt Val) {
 
 // Return the source location of the last character of the AST `Node`.
 template 
-static SourceLocation getEndCharLoc(const NodeTy *Node, const SourceManager 
,
-const LangOptions ) {
+static std::optional
+getEndCharLoc(const NodeTy *Node, const SourceManager ,
+  const LangOptions ) {
   unsigned TkLen = Lexer::MeasureTokenLength(Node->getEndLoc(), SM, LangOpts);
   SourceLocation Loc = Node->getEndLoc().getLocWithOffset(TkLen - 1);
 
-  // We expect `Loc` to be valid. The location is obtained by moving forward
-  // from the beginning of the token 'len(token)-1' characters. The file ID of
-  // the locations within a token must be consistent.
-  assert(Loc.isValid() && "Expected the source location of the last"
-  "character of an AST Node to be always valid");
-  return Loc;
+  if (Loc.isValid())
+return Loc;
+
+  return std::nullopt;
 }
 
 // Return the source location just past the last character of the AST `Node`.
 template 
-static SourceLocation getPastLoc(const NodeTy *Node, const SourceManager ,
- const LangOptions ) {
+static std::optional getPastLoc(const NodeTy *Node,
+const SourceManager ,
+const LangOptions ) {
   SourceLocation Loc =
   Lexer::getLocForEndOfToken(Node->getEndLoc(), 0, SM, LangOpts);
 
-  // We expect `Loc` to be valid as it is either associated to a file ID or
-  //   it must be the end of a macro expansion. (see
-  //   `Lexer::getLocForEndOfToken`)
-  assert(Loc.isValid() && "Expected the source location just past the last "
-  "character of an AST Node to be always valid");
-  return Loc;
+  if (Loc.isValid())
+return Loc;
+
+  return std::nullopt;
 }
 
 // Return text representation of an `Expr`.
-static StringRef getExprText(const Expr *E, const SourceManager ,
- const LangOptions ) {
-  SourceLocation LastCharLoc = getPastLoc(E, SM, LangOpts);
+static std::optional getExprText(const Expr *E,
+const SourceManager ,
+const LangOptions ) {
+  std::optional LastCharLoc = getPastLoc(E, SM, LangOpts);
+
+  if (LastCharLoc)
+return Lexer::getSourceText(
+CharSourceRange::getCharRange(E->getBeginLoc(), *LastCharLoc), SM,
+LangOpts);
 
-  return Lexer::getSourceText(
-  CharSourceRange::getCharRange(E->getBeginLoc(), LastCharLoc), SM,
-  LangOpts);
+  return std::nullopt;
 }
 
 std::optional
@@ -1191,12 +1193,24 @@ DerefSimplePtrArithFixableGadget::getFixits(const 
Strategy ) const {
 CharSourceRange StarWithTrailWhitespace =
 clang::CharSourceRange::getCharRange(DerefOp->getOperatorLoc(),
  LHS->getBeginLoc());
+
+std::optional LHSLocation = getPastLoc(LHS, SM, LangOpts);
+if (!LHSLocation)
+  return std::nullopt;
+
 CharSourceRange PlusWithSurroundingWhitespace =
-clang::CharSourceRange::getCharRange(getPastLoc(LHS, SM, LangOpts),
- RHS->getBeginLoc());
+clang::CharSourceRange::getCharRange(*LHSLocation, RHS->getBeginLoc());
+
+std::optional AddOpLocation =
+getPastLoc(AddOp, SM, LangOpts);
+std::optional DerefOpLocation =
+getPastLoc(DerefOp, SM, LangOpts);
+
+if (!AddOpLocation || !DerefOpLocation)
+  return std::nullopt;
+
 CharSourceRange ClosingParenWithPrecWhitespace =
-

[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D147844#4293743 , @cjdb wrote:

> In D147844#4293693 , @dblaikie 
> wrote:
>
>>> I think some of the cases are ambiguous while others are not.
>>
>> Data would be good to have - if this assessment is true, we'd expect this to 
>> bear out in terms of bug finding, yeah? (that the cases you find to be 
>> ambiguous turn up as real bugs with some significant frequency in a 
>> codebase?)
>
> I disagree that there's a need for bugs to add this warning. Reading 
> ambiguous-but-correct code isn't going to be buggy, but it is going to cause 
> readability issues for any reviewers or maintainers.

That's generally been the bar we use for evaluating warnings - does it find 
bugs. Especially because if it doesn't, it's unlikely to be turned on on large 
pre-existing codebases owing to the cost of cleaning them up with limited value 
in terms of improving readability but not finding any bugs. (& goes 
hand-in-hand with the general policy of not adding off-by-default warnings, 
because they don't get used much and come at a cost to clang's codebase (& some 
(death-by-a-thousand-cuts) cost to compile time performance, even when the 
warning is disabled))

Readability improvements that don't cross the threshold to be the cause of a 
significant number of bugs are moreso the domain of clang-tidy, not clang 
warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D149009: [Sema]Select correct lexical context during template instantiate

2023-04-24 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3598
+  FD->isDefined(FDFriend, true) &&
+  FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) {
+// if Function defined by inline friend, use inline fried as DeclContext

erichkeane wrote:
> So in what case would the currently-instantiated definition NOT also be a 
> friend?  I would think this last condition should be able to be an assert 
> instead.
Last condition cannot be an assert, define and declare in difference place is 
common case, what we need to identifier in here is inlined friend define.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3601
+FD = const_cast(FDFriend);
+Owner = FD->getDescribedFunctionTemplate()->getLexicalDeclContext();
+  }

erichkeane wrote:
> I THINK this should just be:
> `Owner = FD->getLexicalDeclContext()` here.  
The old `Owner` is `FunctionTemplate->getLexicalDeclContext()`. So I think we 
should use same level owner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149009

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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.h:209
 
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   std::map CoveragePrefixMap;

scott.linder wrote:
> What benefit does forcing allocation have? Why not use the default, or switch 
> to `std::vector`?
This doesn't force allocation. I use inline element size 0 to make the member 
variable smaller than a `std::vector`.
`std::vector` likely compiles to larger code.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:72-79
 CGDebugInfo::CGDebugInfo(CodeGenModule )
 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
   DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
   DBuilder(CGM.getModule()) {
-  for (const auto  : CGM.getCodeGenOpts().DebugPrefixMap)
-DebugPrefixMap[KV.first] = KV.second;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().DebugPrefixMap)
+DebugPrefixMap.emplace_back(From, To);
   CreateCompileUnit();

scott.linder wrote:
> Can you use the member-initializer-list here?
No, this doesn't work. We convert a vector of `std::string` to a vector of 
`StringRef`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D148981: [clang][Interp] PointerToBoolean casts

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148981

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


[PATCH] D149059: [clang][Interp] Fix zero-init of float and pointer arrays

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149059

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


[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38ecb9767c14: [NFC][clang] Fix Coverity bugs with 
AUTO_CAUSES_COPY (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149074

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -389,7 +389,7 @@
   Mods = getNextModifiers(Proto, Pos);
 }
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it 
rather
   // than use a standard declaration, so that SemaChecking can range check
   // the immediate passed by the user.
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -447,7 +447,7 @@
   if (!CXXRecord)
 return false;
 
-  for (auto BaseSpecifier : CXXRecord->bases()) {
+  for (const auto  : CXXRecord->bases()) {
 if (!foundStarOperator)
   foundStarOperator = IsOverloadedOperatorPresent(
   BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2806,7 +2806,7 @@
 // Determines whether 'Ranges' intersects with ('Start', 'End').
 static bool affectsRange(ArrayRef Ranges, unsigned Start,
  unsigned End) {
-  for (auto Range : Ranges) {
+  for (const auto  : Ranges) {
 if (Range.getOffset() < End &&
 Range.getOffset() + Range.getLength() > Start) {
   return true;
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3757,7 +3757,7 @@
   Classes.front().initialize(/*Parent=*/nullptr, /*Specifier=*/nullptr);
   detectAmbiguousBases(Classes);
   int Flags = 0;
-  for (auto Class : Classes) {
+  for (const MSRTTIClass  : Classes) {
 if (Class.RD->getNumBases() > 1)
   Flags |= HasBranchingHierarchy;
 // Note: cl.exe does not calculate "HasAmbiguousBases" correctly.  We
Index: clang/lib/CodeGen/CGGPUBuiltin.cpp
===
--- clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -189,7 +189,7 @@
/* ParamsToSkip = */ 0);
 
   SmallVector Args;
-  for (auto A : CallArgs) {
+  for (const auto  : CallArgs) {
 // We don't know how to emit non-scalar varargs.
 if (!A.getRValue(*this).isScalar()) {
   CGM.ErrorUnsupported(E, "non-scalar arg to printf");
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -663,7 +663,7 @@
 
 ExprDependence clang::computeDependence(DesignatedInitExpr *E) {
   auto Deps = E->getInit()->getDependence();
-  for (auto D : E->designators()) {
+  for (const auto  : E->designators()) {
 auto DesignatorDeps = ExprDependence::None;
 if (D.isArrayDesignator())
   DesignatorDeps |= E->getArrayIndex(D)->getDependence();
Index: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
===
--- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -179,7 +179,7 @@
   return true;
 
 // Skip methods in records.
-for (auto P : Context.getParents(*Method)) {
+for (const auto  : Context.getParents(*Method)) {
   if (P.template get())
 return true;
 }


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -389,7 +389,7 @@
   Mods = getNextModifiers(Proto, Pos);
 }
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it rather
   // than use a standard declaration, so that SemaChecking can range check
   // the immediate passed by the user.
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -447,7 +447,7 @@
   if 

[clang] 38ecb97 - [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-04-24T14:52:55-07:00
New Revision: 38ecb9767c1485abe0eb210ceeb827a884bc55c9

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

LOG: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

Reported by Coverity:
AUTO_CAUSES_COPY
Unnecessary object copies can affect performance.

1. Inside "ExtractAPIVisitor.h" file, in 
clang::extractapi::impl::ExtractAPIVisitorBase<::BatchExtractAPIVisitor>::VisitFunctionDecl(clang::FunctionDecl
 const *): Using the auto keyword without an & causes the copy of an object of 
type DynTypedNode.

2. Inside "NeonEmitter.cpp" file, in 
::Intrinsic::Intrinsic(llvm::Record *, llvm::StringRef, 
llvm::StringRef, ::TypeSpec, ::TypeSpec, 
::ClassKind, llvm::ListInit *, ::NeonEmitter &, 
llvm::StringRef, llvm::StringRef, bool, bool): Using the auto keyword without 
an & causes the copy of an object of type Type.

3. Inside "MicrosoftCXXABI.cpp" file, in 
::MSRTTIBuilder::getClassHierarchyDescriptor(): Using the auto keyword 
without an & causes the copy of an object of type MSRTTIClass.

4. Inside "CGGPUBuiltin.cpp" file, in 
clang::CodeGen::CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(clang::CallExpr 
const *): Using the auto keyword without an & causes the copy of an object of 
type CallArg.

5. Inside "SemaDeclAttr.cpp" file, in 
threadSafetyCheckIsSmartPointer(clang::Sema &, clang::RecordType const *): 
Using the auto keyword without an & causes the copy of an object of type 
CXXBaseSpecifier.

6. Inside "ComputeDependence.cpp" file, in 
clang::computeDependence(clang::DesignatedInitExpr *): Using the auto keyword 
without an & causes the copy of an object of type Designator.

7. Inside "Format.cpp" file, In 
clang::format::affectsRange(llvm::ArrayRef, unsigned 
int, unsigned int): Using the auto keyword without an & causes the copy of an 
object of type Range.

Reviewed By: tahonermann

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

Added: 


Modified: 
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/CodeGen/CGGPUBuiltin.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Format/Format.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h 
b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
index 57f2c413545c0..8b3721a4d7adb 100644
--- a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -179,7 +179,7 @@ bool ExtractAPIVisitorBase::VisitFunctionDecl(
   return true;
 
 // Skip methods in records.
-for (auto P : Context.getParents(*Method)) {
+for (const auto  : Context.getParents(*Method)) {
   if (P.template get())
 return true;
 }

diff  --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index c561f0462ed05..5a301c10aca6d 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -663,7 +663,7 @@ ExprDependence 
clang::computeDependence(GenericSelectionExpr *E,
 
 ExprDependence clang::computeDependence(DesignatedInitExpr *E) {
   auto Deps = E->getInit()->getDependence();
-  for (auto D : E->designators()) {
+  for (const auto  : E->designators()) {
 auto DesignatorDeps = ExprDependence::None;
 if (D.isArrayDesignator())
   DesignatorDeps |= E->getArrayIndex(D)->getDependence();

diff  --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp 
b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index c39e0cc75f2d3..1183c2d7b5437 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -189,7 +189,7 @@ RValue 
CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E) {
/* ParamsToSkip = */ 0);
 
   SmallVector Args;
-  for (auto A : CallArgs) {
+  for (const auto  : CallArgs) {
 // We don't know how to emit non-scalar varargs.
 if (!A.getRValue(*this).isScalar()) {
   CGM.ErrorUnsupported(E, "non-scalar arg to printf");

diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index c5218129b0fb7..e5a2b35c0b396 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3757,7 +3757,7 @@ llvm::GlobalVariable 
*MSRTTIBuilder::getClassHierarchyDescriptor() {
   Classes.front().initialize(/*Parent=*/nullptr, /*Specifier=*/nullptr);
   detectAmbiguousBases(Classes);
   int Flags = 0;
-  for (auto Class : Classes) {
+  for (const MSRTTIClass  : Classes) {
 if (Class.RD->getNumBases() > 1)
   Flags |= HasBranchingHierarchy;
 // Note: cl.exe does not calculate "HasAmbiguousBases" correctly.  We

diff  --git a/clang/lib/Format/Format.cpp 

[PATCH] D149084: [clang-tidy] Added bugprone-multi-level-implicit-pointer-conversion check

2023-04-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/multi-level-implicit-pointer-conversion.rst:43
+safety of the conversion before using an explicit cast.
+This extra level of caution can help catch potential issues early on in the
+development process, improving the overall reliability and maintainability of

Should continue previous line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149084

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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-24 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.h:209
 
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   std::map CoveragePrefixMap;

What benefit does forcing allocation have? Why not use the default, or switch 
to `std::vector`?



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:72-79
 CGDebugInfo::CGDebugInfo(CodeGenModule )
 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
   DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
   DBuilder(CGM.getModule()) {
-  for (const auto  : CGM.getCodeGenOpts().DebugPrefixMap)
-DebugPrefixMap[KV.first] = KV.second;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().DebugPrefixMap)
+DebugPrefixMap.emplace_back(From, To);
   CreateCompileUnit();

Can you use the member-initializer-list here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-24 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D147844#4293693 , @dblaikie wrote:

>> I think some of the cases are ambiguous while others are not.
>
> Data would be good to have - if this assessment is true, we'd expect this to 
> bear out in terms of bug finding, yeah? (that the cases you find to be 
> ambiguous turn up as real bugs with some significant frequency in a codebase?)

I disagree that there's a need for bugs to add this warning. Reading 
ambiguous-but-correct code isn't going to be buggy, but it is going to cause 
readability issues for any reviewers or maintainers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D148992: [clang-repl] Fix dynamic library test to avoid cstdio and linker

2023-04-24 Thread Han Zhu via Phabricator via cfe-commits
zhuhan0 accepted this revision.
zhuhan0 added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148992

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


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

I'm afraid I have been bitten by this very issue several more than once. I can 
only assume I'm not the only one. so this looks like a nice improvement.
There are only a few changes in libc++ so it seems fairly low noise.

Did you try to compile llvm with it? I'd be curious to see how many time these 
occurs in clang own diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D149098: [Clang] Add tests and mark as implemented WG14 N2728 (char16_t & char32_t string literals shall be UTF-16 & UTF-32)

2023-04-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

LGTM (modulo nitpicking comment)




Comment at: clang/test/Lexer/char-literal.cpp:49
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif

I think these tests would be clearer with a different verify tag rather than an 
ifdef, but it's kinda preexisting so feel free to ignore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149098

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


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I think some of the cases are ambiguous while others are not.

Data would be good to have - if this assessment is true, we'd expect this to 
bear out in terms of bug finding, yeah? (that the cases you find to be 
ambiguous turn up as real bugs with some significant frequency in a codebase?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D148945: [clang] Remove workaround for old LLVM_ENABLE_PROJECTS=libcxx build

2023-04-24 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5084ba395e48: [clang] Remove workaround for old 
LLVM_ENABLE_PROJECTS=libcxx build (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148945

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -332,13 +332,6 @@
 
   Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
 
-  // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
-  // libc++.so in D.Dir+"/../lib/". Detect this path.
-  // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
-  if (StringRef(D.Dir).startswith(SysRoot) &&
-  D.getVFS().exists(D.Dir + "/../lib/libc++.so"))
-addPathIfExists(D, D.Dir + "/../lib", Paths);
-
   addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
   addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
 }


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -332,13 +332,6 @@
 
   Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
 
-  // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
-  // libc++.so in D.Dir+"/../lib/". Detect this path.
-  // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
-  if (StringRef(D.Dir).startswith(SysRoot) &&
-  D.getVFS().exists(D.Dir + "/../lib/libc++.so"))
-addPathIfExists(D, D.Dir + "/../lib", Paths);
-
   addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
   addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5084ba3 - [clang] Remove workaround for old LLVM_ENABLE_PROJECTS=libcxx build

2023-04-24 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2023-04-24T16:44:05-04:00
New Revision: 5084ba395e487adee67ba38cc5c68ff7e052e37c

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

LOG: [clang] Remove workaround for old LLVM_ENABLE_PROJECTS=libcxx build

We don't support the LLVM_ENABLE_PROJECTS=libcxx build anymore (and have
not for over a year), so it should be fine to remove this workaround now.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 8ce5a16bfe0d..1fbd26aed596 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -332,13 +332,6 @@ Linux::Linux(const Driver , const llvm::Triple , 
const ArgList )
 
   Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
 
-  // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
-  // libc++.so in D.Dir+"/../lib/". Detect this path.
-  // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
-  if (StringRef(D.Dir).startswith(SysRoot) &&
-  D.getVFS().exists(D.Dir + "/../lib/libc++.so"))
-addPathIfExists(D, D.Dir + "/../lib", Paths);
-
   addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
   addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
 }



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


[PATCH] D149098: [Clang] Add tests and mark as implemented WG14 N2728 (char16_t & char32_t string literals shall be UTF-16 & UTF-32)

2023-04-24 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/test/Lexer/char-literal.cpp:2-5
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++17 
-Wfour-char-constants -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++20 
-Wfour-char-constants -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c 
-Wfour-char-constants -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c2x -x c 
-Wfour-char-constants -fsyntax-only -verify %s

C++17 and C2x are added so that UTF-8 character literals are exercised. C++20 
is added to exercise the change in type of UTF-8 literals due to `char8_t`.



Comment at: clang/test/Lexer/char-literal.cpp:48-50
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif

C apparently prefers that programmers use actual control characters rather than 
naming them via UCNs, even in character and string literals. I know not why, 
but that is what N3096 6.4.3 (Universal character names) says.



Comment at: clang/test/Lexer/char-literal.cpp:73-99
+_Static_assert((unsigned char)u8"\U0080"[0] == (unsigned char)0xC2, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif
+_Static_assert((unsigned char)u8"\U0080"[1] == (unsigned char)0x80, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}

The `unsigned char` casts are to work around conversion issues with (signed) 
`char` and the change of type to `char8_t` in C++20 vs C++17.



Comment at: clang/www/c_status.html:932
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2728.htm;>N2728
-  Unknown
+  Yes
 

As far as I can tell, no changes are needed for Clang to implement N2728; 
UTF-16 and UTF-32 have been used for `char16_t` and `char32_t` literals since 
their introduction in C11 and C++11, so there is no specific Clang version to 
mark as a conformance point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149098

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


[PATCH] D149003: [clang] Add test for CWG1821

2023-04-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149003

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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

2023-04-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/Sema/warn-tautological-compare.c:102
+}
\ No newline at end of file


Please add back the missing newline



Comment at: clang/test/SemaCXX/constant-expression-cxx2a.cpp:252
   // ... but in the complete object, the same is not true, so the runtime 
fails.
-  static_assert(dynamic_cast(static_cast()) == nullptr);
+  static_assert(dynamic_cast(static_cast()) == 
nullptr); // expected-warning {{comparison of address of 'g' equal to a null 
pointer is always false}}
 

I don't believe we should be emitting a diagnostic for this case. The 
`static_assert` passes. CC @aaron.ballman 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149000

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


[PATCH] D149098: [Clang] Add tests and mark as implemented WG14 N2728 (char16_t & char32_t string literals shall be UTF-16 & UTF-32)

2023-04-24 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann created this revision.
tahonermann added reviewers: aaron.ballman, erichkeane, cor3ntin.
Herald added a project: All.
tahonermann requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change expands testing of UTF-8, UTF-16, and UTF-32 character and string 
literals as validation that WG14 N2728 (char16_t & char32_t string literals 
shall be UTF-16 & UTF-32) has been implemented.

WG14 N2728: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2728.htm


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149098

Files:
  clang/test/Lexer/char-literal.cpp
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -929,7 +929,7 @@
 
   char16_t & char32_t string literals shall be UTF-16 & UTF-32
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2728.htm;>N2728
-  Unknown
+  Yes
 
 
   IEC 60559 binding
Index: clang/test/Lexer/char-literal.cpp
===
--- clang/test/Lexer/char-literal.cpp
+++ clang/test/Lexer/char-literal.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++17 -Wfour-char-constants -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++20 -Wfour-char-constants -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -Wfour-char-constants -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c2x -x c -Wfour-char-constants -fsyntax-only -verify %s
 
 #ifndef __cplusplus
 typedef __WCHAR_TYPE__ wchar_t;
@@ -38,3 +41,115 @@
 #ifdef __cplusplus
 // expected-error@-2 {{too long}}
 #endif
+
+// UTF-8 character literal code point ranges.
+#if __cplusplus >= 201703L || __STDC_VERSION__ >= 201710L
+_Static_assert(u8'\U' == 0x00, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif
+_Static_assert(u8'\U007F' == 0x7F, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif
+_Static_assert(u8'\U0080', "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#else
+// expected-error@-4 {{character too large for enclosing character literal type}}
+#endif
+_Static_assert((unsigned char)u8'\xFF' == (unsigned char)0xFF, "");
+#endif
+
+// UTF-8 string literal code point ranges.
+_Static_assert(u8"\U"[0] == 0x00, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif
+_Static_assert(u8"\U007F"[0] == 0x7F, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif
+_Static_assert((unsigned char)u8"\U0080"[0] == (unsigned char)0xC2, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif
+_Static_assert((unsigned char)u8"\U0080"[1] == (unsigned char)0x80, "");
+#ifndef __cplusplus
+// expected-error@-2 {{universal character name refers to a control character}}
+#endif
+_Static_assert((unsigned char)u8"\U07FF"[0] == (unsigned char)0xDF, "");
+_Static_assert((unsigned char)u8"\U07FF"[1] == (unsigned char)0xBF, "");
+_Static_assert((unsigned char)u8"\U0800"[0] == (unsigned char)0xE0, "");
+_Static_assert((unsigned char)u8"\U0800"[1] == (unsigned char)0xA0, "");
+_Static_assert((unsigned char)u8"\U0800"[2] == (unsigned char)0x80, "");
+_Static_assert(u8"\UD800"[0], ""); // expected-error {{invalid universal character}}
+_Static_assert(u8"\UDFFF"[0], ""); // expected-error {{invalid universal character}}
+_Static_assert((unsigned char)u8"\U"[0] == (unsigned char)0xEF, "");
+_Static_assert((unsigned char)u8"\U"[1] == (unsigned char)0xBF, "");
+_Static_assert((unsigned char)u8"\U"[2] == (unsigned char)0xBF, "");
+_Static_assert((unsigned char)u8"\U0001"[0] == (unsigned char)0xF0, "");
+_Static_assert((unsigned char)u8"\U0001"[1] == (unsigned char)0x90, "");
+_Static_assert((unsigned char)u8"\U0001"[2] == (unsigned char)0x80, "");
+_Static_assert((unsigned char)u8"\U0001"[3] == (unsigned char)0x80, "");
+_Static_assert((unsigned char)u8"\U0010"[0] == (unsigned char)0xF4, "");
+_Static_assert((unsigned char)u8"\U0010"[1] == (unsigned char)0x8F, "");
+_Static_assert((unsigned char)u8"\U0010"[2] == (unsigned char)0xBF, "");
+_Static_assert((unsigned char)u8"\U0010"[3] == (unsigned char)0xBF, "");
+_Static_assert(u8"\U0011"[0], ""); // expected-error {{invalid universal character}}
+
+#if !defined(__STDC_UTF_16__)
+#error __STDC_UTF_16__ is not defined.

[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D149074#4293543 , @tahonermann 
wrote:

> Looks good to me

Thank you @tahonermann


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

https://reviews.llvm.org/D149074

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


[PATCH] D141389: [DFSAN] Add support for strnlen, strncat, strsep, sscanf and _tolower

2023-04-24 Thread Andrew via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74f00516e5ce: [DFSAN] Add support for strsep. (authored by 
tkuchta, committed by browneee).
Herald added a subscriber: Sanitizers.

Changed prior to commit:
  https://reviews.llvm.org/D141389?vs=51=516515#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141389

Files:
  compiler-rt/lib/dfsan/dfsan_custom.cpp
  compiler-rt/lib/dfsan/done_abilist.txt
  compiler-rt/test/dfsan/custom.cpp

Index: compiler-rt/test/dfsan/custom.cpp
===
--- compiler-rt/test/dfsan/custom.cpp
+++ compiler-rt/test/dfsan/custom.cpp
@@ -1630,6 +1630,51 @@
 #endif
 }
 
+void test_strsep() {
+  char *s = strdup("Hello world/");
+  char *delim = strdup(" /");
+
+  char *p_s = s;
+  char *base = s;
+  char *p_delim = delim;
+
+  // taint delim bytes
+  dfsan_set_label(i_label, p_delim, strlen(p_delim));
+  // taint delim pointer
+  dfsan_set_label(j_label, _delim, sizeof(p_delim));
+  // taint the string data bytes
+  dfsan_set_label(k_label, s, 5);
+  // taint the string pointer
+  dfsan_set_label(m_label, _s, sizeof(p_s));
+
+  char *rv = strsep(_s, p_delim);
+  assert(rv == [0]);
+#ifdef STRICT_DATA_DEPENDENCIES
+  ASSERT_LABEL(rv, m_label);
+  ASSERT_READ_LABEL(rv, strlen(rv), k_label);
+#else
+  ASSERT_LABEL(rv, dfsan_union(dfsan_union(i_label, j_label),
+   dfsan_union(k_label, m_label)));
+  ASSERT_INIT_ORIGIN_EQ_ORIGIN(, p_s);
+#endif
+
+  // taint the remaining string's pointer
+  char **pp_s = _s;
+  char **pp_s_base = pp_s;
+  dfsan_set_label(n_label, pp_s, sizeof(pp_s));
+
+  rv = strsep(pp_s, p_delim);
+
+  assert(rv == [6]);
+#ifdef STRICT_DATA_DEPENDENCIES
+  ASSERT_LABEL(rv, n_label);
+  ASSERT_INIT_ORIGIN_EQ_ORIGIN(, *pp_s);
+#else
+  ASSERT_LABEL(rv, dfsan_union(dfsan_union(i_label, j_label), n_label));
+  ASSERT_INIT_ORIGIN_EQ_ORIGIN(, *pp_s);
+#endif
+}
+
 void test_memchr() {
   char str1[] = "str1";
   dfsan_set_label(i_label, [3], 1);
@@ -2044,6 +2089,7 @@
   test_strncmp();
   test_strncpy();
   test_strpbrk();
+  test_strsep();
   test_strrchr();
   test_strstr();
   test_strtod();
Index: compiler-rt/lib/dfsan/done_abilist.txt
===
--- compiler-rt/lib/dfsan/done_abilist.txt
+++ compiler-rt/lib/dfsan/done_abilist.txt
@@ -283,6 +283,7 @@
 fun:strpbrk=custom
 fun:strrchr=custom
 fun:strstr=custom
+fun:strsep=custom
 
 # Functions which take action based on global state, such as running a callback
 # set by a separate function.
Index: compiler-rt/lib/dfsan/dfsan_custom.cpp
===
--- compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -204,6 +204,57 @@
   return const_cast(ret);
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE char *__dfsw_strsep(char **s, const char *delim,
+  dfsan_label s_label,
+  dfsan_label delim_label,
+  dfsan_label *ret_label) {
+  dfsan_label base_label = dfsan_read_label(s, sizeof(*s));
+  char *base = *s;
+  char *res = strsep(s, delim);
+  if (res != *s) {
+char *token_start = res;
+int token_length = strlen(res);
+// the delimiter byte has been set to NULL
+dfsan_set_label(0, token_start + token_length, 1);
+  }
+
+  if (flags().strict_data_dependencies) {
+*ret_label = res ? base_label : 0;
+  } else {
+size_t s_bytes_read = (res ? strlen(res) : strlen(base)) + 1;
+*ret_label = dfsan_union(
+dfsan_union(base_label, dfsan_read_label(base, sizeof(s_bytes_read))),
+dfsan_union(dfsan_read_label(delim, strlen(delim) + 1),
+dfsan_union(s_label, delim_label)));
+  }
+
+  return res;
+}
+
+SANITIZER_INTERFACE_ATTRIBUTE char *__dfso_strsep(
+char **s, const char *delim, dfsan_label s_label, dfsan_label delim_label,
+dfsan_label *ret_label, dfsan_origin s_origin, dfsan_origin delim_origin,
+dfsan_origin *ret_origin) {
+  dfsan_origin base_origin = dfsan_read_origin_of_first_taint(s, sizeof(*s));
+  char *res = __dfsw_strsep(s, delim, s_label, delim_label, ret_label);
+  if (flags().strict_data_dependencies) {
+if (res)
+  *ret_origin = base_origin;
+  } else {
+if (*ret_label) {
+  if (base_origin) {
+*ret_origin = base_origin;
+  } else {
+dfsan_origin o =
+dfsan_read_origin_of_first_taint(delim, strlen(delim) + 1);
+*ret_origin = o ? o : (s_label ? s_origin : delim_origin);
+  }
+}
+  }
+
+  return res;
+}
+
 static int dfsan_memcmp_bcmp(const void *s1, const void *s2, size_t n,
  size_t *bytes_read) {
   const char *cs1 = (const char *) s1, *cs2 = (const char *) s2;

[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

Looks good to me, thanks @Manna!




Comment at: clang/utils/TableGen/NeonEmitter.cpp:392
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it 
rather

Manna wrote:
> tahonermann wrote:
> > The element type is `Type` (`clang/utils/TableGen/NeonEmitter.cpp`). It 
> > holds a `TypeSpec`, an `enum` value, 5 `bool` values, and 3 `unsigned` 
> > values. I'm ambivalent.
> Thanks @tahonermann for reviews and feedbacks. 
> 
> >>The element type is Type (clang/utils/TableGen/NeonEmitter.cpp). It holds a 
> >>TypeSpec, an enum value, 5 bool values, and 3 unsigned values.
> 
> Yes, I had mixed feeling about this one too. 
> 
> Line 362 in clang/utils/TableGen/NeonEmitter.cpp, we are passing it as a 
> reference. 
> 
>  for (const auto  : Types){
>   if (T.isVector() && T.getNumElements() > 1)
> return false;
> }
> return true;
>   }
> 
Consistency is good then.


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

https://reviews.llvm.org/D149074

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


[PATCH] D134821: [flang][driver] Allow main program to be in an archive

2023-04-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thanks for all the great effort, @ekieri !

@sunshaoce , mostly makes sense, just a few small suggestions. @peixin , wdyt?




Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:601-603
+// A Fortran main program will be lowered to a function named _QQmain. Make
+// _QQmain an undefined symbol, so that we include it even if it hides
+// inside an archive.

WDYT>



Comment at: flang/test/Driver/link-c-main.c:3
+Test that an object file with a c main function can be linked to an executable
+by flang.
+





Comment at: flang/test/Driver/link-c-main.c:5
+
+For now, this test only covers the Gnu toolchain on linux.
+





Comment at: flang/test/Driver/linker-flags.f90:15
 
+! Check linker invocation to generate shared object (only GNU toolchain for 
now)
+! RUN: %flang -### -flang-experimental-exec -shared -target x86_64-linux-gnu 
%S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU-SHARD 
--implicit-check-not _QQmain

Please, could you clarify that in this case `_QQmain` should not be flagged as 
undefined?



Comment at: flang/test/Driver/linker-flags.f90:61
+! Linker invocation to generate a shared object
+! GNU-SHARD-LABEL:  "{{.*}}ld"
+! GNU-SHARD-SAME: "[[object_file]]"




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134821

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


[PATCH] D149088: [clang-format] Add run-clang-format.py script.

2023-04-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang/tools/run-clang-format.py:1
+#!/usr/bin/env python3
+#

Looks like Windows en of lines were mixed with UNIX ones.



Comment at: clang/tools/run-clang-format.py:26
+
+from __future__ import print_function
+import argparse

Is it really necessary since Python 3 is specified explicitly?



Comment at: clang/tools/run-clang-format.py:30
+import os
+import multiprocessing
+import queue

Should be before `os`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149088

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


[PATCH] D149088: [clang-format] Add run-clang-format.py script.

2023-04-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I guess I need to add a test in a similar that run-clang-tidy is tested, but 
I'd like to gather some initial review still.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149088

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


[PATCH] D149088: [clang-format] Add run-clang-format.py script.

2023-04-24 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
curdeius requested review of this revision.
Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please 
try to ensure all code changes have a unit test (unless this is an `NFC` or 
refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja 
FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests 
rather than `EXPECT_EQ` as this will ensure you change is tolerant to random 
whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can 
happen if you are trying to improve the annotation phase to ensure we are 
correctly identifying the type of a token, please add a token annotator test in 
`TokenAnnotatorTest.cpp`


Fixes https://github.com/llvm/llvm-project/issues/62108.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149088

Files:
  clang/tools/CMakeLists.txt
  clang/tools/run-clang-format.py

Index: clang/tools/run-clang-format.py
===
--- /dev/null
+++ clang/tools/run-clang-format.py
@@ -0,0 +1,167 @@
+#!/usr/bin/env python3
+#
+#===- run-clang-format.py - Parallel clang-format runner *- python -*--===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===---===#
+
+"""
+Parallel clang-format runner
+==
+
+Runs clang-format over all files in given directories. Requires clang-format in $PATH.
+
+Example invocations.
+- Run clang-format on all files in the current working directory.
+run-clang-format.py
+
+- Run clang-format on all files in the chosen directories.
+run-clang-format.py dir1 dir2 dir3
+"""
+
+
+from __future__ import print_function
+import argparse
+import fnmatch
+import os
+import multiprocessing
+import queue
+import subprocess
+import sys
+import threading
+
+
+def glob_files(args):
+files = []
+
+extensions = args.extensions.split(',')
+
+for directory in args.directories:
+for root, _, filenames in os.walk(directory):
+for ext in extensions:
+for filename in fnmatch.filter(filenames, '*.' + ext):
+files.append(os.path.join(root, filename))
+
+return files
+
+
+def parse_args(argv=None):
+if argv is None:
+argv = sys.argv
+parser = argparse.ArgumentParser(
+description='Runs clang-format over all files in given directories.'
+' Requires clang-format in PATH.')
+parser.add_argument('--clang-format-binary', metavar='PATH',
+default='clang-format',
+help='path to clang-format binary')
+parser.add_argument('-e', '--extensions', dest='extensions',
+help='comma-delimited list of extensions used to glob source files',
+default="c,cc,cpp,cxx,c++,h,hh,hpp,hxx,h++")
+parser.add_argument('-style',
+help='formatting style',
+default="file")
+parser.add_argument('--no-inplace', dest='inplace', action='store_false',
+help='do not format files inplace, but write output to the console'
+' (useful for debugging)',
+default=True)
+parser.add_argument('-j', metavar='THREAD_COUNT', type=int, default=0,
+help='number of clang-format instances to be run in parallel')
+parser.add_argument('-v', '--verbose', action='store_true',
+help='output verbose comments')
+parser.add_argument(metavar='DIRPATH', dest='directories', nargs='*',
+help='path(s) used to glob source files')
+
+args = parser.parse_args(argv[1:])
+
+if not args.directories:
+args.directories = [os.getcwd()]
+
+check_clang_format_binary(args)
+
+return args
+
+
+def _get_format_invocation(args, filename):
+invocation = [args.clang_format_binary]
+invocation.append('-style=' + args.style)
+if args.inplace:
+invocation.append('-i')
+
+invocation.append(filename)
+return invocation
+
+
+def check_clang_format_binary(args):
+"""Checks if invoking supplied clang-format binary works."""
+try:
+subprocess.check_output([args.clang_format_binary, '--version'])
+except OSError:
+print('Unable to run clang-format. Is clang-format '
+  'binary correctly specified?', 

[PATCH] D146595: [clang] Add "debug_trampoline" attribute

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D146595#4284340 , @dblaikie wrote:

> In D146595#4284268 , @aaron.ballman 
> wrote:
>
>> In D146595#4284220 , @dblaikie 
>> wrote:
>>
>>> In D146595#4281710 , @aprantl 
>>> wrote:
>>>
 Now if we are going to say this explicitly DWARF only feature, that could 
 be an argument to stick with the `trampoline` name. But I'd rather say 
 this is a general feature that — at this point in time — is only implement 
 on DWARF targets.
>>>
>>> Yeah, I'd be inclined to think of this as not a DWARF-specific feature, but 
>>> one only implemented in DWARF at the moment. If CV adds some way to inject 
>>> names into the database of uninteresting symbols, they could use this too.
>>
>> To clarify, my concerns with non-DWARF aren't of the "this needs to work 
>> with every debug format before we should accept it" variety. It's more of 
>> the "if other debug formats support this concept or conceivably would 
>> support this concept in the near future, would we need to materially change 
>> the attribute from what's proposed here?" kind. Basically, I want to try to 
>> avoid a situation where we have to introduce a second attribute for this 
>> same feature, or this attribute needs to be a decl attribute for DWARF and a 
>> type attribute for others, needs arguments for some reason, that sort of 
>> thing. I want to avoid having a set of attributes for DWARF and a different 
>> set of attribute code CodeView, basically.
>
> Fair - we DWARF folks don't probably have enough context to answer that 
> authoritatively. I'm not sure if the CV folks do either (in the sense of 
> knowing all the corners of a less public format is harder - so the usual 
> challenges of proving non-existence come up more), but @akhuang - do you 
> happen to know anything about CV's ability to encode places not to stop when 
> stepping through code?

If we can't find this information out in the next few days, then I'd say it's 
reasonable to move forward without worrying about the behavior of other debug 
formats. If we run into a problem in the future, we can deprecate the attribute 
and replace it with something sufficiently general then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146595

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


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-24 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

I think this is a good diagnostic to add: it improves readability and 
eliminates ambiguities. My only request is that if there isn't already a FixIt 
hint, one be added, please.




Comment at: clang/test/Sema/parentheses.c:94
 
   (void)(x + y > 0 ? 1 : 2); // no warning
   (void)(x + (y > 0) ? 1 : 2); // expected-warning {{operator '?:' has lower 
precedence than '+'}} expected-note 2{{place parentheses}}

I think this should also warn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D141310: [clang] add -Wcompare-function-pointers

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D141310#4285703 , @dblaikie wrote:

> FWIW I think it's still worth some data from applying this to a broad 
> codebase like Chromium/wherever it's planned to be used - whether it's 
> practical to make a codebase clean of this warning, what sort of challenges 
> arise, whether we should consider/need some way to suppress the warning in 
> particular cases, etc.

+1 to trying to find this information before we land the changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141310

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


[PATCH] D147928: [clang] Keep multiple-include optimization for null directives

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though please add a release note to `clang/docs/ReleaseNotes.rst` for the 
fix. Do you need me to commit on your behalf? If so, please let me know what 
name and email address you'd like used for patch attribution.


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

https://reviews.llvm.org/D147928

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


[PATCH] D144603: Disable compiler launcher on external projects and multi stage clang

2023-04-24 Thread Haowei Wu 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 rGe38cdc5933b0: Disable compiler launcher on external projects 
and multi stage clang (authored by haowei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144603

Files:
  clang/CMakeLists.txt
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake


Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -165,6 +165,19 @@
 endforeach()
   endforeach()
 
+  # Populate the non-project-specific passthrough variables
+  foreach(variableName ${LLVM_EXTERNAL_PROJECT_PASSTHROUGH})
+if(DEFINED ${variableName})
+  if("${${variableName}}" STREQUAL "")
+set(value "")
+  else()
+string(REPLACE ";" "|" value "${${variableName}}")
+  endif()
+  list(APPEND PASSTHROUGH_VARIABLES
+-D${variableName}=${value})
+endif()
+  endforeach()
+
   if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
 if(CLANG_IN_TOOLCHAIN)
   if(is_msvc_target)
@@ -327,8 +340,6 @@
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
-   -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
${cmake_args}
${PASSTHROUGH_VARIABLES}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -660,8 +660,6 @@
 LLVM_VERSION_SUFFIX
 LLVM_BINUTILS_INCDIR
 CLANG_REPOSITORY_STRING
-CMAKE_C_COMPILER_LAUNCHER
-CMAKE_CXX_COMPILER_LAUNCHER
 CMAKE_MAKE_PROGRAM
 CMAKE_OSX_ARCHITECTURES
 CMAKE_BUILD_TYPE


Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -165,6 +165,19 @@
 endforeach()
   endforeach()
 
+  # Populate the non-project-specific passthrough variables
+  foreach(variableName ${LLVM_EXTERNAL_PROJECT_PASSTHROUGH})
+if(DEFINED ${variableName})
+  if("${${variableName}}" STREQUAL "")
+set(value "")
+  else()
+string(REPLACE ";" "|" value "${${variableName}}")
+  endif()
+  list(APPEND PASSTHROUGH_VARIABLES
+-D${variableName}=${value})
+endif()
+  endforeach()
+
   if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
 if(CLANG_IN_TOOLCHAIN)
   if(is_msvc_target)
@@ -327,8 +340,6 @@
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
-   -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
${cmake_args}
${PASSTHROUGH_VARIABLES}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -660,8 +660,6 @@
 LLVM_VERSION_SUFFIX
 LLVM_BINUTILS_INCDIR
 CLANG_REPOSITORY_STRING
-CMAKE_C_COMPILER_LAUNCHER
-CMAKE_CXX_COMPILER_LAUNCHER
 CMAKE_MAKE_PROGRAM
 CMAKE_OSX_ARCHITECTURES
 CMAKE_BUILD_TYPE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e38cdc5 - Disable compiler launcher on external projects and multi stage clang

2023-04-24 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2023-04-24T12:15:44-07:00
New Revision: e38cdc5933b026cd25cf70c06f690a431c608d63

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

LOG: Disable compiler launcher on external projects and multi stage clang

When using compiler caching program like ccache, there is no point to
use them on external projects or multi-stage clang builds. As these
builds uses fresh from source code toolchain and will pollute the build
cache. If a compiler launcher is still required, a user can explicity
define `CMAKE_C_COMPILER_LAUNCHER` and `CMAKE_CXX_COMPILER_LAUNCHER` in
`CLANG_BOOTSTRAP_PASSTHROUGH` and `LLVM_EXTERNAL_PROJECT_PASSTHROUGH`
flags to enable compiler launcher in these builds.

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

Added: 


Modified: 
clang/CMakeLists.txt
llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 4508ea4c77aa5..fd8558a16f81d 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -660,8 +660,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
 LLVM_VERSION_SUFFIX
 LLVM_BINUTILS_INCDIR
 CLANG_REPOSITORY_STRING
-CMAKE_C_COMPILER_LAUNCHER
-CMAKE_CXX_COMPILER_LAUNCHER
 CMAKE_MAKE_PROGRAM
 CMAKE_OSX_ARCHITECTURES
 CMAKE_BUILD_TYPE

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake 
b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 73910b4b083a1..44af6c1462bde 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -165,6 +165,19 @@ function(llvm_ExternalProject_Add name source_dir)
 endforeach()
   endforeach()
 
+  # Populate the non-project-specific passthrough variables
+  foreach(variableName ${LLVM_EXTERNAL_PROJECT_PASSTHROUGH})
+if(DEFINED ${variableName})
+  if("${${variableName}}" STREQUAL "")
+set(value "")
+  else()
+string(REPLACE ";" "|" value "${${variableName}}")
+  endif()
+  list(APPEND PASSTHROUGH_VARIABLES
+-D${variableName}=${value})
+endif()
+  endforeach()
+
   if(ARG_USE_TOOLCHAIN AND NOT CMAKE_CROSSCOMPILING)
 if(CLANG_IN_TOOLCHAIN)
   if(is_msvc_target)
@@ -327,8 +340,6 @@ function(llvm_ExternalProject_Add name source_dir)
-DPACKAGE_VERSION=${PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
-   -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
${cmake_args}
${PASSTHROUGH_VARIABLES}



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


[PATCH] D148211: [clang][tests] Fix Flang driver tests for Windows

2023-04-24 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc added a comment.

> May I ask you to commit the change? I do not have commit access.

Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148211

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


[PATCH] D147989: [clang] Fix Attribute Placement

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Oops, I spoke too soon -- it looks like the precommit CI failure is related to 
this patch. This is what I get when I tested locally:

  Assertion failed: NextVal != ArgumentEnd && "Value for integer select 
modifier was" " larger than the number of options in the diagnostic string!", 
file F:\source\llvm-project\clang\lib\Basic\Diagnostic.cpp, line 623
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.  Program arguments: 
f:\\source\\llvm-project\\llvm\\out\\build\\x64-debug\\bin\\clang.exe -cc1 
-internal-isystem 
f:\\source\\llvm-project\\llvm\\out\\build\\x64-debug\\lib\\clang\\17\\include 
-nostdsysteminc -std=c++11 -triple x86_64-unknown-unknown 
F:\\source\\llvm-project\\clang\\test\\CXX\\drs\\dr16xx.cpp -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
  1.  F:\source\llvm-project\clang\test\CXX\drs\dr16xx.cpp:91:3: current 
parser token 'template'
  2.  F:\source\llvm-project\clang\test\CXX\drs\dr16xx.cpp:71:1: parsing 
namespace 'dr1638'
  Exception Code: 0x8003
   #0 0x7ff6625ea26c HandleAbort 
F:\source\llvm-project\llvm\lib\Support\Windows\Signals.inc:419:0
   #1 0x7ffa9b23bc31 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6bc31)
   #2 0x7ffa9b23d889 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6d889)
   #3 0x7ffa9b2430bf (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x730bf)
   #4 0x7ffa9b241091 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x71091)
   #5 0x7ffa9b243a1f (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x73a1f)
   #6 0x7ff662a19b8c HandleSelectModifier 
F:\source\llvm-project\clang\lib\Basic\Diagnostic.cpp:622:0
   #7 0x7ff662a17137 clang::Diagnostic::FormatDiagnostic(char const *, char 
const *, class llvm::SmallVectorImpl &) const 
F:\source\llvm-project\clang\lib\Basic\Diagnostic.cpp:1005:0
   #8 0x7ff662a16518 clang::Diagnostic::FormatDiagnostic(class 
llvm::SmallVectorImpl &) const 
F:\source\llvm-project\clang\lib\Basic\Diagnostic.cpp:805:0
   #9 0x7ff663e5bcc9 clang::TextDiagnosticBuffer::HandleDiagnostic(enum 
clang::DiagnosticsEngine::Level, class clang::Diagnostic const &) 
F:\source\llvm-project\clang\lib\Frontend\TextDiagnosticBuffer.cpp:30:0
  #10 0x7ff663ef2d71 clang::VerifyDiagnosticConsumer::HandleDiagnostic(enum 
clang::DiagnosticsEngine::Level, class clang::Diagnostic const &) 
F:\source\llvm-project\clang\lib\Frontend\VerifyDiagnosticConsumer.cpp:757:0
  #11 0x7ff662a0b66f clang::DiagnosticIDs::EmitDiag(class 
clang::DiagnosticsEngine &, enum clang::DiagnosticIDs::Level) const 
F:\source\llvm-project\clang\lib\Basic\DiagnosticIDs.cpp:839:0
  #12 0x7ff662a0b597 clang::DiagnosticIDs::ProcessDiag(class 
clang::DiagnosticsEngine &) const 
F:\source\llvm-project\clang\lib\Basic\DiagnosticIDs.cpp:831:0
  #13 0x7ff662a267ef clang::DiagnosticsEngine::ProcessDiag(void) 
F:\source\llvm-project\clang\include\clang\Basic\Diagnostic.h:1038:0
  #14 0x7ff662a15f64 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) 
F:\source\llvm-project\clang\lib\Basic\Diagnostic.cpp:549:0
  #15 0x7ff667b47cbc clang::Sema::EmitCurrentDiagnostic(unsigned int) 
F:\source\llvm-project\clang\lib\Sema\Sema.cpp:1575:0
  #16 0x7ff667b89d97 
clang::Sema::ImmediateDiagBuilder::~ImmediateDiagBuilder(void) 
F:\source\llvm-project\clang\include\clang\Sema\Sema.h:1726:0
  #17 0x7ff667b8e9e8 clang::Sema::ImmediateDiagBuilder::`scalar deleting 
dtor'(unsigned int) 
(f:\source\llvm-project\llvm\out\build\x64-debug\bin\clang.exe+0x81fe9e8)
  #18 0x7ff667b72b06 std::_Destroy_in_place(class clang::Sema::ImmediateDiagBuilder &) 
C:\Program Files\Microsoft Visual 
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\xmemory:300:0
  #19 0x7ff667bac5b4 std::_Optional_destruct_base::reset(void) C:\Program Files\Microsoft 
Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\optional:133:0
  #20 0x7ff667b53424 
clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder(void) 
F:\source\llvm-project\clang\lib\Sema\Sema.cpp:1859:0
  #21 0x7ff668618b4a clang::Sema::ParsedFreeStandingDeclSpec(class 
clang::Scope *, enum clang::AccessSpecifier, class clang::DeclSpec &, class 
clang::ParsedAttributesView const &, class llvm::MutableArrayRef, bool, class clang::RecordDecl *&) 
F:\source\llvm-project\clang\lib\Sema\SemaDecl.cpp:5151:0
  #22 0x7ff668618545 clang::Sema::ParsedFreeStandingDeclSpec(class 
clang::Scope *, enum clang::AccessSpecifier, class clang::DeclSpec &, class 
clang::ParsedAttributesView const &, class clang::RecordDecl *&) 
F:\source\llvm-project\clang\lib\Sema\SemaDecl.cpp:4844:0
  #23 0x7ff66797e8e2 clang::Parser::ParseDeclOrFunctionDefInternal(class 
clang::ParsedAttributes &, class clang::ParsedAttributes &, class 
clang::ParsingDeclSpec &, enum 

[PATCH] D148211: [clang][tests] Fix Flang driver tests for Windows

2023-04-24 Thread Bryan Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b85bfffc486: [clang][tests] Fix Flang driver tests for 
Windows (authored by kaadam, committed by bryanpkc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148211

Files:
  clang/test/Driver/flang/flang.f90
  clang/test/Driver/flang/flang_ucase.F90
  clang/test/Driver/flang/multiple-inputs.f90


Index: clang/test/Driver/flang/multiple-inputs.f90
===
--- clang/test/Driver/flang/multiple-inputs.f90
+++ clang/test/Driver/flang/multiple-inputs.f90
@@ -1,7 +1,7 @@
 ! Check that flang driver can handle multiple inputs at once.
 
 ! RUN: %clang --driver-mode=flang -### -fsyntax-only %S/Inputs/one.f90 
%S/Inputs/two.f90 2>&1 | FileCheck --check-prefixes=CHECK-SYNTAX-ONLY %s
-! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/one.f90"
-! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/two.f90"
Index: clang/test/Driver/flang/flang_ucase.F90
===
--- clang/test/Driver/flang/flang_ucase.F90
+++ clang/test/Driver/flang/flang_ucase.F90
@@ -13,7 +13,7 @@
 ! * (no type specified, resulting in an object file)
 
 ! All invocations should begin with flang -fc1, consume up to here.
-! ALL-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! ALL-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 
 ! Check that f90 files are not treated as "previously preprocessed"
 ! ... in --driver-mode=flang.
Index: clang/test/Driver/flang/flang.f90
===
--- clang/test/Driver/flang/flang.f90
+++ clang/test/Driver/flang/flang.f90
@@ -13,7 +13,7 @@
 ! * (no type specified, resulting in an object file)
 
 ! All invocations should begin with flang -fc1, consume up to here.
-! ALL-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! ALL-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 
 ! Check that f90 files are not treated as "previously preprocessed"
 ! ... in --driver-mode=flang.


Index: clang/test/Driver/flang/multiple-inputs.f90
===
--- clang/test/Driver/flang/multiple-inputs.f90
+++ clang/test/Driver/flang/multiple-inputs.f90
@@ -1,7 +1,7 @@
 ! Check that flang driver can handle multiple inputs at once.
 
 ! RUN: %clang --driver-mode=flang -### -fsyntax-only %S/Inputs/one.f90 %S/Inputs/two.f90 2>&1 | FileCheck --check-prefixes=CHECK-SYNTAX-ONLY %s
-! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/one.f90"
-! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/two.f90"
Index: clang/test/Driver/flang/flang_ucase.F90
===
--- clang/test/Driver/flang/flang_ucase.F90
+++ clang/test/Driver/flang/flang_ucase.F90
@@ -13,7 +13,7 @@
 ! * (no type specified, resulting in an object file)
 
 ! All invocations should begin with flang -fc1, consume up to here.
-! ALL-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! ALL-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 
 ! Check that f90 files are not treated as "previously preprocessed"
 ! ... in --driver-mode=flang.
Index: clang/test/Driver/flang/flang.f90
===
--- clang/test/Driver/flang/flang.f90
+++ clang/test/Driver/flang/flang.f90
@@ -13,7 +13,7 @@
 ! * (no type specified, resulting in an object file)
 
 ! All invocations should begin with flang -fc1, consume up to here.
-! ALL-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! ALL-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 
 ! Check that f90 files are not treated as "previously preprocessed"
 ! ... in --driver-mode=flang.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7b85bff - [clang][tests] Fix Flang driver tests for Windows

2023-04-24 Thread Bryan Chan via cfe-commits

Author: Ádám Kallai
Date: 2023-04-24T15:21:08-04:00
New Revision: 7b85bfffc486257361a598a3c9d4b6b67e3f6765

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

LOG: [clang][tests] Fix Flang driver tests for Windows

Updated the regular expression in order to match '.exe' suffix,
if these Flang tests are running on Windows.

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

Added: 


Modified: 
clang/test/Driver/flang/flang.f90
clang/test/Driver/flang/flang_ucase.F90
clang/test/Driver/flang/multiple-inputs.f90

Removed: 




diff  --git a/clang/test/Driver/flang/flang.f90 
b/clang/test/Driver/flang/flang.f90
index 9b16f233b231a..5d8edf6308b00 100644
--- a/clang/test/Driver/flang/flang.f90
+++ b/clang/test/Driver/flang/flang.f90
@@ -13,7 +13,7 @@
 ! * (no type specified, resulting in an object file)
 
 ! All invocations should begin with flang -fc1, consume up to here.
-! ALL-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! ALL-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 
 ! Check that f90 files are not treated as "previously preprocessed"
 ! ... in --driver-mode=flang.

diff  --git a/clang/test/Driver/flang/flang_ucase.F90 
b/clang/test/Driver/flang/flang_ucase.F90
index 113ef75f45b87..50305ee337e10 100644
--- a/clang/test/Driver/flang/flang_ucase.F90
+++ b/clang/test/Driver/flang/flang_ucase.F90
@@ -13,7 +13,7 @@
 ! * (no type specified, resulting in an object file)
 
 ! All invocations should begin with flang -fc1, consume up to here.
-! ALL-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! ALL-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 
 ! Check that f90 files are not treated as "previously preprocessed"
 ! ... in --driver-mode=flang.

diff  --git a/clang/test/Driver/flang/multiple-inputs.f90 
b/clang/test/Driver/flang/multiple-inputs.f90
index f6ee60e48fef3..ada999e927a6a 100644
--- a/clang/test/Driver/flang/multiple-inputs.f90
+++ b/clang/test/Driver/flang/multiple-inputs.f90
@@ -1,7 +1,7 @@
 ! Check that flang driver can handle multiple inputs at once.
 
 ! RUN: %clang --driver-mode=flang -### -fsyntax-only %S/Inputs/one.f90 
%S/Inputs/two.f90 2>&1 | FileCheck --check-prefixes=CHECK-SYNTAX-ONLY %s
-! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/one.f90"
-! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new" "-fc1"
+! CHECK-SYNTAX-ONLY-LABEL: "{{[^"]*}}flang-new{{[^"/]*}}" "-fc1"
 ! CHECK-SYNTAX-ONLY: "{{[^"]*}}/Inputs/two.f90"



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


[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:4662
 
-  for (auto KNPair : KnownNamespaces)
+  for (const auto  : KnownNamespaces)
 Namespaces.addNameSpecifier(KNPair.first);

tahonermann wrote:
> The element type is a pair of `NamespaceDecl *` and `bool`. I would skip this 
> change.
Thanks @tahonermann for the explanation. Removed 


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

https://reviews.llvm.org/D149074

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


[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/utils/TableGen/NeonEmitter.cpp:392
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it 
rather

tahonermann wrote:
> The element type is `Type` (`clang/utils/TableGen/NeonEmitter.cpp`). It holds 
> a `TypeSpec`, an `enum` value, 5 `bool` values, and 3 `unsigned` values. I'm 
> ambivalent.
Thanks @tahonermann for reviews and feedbacks. 

>>The element type is Type (clang/utils/TableGen/NeonEmitter.cpp). It holds a 
>>TypeSpec, an enum value, 5 bool values, and 3 unsigned values.

Yes, I had mixed feeling about this one too. 

Line 362 in clang/utils/TableGen/NeonEmitter.cpp, we are passing it as a 
reference. 

 for (const auto  : Types){
  if (T.isVector() && T.getNumElements() > 1)
return false;
}
return true;
  }



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

https://reviews.llvm.org/D149074

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


[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 516488.
Manna marked 7 inline comments as done.
Manna edited the summary of this revision.
Manna added a comment.

I have addressed @tahonermann review comments.


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

https://reviews.llvm.org/D149074

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -389,7 +389,7 @@
   Mods = getNextModifiers(Proto, Pos);
 }
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it 
rather
   // than use a standard declaration, so that SemaChecking can range check
   // the immediate passed by the user.
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -447,7 +447,7 @@
   if (!CXXRecord)
 return false;
 
-  for (auto BaseSpecifier : CXXRecord->bases()) {
+  for (const auto  : CXXRecord->bases()) {
 if (!foundStarOperator)
   foundStarOperator = IsOverloadedOperatorPresent(
   BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2806,7 +2806,7 @@
 // Determines whether 'Ranges' intersects with ('Start', 'End').
 static bool affectsRange(ArrayRef Ranges, unsigned Start,
  unsigned End) {
-  for (auto Range : Ranges) {
+  for (const auto  : Ranges) {
 if (Range.getOffset() < End &&
 Range.getOffset() + Range.getLength() > Start) {
   return true;
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3757,7 +3757,7 @@
   Classes.front().initialize(/*Parent=*/nullptr, /*Specifier=*/nullptr);
   detectAmbiguousBases(Classes);
   int Flags = 0;
-  for (auto Class : Classes) {
+  for (const MSRTTIClass  : Classes) {
 if (Class.RD->getNumBases() > 1)
   Flags |= HasBranchingHierarchy;
 // Note: cl.exe does not calculate "HasAmbiguousBases" correctly.  We
Index: clang/lib/CodeGen/CGGPUBuiltin.cpp
===
--- clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -189,7 +189,7 @@
/* ParamsToSkip = */ 0);
 
   SmallVector Args;
-  for (auto A : CallArgs) {
+  for (const auto  : CallArgs) {
 // We don't know how to emit non-scalar varargs.
 if (!A.getRValue(*this).isScalar()) {
   CGM.ErrorUnsupported(E, "non-scalar arg to printf");
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -663,7 +663,7 @@
 
 ExprDependence clang::computeDependence(DesignatedInitExpr *E) {
   auto Deps = E->getInit()->getDependence();
-  for (auto D : E->designators()) {
+  for (const auto  : E->designators()) {
 auto DesignatorDeps = ExprDependence::None;
 if (D.isArrayDesignator())
   DesignatorDeps |= E->getArrayIndex(D)->getDependence();
Index: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
===
--- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -179,7 +179,7 @@
   return true;
 
 // Skip methods in records.
-for (auto P : Context.getParents(*Method)) {
+for (const auto  : Context.getParents(*Method)) {
   if (P.template get())
 return true;
 }


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -389,7 +389,7 @@
   Mods = getNextModifiers(Proto, Pos);
 }
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it rather
   // than use a standard declaration, so that SemaChecking can range check
   // the immediate passed by the user.
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -447,7 +447,7 @@
   if (!CXXRecord)
 return false;

[PATCH] D147989: [clang] Fix Attribute Placement

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Do you need someone to land this on your behalf? If so, what name and email 
address would you like used for patch attribution? (I can fix the tiny style 
nit myself when landing, so don't feel obligated to make the change yourself 
unless you're committing the patch.)




Comment at: clang/lib/Sema/SemaDecl.cpp:5045
+return 5;
+  else if (ED->isScoped())
+return 6;

Tiny style nit; NFC (we have a rule about using `else` after a `return`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147989

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


[PATCH] D148458: [clang-tidy][NFC] Split bugprone-exception-escape tests

2023-04-24 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 516481.
PiotrZSL marked an inline comment as done.
PiotrZSL added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148458

Files:
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -32,11 +32,6 @@
   throw 1;
 }
 
-void throwing_throw_nothing() throw() {
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'throwing_throw_nothing' which should not throw exceptions
-  throw 1;
-}
-
 void throw_and_catch() noexcept {
   // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown 
in function 'throw_and_catch' which should not throw exceptions
   try {
@@ -557,7 +552,9 @@
   throw 1;
 }
 
-void explicit_int_thrower() throw(int);
+void explicit_int_thrower() noexcept(false) {
+  throw 1;
+}
 
 void indirect_implicit() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'indirect_implicit' which should not throw exceptions
@@ -677,15 +674,6 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in 
function 'sub_throws' which should not throw exceptions
 };
 
-struct super_throws_again {
-  super_throws_again() throw(int);
-};
-
-struct sub_throws_again : super_throws_again {
-  sub_throws_again() noexcept : super_throws_again() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in 
function 'sub_throws_again' which should not throw exceptions
-};
-
 struct init_member_throws {
   super_throws s;
 
Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-exception-escape %t -- 
-- -fexceptions
+
+void throwing_throw_nothing() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'throwing_throw_nothing' which should not throw exceptions
+  throw 1;
+}
+
+void explicit_int_thrower() throw(int);
+
+void implicit_int_thrower() {
+  throw 5;
+}
+
+void indirect_implicit() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'indirect_implicit' which should not throw exceptions
+  implicit_int_thrower();
+}
+
+void indirect_explicit() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'indirect_explicit' which should not throw exceptions
+  explicit_int_thrower();
+}
+
+struct super_throws {
+  super_throws() throw(int) { throw 42; }
+};
+
+struct sub_throws : super_throws {
+  sub_throws() throw() : super_throws() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in 
function 'sub_throws' which should not throw exceptions
+};


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -32,11 +32,6 @@
   throw 1;
 }
 
-void throwing_throw_nothing() throw() {
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_throw_nothing' which should not throw exceptions
-  throw 1;
-}
-
 void throw_and_catch() noexcept {
   // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_catch' which should not throw exceptions
   try {
@@ -557,7 +552,9 @@
   throw 1;
 }
 
-void explicit_int_thrower() throw(int);
+void explicit_int_thrower() noexcept(false) {
+  throw 1;
+}
 
 void indirect_implicit() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_implicit' which should not throw exceptions
@@ -677,15 +674,6 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions
 };
 
-struct super_throws_again {
-  super_throws_again() throw(int);
-};
-
-struct sub_throws_again : super_throws_again {
-  sub_throws_again() noexcept : super_throws_again() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws_again' which should not throw exceptions
-};
-
 struct init_member_throws {
   super_throws s;
 
Index: 

[PATCH] D149084: [clang-tidy] Added bugprone-multi-level-implicit-pointer-conversion check

2023-04-24 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Detects implicit conversions between pointers of different levels of
indirection.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149084

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/MultiLevelImplicitPointerConversionCheck.cpp
  
clang-tools-extra/clang-tidy/bugprone/MultiLevelImplicitPointerConversionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/multi-level-implicit-pointer-conversion.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/multi-level-implicit-pointer-conversion.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/multi-level-implicit-pointer-conversion.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/multi-level-implicit-pointer-conversion.cpp
@@ -0,0 +1,65 @@
+// RUN: %check_clang_tidy %s bugprone-multi-level-implicit-pointer-conversion %t
+
+using OneStar = void*;
+using OneStarFancy = OneStar;
+
+void takeFirstLevelVoidPtr(OneStar message);
+void takeFirstLevelConstVoidPtr(const OneStarFancy message);
+void takeFirstLevelConstVoidPtrConst(const void* const message);
+void takeSecondLevelVoidPtr(void** message);
+
+void** getSecondLevelVoidPtr();
+void* getFirstLevelVoidPtr();
+int** getSecondLevelIntPtr();
+int* getFirstLevelIntPtr();
+
+int table[5];
+
+void test()
+{
+  void** secondLevelVoidPtr;
+  int* firstLevelIntPtr;
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  void* a = getSecondLevelVoidPtr();
+
+  void** b = getSecondLevelVoidPtr();
+  void* c = getFirstLevelVoidPtr();
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: multilevel pointer conversion from 'int **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  void* d = getSecondLevelIntPtr();
+
+  takeFirstLevelVoidPtr();
+
+  takeFirstLevelVoidPtr(firstLevelIntPtr);
+
+  takeFirstLevelVoidPtr(getFirstLevelIntPtr());
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelVoidPtr(secondLevelVoidPtr);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:30: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelConstVoidPtr(secondLevelVoidPtr);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:35: warning: multilevel pointer conversion from 'void **' to 'const void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelConstVoidPtrConst(secondLevelVoidPtr);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:35: warning: multilevel pointer conversion from 'void ***' to 'const void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelConstVoidPtrConst();
+
+  takeSecondLevelVoidPtr(secondLevelVoidPtr);
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelVoidPtr(getSecondLevelVoidPtr());
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:30: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelConstVoidPtr(getSecondLevelVoidPtr());
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:35: warning: multilevel pointer conversion from 'void **' to 'const void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelConstVoidPtrConst(getSecondLevelVoidPtr());
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: multilevel pointer conversion from 'int **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
+  takeFirstLevelVoidPtr(getSecondLevelIntPtr());
+
+  takeSecondLevelVoidPtr(getSecondLevelVoidPtr());
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -102,6 +102,7 @@
`bugprone-misplaced-pointer-arithmetic-in-alloc `_, "Yes"
`bugprone-misplaced-widening-cast `_,
`bugprone-move-forwarding-reference `_, "Yes"
+   

[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-04-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Need to update RISCVUsage.rst




Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:969
+case KindTy::Spimm:
+  OS << "{Spimm: ";
+  RISCVZC::printSpimm(Spimm.Val, OS);

Why curly braces when everything else uses `<` and `>`?



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1057
+
+  static std::unique_ptr createSpimm(unsigned spimm, SMLoc S,
+   bool IsRV64) {

Capitalize `spimm`



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2339
+if (RegStart != RISCV::X1)
+  return MatchOperand_NoMatch;
+getLexer().Lex();

Should we be using ParseFail with more specific error messages instead of 
NoMatch once we start calling Lex() on tokens? If you use NoMatch, I think we 
need to unwind the tokens that have been lexed.



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:513
+
+inline unsigned encodeRlist(MCRegister EndReg, bool isCInst,
+bool IsRV32E = false) {

isCInst and IsRV32E are unused.



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:515
+bool IsRV32E = false) {
+  auto RlistEncode = [=] {
+switch (EndReg) {

Get rid of the lambda. Create a variable and assign to it in the switch.



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:550
+
+inline static unsigned getStackAdjBase(unsigned rlistVal, bool isRV64,
+   bool isEABI) {

Capitalize variable names



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:554
+assert(0 && "{ra, s0-s10} is not supported, s11 must be included.");
+  if (isEABI) {
+return 16;

Drop curly braces around single line if



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:602
+
+inline static bool getSpimm(unsigned rlistVal, unsigned ,
+int64_t stackAdjustment, bool isRV64, bool isEABI) 
{

Capitalize variable names



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp:494
+  MCOperand MO = MI.getOperand(OpNo);
+  assert(MO.isImm() && "Rlist operand must be immidiate");
+  auto Imm = MO.getImm();

immidiate -> immediate



Comment at: llvm/lib/Target/RISCV/RISCVFeatures.td:356
+: SubtargetFeature<"experimental-zcmp", "HasStdExtZcmp", "true",
+   "'Zcmp' (sequenced instuctions for code-size 
reduction.)", 
+   [FeatureStdExtZca]>;

Drop the `.` after reduction



Comment at: llvm/lib/Target/RISCV/RISCVFeatures.td:360
+   AssemblerPredicate<(all_of FeatureStdExtZcmp, 
(not FeatureStdExtC)),
+   "'Zcmp' (sequenced instuctions for code-size 
reduction.)">;
+

Drop the . after reduction



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td:132
+let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
+class ZcLoad_ri funct3, bits<2> opcode, string opcodestr,
+ RegisterClass cls, DAGOperand opnd>

This isn't used



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td:192
 
+// ZCMP
+let Predicates = [HasStdExtZcmp], Defs = [X10, X11],

ZCMP -> Zcmp



Comment at: llvm/test/CodeGen/RISCV/attributes.ll:73
 
+
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s

Drop this change



Comment at: llvm/test/MC/RISCV/rv32zcmp-invalid.s:5
+# CHECK-ERROR: error: invalid operand for instruction
+cm.mvsa01 a1, a2
+

Do we need to check that we don't except `mvsa01 s0, s0`? The spec says the two 
s registers must be different.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

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


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: dblaikie, cjdb, echristo, clang-language-wg.
aaron.ballman added a comment.

In D147844#4286500 , @philnik wrote:

> I have to say I'm not really convinced this change is a good idea. The cases 
> it flags don't really seem in any way ambiguous/erroneous.

I think some of the cases are ambiguous while others are not. It's taken me a 
while to come up with what I think my brain is doing, maybe this happens for 
others as well. When the ternary conditional expression is a binary expression, 
my brain can figure things out very quickly when the RHS of that binary 
expression is a literal but my brain is much less confident when the RHS of 
that binary expression is an identifier. e.g., `x & 1 ? foo : bar` is easy for 
my brain to go "well, obviously the condition is not testing whether `1` is 
nonzero, so it must be testing the result of `x & 1` instead", but something 
like `x & y ? foo : bar` is far less obvious as to what the behavior is because 
`x & (y ? foo : bar)` is as reasonable a choice as `(x & y) ? foo : bar` 
without putting a lot more thought into it. However, that might be splitting 
hairs with the diagnostic functionality (esp because macros and enumerations 
are sort of like literals and sort of like identifiers, depending on the way 
you want to think of them).

Adding in some more folks for opinions on whether the proposed changes in this 
patch are an improvement or whether we want to tweak the heuristic a bit more. 
My original thinking was that all precedence situations with ternary 
conditional expressions are kind of equally confusing, but given that two folks 
have pushed back on the proposed changes, more opinions would be valuable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

I added a comment to skip the one where the element type is a simple pair. The 
rest look fine to me.




Comment at: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h:182
 // Skip methods in records.
-for (auto P : Context.getParents(*Method)) {
+for (const auto  : Context.getParents(*Method)) {
   if (P.template get())

I think this is probably a good change. `getParents()` returns a 
`DynTypedNodeList` (`clang/include/clang/AST/ParentMapContext.h`) that uses 
`DynTypedNode` as its element type. `DynTypedNode` 
(`clang/include/clang/AST/ASTTypeTraits.h`) has a `llvm::AlignedCharArrayUnion` 
data member that looks like it is sufficiently complicated that avoiding copies 
is probably advantageous.



Comment at: clang/lib/AST/ComputeDependence.cpp:666
   auto Deps = E->getInit()->getDependence();
-  for (auto D : E->designators()) {
+  for (const auto  : E->designators()) {
 auto DesignatorDeps = ExprDependence::None;

The element type here is `Designator` (`clang/include/clang/AST/Expr.h`). It 
functions as a discriminated union; its largest union member has three source 
locations and an `unsigned` value. Copy constructors look to be trivial, but 
still, this seems like a win.



Comment at: clang/lib/CodeGen/CGGPUBuiltin.cpp:192
   SmallVector Args;
-  for (auto A : CallArgs) {
+  for (const auto  : CallArgs) {
 // We don't know how to emit non-scalar varargs.

The element type is `CallArg` (`clang/lib/CodeGen/CGCall.h`). This looks like a 
clear win; `CallArg` is another discriminated union and its `LValue` member 
holds a number of pointer members.



Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:3760
   int Flags = 0;
-  for (auto Class : Classes) {
+  for (const MSRTTIClass  : Classes) {
 if (Class.RD->getNumBases() > 1)

`MSRTTIClass` (`clang/lib/CodeGen/MicrosoftCXXABI.cpp`) holds two pointers and 
three `uint32_t` values. Seems like a reasonable change to me.



Comment at: clang/lib/Format/Format.cpp:2809
  unsigned End) {
-  for (auto Range : Ranges) {
+  for (const auto  : Ranges) {
 if (Range.getOffset() < End &&

The element type is `Range` (`clang/include/clang/Tooling/Core/Replacement.h`) 
and it just holds two `unsigned` values. I don't think this change is needed 
(though I don't think it would hurt anything either).



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:450
 
-  for (auto BaseSpecifier : CXXRecord->bases()) {
+  for (const auto  : CXXRecord->bases()) {
 if (!foundStarOperator)

The element type is `CXXBaseSpecifier` (`clang/include/clang/AST/DeclCXX.h`). 
This change seems fine to me.



Comment at: clang/lib/Sema/SemaLookup.cpp:4662
 
-  for (auto KNPair : KnownNamespaces)
+  for (const auto  : KnownNamespaces)
 Namespaces.addNameSpecifier(KNPair.first);

The element type is a pair of `NamespaceDecl *` and `bool`. I would skip this 
change.



Comment at: clang/utils/TableGen/NeonEmitter.cpp:392
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it 
rather

The element type is `Type` (`clang/utils/TableGen/NeonEmitter.cpp`). It holds a 
`TypeSpec`, an `enum` value, 5 `bool` values, and 3 `unsigned` values. I'm 
ambivalent.


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

https://reviews.llvm.org/D149074

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


[PATCH] D134821: [flang][driver] Allow main program to be in an archive

2023-04-24 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 516476.
sunshaoce added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: pcwang-thead, s.egerton, simoncook, asb.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134821

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  flang/docs/FlangDriver.md
  flang/test/CMakeLists.txt
  flang/test/Driver/link-c-main.c
  flang/test/Driver/link-f90-main.f90
  flang/test/Driver/linker-flags.f90

Index: flang/test/Driver/linker-flags.f90
===
--- flang/test/Driver/linker-flags.f90
+++ flang/test/Driver/linker-flags.f90
@@ -12,6 +12,11 @@
 !   Make sure they're not added.
 ! RUN: %flang -### -flang-experimental-exec -target aarch64-windows-msvc %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MSVC --implicit-check-not libcmt --implicit-check-not oldnames
 
+! Check linker invocation to generate shared object (only GNU toolchain for now)
+! RUN: %flang -### -flang-experimental-exec -shared -target x86_64-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU-SHARD --implicit-check-not _QQmain
+! RUN: %flang -### -flang-experimental-exec -shared -target aarch64-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU-SHARD --implicit-check-not _QQmain
+! RUN: %flang -### -flang-experimental-exec -shared -target riscv64-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU-SHARD --implicit-check-not _QQmain
+
 ! Compiler invocation to generate the object file
 ! CHECK-LABEL: {{.*}} "-emit-obj"
 ! CHECK-SAME:  "-o" "[[object_file:.*\.o]]" {{.*}}Inputs/hello.f90
@@ -23,6 +28,7 @@
 !   executable and may find the GNU linker from MinGW or Cygwin.
 ! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! GNU-SAME: "[[object_file]]"
+! GNU-SAME: --undefined=_QQmain
 ! GNU-SAME: -lFortran_main
 ! GNU-SAME: -lFortranRuntime
 ! GNU-SAME: -lFortranDecimal
@@ -50,3 +56,9 @@
 ! MSVC-SAME: FortranDecimal.lib
 ! MSVC-SAME: /subsystem:console
 ! MSVC-SAME: "[[object_file]]"
+
+! Linker invocation to generate a shared object
+! GNU-SHARD-LABEL:  "{{.*}}ld"
+! GNU-SHARD-SAME: "[[object_file]]"
+! GNU-SHARD-SAME: -lFortranRuntime
+! GNU-SHARD-SAME: -lFortranDecimal
Index: flang/test/Driver/link-f90-main.f90
===
--- /dev/null
+++ flang/test/Driver/link-f90-main.f90
@@ -0,0 +1,23 @@
+! Test that a fortran main program can be linked to an executable
+! by flang.
+!
+! For now, this test only covers the Gnu toolchain on linux.
+
+!REQUIRES: x86-registered-target || aarch64-registered-target || riscv64-registered-target
+!REQUIRES: system-linux
+
+! RUN: %flang_fc1 -emit-obj %s -o %t.o
+! RUN: %flang -target x86_64-unknown-linux-gnu %t.o -o %t.out -flang-experimental-exec
+! RUN: llvm-objdump --syms %t.out | FileCheck %s
+
+! Test that it also works if the program is bundled in an archive.
+
+! RUN: llvm-ar -r %t.a %t.o
+! RUN: %flang -target x86_64-unknown-linux-gnu %t.a -o %ta.out -flang-experimental-exec
+! RUN: llvm-objdump --syms %ta.out | FileCheck %s
+
+end program
+
+! CHECK-DAG: F .text {{[a-f0-9]+}} main
+! CHECK-DAG: F .text {{[a-f0-9]+}} _QQmain
+! CHECK-DAG: _FortranAProgramStart
Index: flang/test/Driver/link-c-main.c
===
--- /dev/null
+++ flang/test/Driver/link-c-main.c
@@ -0,0 +1,28 @@
+/*
+Test that an object file with a c main function can be linked to an executable
+by flang.
+
+For now, this test only covers the Gnu toolchain on linux.
+
+REQUIRES: x86-registered-target || aarch64-registered-target || riscv64-registered-target
+REQUIRES: system-linux, c-compiler
+
+RUN: %cc -c %s -o %t.o
+RUN: %flang -target x86_64-unknown-linux-gnu %t.o -o %t.out -flang-experimental-exec
+RUN: llvm-objdump --syms %t.out | FileCheck %s --implicit-check-not Fortran
+
+Test that it also works if the c-main is bundled in an archive.
+
+RUN: llvm-ar -r %t.a %t.o
+RUN: %flang -target x86_64-unknown-linux-gnu %t.a -o %ta.out -flang-experimental-exec
+RUN: llvm-objdump --syms %ta.out | FileCheck %s --implicit-check-not Fortran
+*/
+
+int main(void) {
+return 0;
+}
+
+/*
+CHECK-DAG: F .text {{[a-f0-9]+}} main
+CHECK-DAG: *UND* {{[a-f0-9]+}} _QQmain
+*/
Index: flang/test/CMakeLists.txt
===
--- flang/test/CMakeLists.txt
+++ flang/test/CMakeLists.txt
@@ -57,6 +57,7 @@
   fir-opt
   tco
   bbc
+  llvm-ar
   llvm-dis
   llvm-objdump
   llvm-readobj
Index: flang/docs/FlangDriver.md
===
--- flang/docs/FlangDriver.md
+++ flang/docs/FlangDriver.md
@@ -149,13 +149,6 @@
 +- 3: backend, {2}, assembler
 4: assembler, {3}, object
 ```
-Note that currently Flang does not support code-generation and 

[PATCH] D134821: [flang][driver] Allow main program to be in an archive

2023-04-24 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce added a comment.

I would like to help land this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134821

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


[PATCH] D144603: Disable compiler launcher on external projects and multi stage clang

2023-04-24 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144603

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


[PATCH] D134821: [flang][driver] Allow main program to be in an archive

2023-04-24 Thread Emil Kieri via Phabricator via cfe-commits
ekieri abandoned this revision.
ekieri added a comment.
Herald added a subscriber: sunshaoce.

Sorry to drop out on this. I got interrupted by other duties in life, and now I 
am no longer able to continue this work. If anybody wants to pick up the ball 
from here, please feel free to commandeer the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134821

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

lib/CodeGen changes look OK to me.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6257
+  // Device code should not be at top level.
+  if (LangOpts.CUDA && LangOpts.CUDAIsDevice)
+return;

Could you give me an example of what exactly we'll be skipping here?
Will it affect `__device__` variables? 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

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


[PATCH] D148274: [clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization

2023-04-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:5364-5368
 if (const ConstantArrayType *CAT =
 S.getASTContext().getAsConstantArrayType(Entity.getType()))
   ArrayLength = CAT->getSize().getZExtValue();
 else
   ArrayLength = Args.size();

What happens if the array is of `VariableArrayType` or 
`DependentSizedArrayType`? I guess we shouldn't get here in the latter case, 
but the former case seems possible, and presumably shouldn't result in 
constructing a value of `ConstantArrayType`. 
[Test](https://godbolt.org/z/377TWzn7r):

```
constexpr int f(int n, int i) {
int arr[n](1, 2, 3);
return arr[i];
}

constexpr int a = f(1, 2);
constexpr int b = f(4, 3);
```

GCC appears to leave the type alone in this case, and treats the evaluation as 
UB if `n` is less than the number of initializers given. That matches what GCC 
does for a `{...}` initializer of a VLA. We should probably match what Clang 
does for `{...}` initialization of a VLA and reject.



Comment at: clang/lib/Sema/SemaInit.cpp:5391-5393
+ResultType = S.Context.getConstantArrayType(
+AT->getElementType(), llvm::APInt(/*numBits=*/32, ArrayLength),
+/*SizeExpr=*/nullptr, ArrayType::Normal, 0);

It would be nice to use the original type here in the case where we didn't add 
an array bound, so we preserve type sugar (typedefs etc). Also, do we ever need 
to preserve type qualifiers from the original entity's type?



Comment at: clang/lib/Sema/SemaInit.cpp:5401
+InitializedEntity SubEntity =
+InitializedEntity::InitializeBase(S.getASTContext(), , false);
+if (EntityIndexToProcess < Args.size()) {

Does this have the same wrong-lifetime-kind problem as members did?



Comment at: clang/lib/Sema/SemaInit.cpp:5476
+  InitializedEntity SubEntity =
+  InitializedEntity::InitializeMemberFromDefaultMemberInitializer(
+  FD);

Does this entity kind do the right thing for lifetime warnings? (I'm not sure 
why this is a distinct kind of `InitializedEntity`; the thing that changes here 
is not the entity, it's how it's initialized.)



Comment at: clang/lib/Sema/SemaInit.cpp:5486-5487
+  //   The remaining elements...otherwise are value initialzed
+  InitializedEntity SubEntity =
+  InitializedEntity::InitializeMember(FD, );
+  InitializationKind SubKind = InitializationKind::CreateValue(

Is there any possibility of lifetime warnings here? I don't *think* value 
initialization can ever create problems, but it would seem more obviously right 
to use the parenthesized aggregate initialization entity kind here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148274

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


[PATCH] D125171: [clang-format] Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-04-24 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin updated this revision to Diff 516452.
jrmolin added a comment.

pulled upstream/main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25429,6 +25429,68 @@
   verifyFormat("auto x = 5s .count() == 5;");
 }
 
+TEST_F(FormatTest, BreakBeforeParameterList) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.BreakBeforeFunctionParameters, FormatStyle::FPBS_Leave);
+  Style.BinPackParameters = false;
+
+  // test Leave (basically transparent mode)
+
+  // verify that there is no break by default
+  verifyFormat("int function1();\n" // formatted
+   "int function2(int param1, int param2, int param3);\n"
+   "void function3(int param1, int param2, int param3) {}\n"
+   "int function4(int param1, int param2, int param3);\n",
+   "int function1();\n" // original
+   "int function2(\n"
+   "int param1, int param2, int param3);\n"
+   "void function3(int param1, int param2, int param3) {}\n"
+   "int function4(int param1, int param2, int param3);\n",
+   Style);
+
+  // test Always
+  // verify that there is a break when told to break
+  Style.BreakBeforeFunctionParameters = FormatStyle::FPBS_Always;
+  verifyFormat("int function1(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n"
+   "int function2();\n"
+   "void function3(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3) {}\n"
+   "int function4(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n"
+   "int function5(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n",
+   Style);
+
+  // verify that having no parameters doesn't affect the parentheses
+  verifyFormat("void function1() {}\n", // the formatted part
+   "void function1() {}\n", // the original
+   Style);
+
+  verifyFormat("void function1();\n", // the formatted part
+   "void function1();\n", // the original
+   Style);
+
+  // test Never
+  Style.BreakBeforeFunctionParameters = FormatStyle::FPBS_Never;
+  verifyFormat("int function1();\n" // the formatted part
+   "int function2(int param1, int param2, int param3);\n",
+   "int function1();\n" // the original
+   "int function2(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n",
+   Style);
+}
+
 TEST_F(FormatTest, InterfaceAsClassMemberName) {
   verifyFormat("class Foo {\n"
"  int interface;\n"
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -607,6 +607,17 @@
   CHECK_PARSE("BreakBeforeBraces: Custom", BreakBeforeBraces,
   FormatStyle::BS_Custom);
 
+  CHECK_PARSE("BreakBeforeFunctionParameters: Always",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Always);
+  CHECK_PARSE("BreakBeforeFunctionParameters: Leave",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Leave);
+  CHECK_PARSE("BreakBeforeFunctionParameters: true",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Always);
+  CHECK_PARSE("BreakBeforeFunctionParameters: false",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Leave);
+  CHECK_PARSE("BreakBeforeFunctionParameters: Never",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Never);
+
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
   CHECK_PARSE("BraceWrapping:\n"
   "  AfterControlStatement: MultiLine",
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4867,6 +4867,21 @@
 return true;
   }
 
+  // If BreakBeforeFunctionParameters is Always, we want to break before
+  // the next parameter, if there is one. If it is Leave and a newline exists,
+  // make sure we insert one. Otherwise, no newline.
+  if (Left.is(tok::l_paren) && 

[PATCH] D125171: [clang-format] Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-04-24 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin updated this revision to Diff 516450.
jrmolin marked an inline comment as done.
jrmolin added a comment.

change formatting of enum options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25429,6 +25429,68 @@
   verifyFormat("auto x = 5s .count() == 5;");
 }
 
+TEST_F(FormatTest, BreakBeforeParameterList) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.BreakBeforeFunctionParameters, FormatStyle::FPBS_Leave);
+  Style.BinPackParameters = false;
+
+  // test Leave (basically transparent mode)
+
+  // verify that there is no break by default
+  verifyFormat("int function1();\n" // formatted
+   "int function2(int param1, int param2, int param3);\n"
+   "void function3(int param1, int param2, int param3) {}\n"
+   "int function4(int param1, int param2, int param3);\n",
+   "int function1();\n" // original
+   "int function2(\n"
+   "int param1, int param2, int param3);\n"
+   "void function3(int param1, int param2, int param3) {}\n"
+   "int function4(int param1, int param2, int param3);\n",
+   Style);
+
+  // test Always
+  // verify that there is a break when told to break
+  Style.BreakBeforeFunctionParameters = FormatStyle::FPBS_Always;
+  verifyFormat("int function1(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n"
+   "int function2();\n"
+   "void function3(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3) {}\n"
+   "int function4(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n"
+   "int function5(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n",
+   Style);
+
+  // verify that having no parameters doesn't affect the parentheses
+  verifyFormat("void function1() {}\n", // the formatted part
+   "void function1() {}\n", // the original
+   Style);
+
+  verifyFormat("void function1();\n", // the formatted part
+   "void function1();\n", // the original
+   Style);
+
+  // test Never
+  Style.BreakBeforeFunctionParameters = FormatStyle::FPBS_Never;
+  verifyFormat("int function1();\n" // the formatted part
+   "int function2(int param1, int param2, int param3);\n",
+   "int function1();\n" // the original
+   "int function2(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n",
+   Style);
+}
+
 TEST_F(FormatTest, InterfaceAsClassMemberName) {
   verifyFormat("class Foo {\n"
"  int interface;\n"
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -607,6 +607,17 @@
   CHECK_PARSE("BreakBeforeBraces: Custom", BreakBeforeBraces,
   FormatStyle::BS_Custom);
 
+  CHECK_PARSE("BreakBeforeFunctionParameters: Always",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Always);
+  CHECK_PARSE("BreakBeforeFunctionParameters: Leave",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Leave);
+  CHECK_PARSE("BreakBeforeFunctionParameters: true",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Always);
+  CHECK_PARSE("BreakBeforeFunctionParameters: false",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Leave);
+  CHECK_PARSE("BreakBeforeFunctionParameters: Never",
+  BreakBeforeFunctionParameters, FormatStyle::FPBS_Never);
+
   Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
   CHECK_PARSE("BraceWrapping:\n"
   "  AfterControlStatement: MultiLine",
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4867,6 +4867,21 @@
 return true;
   }
 
+  // If BreakBeforeFunctionParameters is Always, we want to break before
+  // the next parameter, if there is one. If it is Leave and a newline exists,
+  // make sure we insert one. 

[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

2023-04-24 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

The patch this is dependent on has now been accepted and landed, so this should 
be ready for review now if anyone is available!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 516445.
Manna edited the summary of this revision.

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

https://reviews.llvm.org/D149074

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -389,7 +389,7 @@
   Mods = getNextModifiers(Proto, Pos);
 }
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it rather
   // than use a standard declaration, so that SemaChecking can range check
   // the immediate passed by the user.
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -4659,7 +4659,7 @@
 const llvm::MapVector ) {
   SearchNamespaces = true;
 
-  for (auto KNPair : KnownNamespaces)
+  for (const auto  : KnownNamespaces)
 Namespaces.addNameSpecifier(KNPair.first);
 
   bool SSIsTemplate = false;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -447,7 +447,7 @@
   if (!CXXRecord)
 return false;
 
-  for (auto BaseSpecifier : CXXRecord->bases()) {
+  for (const auto  : CXXRecord->bases()) {
 if (!foundStarOperator)
   foundStarOperator = IsOverloadedOperatorPresent(
   BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2806,7 +2806,7 @@
 // Determines whether 'Ranges' intersects with ('Start', 'End').
 static bool affectsRange(ArrayRef Ranges, unsigned Start,
  unsigned End) {
-  for (auto Range : Ranges) {
+  for (const auto  : Ranges) {
 if (Range.getOffset() < End &&
 Range.getOffset() + Range.getLength() > Start) {
   return true;
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3757,7 +3757,7 @@
   Classes.front().initialize(/*Parent=*/nullptr, /*Specifier=*/nullptr);
   detectAmbiguousBases(Classes);
   int Flags = 0;
-  for (auto Class : Classes) {
+  for (const MSRTTIClass  : Classes) {
 if (Class.RD->getNumBases() > 1)
   Flags |= HasBranchingHierarchy;
 // Note: cl.exe does not calculate "HasAmbiguousBases" correctly.  We
Index: clang/lib/CodeGen/CGGPUBuiltin.cpp
===
--- clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -189,7 +189,7 @@
/* ParamsToSkip = */ 0);
 
   SmallVector Args;
-  for (auto A : CallArgs) {
+  for (const auto  : CallArgs) {
 // We don't know how to emit non-scalar varargs.
 if (!A.getRValue(*this).isScalar()) {
   CGM.ErrorUnsupported(E, "non-scalar arg to printf");
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -663,7 +663,7 @@
 
 ExprDependence clang::computeDependence(DesignatedInitExpr *E) {
   auto Deps = E->getInit()->getDependence();
-  for (auto D : E->designators()) {
+  for (const auto  : E->designators()) {
 auto DesignatorDeps = ExprDependence::None;
 if (D.isArrayDesignator())
   DesignatorDeps |= E->getArrayIndex(D)->getDependence();
Index: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
===
--- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -179,7 +179,7 @@
   return true;
 
 // Skip methods in records.
-for (auto P : Context.getParents(*Method)) {
+for (const auto  : Context.getParents(*Method)) {
   if (P.template get())
 return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

2023-04-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: tahonermann.
Herald added subscribers: kosarev, tpr.
Herald added a reviewer: aaron.ballman.
Herald added a reviewer: ributzka.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
Manna requested review of this revision.
Herald added a reviewer: dang.

Reported by Coverity:
AUTO_CAUSES_COPY
Unnecessary object copies can affect performance.

1. Inside "ExtractAPIVisitor.h" file, in 
clang::​extractapi::​impl::​ExtractAPIVisitorBase<::​BatchExtractAPIVisitor>::​VisitFunctionDecl(clang::​FunctionDecl
 const *): Using the auto keyword without an & causes the copy of an object of 
type DynTypedNode.

2. Inside "NeonEmitter.cpp" file, in 
::​Intrinsic::​Intrinsic(llvm::​Record *, llvm::​StringRef, 
llvm::​StringRef, ::​TypeSpec, ::​TypeSpec, 
::​ClassKind, llvm::​ListInit *, ::​NeonEmitter &, 
llvm::​StringRef, llvm::​StringRef, bool, bool): Using the auto keyword without 
an & causes the copy of an object of type Type.

3. Inside "MicrosoftCXXABI.cpp" file, in 
::​MSRTTIBuilder::​getClassHierarchyDescriptor(): Using the auto 
keyword without an & causes the copy of an object of type MSRTTIClass.

4. Inside "Registry.cpp" file, in 
clang::​ast_matchers::​dynamic::​Registry::​getAcceptedCompletionTypes(llvm::​ArrayRef>): Using the auto keyword without an & causes he copy 
of an object of type ASTNodeKind.

5. Inside "Tokens.cpp" file, in 
clang::​syntax::​TokenBuffer::​macroExpansions(clang::​FileID): Using the auto 
keyword without an & causes he copy of an object of type Mapping.

6. Inside "CGGPUBuiltin.cpp" file, in 
clang::​CodeGen::​CodeGenFunction::​EmitAMDGPUDevicePrintfCallExpr(clang::​CallExpr
 const *): Using the auto keyword without an & causes the copy of an object of 
type CallArg.

7. Inside "SemaDeclAttr.cpp" file, in 
threadSafetyCheckIsSmartPointer(clang::​Sema &, clang::​RecordType const *): 
Using the auto keyword without an & causes the copy of an object of type 
CXXBaseSpecifier.

8. Inside "ComputeDependence.cpp" file, in 
clang::​computeDependence(clang::​DesignatedInitExpr *): Using the auto keyword 
without an & causes the copy of an object of type Designator.

9. Inside "Format.cpp" file, In 
clang::​format::​affectsRange(llvm::​ArrayRef, 
unsigned int, unsigned int): Using the auto keyword without an & causes the 
copy of an object of type Range.

10. Inside "SemaLookup.cpp" file, In 
clang::​TypoCorrectionConsumer::​addNamespaces(llvm::​MapVector, 
llvm::​detail::​DenseMapPair>, 
std::​vector, 
std::​allocator>>> const &): Using 
the auto keyword without an & causes  the copy of an object of type pair.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149074

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -389,7 +389,7 @@
   Mods = getNextModifiers(Proto, Pos);
 }
 
-for (auto Type : Types) {
+for (const auto  : Types) {
   // If this builtin takes an immediate argument, we need to #define it rather
   // than use a standard declaration, so that SemaChecking can range check
   // the immediate passed by the user.
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -609,7 +609,7 @@
   auto  = FileIt->second;
   std::vector Expansions;
   auto  = File.SpelledTokens;
-  for (auto Mapping : File.Mappings) {
+  for (const auto  : File.Mappings) {
 const syntax::Token *Token = [Mapping.BeginSpelled];
 if (Token->kind() == tok::TokenKind::identifier)
   Expansions.push_back(Token);
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -4659,7 +4659,7 @@
 const llvm::MapVector ) {
   SearchNamespaces = true;
 
-  for (auto KNPair : KnownNamespaces)
+  for (const auto  : KnownNamespaces)
 Namespaces.addNameSpecifier(KNPair.first);
 
   bool SSIsTemplate = false;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -447,7 +447,7 @@
   if (!CXXRecord)
 return false;
 
-  for (auto BaseSpecifier : CXXRecord->bases()) {
+  for (const auto  : CXXRecord->bases()) {
 if 

[PATCH] D147666: [OPENMP] Adds /lib to rpath to avoid need to set LD_LIBRARY_PATH to find plugins.

2023-04-24 Thread Greg Rodgers via Phabricator via cfe-commits
gregrodgers abandoned this revision.
gregrodgers added a comment.

Its ugly, but to avoid requirement to set LD_LIBRARY_PATH for end-users who may 
need LD_LIBRARY_PATH for their own application, we will modify the compiler 
installation with these bash commands where _INSTALL_DIR is the installation 
directory.

  echo "-Wl,-rpath=${_INSTALL_DIR}/lib" > ${_INSTALL_DIR}/bin/rpath.cfg
  echo "-L${_INSTALL_DIR}/lib" >> ${_INSTALL_DIR}/bin/rpath.cfg
  ln -sf rpath.cfg ${_INSTALL_DIR}/bin/clang++.cfg
  ln -sf rpath.cfg ${_INSTALL_DIR}/bin/clang.cfg
  ln -sf rpath.cfg ${_INSTALL_DIR}/bin/flang.cfg
  ln -sf rpath.cfg ${_INSTALL_DIR}/bin/flang-new.cfg

My apologies to linux distro packaging teams.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147666

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


[PATCH] D147481: [M68k] Add basic Clang supports for M68881/2

2023-04-24 Thread Min-Yih Hsu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b617081420d: [M68k] Add basic Clang support for M68881/2 
(authored by myhsu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147481

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/M68k.cpp
  clang/lib/Basic/Targets/M68k.h
  clang/lib/Driver/ToolChains/Arch/M68k.cpp
  clang/lib/Driver/ToolChains/Arch/M68k.h
  clang/test/Driver/m68k-features.cpp
  clang/test/Driver/m68k-macros.cpp

Index: clang/test/Driver/m68k-macros.cpp
===
--- clang/test/Driver/m68k-macros.cpp
+++ clang/test/Driver/m68k-macros.cpp
@@ -1,10 +1,19 @@
 // Check macro definitions
-// RUN: %clang -target m68k-unknown-linux -m68000 -dM -E %s | FileCheck --check-prefix=CHECK-MX %s
+
+// Since '__HAVE_68881__' sorted before most of the 'mc680x0' macros, we need to put it here.
+// CHECK-MX881: #define __HAVE_68881__ 1
+// CHECK-NOMX881-NOT: #define __HAVE_68881__ 1
+
+// RUN: %clang -target m68k-unknown-linux -m68000 -dM -E %s | FileCheck --check-prefixes=CHECK-MX,CHECK-NOMX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68000 -mhard-float -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68000 -m68881 -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
 // CHECK-MX: #define __mc68000 1
 // CHECK-MX: #define __mc68000__ 1
 // CHECK-MX: #define mc68000 1
 
-// RUN: %clang -target m68k-unknown-linux -m68010 -dM -E %s | FileCheck --check-prefix=CHECK-MX10 %s
+// RUN: %clang -target m68k-unknown-linux -m68010 -dM -E %s | FileCheck --check-prefixes=CHECK-MX10,CHECK-NOMX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68010 -mhard-float -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68010 -m68881 -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
 // CHECK-MX10: #define __mc68000 1
 // CHECK-MX10: #define __mc68000__ 1
 // CHECK-MX10: #define __mc68010 1
@@ -12,7 +21,8 @@
 // CHECK-MX10: #define mc68000 1
 // CHECK-MX10: #define mc68010 1
 
-// RUN: %clang -target m68k-unknown-linux -m68020 -dM -E %s | FileCheck --check-prefix=CHECK-MX20 %s
+// RUN: %clang -target m68k-unknown-linux -m68020 -dM -E %s | FileCheck --check-prefixes=CHECK-MX20,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68020 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
 // CHECK-MX20: #define __mc68000 1
 // CHECK-MX20: #define __mc68000__ 1
 // CHECK-MX20: #define __mc68020 1
@@ -20,7 +30,8 @@
 // CHECK-MX20: #define mc68000 1
 // CHECK-MX20: #define mc68020 1
 
-// RUN: %clang -target m68k-unknown-linux -m68030 -dM -E %s | FileCheck --check-prefix=CHECK-MX30 %s
+// RUN: %clang -target m68k-unknown-linux -m68030 -dM -E %s | FileCheck --check-prefixes=CHECK-MX30,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68030 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
 // CHECK-MX30: #define __mc68000 1
 // CHECK-MX30: #define __mc68000__ 1
 // CHECK-MX30: #define __mc68030 1
@@ -28,7 +39,8 @@
 // CHECK-MX30: #define mc68000 1
 // CHECK-MX30: #define mc68030 1
 
-// RUN: %clang -target m68k-unknown-linux -m68040 -dM -E %s | FileCheck --check-prefix=CHECK-MX40 %s
+// RUN: %clang -target m68k-unknown-linux -m68040 -dM -E %s | FileCheck --check-prefixes=CHECK-MX40,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68040 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
 // CHECK-MX40: #define __mc68000 1
 // CHECK-MX40: #define __mc68000__ 1
 // CHECK-MX40: #define __mc68040 1
@@ -36,7 +48,8 @@
 // CHECK-MX40: #define mc68000 1
 // CHECK-MX40: #define mc68040 1
 
-// RUN: %clang -target m68k-unknown-linux -m68060 -dM -E %s | FileCheck --check-prefix=CHECK-MX60 %s
+// RUN: %clang -target m68k-unknown-linux -m68060 -dM -E %s | FileCheck --check-prefixes=CHECK-MX60,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68060 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
 // CHECK-MX60: #define __mc68000 1
 // CHECK-MX60: #define __mc68000__ 1
 // CHECK-MX60: #define __mc68060 1
Index: clang/test/Driver/m68k-features.cpp
===
--- clang/test/Driver/m68k-features.cpp
+++ clang/test/Driver/m68k-features.cpp
@@ -59,3 +59,23 @@
 // RUN: FileCheck --check-prefix=CHECK-FIXED-D7 < %t %s
 // CHECK-FIXED-D7: "-target-feature" "+reserve-d7"
 
+//  Floating point 
+// RUN: %clang -target m68k -m68000 -mhard-float -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MX881 < %t %s
+// RUN: %clang -target m68k -m68000 -m68881 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MX881 < %t %s
+
+// RUN: %clang -target m68k -m68010 -mhard-float -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MX881 < %t %s
+// RUN: %clang -target m68k -m68010 -m68881 

[clang] 9b61708 - [M68k] Add basic Clang support for M68881/2

2023-04-24 Thread Min-Yih Hsu via cfe-commits

Author: Min-Yih Hsu
Date: 2023-04-24T09:32:49-07:00
New Revision: 9b617081420dc579c52b53a4d8929b206b206eed

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

LOG: [M68k] Add basic Clang support for M68881/2

  - Add the `-m68881` flag
  - Add floating point feature detection
  - Macro definitions

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/M68k.cpp
clang/lib/Basic/Targets/M68k.h
clang/lib/Driver/ToolChains/Arch/M68k.cpp
clang/lib/Driver/ToolChains/Arch/M68k.h
clang/test/Driver/m68k-features.cpp
clang/test/Driver/m68k-macros.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d8ae398c61218..ceab53171eaee 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4650,6 +4650,8 @@ def m68030 : Flag<["-"], "m68030">, 
Group;
 def m68040 : Flag<["-"], "m68040">, Group;
 def m68060 : Flag<["-"], "m68060">, Group;
 
+def m68881 : Flag<["-"], "m68881">, Group;
+
 foreach i = {0-6} in
   def ffixed_a#i : Flag<["-"], "ffixed-a"#i>, Group,
 HelpText<"Reserve the a"#i#" register (M68k only)">;

diff  --git a/clang/lib/Basic/Targets/M68k.cpp 
b/clang/lib/Basic/Targets/M68k.cpp
index 437ad7253a31c..1b0cc4d0b13ff 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -27,8 +27,8 @@ namespace clang {
 namespace targets {
 
 M68kTargetInfo::M68kTargetInfo(const llvm::Triple ,
-   const TargetOptions &)
-: TargetInfo(Triple) {
+   const TargetOptions )
+: TargetInfo(Triple), TargetOpts(Opts) {
 
   std::string Layout;
 
@@ -120,6 +120,11 @@ void M68kTargetInfo::getTargetDefines(const LangOptions 
,
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
   }
+
+  // Floating point
+  if (TargetOpts.FeatureMap.lookup("isa-68881") ||
+  TargetOpts.FeatureMap.lookup("isa-68882"))
+Builder.defineMacro("__HAVE_68881__");
 }
 
 ArrayRef M68kTargetInfo::getTargetBuiltins() const {

diff  --git a/clang/lib/Basic/Targets/M68k.h b/clang/lib/Basic/Targets/M68k.h
index dea9b59334919..1af00115a5059 100644
--- a/clang/lib/Basic/Targets/M68k.h
+++ b/clang/lib/Basic/Targets/M68k.h
@@ -36,6 +36,8 @@ class LLVM_LIBRARY_VISIBILITY M68kTargetInfo : public 
TargetInfo {
 CK_68060
   } CPU = CK_Unknown;
 
+  const TargetOptions 
+
 public:
   M68kTargetInfo(const llvm::Triple , const TargetOptions &);
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/M68k.cpp 
b/clang/lib/Driver/ToolChains/Arch/M68k.cpp
index 628c252e83864..963f7a187d636 100644
--- a/clang/lib/Driver/ToolChains/Arch/M68k.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/M68k.cpp
@@ -65,13 +65,35 @@ std::string m68k::getM68kTargetCPU(const ArgList ) {
   return "";
 }
 
+static void addFloatABIFeatures(const llvm::opt::ArgList ,
+std::vector ) {
+  Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float,
+   options::OPT_m68881);
+  // Opt out FPU even for newer CPUs.
+  if (A && A->getOption().matches(options::OPT_msoft_float)) {
+Features.push_back("-isa-68881");
+Features.push_back("-isa-68882");
+return;
+  }
+
+  std::string CPU = m68k::getM68kTargetCPU(Args);
+  // Only enable M68881 for CPU < 68020 if the related flags are present.
+  if ((A && (CPU == "M68000" || CPU == "M68010")) ||
+  // Otherwise, by default we assume newer CPUs have M68881/2.
+  CPU == "M68020")
+Features.push_back("+isa-68881");
+  else if (CPU == "M68030" || CPU == "M68040" || CPU == "M68060")
+// Note that although CPU >= M68040 imply M68882, we still add `isa-68882`
+// anyway so that it's easier to add or not add the corresponding macro
+// definitions later, in case we want to disable 68881/2 in newer CPUs
+// (with -msoft-float, for instance).
+Features.push_back("+isa-68882");
+}
+
 void m68k::getM68kTargetFeatures(const Driver , const llvm::Triple ,
  const ArgList ,
  std::vector ) {
-
-  m68k::FloatABI FloatABI = m68k::getM68kFloatABI(D, Args);
-  if (FloatABI == m68k::FloatABI::Soft)
-Features.push_back("-hard-float");
+  addFloatABIFeatures(Args, Features);
 
   // Handle '-ffixed-' flags
   if (Args.hasArg(options::OPT_ffixed_a0))
@@ -105,21 +127,3 @@ void m68k::getM68kTargetFeatures(const Driver , const 
llvm::Triple ,
   if (Args.hasArg(options::OPT_ffixed_d7))
 Features.push_back("+reserve-d7");
 }
-
-m68k::FloatABI m68k::getM68kFloatABI(const Driver , const ArgList ) {

[PATCH] D148355: [analyzer] Fix comparison logic in ArrayBoundCheckerV2

2023-04-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Please mark comments "Done" where applicable.




Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:173
+  const MemSpaceRegion *SR = rawOffset.getRegion()->getMemorySpace();
+  if (SR->getKind() != MemRegion::UnknownSpaceRegionKind) {
+// a pointer to UnknownSpaceRegionKind may point to the middle of

donat.nagy wrote:
> donat.nagy wrote:
> > steakhal wrote:
> > > donat.nagy wrote:
> > > > steakhal wrote:
> > > > > 
> > > > You're completely right, I just blindly copied this test from the 
> > > > needlessly overcomplicated `computeExtentBegin()`.
> > > Hold on. This would only skip the lower bounds check if it's an 
> > > `UnknownSpaceRegion`.
> > > Shouldn't we early return instead?
> > This behavior is inherited from the code before my commit: the old block 
> > `if ( /*... =*/ extentBegin.getAs() ) { /* ... */ }` is equivalent 
> > to `if (llvm::isa(SR)) { /*...*/ }` and there was no 
> > early return connected to //this// NonLocness check. (The old code skipped 
> > the upper bound check if the result of `evalBinOpNN()` is unknown, and 
> > that's what I changed because I saw no reason to do an early return there.)
> > 
> > After some research into the memory region model, I think that there is no 
> > reason to perform an early return -- in fact, the condition of this  `if` 
> > seems to be too narrow because we would like to warn about code like
> >   struct foo {
> > int tag;
> > int array[5];
> >   };
> >   int f(struct foo *p) {
> > return p->arr[-1];
> >   }
> > despite the fact that it's indexing into a `FieldRegion` inside a 
> > `SymbolicRegion` in `UnknownSpaceRegion`. That is, instead of checking the 
> > top-level MemorySpace, the correct logic would be checking the kind of the 
> > memory region and/or perhaps its immediate super-region.
> > 
> > As this is a complex topic and completely unrelated to the main goal of 
> > this commit; I'd prefer to keep the old (not ideal, but working) logic in 
> > this patch, then revisit this question by creating a separate follow-up 
> > commit.
> Minor nitpick: your suggested change accidentally negated the conditional :) 
> ... and I said that it's "completely right". I'm glad that I noticed this and 
> inserted the "!" before the `isa` check because otherwise it could've been 
> annoying to debug this...
Agreed.



Comment at: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp:173
+  const MemSpaceRegion *SR = rawOffset.getRegion()->getMemorySpace();
+  if (SR->getKind() != MemRegion::UnknownSpaceRegionKind) {
+// a pointer to UnknownSpaceRegionKind may point to the middle of

steakhal wrote:
> donat.nagy wrote:
> > donat.nagy wrote:
> > > steakhal wrote:
> > > > donat.nagy wrote:
> > > > > steakhal wrote:
> > > > > > 
> > > > > You're completely right, I just blindly copied this test from the 
> > > > > needlessly overcomplicated `computeExtentBegin()`.
> > > > Hold on. This would only skip the lower bounds check if it's an 
> > > > `UnknownSpaceRegion`.
> > > > Shouldn't we early return instead?
> > > This behavior is inherited from the code before my commit: the old block 
> > > `if ( /*... =*/ extentBegin.getAs() ) { /* ... */ }` is 
> > > equivalent to `if (llvm::isa(SR)) { /*...*/ }` and 
> > > there was no early return connected to //this// NonLocness check. (The 
> > > old code skipped the upper bound check if the result of `evalBinOpNN()` 
> > > is unknown, and that's what I changed because I saw no reason to do an 
> > > early return there.)
> > > 
> > > After some research into the memory region model, I think that there is 
> > > no reason to perform an early return -- in fact, the condition of this  
> > > `if` seems to be too narrow because we would like to warn about code like
> > >   struct foo {
> > > int tag;
> > > int array[5];
> > >   };
> > >   int f(struct foo *p) {
> > > return p->arr[-1];
> > >   }
> > > despite the fact that it's indexing into a `FieldRegion` inside a 
> > > `SymbolicRegion` in `UnknownSpaceRegion`. That is, instead of checking 
> > > the top-level MemorySpace, the correct logic would be checking the kind 
> > > of the memory region and/or perhaps its immediate super-region.
> > > 
> > > As this is a complex topic and completely unrelated to the main goal of 
> > > this commit; I'd prefer to keep the old (not ideal, but working) logic in 
> > > this patch, then revisit this question by creating a separate follow-up 
> > > commit.
> > Minor nitpick: your suggested change accidentally negated the conditional 
> > :) ... and I said that it's "completely right". I'm glad that I noticed 
> > this and inserted the "!" before the `isa` check because otherwise it 
> > could've been annoying to debug this...
> Agreed.
Sorry about that. Happens


Repository:
  rG LLVM Github Monorepo

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


[PATCH] D145416: [clang] model 'p' inline asm constraint as reading memory

2023-04-24 Thread James Y Knight via Phabricator via cfe-commits
jyknight requested changes to this revision.
jyknight added a comment.
This revision now requires changes to proceed.

I believe this is abandoned, correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145416

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


[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-04-24 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 516435.
VincentWu marked 2 inline comments as done.
VincentWu added a comment.

remove testcse of Codegen & rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmp-invalid.s
  llvm/test/MC/RISCV/rv32zcmp-valid.s
  llvm/test/MC/RISCV/rv64zcmp-invalid.s
  llvm/test/MC/RISCV/rv64zcmp-valid.s

Index: llvm/test/MC/RISCV/rv64zcmp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmp-valid.s
@@ -0,0 +1,149 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=experimental-zcmp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=experimental-zcmp < %s \
+# RUN: | llvm-objdump --mattr=-c,experimental-zcmp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.mvsa01 s1, s0
+# CHECK-ASM: encoding: [0xa2,0xac]
+cm.mvsa01 s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.mva01s s1, s0
+# CHECK-ASM: encoding: [0xe2,0xac]
+cm.mva01s s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbe]
+cm.popret {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbe]
+cm.popret {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbe]
+cm.popret {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbe]
+cm.popret {ra,s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbe]
+cm.popret {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbe]
+cm.popret {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbe]
+cm.popret {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbe]
+cm.popret {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbe]
+cm.popret {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbc]
+cm.popretz {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbc]
+cm.popretz {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbc]
+cm.popretz {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbc]
+cm.popretz {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbc]
+cm.popretz {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbc]
+cm.popretz {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbc]
+cm.popretz {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbc]
+cm.popretz {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbc]
+cm.popretz {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xba]
+cm.pop {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xba]
+cm.pop {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0}, 16
+# CHECK-ASM: encoding: [0x52,0xba]
+cm.pop {ra, s0}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xba]
+cm.pop {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xba]
+cm.pop {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xba]
+cm.pop {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xba]
+cm.pop {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xba]
+cm.pop {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.push {ra}, -16
+# CHECK-ASM: encoding: [0x42,0xb8]
+cm.push {ra}, -16
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0}, -32
+# CHECK-ASM: encoding: [0x56,0xb8]
+cm.push {ra, s0}, -32
+
+# CHECK-ASM-AND-OBJ: 

[PATCH] D148038: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

2023-04-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D148038#4292549 , @agozillon wrote:

> In D148038#4292262 , @awarzynski 
> wrote:
>
>> LGTM, thanks for addressing my comments!
>
> Thank you for your time and the great review comments as always!

Thanks you 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148038

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


[clang] 8eea50c - Add missing HTML closing tag

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T11:58:50-04:00
New Revision: 8eea50c7c5569b13f8c910349754c72337075b1f

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

LOG: Add missing HTML closing tag

The  tag was missing for this entry.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 423fc0e1ae4a..4b6b0283767c 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -141,7 +141,7 @@ Open Clang Projects
 The second stage would be to produce a configuration file (that can be used
 independently of the Host) so that Clang can read it and not need a gazillion
 of command-line options. Such file should be simple JSON / INI or anything that
-a text editor could change.
+a text editor could change.
 
 
 If you hit a bug with Clang, it is very useful for us if you reduce the code



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


[clang] 8aea6e0 - [clang][Interp][NFC] Take a QualType in visitZeroInitializer()

2023-04-24 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-04-24T17:58:15+02:00
New Revision: 8aea6e004fd2edafbdee2d3d13571ab5eace004e

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

LOG: [clang][Interp][NFC] Take a QualType in visitZeroInitializer()

The given expression is not necessarily usable to obtain a type for,
so we can't use it to get the floating point semantics. Pass a QualType
instead, which we can use--and classify() that here.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index a8e8b2997ddef..e28532b288871 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -390,7 +390,7 @@ bool 
ByteCodeExprGen::VisitImplicitValueInitExpr(const ImplicitValueIni
   if (!T)
 return false;
 
-  return this->visitZeroInitializer(*T, E);
+  return this->visitZeroInitializer(E->getType(), E);
 }
 
 template 
@@ -929,7 +929,12 @@ bool ByteCodeExprGen::visitConditional(
 }
 
 template 
-bool ByteCodeExprGen::visitZeroInitializer(PrimType T, const Expr *E) 
{
+bool ByteCodeExprGen::visitZeroInitializer(QualType QT,
+const Expr *E) {
+  // FIXME: We need the QualType to get the float semantics, but that means we
+  //   classify it over and over again in array situations.
+  PrimType T = classifyPrim(QT);
+
   switch (T) {
   case PT_Bool:
 return this->emitZeroBool(E);
@@ -954,8 +959,7 @@ bool 
ByteCodeExprGen::visitZeroInitializer(PrimType T, const Expr *E) {
   case PT_FnPtr:
 return this->emitNullFnPtr(E);
   case PT_Float: {
-return this->emitConstFloat(
-APFloat::getZero(Ctx.getFloatSemantics(E->getType())), E);
+return this->emitConstFloat(APFloat::getZero(Ctx.getFloatSemantics(QT)), 
E);
   }
   }
   llvm_unreachable("unknown primitive type");

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 85588c6ecd3c1..a3aab16c4a083 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -201,7 +201,7 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
   friend class ArrayIndexScope;
 
   /// Emits a zero initializer.
-  bool visitZeroInitializer(PrimType T, const Expr *E);
+  bool visitZeroInitializer(QualType QT, const Expr *E);
 
   enum class DerefKind {
 /// Value is read and pushed to stack.



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


[clang] d64811f - Remove the "implement better version of existing tools" open project

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T11:56:25-04:00
New Revision: d64811f976b4305b54a5cbe0427002f5460c2d89

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

LOG: Remove the "implement better version of existing tools" open project

This project doesn't really relate to improving Clang itself and it
contained stale suggestions like working on code modification
functionality in clang-format.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index c7cde4f2c040..423fc0e1ae4a 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -95,21 +95,6 @@ Open Clang Projects
 from source code. The tool is in early stages of development and could use more
 dedicated effort to complete the implementation.
 
-Use clang libraries to implement better versions of existing tools:
-Clang is built as a set of libraries, which means that it is possible to
-implement capabilities similar to other source language tools, improving them
-in various ways.  Three examples are https://github.com/distcc;>distcc, the http://delta.tigris.org/;>delta testcase reduction tool, and the
-"indent" source reformatting tool.
-distcc can be improved to scale better and be more efficient.  Delta could be
-faster and more efficient at reducing C-family programs if built on the clang
-preprocessor. The clang-based indent replacement,
-https://clang.llvm.org/docs/ClangFormat.html;>clang-format,
-could be taught to handle simple structural rules like those in https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code;>the
 LLVM coding
-standards.
-
 Self-testing using clang: There are several neat ways to
 improve the quality of clang by self-testing. Some examples:
 



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


[clang] 5259ff7 - Reword the open project for generating documentation

2023-04-24 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-24T11:55:11-04:00
New Revision: 5259ff7f0aef9aa1871e623608d5c00d3284adb0

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

LOG: Reword the open project for generating documentation

Work already began on this project, so this updates the wording to
discuss clang-doc specifically.

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 3d55099df869..c7cde4f2c040 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -88,14 +88,12 @@ Open Clang Projects
 performance as well as to find ways to proactively alert us when we've
 introduced a change that has significant negative impact on build times.
 
-Implement an tool to generate code documentation: Clang's
-library-based design allows it to be used by a variety of tools that reason
-about source code. One great application of Clang would be to build an
-auto-documentation system like doxygen that generates code documentation from
-source code. The advantage of using Clang for such a tool is that the tool 
would
-use the same preprocessor/parser/ASTs as the compiler itself, giving it a very
-rich understanding of the code. Clang is already able to read and understand
-doxygen markup, but cannot yet generate documentation from it.
+Improve clang-doc: Clang's library-based design allows it to be used
+by a variety of tools that reason about source code.
+https://clang.llvm.org/extra/clang-doc.html;>clang-doc is one
+great application of this functionality, which generates code documentation
+from source code. The tool is in early stages of development and could use more
+dedicated effort to complete the implementation.
 
 Use clang libraries to implement better versions of existing tools:
 Clang is built as a set of libraries, which means that it is possible to



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


[PATCH] D147684: [clangd] Add batch fixes for include-cleaner diagnostics

2023-04-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

can you also add test coverage for the new LSP fields?




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:439
+  for (auto  : RemoveAll.Edits) {
+E.annotationId.emplace();
+*E.annotationId = RemoveAllUnusedID;

nit: `E.annotationId.emplace(RemoveAllUnusedID);` (same for others)



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:443
+  RemoveAll.Annotations.push_back({RemoveAllUnusedID,
+   {/*label=*/"", /*needsConfirmation=*/true,
+/*description=*/std::nullopt}});

rather than an empty label, let's duplicate `RemoveAll.Message` here. As that 
context will probably be lost after executing the code action.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:464
+  "AddAllMissingIncludes";
+  for (auto  : AddAllMissing.Edits) {
+E.annotationId.emplace();

i think you want to populate `AddAllMissing.Edits` from `Edits` first



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:468
+  }
+  // FIXME(hokein): emit used symbol reference in the annotation.
+  AddAllMissing.Annotations.push_back(

unless we want a really wordy description, this would actually require us to 
attach one annotation per edit, rather than using the same annotation for all 
the edits.
can you check what changes in the UI when we have multiple annotations for a 
single workspace edit?



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:484
+  FixAll.Annotations.push_back({FixAllID, {
+/*label=*/"", /*needsConfirmation=*/true, /*description=*/std::nullopt
+  }});

again let's use `FixAll.Message` as label



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:493
+llvm::StringRef Code) {
+  std::optional RemoveAllUnused, AddAllMissing, FixAll;
+  std::vector UnusedIncludes = generateUnusedIncludeDiagnostics(

can you declare these right before their use sides, rather than on the same 
line?



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:496
+  AST.tuPath(), Findings.UnusedIncludes, Code);
+  if (!UnusedIncludes.empty())
+RemoveAllUnused = removeAllUnusedIncludes(UnusedIncludes);

UnusedIncludes.size() > 1



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:501
+  AST, Findings.MissingIncludes, Code);
+  if (!MissingIncludeDiags.empty())
+AddAllMissing = addAllMissingIncludes(MissingIncludeDiags);

MissingIncludeDiags.size() > 1



Comment at: clang-tools-extra/clangd/Protocol.h:253
+  /// The actual annotation identifier.
+  std::optional annotationId = std::nullopt;
 };

rather than packing up a new field here, can we have a `struct 
AnnotatedTextEdit : TextEdit` ?

it's surely more convenient this way but creates some confusion in call sites 
that're trying to create a regular textedit.

also we can use the empty string again, no need for optional.



Comment at: clang-tools-extra/clangd/Protocol.h:264
+struct ChangeAnnotation {
+  // A human-readable string describing the actual change. The string
+  // is rendered prominent in the user interface.

nit: triple slashes, here and elsewhere



Comment at: clang-tools-extra/clangd/Protocol.h:274
+  // the user interface.
+  std::optional description;
+};

no need for optional here, we can use the empty string



Comment at: clang-tools-extra/clangd/Protocol.h:1027
+   /// AnnotatedTextEdit.
+  std::optional> changeAnnotations;
 };

i don't think there's any difference between an empty map and a nullopt here, 
right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147684

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


  1   2   >