[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-11 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 249838.
MarcusJohnson91 added a comment.

New squashed commit with all changes present


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

https://reviews.llvm.org/D75791

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2436,14 +2436,14 @@
 }
 
 TEST_F(FormatTest, FormatsExternC) {
-  verifyFormat("extern \"C\" {\nint a;");
+  verifyFormat("extern \"C\" {\nint a; /*2.1*/");
   verifyFormat("extern \"C\" {}");
   verifyFormat("extern \"C\" {\n"
-   "int foo();\n"
+   "int FormatsExternC_1();\n"
"}");
-  verifyFormat("extern \"C\" int foo() {}");
-  verifyFormat("extern \"C\" int foo();");
-  verifyFormat("extern \"C\" int foo() {\n"
+  verifyFormat("extern \"C\" int FormatsExternC_2() {}");
+  verifyFormat("extern \"C\" int FormatsExternC_3();");
+  verifyFormat("extern \"C\" int FormatsExternC_4() {\n"
"  int i = 42;\n"
"  return i;\n"
"}");
@@ -2451,9 +2451,9 @@
   FormatStyle Style = getLLVMStyle();
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterFunction = true;
-  verifyFormat("extern \"C\" int foo() {}", Style);
-  verifyFormat("extern \"C\" int foo();", Style);
-  verifyFormat("extern \"C\" int foo()\n"
+  verifyFormat("extern \"C\" int FormatsExternC_5() {}", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_6();", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_7()\n"
"{\n"
"  int i = 42;\n"
"  return i;\n"
@@ -2462,16 +2462,41 @@
 
   Style.BraceWrapping.AfterExternBlock = true;
   Style.BraceWrapping.SplitEmptyRecord = false;
-  verifyFormat("extern \"C\"\n"
-   "{}",
-   Style);
-  verifyFormat("extern \"C\"\n"
-   "{\n"
-   "  int foo();\n"
+  verifyFormat("extern \"C\"\n{}", Style);
+  verifyFormat("extern \"C\"\n{\nint FormatsExternC_8();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n"
+   "int FormatsExternC_9();\n"
"}",
Style);
 }
 
+TEST_F(FormatTest, FormatsExternBlock) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentWidth = 2;
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_1();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_2();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_3();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_4();\n}", Style);
+}
+
 TEST_F(FormatTest, FormatsInlineASM) {
   verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));");
   verifyFormat("asm(\"nop\" ::: \"memory\");");
@@ -12636,6 +12661,7 @@
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
+  CHECK_PARSE_BOOL(IndentExternBlock);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,11 +1085,21 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock) {
+if (Style.BraceWrapping.AfterExternBlock == true &&
+Style.IndentExternBlock == true) {
   addUnwrappedLine();
-  parseBlock(/*MustBeDeclaration=*/true);
-} else {
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true);
+} else if (Style.BraceWrapping.AfterExternBlock == false &&
+   Style.IndentExternBlock == false) {
   parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
+} else if (Style.BraceWrapping.AfterExternBlock == false &&
+   Style.IndentExternBlock == true) {
+  

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-11 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 updated this revision to Diff 249835.
shiva0217 added a comment.

Update the patch to address @apazos's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/riscv-sdata-module-flag.c
  clang/test/Driver/riscv-G-warning.c
  clang/test/Driver/riscv-sdata-warning.c

Index: clang/test/Driver/riscv-sdata-warning.c
===
--- /dev/null
+++ clang/test/Driver/riscv-sdata-warning.c
@@ -0,0 +1,8 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang -S -target riscv32-unknown-elf -fpic -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIC-SDATA %s
+// CHECK-PIC-SDATA: warning: ignoring '-msmall-data-limit=' with -mcmodel=large for -fpic or RV64
+
+// RUN: %clang -S -target riscv64-unknown-elf -mcmodel=large -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-RV64-LARGE-SDATA %s
+// CHECK-RV64-LARGE-SDATA: warning: ignoring '-msmall-data-limit=' with -mcmodel=large for -fpic or RV64
Index: clang/test/Driver/riscv-G-warning.c
===
--- /dev/null
+++ clang/test/Driver/riscv-G-warning.c
@@ -0,0 +1,4 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang -S -target riscv32-unknown-elf -G4 -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-G %s
+// CHECK-G: warning: ignoring '-G' with -msmall-data-limit= in the command line
Index: clang/test/CodeGen/riscv-sdata-module-flag.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-sdata-module-flag.c
@@ -0,0 +1,36 @@
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-DEFAULT
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -G4 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-G4
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -msmall-data-limit=0 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-S0
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -fpic -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-PIC
+
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-DEFAULT
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -G4 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-G4
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -msmall-data-limit=0 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-S0
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -fpic -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-PIC
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -mcmodel=large -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-LARGE
+
+void test() {}
+
+// RV32-DEFAULT: !{i32 1, !"SmallDataLimit", i32 8}
+// RV32-G4:  !{i32 1, !"SmallDataLimit", i32 4}
+// RV32-S0:  !{i32 1, !"SmallDataLimit", i32 0}
+// RV32-PIC: !{i32 1, !"SmallDataLimit", i32 0}
+
+// RV64-DEFAULT: !{i32 1, !"SmallDataLimit", i32 8}
+// RV64-G4:  !{i32 1, !"SmallDataLimit", i32 4}
+// RV64-S0:  !{i32 1, !"SmallDataLimit", i32 0}
+// RV64-PIC: !{i32 1, !"SmallDataLimit", i32 0}
+// RV64-LARGE:   !{i32 1, !"SmallDataLimit", i32 0}
+
+// The value will be passed by module flag instead of target feature.
+// RV32-S0-NOT: +small-data-limit=
+// RV64-S0-NOT: +small-data-limit=
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -923,6 +923,8 @@
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
+  Opts.SmallDataLimit =
+  getLastArgIntValue(Args, OPT_msmall_data_limit, 0, Diags);
   Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
   Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
   Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1960,6 +1960,42 @@
   }
 }
 
+static void SetRISCVSmallDataLimit(const ToolChain , const ArgList ,
+   ArgStringList ) 

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-11 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 added a comment.

In D57497#1917835 , @apazos wrote:

> Shiva, I see a warning always  being printed:
>
>   '+small-data-limit=' is not a recognized feature for this target (ignoring 
> feature)
>   
>
> This is because it is being passed down as a target feature.
>
> Might be good to add a test case to make sure the SmallDataLimit module flag 
> is created, no target feature is passed, and that no warnings are printed.


Hi Ana,
Thanks for catching this, I'll fix it and add testing lines for it.

In D57497#1918483 , @apazos wrote:

> Shiva, I am not sure how the SDataLimit is being honored in LTO mode. 
>  Where does getModuleMetadata get called?
>  If the SelectSectionForGlobal api is called without getModuleMetadata being 
> called first, it will use the default 8 instead of honoring the SDataLimit.


It seems that SDataLimit will be honored in LTO mode because getModuleMetadata 
will be called in AsmPrinter::doInitialization and SelectSectionForGlobal will 
be called from 
AsmPrinter::doFinalization->emitGlobalVariable->SectionForGLobal->SelectSecfionForGlobal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-03-11 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka added a comment.

I tried to reproduce the problem on the builder in a temporary folder and I 
found that CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR == .
Here is a list of all CMAKE_ variables available on a moment of initial 
configuration:

  -- CMAKE_AR: c:/buildbot/temp/build/bin/llvm-ar.exe
  -- CMAKE_BINARY_DIR: C:/buildbot/temp/build
  -- CMAKE_BUILD_TYPE: Release
  -- CMAKE_CL_SHOWINCLUDES_PREFIX: Note: including file:
  -- CMAKE_COMMAND: C:/Program Files/CMake/bin/cmake.exe
  -- CMAKE_CPACK_COMMAND: C:/Program Files/CMake/bin/cpack.exe
  -- CMAKE_CROSSCOMPILING: ON
  -- CMAKE_CTEST_COMMAND: C:/Program Files/CMake/bin/ctest.exe
  -- CMAKE_CURRENT_BINARY_DIR: C:/buildbot/temp/build
  -- CMAKE_CURRENT_LIST_DIR: C:/buildbot/temp/llvm-project/clang/cmake/caches
  -- CMAKE_CURRENT_LIST_FILE: 
C:/buildbot/temp/llvm-project/clang/cmake/caches/CrossWinToARMLinux.cmake
  -- CMAKE_CURRENT_SOURCE_DIR: C:/buildbot/temp/build
  -- CMAKE_CXX_FLAGS: -D__OPTIMIZE__
  -- CMAKE_C_COMPILER_TARGET: armv7-linux-gnueabihf
  -- CMAKE_FILES_DIRECTORY: /CMakeFiles
  -- CMAKE_HOST_SYSTEM_NAME: Windows
  -- CMAKE_HOST_WIN32: 1
  -- CMAKE_INSTALL_PREFIX: ../install
  -- CMAKE_MAJOR_VERSION: 3
  -- CMAKE_MINOR_VERSION: 10
  -- CMAKE_PATCH_VERSION: 2
  -- CMAKE_ROOT: C:/Program Files/CMake/share/cmake-3.10
  -- CMAKE_SOURCE_DIR: C:/buildbot/temp/build
  -- CMAKE_TWEAK_VERSION: 0
  -- CMAKE_VERSION: 3.10.2

Looks like this is a feature (bug?_ of CMake. CMake doc says

  CMAKE_SOURCE_DIR
  The path to the top level of the source tree.
  
  This is the full path to the top level of the current CMake source tree. For 
an in-source build, this would be the same as CMAKE_BINARY_DIR.
  
  When run in -P script mode, CMake sets the variables CMAKE_BINARY_DIR, 
CMAKE_SOURCE_DIR, CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR to the 
current working directory.

`-C` could be some kind of the script mode. May be. We use CMake 3.10.2 on the 
builders.

I think may be it is optimal to use `CMAKE_CURRENT_LIST_DIR` to calculate a 
direct path to required file. We always know where it is.

Something like that

  get_filename_component(LIBCXX_CXX_ABI_INCLUDE_PATHS
 "${CMAKE_CURRENT_LIST_DIR}/../../../libcxxabi/include"
 ABSOLUTE CACHE) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74347



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


[PATCH] D76040: [TableGen] Move generated *Attr class methods out of line

2020-03-11 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, thanks.   LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76040



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


[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-03-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D72841#1917459 , @rjmccall wrote:

> In D72841#1917340 , @mibintc wrote:
>
> > @rjmccall Since CompoundAssignmentOperator derives from BinaryOperator, 
> > it's not simple to add Trailing storage here.  I think I will have to fold 
> > CompoundAssignmentOperator into BinaryOperator and then add the 2 extra 
> > fields needed by CompoundAssignmentOperator into Trailing storage.  Can you 
> > think of a better way?  I worked on Trailing storage for UnaryOperator 
> > first and that wasn't too bad, but Binary is a different story.
>
>
> It's something we deal with occasionally, but it's definitely annoying.  You 
> basically have to test for which concrete class you have and then ask that 
> class for its trailing storage.
>
> Collapsing the types might be okay but could get involved.


To be clear, we do this in the Clang AST by doing a lot of hand-rolled trailing 
storage rather than by using llvm::TrailingStorage.  If you're willing to do 
the refactors necessary to use the latter, though, that's great; but as 
mentioned, you'll need to either collapse CompoundAssignmentOperator into 
BinaryOperator or introduce a concrete subclass for the non-compound operators 
and make BinaryOperator an abstract node.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D76040: [TableGen] Move generated *Attr class methods out of line

2020-03-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk marked an inline comment as done.
rnk added a comment.

The main things going out of line are:

- Create* factory methods
- Constructors
- Enum/string converters (use StringSwitch -> slow to instantiate)

Here's two examples from before & after:
https://reviews.llvm.org/P8203
https://reviews.llvm.org/P8204

The constructors and factory methods *could* be trivial, but some of them are 
quite complex.




Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:269
 
 void writeAccessors(raw_ostream ) const override {
   OS << "  " << type << " get" << getUpperName() << "() const {\n";

Most trivial accessors are still defined inline, like here. I think there's 
only one override of writeAccesorDefinitions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76040



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


[PATCH] D76040: [TableGen] Move generated *Attr class methods out of line

2020-03-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Are there any classes of methods which are worth continuing to generate inline? 
 Surely some of the accessors are trivial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76040



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


[clang] c4d23d8 - Add a missing include to clang unit tests

2020-03-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-11T21:05:20-07:00
New Revision: c4d23d8854840294bf49c524f93e2be85a401f00

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

LOG: Add a missing include to clang unit tests

Added: 


Modified: 
clang/unittests/AST/DeclTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/DeclTest.cpp 
b/clang/unittests/AST/DeclTest.cpp
index e095c4518ed6..f6aa7de08147 100644
--- a/clang/unittests/AST/DeclTest.cpp
+++ b/clang/unittests/AST/DeclTest.cpp
@@ -14,9 +14,10 @@
 #include "clang/AST/Mangle.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Tooling/Tooling.h"
-#include "gtest/gtest.h"
 #include "llvm/IR/DataLayout.h"
+#include "gtest/gtest.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::tooling;



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


[clang-tools-extra] d7c5037 - Prune TargetInfo.h include from ParsedAttr.h, NFC

2020-03-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-11T20:47:11-07:00
New Revision: d7c5037e6b9f0ac76f4880c529ae4e14b78e0bf0

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

LOG: Prune TargetInfo.h include from ParsedAttr.h, NFC

Saves ~400 includes of related headers:

$ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
| grep '^[-+] ' | sort | uniq -c | sort -nr
468 -llvm-project/clang/include/clang/Basic/TargetInfo.h
468 -llvm-project/clang/include/clang/Basic/TargetCXXABI.h
368 -llvm-project/llvm/include/llvm/Support/CodeGen.h
368 -llvm-project/clang/include/clang/Basic/XRayInstr.h
368 -llvm-project/clang/include/clang/Basic/CodeGenOptions.h
368 -llvm-project/clang/include/clang/Basic/CodeGenOptions.def
367 -llvm-project/llvm/include/llvm/ADT/FloatingPointMode.h
367 -llvm-project/clang/include/clang/Basic/DebugInfoOptions.h

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
clang/lib/Parse/ParseObjc.cpp
clang/lib/Sema/SemaAvailability.cpp
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Tooling/AllTUsExecution.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 7a807280d9b1..068d56c1a8a8 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -26,6 +26,7 @@
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Regex.h"
 #include 
 #include 
 using namespace clang;

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 163c353681bc..18ce478805f8 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -19,6 +19,10 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Timer.h"
 
+namespace llvm {
+class Regex;
+}
+
 namespace clang {
 
 class ASTContext;

diff  --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp 
b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 7e5501ccc60a..f20182bd25e6 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -8,6 +8,7 @@
 
 #include "ExpandModularHeadersPPCallbacks.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Serialization/ASTReader.h"

diff  --git 
a/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp 
b/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
index e9552bcb7b20..1b0cf899a299 100644
--- a/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
@@ -9,6 +9,7 @@
 #include "DefaultOperatorNewAlignmentCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang::ast_matchers;
 

diff  --git a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp 
b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
index ac0b61c96a93..86734b932cdb 100644
--- a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
@@ -9,6 +9,7 @@
 #include "SIMDIntrinsicsCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Regex.h"

diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index 0e0d5cce6d3c..4894e689475a 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h

[PATCH] D76038: PR45000: Use Sema::SetParamDefaultArgument in TransformLambdaExpr

2020-03-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Seems the same issue in `Sema::SubstParmVarDecl` was fixed in 
rGdc40b618cf397df7369406b3f61e91ccb57fb9f6 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76038



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


[PATCH] D75897: [X86] Support intrinsic _mm_broadcastsi128_si256

2020-03-11 Thread Kan Shengchen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG214d24e1f8e0: [X86] Support intrinsic 
_mm_broadcastsi128_si256 (authored by skan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75897

Files:
  clang/lib/Headers/avx2intrin.h
  clang/test/CodeGen/avx2-builtins.c


Index: clang/test/CodeGen/avx2-builtins.c
===
--- clang/test/CodeGen/avx2-builtins.c
+++ clang/test/CodeGen/avx2-builtins.c
@@ -208,6 +208,12 @@
   return _mm256_broadcastsi128_si256(a);
 }
 
+__m256i test_mm_broadcastsi128_si256(__m128i a) {
+  // CHECK-LABEL: test_mm_broadcastsi128_si256
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
+  return _mm_broadcastsi128_si256(a);
+}
+
 __m128 test_mm_broadcastss_ps(__m128 a) {
   // CHECK-LABEL: test_mm_broadcastss_ps
   // CHECK-NOT: @llvm.x86.avx2.vbroadcast.ss.ps
Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -740,6 +740,8 @@
   return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 
1);
 }
 
+#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X)
+
 #define _mm_blend_epi32(V1, V2, M) \
   (__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \
  (__v4si)(__m128i)(V2), (int)(M))


Index: clang/test/CodeGen/avx2-builtins.c
===
--- clang/test/CodeGen/avx2-builtins.c
+++ clang/test/CodeGen/avx2-builtins.c
@@ -208,6 +208,12 @@
   return _mm256_broadcastsi128_si256(a);
 }
 
+__m256i test_mm_broadcastsi128_si256(__m128i a) {
+  // CHECK-LABEL: test_mm_broadcastsi128_si256
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
+  return _mm_broadcastsi128_si256(a);
+}
+
 __m128 test_mm_broadcastss_ps(__m128 a) {
   // CHECK-LABEL: test_mm_broadcastss_ps
   // CHECK-NOT: @llvm.x86.avx2.vbroadcast.ss.ps
Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -740,6 +740,8 @@
   return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 1);
 }
 
+#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X)
+
 #define _mm_blend_epi32(V1, V2, M) \
   (__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \
  (__v4si)(__m128i)(V2), (int)(M))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Logan Smith via Phabricator via cfe-commits
logan-5 marked an inline comment as done.
logan-5 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp:202
+void macro_test(T t) {
+#define MACRO(x) find_if(x, x, x)
+

Quuxplusone wrote:
> logan-5 wrote:
> > EricWF wrote:
> > > Arguably this is *exactly* the kind of code we want to diagnose.
> > > 
> > > The call in the macro either, 
> > >   * Is a "customization point" and should be whitelisted. Or,
> > >   * It resolves the same in expansion (and can be qualified), Or,
> > >   * It is a bug. 
> > > 
> > > You mentioned false positives in things like `assert`. Can you provide 
> > > examples?
> > Fair enough. Disabling the check for macros does seem short sighted on 
> > closer thought.
> > 
> > When I run the check over LLVM in debug, `assert` expands to 
> > `(__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, 
> > #e) : (void)0)`. If the assert() is inside a function template, the check 
> > claims that `unqualified call to '__assert_rtn' may be resolved through 
> > ADL`. Inspecting the AST, this seems to be due to the fact that `__func__` 
> > has dependent type. I suppose `__func__` could be special cased to be 
> > ignored, or all uglified names, or something?
> Ouch, is that because `__func__` is an array of char with dependent length?
> ```
> template
> void foo() {
> char buf[sizeof(T)];
> memset(buf, '\0', sizeof buf);
> }
> ```
> Unqualified call to `memset`, where one of the arguments has dependent type 
> `char[sizeof(T)]` — does that trigger the diagnostic?
Yep. So, I suppose the check should not trigger for expressions of 
`DependentSizedArrayType` of `char`? Or of any built-in type, really?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D76040: [TableGen] Move generated *Attr class methods out of line

2020-03-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: aaron.ballman, rjmccall, jdoerfert.
Herald added a project: clang.

After this change, clang spends ~200ms parsing Attrs.inc instead of
~560ms. A large part of the cost was from the StringSwitch
instantiations, but this is a good way to avoid similar problems in the
future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76040

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -426,8 +426,8 @@
 }
 
 void writeCtorBody(raw_ostream ) const override {
-  OS << "  if (!" << getUpperName() << ".empty())\n";
-  OS << "std::memcpy(" << getLowerName() << ", " << getUpperName()
+  OS << "if (!" << getUpperName() << ".empty())\n";
+  OS << "  std::memcpy(" << getLowerName() << ", " << getUpperName()
  << ".data(), " << getLowerName() << "Length);\n";
 }
 
@@ -691,7 +691,7 @@
 }
 
 void writeCtorBody(raw_ostream ) const override {
-  OS << "std::copy(" << getUpperName() << ", " << getUpperName()
+  OS << "  std::copy(" << getUpperName() << ", " << getUpperName()
  << " + " << ArgSizeName << ", " << ArgName << ");\n";
 }
 
@@ -894,37 +894,45 @@
   OS << "}\n";
 }
 
-void writeConversion(raw_ostream ) const {
-  OS << "  static bool ConvertStrTo" << type << "(StringRef Val, ";
-  OS << type << " ) {\n";
-  OS << "Optional<" << type << "> R = llvm::StringSwitch R = llvm::StringSwitch>(Val)\n";
   for (size_t I = 0; I < enums.size(); ++I) {
-OS << "  .Case(\"" << values[I] << "\", ";
+OS << ".Case(\"" << values[I] << "\", ";
 OS << getAttrName() << "Attr::" << enums[I] << ")\n";
   }
-  OS << "  .Default(Optional<" << type << ">());\n";
-  OS << "if (R) {\n";
-  OS << "  Out = *R;\n  return true;\n}\n";
-  OS << "return false;\n";
-  OS << "  }\n\n";
+  OS << ".Default(Optional<" << type << ">());\n";
+  OS << "  if (R) {\n";
+  OS << "Out = *R;\n  return true;\n}\n";
+  OS << "  return false;\n";
+  OS << "}\n\n";
 
   // Mapping from enumeration values back to enumeration strings isn't
   // trivial because some enumeration values have multiple named
   // enumerators, such as type_visibility(internal) and
   // type_visibility(hidden) both mapping to TypeVisibilityAttr::Hidden.
-  OS << "  static const char *Convert" << type << "ToStr("
- << type << " Val) {\n"
- << "switch(Val) {\n";
+  OS << "const char *" << getAttrName() << "Attr::Convert" << type
+ << "ToStr(" << type << " Val) {\n"
+ << "  switch(Val) {\n";
   SmallDenseSet Uniques;
   for (size_t I = 0; I < enums.size(); ++I) {
 if (Uniques.insert(enums[I]).second)
-  OS << "case " << getAttrName() << "Attr::" << enums[I]
+  OS << "  case " << getAttrName() << "Attr::" << enums[I]
  << ": return \"" << values[I] << "\";\n";
   }
-  OS << "}\n"
- << "llvm_unreachable(\"No enumerator with that value\");\n"
- << "  }\n";
+  OS << "  }\n"
+ << "  llvm_unreachable(\"No enumerator with that value\");\n"
+ << "}\n";
 }
   };
 
@@ -1006,33 +1014,42 @@
   OS << "  " << WritePCHRecord(QualifiedTypeName, "(*i)");
 }
 
-void writeConversion(raw_ostream ) const {
-  OS << "  static bool ConvertStrTo" << type << "(StringRef Val, ";
+void writeConversion(raw_ostream , bool Header) const {
+  if (Header) {
+OS << "  static bool ConvertStrTo" << type << "(StringRef Val, " << type
+   << " );\n";
+OS << "  static const char *Convert" << type << "ToStr(" << type
+   << " Val);\n";
+return;
+  }
+
+  OS << "bool " << getAttrName() << "Attr::ConvertStrTo" << type
+ << "(StringRef Val, ";
   OS << type << " ) {\n";
-  OS << "Optional<" << type << "> R = llvm::StringSwitch R = llvm::StringSwitch>(Val)\n";
   for (size_t I = 0; I < enums.size(); ++I) {
-OS << "  .Case(\"" << values[I] << "\", ";
+OS << ".Case(\"" << values[I] << "\", ";
 OS << getAttrName() << "Attr::" << enums[I] << ")\n";
   }
-  OS << "  .Default(Optional<" << type << ">());\n";
-  OS << "if (R) {\n";
-  OS << "  Out = *R;\n  return true;\n}\n";
-  OS << "return false;\n";
-  OS << "  }\n\n";
+  OS << ".Default(Optional<" << type << ">());\n";
+  OS << "  if (R) {\n";
+  OS << "Out = *R;\n  return true;\n}\n";
+  OS << "  return false;\n";
+  OS << "}\n\n";
 
-  OS << "  static const char *Convert" << type << "ToStr("
+  

[PATCH] D76038: PR45000: Use Sema::SetParamDefaultArgument in TransformLambdaExpr

2020-03-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert planned changes to this revision.
aaronpuchert added a comment.

In D76038#1918571 , @aaronpuchert 
wrote:

> @rsmith, should I put a testcase under `test/SemaTemplate/`, perhaps as 
> `instantiate-lambda.cpp`?


I'll probably put it into `test/SemaCXX/vartemplate-lambda.cpp` like D23096 
 that added the loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76038



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


[PATCH] D76038: PR45000: Use Sema::SetParamDefaultArgument in TransformLambdaExpr

2020-03-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

@rsmith, should I put a testcase under `test/SemaTemplate/`, perhaps as 
`instantiate-lambda.cpp`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76038



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


[PATCH] D76039: [HIP] Let clang recognize .hip extension

2020-03-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.

https://reviews.llvm.org/D76039

Files:
  clang/lib/Frontend/FrontendOptions.cpp
  clang/test/CodeGenCUDA/hip-pinned-shadow.cu
  clang/test/CodeGenCUDA/hip-pinned-shadow.hip
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-default-gpu-arch.hip
  clang/test/Driver/hip-device-libs.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-no-device-libs.hip
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-printf.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-syntax-only.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-opt.hip

Index: clang/test/Driver/hip-toolchain-opt.hip
===
--- clang/test/Driver/hip-toolchain-opt.hip
+++ clang/test/Driver/hip-toolchain-opt.hip
@@ -4,56 +4,56 @@
 
 // RUN: %clang -### \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,DEFAULT %s
 
 // RUN: %clang -### -O0 \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O0 %s
 
 // RUN: %clang -### -O1 \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O1 %s
 
 // RUN: %clang -### -O2 \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O2 %s
 
 // RUN: %clang -### -O3 \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,O3 %s
 
 // RUN: %clang -### -Os \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Os %s
 
 // RUN: %clang -### -Oz \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Oz %s
 
 // RUN: %clang -### -Og \
 // RUN:   -target x86_64-unknown-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -c -nogpulib \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck --check-prefixes=ALL,Og %s
Index: clang/test/Driver/hip-toolchain-mllvm.hip
===
--- clang/test/Driver/hip-toolchain-mllvm.hip
+++ clang/test/Driver/hip-toolchain-mllvm.hip
@@ -3,7 +3,7 @@
 // REQUIRES: amdgpu-registered-target
 
 // RUN: %clang -### -target x86_64-linux-gnu \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -mllvm -amdgpu-function-calls=0 \
 // RUN:   %s 2>&1 | FileCheck %s
 
Index: clang/test/Driver/hip-toolchain-features.hip
===
--- clang/test/Driver/hip-toolchain-features.hip
+++ clang/test/Driver/hip-toolchain-features.hip
@@ -3,10 +3,10 @@
 // REQUIRES: amdgpu-registered-target
 
 // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
 // RUN:   -mxnack 2>&1 | FileCheck %s -check-prefix=XNACK
 // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
 // RUN:   -mno-xnack 2>&1 | FileCheck %s -check-prefix=NOXNACK
 
 // XNACK: {{.*}}clang{{.*}}"-target-feature" "+xnack"
@@ -14,10 +14,10 @@
 
 
 // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
 // RUN:   -msram-ecc 2>&1 | FileCheck %s -check-prefix=SRAM
 // RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   

[clang] 214d24e - [X86] Support intrinsic _mm_broadcastsi128_si256

2020-03-11 Thread Shengchen Kan via cfe-commits

Author: Shengchen Kan
Date: 2020-03-12T10:56:39+08:00
New Revision: 214d24e1f8e0737a5aa2e2c52a1ae095fb1c1abd

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

LOG: [X86] Support intrinsic _mm_broadcastsi128_si256

Reviewers: LuoYuanke, craig.topper, RKSimon, pengfei

Reviewed By: craig.topper

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Headers/avx2intrin.h
clang/test/CodeGen/avx2-builtins.c

Removed: 




diff  --git a/clang/lib/Headers/avx2intrin.h b/clang/lib/Headers/avx2intrin.h
index 162e83ea2fbc..cc16720949ea 100644
--- a/clang/lib/Headers/avx2intrin.h
+++ b/clang/lib/Headers/avx2intrin.h
@@ -740,6 +740,8 @@ _mm256_broadcastsi128_si256(__m128i __X)
   return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 
1);
 }
 
+#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X)
+
 #define _mm_blend_epi32(V1, V2, M) \
   (__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \
  (__v4si)(__m128i)(V2), (int)(M))

diff  --git a/clang/test/CodeGen/avx2-builtins.c 
b/clang/test/CodeGen/avx2-builtins.c
index f4c1c3cf4f35..95659895eeaf 100644
--- a/clang/test/CodeGen/avx2-builtins.c
+++ b/clang/test/CodeGen/avx2-builtins.c
@@ -208,6 +208,12 @@ __m256i test_mm256_broadcastsi128_si256(__m128i a) {
   return _mm256_broadcastsi128_si256(a);
 }
 
+__m256i test_mm_broadcastsi128_si256(__m128i a) {
+  // CHECK-LABEL: test_mm_broadcastsi128_si256
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
+  return _mm_broadcastsi128_si256(a);
+}
+
 __m128 test_mm_broadcastss_ps(__m128 a) {
   // CHECK-LABEL: test_mm_broadcastss_ps
   // CHECK-NOT: @llvm.x86.avx2.vbroadcast.ss.ps



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


Re: [PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Eric Fiselier via cfe-commits
On Wed, Mar 11, 2020 at 8:35 PM Arthur O'Dwyer via Phabricator <
revi...@reviews.llvm.org> wrote:

> Quuxplusone added inline comments.
>
>
> 
> Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h:27
> +class UnintendedADLCheck : public ClangTidyCheck {
> +  const bool IgnoreOverloadedOperators;
> +  const std::vector AllowedIdentifiers;
> 
> EricWF wrote:
> > I think we should always ignore operators. I don't see value in having a
> mode where every comparison triggers this warning.
> >
> I think there's value in that mode, for library writers (not libc++) who
> really care about finding every unintentional ADL in their whole library.
> The standard library is designed not-to-work with types like
> [`Holder`](
> https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/),
> but someone else's library might be designed to work even in that case, and
> then they'd want to hear about ADL lookups for things like `operator,`.
> Besides, it's just 1 extra line of code in the patch, isn't it?
>

I think the matcher you're describing this library to want is:

cxxOperatorCallExpr()

Because every instance of that node denotes a call to an overloaded
operator written using operator syntax.
This check doesn't need to indulge that strange use case.


> However, I now think I may not understand how this check works. I thought
> it looked for unqualified calls (even in templates) that "may" use ADL, but
> now that I look again at the tests, it seems to trigger only on concrete
> calls (in concrete template instantiations) that "do" use ADL, which sounds
> still useful but much less comprehensive than I had thought.
>
> I think it would catch
> ```
> template void foo(T t) { t, 0; }
> struct S { friend void operator,(S, int); };
> template void foo(S);
> ```
> but not
> ```
> template void foo(T t) { t, 0; }
> struct S { friend void operator,(S, int); };
> template void foo(int);
> ```
> or
> ```
> template void foo(T t) { t, 0; }
> ```
> is that right?
>
>
That's correct.


>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D72282/new/
>
> https://reviews.llvm.org/D72282
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76038: PR45000: Use Sema::SetParamDefaultArgument in TransformLambdaExpr

2020-03-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We have to properly initialize from the given initialization expression
to make types match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76038

Files:
  clang/lib/Sema/TreeTransform.h


Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11882,7 +11882,7 @@
   Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, P);
   ExprResult R = getDerived().TransformExpr(
   E->getCallOperator()->getParamDecl(I)->getDefaultArg());
-  P->setDefaultArg(R.get());
+  getSema().SetParamDefaultArgument(P, R.get(), R.get()->getBeginLoc());
 }
   }
 


Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11882,7 +11882,7 @@
   Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, P);
   ExprResult R = getDerived().TransformExpr(
   E->getCallOperator()->getParamDecl(I)->getDefaultArg());
-  P->setDefaultArg(R.get());
+  getSema().SetParamDefaultArgument(P, R.get(), R.get()->getBeginLoc());
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp:202
+void macro_test(T t) {
+#define MACRO(x) find_if(x, x, x)
+

logan-5 wrote:
> EricWF wrote:
> > Arguably this is *exactly* the kind of code we want to diagnose.
> > 
> > The call in the macro either, 
> >   * Is a "customization point" and should be whitelisted. Or,
> >   * It resolves the same in expansion (and can be qualified), Or,
> >   * It is a bug. 
> > 
> > You mentioned false positives in things like `assert`. Can you provide 
> > examples?
> Fair enough. Disabling the check for macros does seem short sighted on closer 
> thought.
> 
> When I run the check over LLVM in debug, `assert` expands to 
> `(__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) 
> : (void)0)`. If the assert() is inside a function template, the check claims 
> that `unqualified call to '__assert_rtn' may be resolved through ADL`. 
> Inspecting the AST, this seems to be due to the fact that `__func__` has 
> dependent type. I suppose `__func__` could be special cased to be ignored, or 
> all uglified names, or something?
Ouch, is that because `__func__` is an array of char with dependent length?
```
template
void foo() {
char buf[sizeof(T)];
memset(buf, '\0', sizeof buf);
}
```
Unqualified call to `memset`, where one of the arguments has dependent type 
`char[sizeof(T)]` — does that trigger the diagnostic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D75573: [Sema][SVE] Reject aligned/_Alignas for sizeless types

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

LGTM

Technically, you could still do math on the address, and the difference would 
be visible. Granted, it's unlikely to matter in practice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75573



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


[PATCH] D75736: [Sema][SVE] Don't allow static or thread-local variables to have sizeless type

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D75736/new/

https://reviews.llvm.org/D75736



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


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Logan Smith via Phabricator via cfe-commits
logan-5 marked 2 inline comments as done.
logan-5 added a comment.

Thanks for the feedback.

In D72282#1918253 , @EricWF wrote:

> - This check should suggest fixes. It knows what function is actually being 
> resolved, and it has enough information to create a minimally qualified name 
> that resolves it.


True, though of course it will only be able to do so for the non-template 
version of the warning, since in the template version it only knows that the 
call _may_ be resolved through ADL.

> - This check should ignore hidden friends, since their entire purpose is to 
> be called via ADL.
> - This check should allow whitelisting namespaces that opt-out of ADL into 
> their namespace. This makes it much easier to roll out the clang-tidy 
> incrementally.

I want to make absolutely sure I understand the last bullet. You'd like a 
whitelist of namespaces where, if a call is resolved by ADL to a function 
within any of those namespaces, the check doesn't fire?

I like all these suggestions. I'll work on an updated patch.




Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h:27
+class UnintendedADLCheck : public ClangTidyCheck {
+  const bool IgnoreOverloadedOperators;
+  const std::vector AllowedIdentifiers;

Quuxplusone wrote:
> EricWF wrote:
> > I think we should always ignore operators. I don't see value in having a 
> > mode where every comparison triggers this warning.
> > 
> I think there's value in that mode, for library writers (not libc++) who 
> really care about finding every unintentional ADL in their whole library. The 
> standard library is designed not-to-work with types like 
> [`Holder`](https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/),
>  but someone else's library might be designed to work even in that case, and 
> then they'd want to hear about ADL lookups for things like `operator,`. 
> Besides, it's just 1 extra line of code in the patch, isn't it?
> 
> However, I now think I may not understand how this check works. I thought it 
> looked for unqualified calls (even in templates) that "may" use ADL, but now 
> that I look again at the tests, it seems to trigger only on concrete calls 
> (in concrete template instantiations) that "do" use ADL, which sounds still 
> useful but much less comprehensive than I had thought.
> 
> I think it would catch
> ```
> template void foo(T t) { t, 0; }
> struct S { friend void operator,(S, int); };
> template void foo(S);
> ```
> but not
> ```
> template void foo(T t) { t, 0; }
> struct S { friend void operator,(S, int); };
> template void foo(int);
> ```
> or
> ```
> template void foo(T t) { t, 0; }
> ```
> is that right?
@Quuxplusone your initial understanding was right; the check fires on both 
templates that "may" use ADL as well as concrete instantiations that "do." 
There are tests for both, but I see now that I failed to add tests for the 
"may" case for operators, which I'll do.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp:202
+void macro_test(T t) {
+#define MACRO(x) find_if(x, x, x)
+

EricWF wrote:
> Arguably this is *exactly* the kind of code we want to diagnose.
> 
> The call in the macro either, 
>   * Is a "customization point" and should be whitelisted. Or,
>   * It resolves the same in expansion (and can be qualified), Or,
>   * It is a bug. 
> 
> You mentioned false positives in things like `assert`. Can you provide 
> examples?
Fair enough. Disabling the check for macros does seem short sighted on closer 
thought.

When I run the check over LLVM in debug, `assert` expands to 
`(__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : 
(void)0)`. If the assert() is inside a function template, the check claims that 
`unqualified call to '__assert_rtn' may be resolved through ADL`. Inspecting 
the AST, this seems to be due to the fact that `__func__` has dependent type. I 
suppose `__func__` could be special cased to be ignored, or all uglified names, 
or something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D75737: [Sema][SVE] Don't allow fields to have sizeless type

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:1633
+if (RequireCompleteSizedType(Loc, FieldType,
+ diag::err_field_incomplete_or_sizeless)) {
   RD->setInvalidDecl();

Can BuildCaptureField actually print an error?  If it can, do you have a 
testcase?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75737



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


[PATCH] D75734: [Sema][SVE] Reject atomic sizeless types

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D75734/new/

https://reviews.llvm.org/D75734



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


[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D75571/new/

https://reviews.llvm.org/D75571



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


[PATCH] D75738: [Sema][SVE] Reject by-copy capture of sizeless types

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D75738/new/

https://reviews.llvm.org/D75738



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


[clang] ab69cd0 - [X86] Support intrinsic _mm_cldemote

2020-03-11 Thread Shengchen Kan via cfe-commits

Author: Shengchen Kan
Date: 2020-03-12T10:03:41+08:00
New Revision: ab69cd0779c529519eb7d26e0fa1b8dfb505f838

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

LOG: [X86] Support intrinsic _mm_cldemote

Reviewers: LuoYuanke, craig.topper, RKSimon, pengfei

Reviewed By: craig.topper

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Headers/cldemoteintrin.h
clang/test/CodeGen/cldemote.c

Removed: 




diff  --git a/clang/lib/Headers/cldemoteintrin.h 
b/clang/lib/Headers/cldemoteintrin.h
index 2413e7dea7a1..cfb951c1b4a9 100644
--- a/clang/lib/Headers/cldemoteintrin.h
+++ b/clang/lib/Headers/cldemoteintrin.h
@@ -18,11 +18,19 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
 
+/// Hint to hardware that the cache line that contains \p __P should be demoted
+/// from the cache closest to the processor core to a level more distant from
+/// the processor core.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLDEMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS
 _cldemote(const void * __P) {
   __builtin_ia32_cldemote(__P);
 }
 
+#define _mm_cldemote(p) _cldemote(p)
 #undef __DEFAULT_FN_ATTRS
 
 #endif

diff  --git a/clang/test/CodeGen/cldemote.c b/clang/test/CodeGen/cldemote.c
index 8c7bdf539333..f5f7ad9f27ea 100644
--- a/clang/test/CodeGen/cldemote.c
+++ b/clang/test/CodeGen/cldemote.c
@@ -7,4 +7,6 @@ void test_cldemote(const void *p) {
   //CHECK-LABEL: @test_cldemote
   //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
   _cldemote(p);
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _mm_cldemote(p);
 }



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


[PATCH] D75896: [X86] Support intrinsic _mm_cldemote

2020-03-11 Thread Kan Shengchen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab69cd0779c5: [X86] Support intrinsic _mm_cldemote (authored 
by skan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75896

Files:
  clang/lib/Headers/cldemoteintrin.h
  clang/test/CodeGen/cldemote.c


Index: clang/test/CodeGen/cldemote.c
===
--- clang/test/CodeGen/cldemote.c
+++ clang/test/CodeGen/cldemote.c
@@ -7,4 +7,6 @@
   //CHECK-LABEL: @test_cldemote
   //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
   _cldemote(p);
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _mm_cldemote(p);
 }
Index: clang/lib/Headers/cldemoteintrin.h
===
--- clang/lib/Headers/cldemoteintrin.h
+++ clang/lib/Headers/cldemoteintrin.h
@@ -18,11 +18,19 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
 
+/// Hint to hardware that the cache line that contains \p __P should be demoted
+/// from the cache closest to the processor core to a level more distant from
+/// the processor core.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLDEMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS
 _cldemote(const void * __P) {
   __builtin_ia32_cldemote(__P);
 }
 
+#define _mm_cldemote(p) _cldemote(p)
 #undef __DEFAULT_FN_ATTRS
 
 #endif


Index: clang/test/CodeGen/cldemote.c
===
--- clang/test/CodeGen/cldemote.c
+++ clang/test/CodeGen/cldemote.c
@@ -7,4 +7,6 @@
   //CHECK-LABEL: @test_cldemote
   //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
   _cldemote(p);
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _mm_cldemote(p);
 }
Index: clang/lib/Headers/cldemoteintrin.h
===
--- clang/lib/Headers/cldemoteintrin.h
+++ clang/lib/Headers/cldemoteintrin.h
@@ -18,11 +18,19 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
 
+/// Hint to hardware that the cache line that contains \p __P should be demoted
+/// from the cache closest to the processor core to a level more distant from
+/// the processor core.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLDEMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS
 _cldemote(const void * __P) {
   __builtin_ia32_cldemote(__P);
 }
 
+#define _mm_cldemote(p) _cldemote(p)
 #undef __DEFAULT_FN_ATTRS
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75894: [X86] Support intrinsics _bextr2*

2020-03-11 Thread Kan Shengchen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG560aa53f8fe5: [X86] Support intrinsics _bextr2* (authored by 
skan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75894

Files:
  clang/lib/Headers/bmiintrin.h
  clang/test/CodeGen/bmi-builtins.c


Index: clang/test/CodeGen/bmi-builtins.c
===
--- clang/test/CodeGen/bmi-builtins.c
+++ clang/test/CodeGen/bmi-builtins.c
@@ -155,6 +155,12 @@
   return _bextr_u32(__X, __Y, __Z);
 }
 
+unsigned int test_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK-LABEL: test_bextr2_u32
+  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+  return _bextr2_u32(__X, __Y);
+}
+
 unsigned int test_blsi_u32(unsigned int __X) {
   // CHECK-LABEL: test_blsi_u32
   // CHECK: sub i32 0, %{{.*}}
@@ -196,6 +202,13 @@
   return _bextr_u64(__X, __Y, __Z);
 }
 
+unsigned long long test_bextr2_u64(unsigned long long __X,
+   unsigned long long __Y) {
+  // CHECK-LABEL: test_bextr2_u64
+  // CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+  return _bextr2_u64(__X, __Y);
+}
+
 unsigned long long test_blsi_u64(unsigned long long __X) {
   // CHECK-LABEL: test_blsi_u64
   // CHECK: sub i64 0, %{{.*}}
Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -192,6 +192,28 @@
   return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned integer used to specify which bits are extracted. Bits [7:0]
+///specify the index of the least significant bit. Bits [15:8] specify the
+///number of bits to be extracted.
+/// \returns An unsigned integer whose least significant bits contain the
+///extracted bits.
+/// \see __bextr_u32
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
+_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  return __builtin_ia32_bextr_u32(__X, __Y);
+}
+
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///
@@ -321,6 +343,28 @@
   return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned 64-bit integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned 64-bit integer used to specify which bits are extracted. 
Bits
+///[7:0] specify the index of the least significant bit. Bits [15:8] 
specify
+///the number of bits to be extracted.
+/// \returns An unsigned 64-bit integer whose least significant bits contain 
the
+///extracted bits.
+/// \see __bextr_u64
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+_bextr2_u64(unsigned long long __X, unsigned long long __Y) {
+  return __builtin_ia32_bextr_u64(__X, __Y);
+}
+
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///


Index: clang/test/CodeGen/bmi-builtins.c
===
--- clang/test/CodeGen/bmi-builtins.c
+++ clang/test/CodeGen/bmi-builtins.c
@@ -155,6 +155,12 @@
   return _bextr_u32(__X, __Y, __Z);
 }
 
+unsigned int test_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK-LABEL: test_bextr2_u32
+  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+  return _bextr2_u32(__X, __Y);
+}
+
 unsigned int test_blsi_u32(unsigned int __X) {
   // CHECK-LABEL: test_blsi_u32
   // CHECK: sub i32 0, %{{.*}}
@@ -196,6 +202,13 @@
   return _bextr_u64(__X, __Y, __Z);
 }
 
+unsigned long long test_bextr2_u64(unsigned long long __X,
+   unsigned long long __Y) {
+  // CHECK-LABEL: test_bextr2_u64
+  // CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+  return _bextr2_u64(__X, __Y);
+}
+
 unsigned long long test_blsi_u64(unsigned long long __X) {
   // CHECK-LABEL: test_blsi_u64
   // CHECK: sub i64 0, %{{.*}}
Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -192,6 

[PATCH] D75690: [SVE][Inline-Asm] Add constraints for SVE ACLE types

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D75690



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


[clang] 560aa53 - [X86] Support intrinsics _bextr2*

2020-03-11 Thread Shengchen Kan via cfe-commits

Author: Shengchen Kan
Date: 2020-03-12T09:26:51+08:00
New Revision: 560aa53f8fe58abcbc4bb441b631e8a401ee78fe

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

LOG: [X86] Support intrinsics _bextr2*

Reviewers: LuoYuanke, craig.topper, RKSimon, pengfei

Reviewed By: craig.topper

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Headers/bmiintrin.h
clang/test/CodeGen/bmi-builtins.c

Removed: 




diff  --git a/clang/lib/Headers/bmiintrin.h b/clang/lib/Headers/bmiintrin.h
index 841bd84070e8..937f1683b544 100644
--- a/clang/lib/Headers/bmiintrin.h
+++ b/clang/lib/Headers/bmiintrin.h
@@ -192,6 +192,28 @@ _bextr_u32(unsigned int __X, unsigned int __Y, unsigned 
int __Z)
   return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned integer used to specify which bits are extracted. Bits [7:0]
+///specify the index of the least significant bit. Bits [15:8] specify the
+///number of bits to be extracted.
+/// \returns An unsigned integer whose least significant bits contain the
+///extracted bits.
+/// \see __bextr_u32
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
+_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  return __builtin_ia32_bextr_u32(__X, __Y);
+}
+
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///
@@ -321,6 +343,28 @@ _bextr_u64(unsigned long long __X, unsigned int __Y, 
unsigned int __Z)
   return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned 64-bit integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned 64-bit integer used to specify which bits are extracted. 
Bits
+///[7:0] specify the index of the least significant bit. Bits [15:8] 
specify
+///the number of bits to be extracted.
+/// \returns An unsigned 64-bit integer whose least significant bits contain 
the
+///extracted bits.
+/// \see __bextr_u64
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+_bextr2_u64(unsigned long long __X, unsigned long long __Y) {
+  return __builtin_ia32_bextr_u64(__X, __Y);
+}
+
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///

diff  --git a/clang/test/CodeGen/bmi-builtins.c 
b/clang/test/CodeGen/bmi-builtins.c
index 9f2d776299f8..409dd40c4a33 100644
--- a/clang/test/CodeGen/bmi-builtins.c
+++ b/clang/test/CodeGen/bmi-builtins.c
@@ -155,6 +155,12 @@ unsigned int test_bextr_u32(unsigned int __X, unsigned int 
__Y,
   return _bextr_u32(__X, __Y, __Z);
 }
 
+unsigned int test_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK-LABEL: test_bextr2_u32
+  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+  return _bextr2_u32(__X, __Y);
+}
+
 unsigned int test_blsi_u32(unsigned int __X) {
   // CHECK-LABEL: test_blsi_u32
   // CHECK: sub i32 0, %{{.*}}
@@ -196,6 +202,13 @@ unsigned long long test_bextr_u64(unsigned long __X, 
unsigned int __Y,
   return _bextr_u64(__X, __Y, __Z);
 }
 
+unsigned long long test_bextr2_u64(unsigned long long __X,
+   unsigned long long __Y) {
+  // CHECK-LABEL: test_bextr2_u64
+  // CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+  return _bextr2_u64(__X, __Y);
+}
+
 unsigned long long test_blsi_u64(unsigned long long __X) {
   // CHECK-LABEL: test_blsi_u64
   // CHECK: sub i64 0, %{{.*}}



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


[PATCH] D75298: [Clang][SVE] Parse builtin type string for scalable vectors

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Changing the way we expose the builtins isn't going to affect most of the code 
related to the SVE intrinsics.  I'm fine sticking with a known working 
approach, and trying to address that issue later.


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

https://reviews.llvm.org/D75298



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


[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-11 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, AlexanderLanin.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Escapes replacement text when exporting to yaml and unescapes when importing 
from yaml.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76037

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/unittests/Tooling/ReplacementsYamlTest.cpp

Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -46,28 +46,35 @@
YamlContentStream.str().c_str());
 }
 
-TEST(ReplacementsYamlTest, serializesNewLines) {
-  TranslationUnitReplacements Doc;
+TEST(ReplacementsYamlTest, handlesEscaped) {
+  TranslationUnitReplacements Doc, NewDoc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n");
+  const StringRef FilePath = "/path/to/file1.h";
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\\t\r\n");
 
-  std::string YamlContent;
-  llvm::raw_string_ostream YamlContentStream(YamlContent);
+  SmallString<512> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
 
   yaml::Output YAML(YamlContentStream);
   YAML << Doc;
+  yaml::Input IYAML(YamlContent);
+  IYAML >> NewDoc;
 
-  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
-  ASSERT_STREQ("---\n"
-   "MainSourceFile:  '/path/to/source.cpp'\n"
-   "Replacements:\n"
-   "  - FilePath:'/path/to/file1.h'\n"
-   "Offset:  0\n"
-   "Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
-   "...\n",
-   YamlContentStream.str().c_str());
+  ASSERT_EQ(Doc.MainSourceFile, NewDoc.MainSourceFile);
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  if (Doc.Replacements.size() != NewDoc.Replacements.size()) {
+for (auto DocR = Doc.Replacements.begin(),
+  NewDocR = NewDoc.Replacements.begin(),
+  DocE = Doc.Replacements.end();
+ DocR != DocE; DocR++, NewDocR++) {
+  ASSERT_EQ(DocR->getFilePath(), NewDocR->getFilePath());
+  ASSERT_EQ(DocR->getLength(), NewDocR->getLength());
+  ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+  ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+}
+  }
 }
 
 TEST(ReplacementsYamlTest, deserializesReplacements) {
Index: clang/include/clang/Tooling/ReplacementsYaml.h
===
--- clang/include/clang/Tooling/ReplacementsYaml.h
+++ clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,17 +35,66 @@
 
 NormalizedReplacement(const IO &, const clang::tooling::Replacement )
 : FilePath(R.getFilePath()), Offset(R.getOffset()),
-  Length(R.getLength()), ReplacementText(R.getReplacementText()) {
-  size_t lineBreakPos = ReplacementText.find('\n');
-  while (lineBreakPos != std::string::npos) {
-ReplacementText.replace(lineBreakPos, 1, "\n\n");
-lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);
+  Length(R.getLength()),
+  ReplacementText(escape(R.getReplacementText())) {}
+
+struct Escapes {
+  char EscapeChar;
+  char WrittenChar;
+};
+
+std::string escape(StringRef Str) {
+  constexpr Escapes EscapeChars[] = {
+  {'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  for (char C : Str) {
+if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+  if (C == Escape.EscapeChar) {
+Builder << '\\' << Escape.WrittenChar;
+return true;
+  }
+  return false;
+})) {
+  Builder << C;
+}
+  }
+  return Res;
+}
+
+std::string unescape(StringRef Str) {
+  constexpr Escapes EscapeChars[] = {
+  {'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  while (!Str.empty()) {
+if (Str.consume_front("\\")) {
+  if (Str.empty()) {
+Builder << '\\';
+break;
+  }
+  char C = Str.front();
+  Str = Str.drop_front();
+  if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+if (C == Escape.WrittenChar) {
+  Builder << Escape.EscapeChar;
+  return true;
+}
+return false;
+  })) {
+Builder << '\\' << C;
+  }
+  continue;
+}
+Builder << Str.front();
+  

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-11 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Shiva, I am not sure how the SDataLimit is being honored in LTO mode. 
Where does getModuleMetadata get called?
If the SelectSectionForGlobal api is called without getModuleMetadata being 
called first, it will use the default 8 instead of honoring the SDataLimit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[PATCH] D75570: [AST][SVE] Add new Type queries for sizeless types

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D75570/new/

https://reviews.llvm.org/D75570



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


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h:27
+class UnintendedADLCheck : public ClangTidyCheck {
+  const bool IgnoreOverloadedOperators;
+  const std::vector AllowedIdentifiers;

EricWF wrote:
> I think we should always ignore operators. I don't see value in having a mode 
> where every comparison triggers this warning.
> 
I think there's value in that mode, for library writers (not libc++) who really 
care about finding every unintentional ADL in their whole library. The standard 
library is designed not-to-work with types like 
[`Holder`](https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/),
 but someone else's library might be designed to work even in that case, and 
then they'd want to hear about ADL lookups for things like `operator,`. 
Besides, it's just 1 extra line of code in the patch, isn't it?

However, I now think I may not understand how this check works. I thought it 
looked for unqualified calls (even in templates) that "may" use ADL, but now 
that I look again at the tests, it seems to trigger only on concrete calls (in 
concrete template instantiations) that "do" use ADL, which sounds still useful 
but much less comprehensive than I had thought.

I think it would catch
```
template void foo(T t) { t, 0; }
struct S { friend void operator,(S, int); };
template void foo(S);
```
but not
```
template void foo(T t) { t, 0; }
struct S { friend void operator,(S, int); };
template void foo(int);
```
or
```
template void foo(T t) { t, 0; }
```
is that right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-11 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast updated this revision to Diff 249802.
PaulkaToast added a comment.

Mocked the header files so that we don't experience failures due to differences 
in systems. Mind taking a quick look @aaron.ballman?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/resource/include/stdatomic.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/resource/include/stddef.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/math.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/stdio.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/stdlib.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/string.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t \
+// RUN:   -- -- -isystem %S/Inputs/llvmlibc/system \
+// RUN:   -resource-dir %S/Inputs/llvmlibc/resource
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdio.h not allowed
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdlib.h not allowed
+#include "string.h"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header string.h not allowed
+#include "stdatomic.h"
+#include 
+// Compiler provided headers should not throw warnings.
Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
@@ -0,0 +1,8 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t \
+// RUN:   -- -header-filter=.* \
+// RUN:   -- -I %S/Inputs/llvmlibc \
+// RUN:   -isystem %S/Inputs/llvmlibc/system \
+// RUN:   -resource-dir %S/Inputs/llvmlibc/resource
+
+#include "transitive.h"
+// CHECK-MESSAGES: :1:1: warning: system libc header math.h not allowed, transitively included from {{.*}}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -68,6 +68,7 @@
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
 ``llvm-``  Checks related to the LLVM coding conventions.
+``llvmlibc-``  Checks related to the LLVM-libc coding standards.
 ``misc-``  Checks that we didn't have a better category for.
 ``modernize-`` Checks that advocate usage of modern (currently "modern"
means "C++11") language constructs.
Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - llvmlibc-restrict-system-libc-headers
+
+llvmlibc-restrict-system-libc-headers
+=
+
+Finds includes of system libc headers not provided by the compiler within
+llvm-libc implementations.
+
+.. code-block:: c++
+
+   #include // Not allowed because it is part of system libc.
+   #include// Allowed because it is provided by the compiler.
+   #include "internal/stdio.h"   // Allowed because it is NOT 

[clang-tools-extra] d6497a5 - Add missing StringMap.h inclusion, apparently clangd is not covered by check-clang-tools zzz

2020-03-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-11T16:47:49-07:00
New Revision: d6497a521bbd4024ed39a384b44af5f4f4a81e05

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

LOG: Add missing StringMap.h inclusion, apparently clangd is not covered by 
check-clang-tools zzz

Added: 


Modified: 
clang-tools-extra/clangd/FS.h

Removed: 




diff  --git a/clang-tools-extra/clangd/FS.h b/clang-tools-extra/clangd/FS.h
index d8cc4438ef7f..7b7f7cb25fac 100644
--- a/clang-tools-extra/clangd/FS.h
+++ b/clang-tools-extra/clangd/FS.h
@@ -12,6 +12,7 @@
 #include "Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
 namespace clang {



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


[PATCH] D76032: [HIP] Fix duplicate clang -cc1 options on MSVC toolchain

2020-03-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a reviewer: rnk.
tra added a comment.

LGTM, but I'm not familiar with the details of clang-cl. I've added Reid who'd 
have a better idea.


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

https://reviews.llvm.org/D76032



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


[PATCH] D76030: [CUDA] Warn about unsupported CUDA SDK version only if it's used.

2020-03-11 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 249792.
tra added a comment.

clang-formatted the changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76030

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/test/Driver/cuda-version-check.cu

Index: clang/test/Driver/cuda-version-check.cu
===
--- clang/test/Driver/cuda-version-check.cu
+++ clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,10 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// Make sure that we don't warn about CUDA version during C++ compilation.
+// RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
+// RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION_CXX
 
 // The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
@@ -62,3 +66,4 @@
 // ERR_SM61-NOT: error: GPU arch sm_61
 
 // UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
+// UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -30,6 +30,8 @@
   const Driver 
   bool IsValid = false;
   CudaVersion Version = CudaVersion::UNKNOWN;
+  std::string DetectedVersion;
+  bool DetectedVersionIsNotSupported = false;
   std::string InstallPath;
   std::string BinPath;
   std::string LibPath;
@@ -75,6 +77,10 @@
   std::string getLibDeviceFile(StringRef Gpu) const {
 return LibDeviceMap.lookup(Gpu);
   }
+  void WarnIfUnsupportedVersion();
+
+private:
+  void ParseCudaVersionFile(llvm::StringRef V);
 };
 
 namespace tools {
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -33,24 +33,28 @@
 
 // Parses the contents of version.txt in an CUDA installation.  It should
 // contain one line of the from e.g. "CUDA Version 7.5.2".
-static CudaVersion ParseCudaVersionFile(const Driver , llvm::StringRef V) {
+void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) {
+  Version = CudaVersion::UNKNOWN;
   if (!V.startswith("CUDA Version "))
-return CudaVersion::UNKNOWN;
+return;
   V = V.substr(strlen("CUDA Version "));
   SmallVector VersionParts;
   V.split(VersionParts, '.');
   if (VersionParts.size() < 2)
-return CudaVersion::UNKNOWN;
-  std::string MajorMinor = join_items(".", VersionParts[0], VersionParts[1]);
-  CudaVersion Version = CudaStringToVersion(MajorMinor);
+return;
+  DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]);
+  Version = CudaStringToVersion(DetectedVersion);
   if (Version != CudaVersion::UNKNOWN)
-return Version;
+return;
 
-  // Issue a warning and assume that the version we've found is compatible with
-  // the latest version we support.
-  D.Diag(diag::warn_drv_unknown_cuda_version)
-  << MajorMinor << CudaVersionToString(CudaVersion::LATEST);
-  return CudaVersion::LATEST;
+  Version = CudaVersion::LATEST;
+  DetectedVersionIsNotSupported = true;
+}
+
+void CudaInstallationDetector::WarnIfUnsupportedVersion() {
+  if (DetectedVersionIsNotSupported)
+D.Diag(diag::warn_drv_unknown_cuda_version)
+<< DetectedVersion << CudaVersionToString(Version);
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
@@ -149,7 +153,7 @@
   // version.txt isn't present.
   Version = CudaVersion::CUDA_70;
 } else {
-  Version = ParseCudaVersionFile(D, (*VersionFile)->getBuffer());
+  ParseCudaVersionFile((*VersionFile)->getBuffer());
 }
 
 if (Version >= CudaVersion::CUDA_90) {
@@ -567,8 +571,10 @@
  const Action::OffloadKind OK)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
-  if (CudaInstallation.isValid())
+  if (CudaInstallation.isValid()) {
+CudaInstallation.WarnIfUnsupportedVersion();
 getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
+  }
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
   getProgramPaths().push_back(getDriver().Dir);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8527c1e - Added constraints on cl-options.cu test

2020-03-11 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-03-11T16:06:09-07:00
New Revision: 8527c1ed66c63db0590cd69320ba0bf8fad59b87

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

LOG: Added constraints on cl-options.cu test

Added: 


Modified: 
clang/test/Driver/cl-options.cu

Removed: 




diff  --git a/clang/test/Driver/cl-options.cu b/clang/test/Driver/cl-options.cu
index 7597970af160..2fd393e06d2d 100644
--- a/clang/test/Driver/cl-options.cu
+++ b/clang/test/Driver/cl-options.cu
@@ -3,6 +3,10 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
 // -stack-protector should not be passed to device-side CUDA compilation
 // RUN: %clang_cl -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck 
-check-prefix=GS-default %s
 // GS-default: "-cc1" "-triple" "nvptx64-nvidia-cuda"



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


[Diffusion] rG825235c140e7: Revert "[Sema] Use the canonical type in function isVector"

2020-03-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Can we change the element type of the vector to `_Float16`?

`typedef __attribute__((neon_vector_type(4))) _Float16 float16x4_t;`

It seems that the original plan discussed on llvm-dev 
(http://lists.llvm.org/pipermail/cfe-dev/2017-May/053768.html) was to introduce 
`_Float16` and use it instead of `__fp16` for ARMv8.2-A, but the subsequent 
patches that were committed are making NeonEmitter.cpp emit typedefs of vectors 
that have `__fp16` as the element type.


BRANCHES
  master, release/10.x

Users:
  ahatanak (Author)

https://reviews.llvm.org/rG825235c140e7



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


[PATCH] D75560: Make Decl:: setOwningModuleID() public. (NFC)

2020-03-11 Thread Adrian Prantl via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b366e75d413: Make Decl::setOwningModuleID() public. (NFC) 
(authored by aprantl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75560

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/DeclTemplate.h


Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -1891,6 +1891,10 @@
 return *TemplateArgs;
   }
 
+  void setTemplateArgs(TemplateArgumentList *Args) {
+TemplateArgs = Args;
+  }
+
   /// Determine the kind of specialization that this
   /// declaration represents.
   TemplateSpecializationKind getSpecializationKind() const {
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -2722,8 +2722,6 @@
 
   ExplicitSpecifier ExplicitSpec;
 
-  void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
-
 public:
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
@@ -2745,6 +2743,7 @@
 
   /// Return true if the declartion is already resolved to be explicit.
   bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
+  void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
 
   /// Returns the type that this conversion function is converting to.
   QualType getConversionType() const {
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -626,7 +626,16 @@
 setModuleOwnershipKind(ModuleOwnershipKind::ModulePrivate);
   }
 
-  /// Set the owning module ID.
+public:
+  /// Set the FromASTFile flag. This indicates that this declaration
+  /// was deserialized and not parsed from source code and enables
+  /// features such as module ownership information.
+  void setFromASTFile() {
+FromASTFile = true;
+  }
+
+  /// Set the owning module ID.  This may only be called for
+  /// deserialized Decls.
   void setOwningModuleID(unsigned ID) {
 assert(isFromASTFile() && "Only works on a deserialized declaration");
 *((unsigned*)this - 2) = ID;
Index: clang/include/clang/AST/Decl.h
===
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -3539,6 +3539,7 @@
   /// negative enumerators of this enum. (see getNumNegativeBits)
   void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; }
 
+public:
   /// True if this tag declaration is a scoped enumeration. Only
   /// possible in C++11 mode.
   void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; }
@@ -3555,6 +3556,7 @@
   /// Microsoft-style enumeration with a fixed underlying type.
   void setFixed(bool Fixed = true) { EnumDeclBits.IsFixed = Fixed; }
 
+private:
   /// True if a valid hash is stored in ODRHash.
   bool hasODRHash() const { return EnumDeclBits.HasODRHash; }
   void setHasODRHash(bool Hash = true) { EnumDeclBits.HasODRHash = Hash; }


Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -1891,6 +1891,10 @@
 return *TemplateArgs;
   }
 
+  void setTemplateArgs(TemplateArgumentList *Args) {
+TemplateArgs = Args;
+  }
+
   /// Determine the kind of specialization that this
   /// declaration represents.
   TemplateSpecializationKind getSpecializationKind() const {
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -2722,8 +2722,6 @@
 
   ExplicitSpecifier ExplicitSpec;
 
-  void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
-
 public:
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
@@ -2745,6 +2743,7 @@
 
   /// Return true if the declartion is already resolved to be explicit.
   bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
+  void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
 
   /// Returns the type that this conversion function is converting to.
   QualType getConversionType() const {
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -626,7 +626,16 @@
 setModuleOwnershipKind(ModuleOwnershipKind::ModulePrivate);
   }
 
-  /// Set the owning 

[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-11 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D73245#1918148 , @EricWF wrote:

> I've already stated my disapproval of this patch. Libc++ has never and will 
> never provide nor value C++03 conformance.
>  Moving backwards to C++03 is inconsistent with the libraries general 
> direction.


@EricWF makes a point here, we want to move away from C++03.

> This patch disables tests, which could hide bugs, including serious ABI 
> differences between dialects.
> 
> I would like to unbreak compilation on NetBSD. But all that's needed there is 
> to provide our own correct declaration of max_align_t.
>  I don't see why C++03 conformance is a necessary condition.

Is there anything that can be done on the NetBSD side to solve this? Basically, 
just imagine that libc++ doesn't provide a C++03 mode at all -- what would you 
do then? I think that's the right mindset to solve this specific problem.


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

https://reviews.llvm.org/D73245



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


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.



- This check should suggest fixes. It knows what function is actually being 
resolved, and it has enough information to create a minimally qualified name 
that resolves it.
- This check should ignore hidden friends, since their entire purpose is to be 
called via ADL.
- This check should allow whitelisting namespaces that opt-out of ADL into 
their namespace. This makes it much easier to roll out the clang-tidy 
incrementally.




Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h:27
+class UnintendedADLCheck : public ClangTidyCheck {
+  const bool IgnoreOverloadedOperators;
+  const std::vector AllowedIdentifiers;

I think we should always ignore operators. I don't see value in having a mode 
where every comparison triggers this warning.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp:54
+  move(a);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ns::move' 
through ADL [bugprone-unintended-adl]
+  forward(a);

JonasToth wrote:
> logan-5 wrote:
> > Quuxplusone wrote:
> > > This is awesome. :)  Please also consider ADL where there's more than one 
> > > associated namespace, something like this: https://godbolt.org/z/S73Gzy
> > > ```
> > > template struct Templated { };
> > > Templated testX() {
> > > Templated x;
> > > using std::move;
> > > return move(x);  // "correctly" resolves to std::move today, but 
> > > still does unintended ADL
> > > }
> > > ```
> > > Please add a test isomorphic to the above, unless you think it's already 
> > > covered by one of the existing tests.
> > It's interesting, that code only triggers the check (i.e. my AST matchers 
> > only think it's doing ADL) without the `using std::move`. I admit I'm a bit 
> > confused as to why.
> The matcher itself only ask the `CallExpr->usesADL()` (not sure about the 
> method name right now, but basically that). So the reason is probably hidden 
> somewhere in `Sema`, if the matcher is the issue.
A call expression only "usesADL" if the callee was found only through ADL 
lookup. If it's found through normal lookup, then it doesn't "use adl", even 
though ADL lookup is also performed and that ADL lookup considers `std::move`.

I've been considering adding `CallExpr::considersADL`, but I'm not convinced 
it's needed.
There's more than enough work to be done cleaning up call's that depend on ADL.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp:202
+void macro_test(T t) {
+#define MACRO(x) find_if(x, x, x)
+

Arguably this is *exactly* the kind of code we want to diagnose.

The call in the macro either, 
  * Is a "customization point" and should be whitelisted. Or,
  * It resolves the same in expansion (and can be qualified), Or,
  * It is a bug. 

You mentioned false positives in things like `assert`. Can you provide examples?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[clang] 2b366e7 - Make Decl::setOwningModuleID() public. (NFC)

2020-03-11 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2020-03-11T15:50:03-07:00
New Revision: 2b366e75d41341e7cb2e763b20c4fc8fd3bd4b3c

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

LOG: Make Decl::setOwningModuleID() public. (NFC)

This API is going to be used by LLDB to recreate owning module
information for Decls deserialized from DWARF.

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

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/DeclTemplate.h

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index bc7676534175..0ce8b852b2ff 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -3539,6 +3539,7 @@ class EnumDecl : public TagDecl {
   /// negative enumerators of this enum. (see getNumNegativeBits)
   void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; }
 
+public:
   /// True if this tag declaration is a scoped enumeration. Only
   /// possible in C++11 mode.
   void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; }
@@ -3555,6 +3556,7 @@ class EnumDecl : public TagDecl {
   /// Microsoft-style enumeration with a fixed underlying type.
   void setFixed(bool Fixed = true) { EnumDeclBits.IsFixed = Fixed; }
 
+private:
   /// True if a valid hash is stored in ODRHash.
   bool hasODRHash() const { return EnumDeclBits.HasODRHash; }
   void setHasODRHash(bool Hash = true) { EnumDeclBits.HasODRHash = Hash; }

diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 91c372585b07..05dec109828d 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -626,7 +626,16 @@ class alignas(8) Decl {
 setModuleOwnershipKind(ModuleOwnershipKind::ModulePrivate);
   }
 
-  /// Set the owning module ID.
+public:
+  /// Set the FromASTFile flag. This indicates that this declaration
+  /// was deserialized and not parsed from source code and enables
+  /// features such as module ownership information.
+  void setFromASTFile() {
+FromASTFile = true;
+  }
+
+  /// Set the owning module ID.  This may only be called for
+  /// deserialized Decls.
   void setOwningModuleID(unsigned ID) {
 assert(isFromASTFile() && "Only works on a deserialized declaration");
 *((unsigned*)this - 2) = ID;

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 23b1adb26603..987738f73676 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2722,8 +2722,6 @@ class CXXConversionDecl : public CXXMethodDecl {
 
   ExplicitSpecifier ExplicitSpec;
 
-  void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
-
 public:
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
@@ -2745,6 +2743,7 @@ class CXXConversionDecl : public CXXMethodDecl {
 
   /// Return true if the declartion is already resolved to be explicit.
   bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
+  void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
 
   /// Returns the type that this conversion function is converting to.
   QualType getConversionType() const {

diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 7a9f623d8152..def1ab18706c 100755
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -1891,6 +1891,10 @@ class ClassTemplateSpecializationDecl
 return *TemplateArgs;
   }
 
+  void setTemplateArgs(TemplateArgumentList *Args) {
+TemplateArgs = Args;
+  }
+
   /// Determine the kind of specialization that this
   /// declaration represents.
   TemplateSpecializationKind getSpecializationKind() const {



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


[clang] 213aea4 - Remove unused Endian.h includes, NFC

2020-03-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-11T15:45:34-07:00
New Revision: 213aea4c5836934771eb97eb97e4c964053a8596

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

LOG: Remove unused Endian.h includes, NFC

Mainly avoids including Host.h everywhere:

$ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \
| grep '^[-+] ' | sort | uniq -c | sort -nr
   3141 - 
/usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Host.h

Added: 


Modified: 
clang/lib/Driver/Distro.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
clang/tools/driver/cc1gen_reproducer_main.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp
clang/unittests/CodeGen/TBAAMetadataTest.cpp
clang/unittests/Driver/DistroTest.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp
lld/ELF/DriverUtils.cpp
lld/MinGW/Driver.cpp
lld/wasm/Driver.cpp
lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
llvm/include/llvm/Support/Endian.h
llvm/tools/llvm-ar/llvm-ar.cpp
llvm/tools/llvm-exegesis/lib/LlvmState.cpp
llvm/tools/llvm-objcopy/llvm-objcopy.cpp
llvm/unittests/Support/CommandLineTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index 06707fefc9d0..acfde7d8bd0b 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -11,9 +11,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/ADT/Triple.h"
 
 using namespace clang::driver;
 using namespace clang;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 642b00b57fb6..37761893f137 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -38,8 +38,8 @@
 #include "ToolChains/NaCl.h"
 #include "ToolChains/NetBSD.h"
 #include "ToolChains/OpenBSD.h"
-#include "ToolChains/PS4CPU.h"
 #include "ToolChains/PPCLinux.h"
+#include "ToolChains/PS4CPU.h"
 #include "ToolChains/RISCVToolchain.h"
 #include "ToolChains/Solaris.h"
 #include "ToolChains/TCE.h"
@@ -71,6 +71,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"

diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index d6050925cd9e..01c5a9175da2 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -18,6 +18,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"

diff  --git a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp 
b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
index 99298316718b..f1ab2aed54c0 100644
--- a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -12,6 +12,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"

diff  --git a/clang/tools/driver/cc1gen_reproducer_main.cpp 
b/clang/tools/driver/cc1gen_reproducer_main.cpp
index 4aadab7301bc..472055ee2170 100644
--- a/clang/tools/driver/cc1gen_reproducer_main.cpp
+++ b/clang/tools/driver/cc1gen_reproducer_main.cpp
@@ -18,6 +18,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/YAMLTraits.h"

diff  --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 8e467527eadb..493b847fa5fa 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1,8 +1,9 @@
 #include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/AST/ASTStructuralEquivalence.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Host.h"
 
 #include "Language.h"
 #include 

[PATCH] D76030: [CUDA] Warn about unsupported CUDA SDK version only if it's used.

2020-03-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl 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/D76030/new/

https://reviews.llvm.org/D76030



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-03-11 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb updated this revision to Diff 249779.
broadwaylamb added a comment.

Add one more libc++abi header search path when building libc++

@vvereschaka this is supposed to fix the buildbot failure. It's more of a sweep 
under the rug type of fix. The real problem is that the value of the 
`CMAKE_SOURCE_DIR` variable is unexpected.

See for yourself.

Before 0197eac3330c04a49519f3e4dac38c4de605c654 
 I had the 
following in the build log:

  -- Looking for cxxabi.h in 
C:/buildbot/as-builder-1/llvm-clang-win-x-armv7l/llvm-project/libcxxabi/include 
- found

After (note the missing 'llvm-project' component in the path):

  -- Looking for cxxabi.h in 
C:/buildbot/as-builder-1/llvm-clang-win-x-armv7l/libcxxabi/include - not found

Maybe you have an idea of why this is happening? This all works fine on my 
machine even if I reproduce the directory layout used on the buildbot and 
invoke CMake from the `build` directory:

  llvm-clang-win-x-armv7l
  ├───build
  └───llvm-project


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74347

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include;${CMAKE_SOURCE_DIR}/../llvm-project/libcxxabi/include"
 CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${CMAKE_SOURCE_DIR}/../libcxxabi/include;${CMAKE_SOURCE_DIR}/../llvm-project/libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76032: [HIP] Fix duplicate clang -cc1 options on MSVC toolchain

2020-03-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.

HIPToolChain::TranslateArgs call TranslateArgs of host toolchain with the input 
args to get a list of derived args called DAL, then
go through the input args by itself and append them to DAL.

This assumes that the host toolchain should not append any unchanged args to 
DAL, otherwise there will be duplicates since
HIPToolChain will append it again.

This works for GNU toolchain since it returns an empty list for DAL.

However, MSVC toolchain will append unchanged args to DAL, which causes 
duplicate args.

This patch let MSVC toolchain not append unchanged args for HIP offloading 
kind, which fixes this issue.


https://reviews.llvm.org/D76032

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -8,3 +8,8 @@
 //
 // CHECK: clang{{.*}}" "-cc1" {{.*}} "-fcuda-is-device"
 // CHECK-SAME: "--gpu-max-threads-per-block=1024"
+
+// RUN: %clang -### -x hip -target x86_64-pc-windows-msvc -fms-extensions \
+// RUN:   -mllvm -amdgpu-early-inline-all=true  %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=MLLVM %s
+// MLLVM-NOT: 
"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"{{.*}}"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1483,7 +1483,8 @@
 
 llvm::opt::DerivedArgList *
 MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList ,
- StringRef BoundArch, Action::OffloadKind) const {
+ StringRef BoundArch,
+ Action::OffloadKind OFK) const {
   DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
   const OptTable  = getDriver().getOpts();
 
@@ -1522,7 +1523,8 @@
 } else if (A->getOption().matches(options::OPT_D)) {
   // Translate -Dfoo#bar into -Dfoo=bar.
   TranslateDArg(A, *DAL, Opts);
-} else {
+} else if (OFK != Action::OFK_HIP) {
+  // HIP Toolchain translates input args by itself.
   DAL->append(A);
 }
   }


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -8,3 +8,8 @@
 //
 // CHECK: clang{{.*}}" "-cc1" {{.*}} "-fcuda-is-device"
 // CHECK-SAME: "--gpu-max-threads-per-block=1024"
+
+// RUN: %clang -### -x hip -target x86_64-pc-windows-msvc -fms-extensions \
+// RUN:   -mllvm -amdgpu-early-inline-all=true  %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=MLLVM %s
+// MLLVM-NOT: "-mllvm"{{.*}}"-amdgpu-early-inline-all=true"{{.*}}"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1483,7 +1483,8 @@
 
 llvm::opt::DerivedArgList *
 MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList ,
- StringRef BoundArch, Action::OffloadKind) const {
+ StringRef BoundArch,
+ Action::OffloadKind OFK) const {
   DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
   const OptTable  = getDriver().getOpts();
 
@@ -1522,7 +1523,8 @@
 } else if (A->getOption().matches(options::OPT_D)) {
   // Translate -Dfoo#bar into -Dfoo=bar.
   TranslateDArg(A, *DAL, Opts);
-} else {
+} else if (OFK != Action::OFK_HIP) {
+  // HIP Toolchain translates input args by itself.
   DAL->append(A);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I'll be picking this up seriously this week.
I'm currently getting an internal version of this clang-tidy reviewed,
and my plan was to submit it upstream after because I didn't see this
patch until now (bad email filters).

I think we can unify the two checks,

Thanks for working on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D76030: [CUDA] Warn about unsupported CUDA SDK version only if it's used.

2020-03-11 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 249773.
tra retitled this revision from "[CUDA] Warn about unsupported CUDA SDK version 
only if it's used. " to "[CUDA] Warn about unsupported CUDA SDK version 
only if it's used.".
tra added a comment.

Added a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76030

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/test/Driver/cuda-version-check.cu

Index: clang/test/Driver/cuda-version-check.cu
===
--- clang/test/Driver/cuda-version-check.cu
+++ clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,10 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// Make sure that we don't warn about CUDA version during C++ compilation.
+// RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
+// RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION_CXX
 
 // The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
@@ -62,3 +66,4 @@
 // ERR_SM61-NOT: error: GPU arch sm_61
 
 // UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
+// UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -30,6 +30,8 @@
   const Driver 
   bool IsValid = false;
   CudaVersion Version = CudaVersion::UNKNOWN;
+  std::string DetectedVersion;
+  bool DetectedVersionIsNotSupported = false;
   std::string InstallPath;
   std::string BinPath;
   std::string LibPath;
@@ -75,6 +77,10 @@
   std::string getLibDeviceFile(StringRef Gpu) const {
 return LibDeviceMap.lookup(Gpu);
   }
+  void WarnIfUnsupportedVersion();
+
+ private:
+  void ParseCudaVersionFile(llvm::StringRef V);
 };
 
 namespace tools {
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -33,24 +33,28 @@
 
 // Parses the contents of version.txt in an CUDA installation.  It should
 // contain one line of the from e.g. "CUDA Version 7.5.2".
-static CudaVersion ParseCudaVersionFile(const Driver , llvm::StringRef V) {
+void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) {
+  Version = CudaVersion::UNKNOWN;
   if (!V.startswith("CUDA Version "))
-return CudaVersion::UNKNOWN;
+return;
   V = V.substr(strlen("CUDA Version "));
   SmallVector VersionParts;
   V.split(VersionParts, '.');
   if (VersionParts.size() < 2)
-return CudaVersion::UNKNOWN;
-  std::string MajorMinor = join_items(".", VersionParts[0], VersionParts[1]);
-  CudaVersion Version = CudaStringToVersion(MajorMinor);
+return;
+  DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]);
+  Version = CudaStringToVersion(DetectedVersion);
   if (Version != CudaVersion::UNKNOWN)
-return Version;
+return;
 
-  // Issue a warning and assume that the version we've found is compatible with
-  // the latest version we support.
-  D.Diag(diag::warn_drv_unknown_cuda_version)
-  << MajorMinor << CudaVersionToString(CudaVersion::LATEST);
-  return CudaVersion::LATEST;
+  Version = CudaVersion::LATEST;
+  DetectedVersionIsNotSupported = true;
+}
+
+void CudaInstallationDetector::WarnIfUnsupportedVersion() {
+  if (DetectedVersionIsNotSupported)
+D.Diag(diag::warn_drv_unknown_cuda_version)
+<< DetectedVersion << CudaVersionToString(Version);
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
@@ -149,7 +153,7 @@
   // version.txt isn't present.
   Version = CudaVersion::CUDA_70;
 } else {
-  Version = ParseCudaVersionFile(D, (*VersionFile)->getBuffer());
+  ParseCudaVersionFile((*VersionFile)->getBuffer());
 }
 
 if (Version >= CudaVersion::CUDA_90) {
@@ -567,8 +571,10 @@
  const Action::OffloadKind OK)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
-  if (CudaInstallation.isValid())
+  if (CudaInstallation.isValid()) {
+CudaInstallation.WarnIfUnsupportedVersion();
 getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
+  }
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
   getProgramPaths().push_back(getDriver().Dir);

[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

I've already stated my disapproval of this patch. Libc++ has never and will 
never provide nor value C++03 conformance.
Moving backwards to C++03 is inconsistent with the libraries general direction.

This patch disables tests, which could hide bugs, including serious ABI 
differences between dialects.

I would like to unbreak compilation on NetBSD. But all that's needed there is 
to provide our own correct declaration of max_align_t.
I don't see why C++03 conformance is a necessary condition.

If you would still like to proceed in this direction. Please remove me as a 
reviewer.




Comment at: 
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp:156
 
+#if TEST_STD_VER >= 11
 #if defined(NO_SIZE) && defined(NO_ALIGN)

It's important these tests continue to pass in C++03.


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

https://reviews.llvm.org/D73245



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


[PATCH] D73231: [CUDA] Assume the latest known CUDA version if we've found an unknown one.

2020-03-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

This patch should fix it: https://reviews.llvm.org/D76030


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73231



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


[PATCH] D76030: [CUDA] Warn about unsupported CUDA SDK version only if it's used.

2020-03-11 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: yaxunl.
Herald added subscribers: sanjoy.google, bixia.
Herald added a project: clang.
tra updated this revision to Diff 249773.
tra retitled this revision from "[CUDA] Warn about unsupported CUDA SDK version 
only if it's used. " to "[CUDA] Warn about unsupported CUDA SDK version 
only if it's used.".
tra added a comment.

Added a test.


This fixes an issue with clang issuing a warning about unknown CUDA SDK if it's 
detected during non-CUDA compilation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76030

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/test/Driver/cuda-version-check.cu

Index: clang/test/Driver/cuda-version-check.cu
===
--- clang/test/Driver/cuda-version-check.cu
+++ clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,10 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// Make sure that we don't warn about CUDA version during C++ compilation.
+// RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
+// RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION_CXX
 
 // The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
@@ -62,3 +66,4 @@
 // ERR_SM61-NOT: error: GPU arch sm_61
 
 // UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
+// UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -30,6 +30,8 @@
   const Driver 
   bool IsValid = false;
   CudaVersion Version = CudaVersion::UNKNOWN;
+  std::string DetectedVersion;
+  bool DetectedVersionIsNotSupported = false;
   std::string InstallPath;
   std::string BinPath;
   std::string LibPath;
@@ -75,6 +77,10 @@
   std::string getLibDeviceFile(StringRef Gpu) const {
 return LibDeviceMap.lookup(Gpu);
   }
+  void WarnIfUnsupportedVersion();
+
+ private:
+  void ParseCudaVersionFile(llvm::StringRef V);
 };
 
 namespace tools {
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -33,24 +33,28 @@
 
 // Parses the contents of version.txt in an CUDA installation.  It should
 // contain one line of the from e.g. "CUDA Version 7.5.2".
-static CudaVersion ParseCudaVersionFile(const Driver , llvm::StringRef V) {
+void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) {
+  Version = CudaVersion::UNKNOWN;
   if (!V.startswith("CUDA Version "))
-return CudaVersion::UNKNOWN;
+return;
   V = V.substr(strlen("CUDA Version "));
   SmallVector VersionParts;
   V.split(VersionParts, '.');
   if (VersionParts.size() < 2)
-return CudaVersion::UNKNOWN;
-  std::string MajorMinor = join_items(".", VersionParts[0], VersionParts[1]);
-  CudaVersion Version = CudaStringToVersion(MajorMinor);
+return;
+  DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]);
+  Version = CudaStringToVersion(DetectedVersion);
   if (Version != CudaVersion::UNKNOWN)
-return Version;
+return;
 
-  // Issue a warning and assume that the version we've found is compatible with
-  // the latest version we support.
-  D.Diag(diag::warn_drv_unknown_cuda_version)
-  << MajorMinor << CudaVersionToString(CudaVersion::LATEST);
-  return CudaVersion::LATEST;
+  Version = CudaVersion::LATEST;
+  DetectedVersionIsNotSupported = true;
+}
+
+void CudaInstallationDetector::WarnIfUnsupportedVersion() {
+  if (DetectedVersionIsNotSupported)
+D.Diag(diag::warn_drv_unknown_cuda_version)
+<< DetectedVersion << CudaVersionToString(Version);
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
@@ -149,7 +153,7 @@
   // version.txt isn't present.
   Version = CudaVersion::CUDA_70;
 } else {
-  Version = ParseCudaVersionFile(D, (*VersionFile)->getBuffer());
+  ParseCudaVersionFile((*VersionFile)->getBuffer());
 }
 
 if (Version >= CudaVersion::CUDA_90) {
@@ -567,8 +571,10 @@
  const Action::OffloadKind OK)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
-  if (CudaInstallation.isValid())
+  if (CudaInstallation.isValid()) {
+CudaInstallation.WarnIfUnsupportedVersion();
 getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
+  }
   // Lookup 

[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/5]

2020-03-11 Thread Scott Constable via Phabricator via cfe-commits
sconstab updated this revision to Diff 249765.
sconstab added a comment.

Added help text for the CLI options


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

https://reviews.llvm.org/D75936

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/ImmutableGraph.h
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
@@ -0,0 +1,129 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -x86-lvi-load-dot-verify -o %t < %s | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @test(i32* %untrusted_user_ptr, i32* %secret, i32 %secret_size) #0 {
+entry:
+  %untrusted_user_ptr.addr = alloca i32*, align 8
+  %secret.addr = alloca i32*, align 8
+  %secret_size.addr = alloca i32, align 4
+  %ret_val = alloca i32, align 4
+  %i = alloca i32, align 4
+  store i32* %untrusted_user_ptr, i32** %untrusted_user_ptr.addr, align 8
+  store i32* %secret, i32** %secret.addr, align 8
+  store i32 %secret_size, i32* %secret_size.addr, align 4
+  store i32 0, i32* %ret_val, align 4
+  call void @llvm.x86.sse2.lfence()
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+  %0 = load i32, i32* %i, align 4
+  %1 = load i32, i32* %secret_size.addr, align 4
+  %cmp = icmp slt i32 %0, %1
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+  %2 = load i32, i32* %i, align 4
+  %rem = srem i32 %2, 2
+  %cmp1 = icmp eq i32 %rem, 0
+  br i1 %cmp1, label %if.then, label %if.else
+
+if.then:  ; preds = %for.body
+  %3 = load i32*, i32** %secret.addr, align 8
+  %4 = load i32, i32* %ret_val, align 4
+  %idxprom = sext i32 %4 to i64
+  %arrayidx = getelementptr inbounds i32, i32* %3, i64 %idxprom
+  %5 = load i32, i32* %arrayidx, align 4
+  %6 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  store i32 %5, i32* %6, align 4
+  br label %if.end
+
+if.else:  ; preds = %for.body
+  %7 = load i32*, i32** %secret.addr, align 8
+  %8 = load i32, i32* %ret_val, align 4
+  %idxprom2 = sext i32 %8 to i64
+  %arrayidx3 = getelementptr inbounds i32, i32* %7, i64 %idxprom2
+  store i32 42, i32* %arrayidx3, align 4
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  %9 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  %10 = load i32, i32* %9, align 4
+  store i32 %10, i32* %ret_val, align 4
+  br label %for.inc
+
+for.inc:  ; preds = %if.end
+  %11 = load i32, i32* %i, align 4
+  %inc = add nsw i32 %11, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:  ; preds = %for.cond
+  %12 = load i32, i32* %ret_val, align 4
+  ret i32 %12
+}
+
+; CHECK:  digraph "Speculative gadgets for \"test\" function" {
+; CHECK-NEXT: label="Speculative gadgets for \"test\" function";
+; CHECK:  Node0x{{[0-9a-f]+}} [shape=record,color = green,label="{LFENCE\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 0];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{JCC_1 %bb.6, 13, implicit killed $eflags\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{CMP32rm killed renamable $eax, %stack.2.secret_size.addr, 1, $noreg, 0, $noreg, implicit-def $eflags :: (dereferenceable load 4 from %ir.secret_size.addr)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> 

[PATCH] D76029: Summary: Fix DanglingHandleCheck to match conversion operator whose return type is a type alias, e.g. `std::string`'s conversion operator to `std::string_view`.

2020-03-11 Thread Xiaoyi Zhang via Phabricator via cfe-commits
zhangxy988 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zhangxy988 added a reviewer: alexfh.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76029

Files:
  clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-dangling-handle.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-dangling-handle.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-dangling-handle.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-dangling-handle.cpp
@@ -45,26 +45,30 @@
   value_type& operator[](Key&& key);
 };
 
+template 
 class basic_string_view;
 
+template 
 class basic_string {
- public:
+public:
+  typedef basic_string_view<_CharT> __self_view;
   basic_string();
   basic_string(const char*);
 
-  operator basic_string_view() const noexcept;
+  operator __self_view() const noexcept;
 
   ~basic_string();
 };
 
-typedef basic_string string;
+typedef basic_string string;
 
+template 
 class basic_string_view {
- public:
+public:
   basic_string_view(const char*);
 };
 
-typedef basic_string_view string_view;
+typedef basic_string_view string_view;
 
 }  // namespace std
 
Index: clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
@@ -27,7 +27,8 @@
   return expr(
   anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
  hasArgument(0, Arg)),
-cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)),
+cxxMemberCallExpr(hasType(hasUnqualifiedDesugaredType(recordType(
+  hasDeclaration(cxxRecordDecl(IsAHandle),
   callee(memberExpr(member(cxxConversionDecl(,
   on(Arg;
 }


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-dangling-handle.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-dangling-handle.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-dangling-handle.cpp
@@ -45,26 +45,30 @@
   value_type& operator[](Key&& key);
 };
 
+template 
 class basic_string_view;
 
+template 
 class basic_string {
- public:
+public:
+  typedef basic_string_view<_CharT> __self_view;
   basic_string();
   basic_string(const char*);
 
-  operator basic_string_view() const noexcept;
+  operator __self_view() const noexcept;
 
   ~basic_string();
 };
 
-typedef basic_string string;
+typedef basic_string string;
 
+template 
 class basic_string_view {
- public:
+public:
   basic_string_view(const char*);
 };
 
-typedef basic_string_view string_view;
+typedef basic_string_view string_view;
 
 }  // namespace std
 
Index: clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
@@ -27,7 +27,8 @@
   return expr(
   anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
  hasArgument(0, Arg)),
-cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)),
+cxxMemberCallExpr(hasType(hasUnqualifiedDesugaredType(recordType(
+  hasDeclaration(cxxRecordDecl(IsAHandle),
   callee(memberExpr(member(cxxConversionDecl(,
   on(Arg;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75934: Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI) [2/5]

2020-03-11 Thread Scott Constable via Phabricator via cfe-commits
sconstab updated this revision to Diff 249763.
sconstab added a comment.

Added help text for driver CLI options.


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

https://reviews.llvm.org/D75934

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86FastISel.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrControl.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86LoadValueInjectionIndirectThunks.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
@@ -0,0 +1,282 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown < %s | FileCheck %s --check-prefix=X64
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -O0 < %s | FileCheck %s --check-prefix=X64FAST
+;
+; Note that a lot of this code was lifted from retpoline.ll.
+
+declare void @bar(i32)
+
+; Test a simple indirect call and tail call.
+define void @icall_reg(void (i32)* %fp, i32 %x) #0 {
+entry:
+  tail call void @bar(i32 %x)
+  tail call void %fp(i32 %x)
+  tail call void @bar(i32 %x)
+  tail call void %fp(i32 %x)
+  ret void
+}
+
+; X64-LABEL: icall_reg:
+; X64-DAG:   movq %rdi, %[[fp:[^ ]*]]
+; X64-DAG:   movl %esi, %[[x:[^ ]*]]
+; X64:   movl %esi, %edi
+; X64:   callq bar
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   callq __x86_indirect_thunk_r11
+; X64:   movl %[[x]], %edi
+; X64:   callq bar
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   jmp __x86_indirect_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: icall_reg:
+; X64FAST:   callq bar
+; X64FAST:   callq __x86_indirect_thunk_r11
+; X64FAST:   callq bar
+; X64FAST:   jmp __x86_indirect_thunk_r11 # TAILCALL
+
+
+@global_fp = external global void (i32)*
+
+; Test an indirect call through a global variable.
+define void @icall_global_fp(i32 %x, void (i32)** %fpp) #0 {
+  %fp1 = load void (i32)*, void (i32)** @global_fp
+  call void %fp1(i32 %x)
+  %fp2 = load void (i32)*, void (i32)** @global_fp
+  tail call void %fp2(i32 %x)
+  ret void
+}
+
+; X64-LABEL: icall_global_fp:
+; X64-DAG:   movl %edi, %[[x:[^ ]*]]
+; X64-DAG:   movq global_fp(%rip), %r11
+; X64:   callq __x86_indirect_thunk_r11
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq global_fp(%rip), %r11
+; X64:   jmp __x86_indirect_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: icall_global_fp:
+; X64FAST:   movq global_fp(%rip), %r11
+; X64FAST:   callq __x86_indirect_thunk_r11
+; X64FAST:   movq global_fp(%rip), %r11
+; X64FAST:   jmp __x86_indirect_thunk_r11 # TAILCALL
+
+
+%struct.Foo = type { void (%struct.Foo*)** }
+
+; Test an indirect call through a vtable.
+define void @vcall(%struct.Foo* %obj) #0 {
+  %vptr_field = getelementptr %struct.Foo, %struct.Foo* %obj, i32 0, i32 0
+  %vptr = load void (%struct.Foo*)**, void (%struct.Foo*)*** %vptr_field
+  %vslot = getelementptr void(%struct.Foo*)*, void(%struct.Foo*)** %vptr, i32 1
+  %fp = load void(%struct.Foo*)*, void(%struct.Foo*)** %vslot
+  tail call void %fp(%struct.Foo* %obj)
+  tail call void %fp(%struct.Foo* %obj)
+  ret void
+}
+
+; X64-LABEL: vcall:
+; X64:   movq %rdi, %[[obj:[^ ]*]]
+; X64:   movq (%rdi), %[[vptr:[^ ]*]]
+; X64:   movq 8(%[[vptr]]), %[[fp:[^ ]*]]
+; X64:   movq %[[fp]], %r11
+; X64:   callq __x86_indirect_thunk_r11
+; X64-DAG:   movq %[[obj]], %rdi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   jmp __x86_indirect_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: vcall:
+; X64FAST:   callq __x86_indirect_thunk_r11
+; X64FAST:   jmp __x86_indirect_thunk_r11 # TAILCALL
+
+
+declare void @direct_callee()
+
+define void @direct_tail() #0 {
+  tail call void @direct_callee()
+  ret void
+}
+
+; X64-LABEL: direct_tail:
+; X64:   jmp direct_callee # TAILCALL
+; X64FAST-LABEL: direct_tail:
+; X64FAST:   jmp direct_callee # TAILCALL
+
+
+declare void @nonlazybind_callee() #1
+
+define void @nonlazybind_caller() #0 {
+  call void @nonlazybind_callee()
+  tail call void @nonlazybind_callee()
+  ret void
+}
+
+; X64-LABEL: nonlazybind_caller:
+; X64:   movq nonlazybind_callee@GOTPCREL(%rip), %[[REG:.*]]
+; X64:   movq %[[REG]], %r11
+; X64:   callq __x86_indirect_thunk_r11
+; X64:   movq %[[REG]], %r11
+; X64:   jmp 

[clang] 828fe79 - Revert "Temporarily re-apply https://reviews.llvm.org/D74347"

2020-03-11 Thread Vladimir Vereschaka via cfe-commits

Author: Vladimir Vereschaka
Date: 2020-03-11T15:00:56-07:00
New Revision: 828fe7916f91fb7aed5e711bfeb1a30ad197a2c3

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

LOG: Revert "Temporarily re-apply https://reviews.llvm.org/D74347;

This reverts commit 0197eac3330c04a49519f3e4dac38c4de605c654.

The changes break Armv7/Aarch64 toolchain builders:
* http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/5570
* http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/5600

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 7a6af734f0de..50957b153328 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,9 +83,6 @@ set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
-set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
-set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
-set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 249760.
nickdesaulniers added a comment.

- drop `auto` as type is no longer implicit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1528,13 +1528,13 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = ConsumeToken();
 
-  if (Tok.is(tok::kw_volatile)) {
-   

[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 249754.
nickdesaulniers marked 8 inline comments as done.
nickdesaulniers added a comment.

- address latest review comments, more refactoring


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1528,13 +1528,13 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = 

[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 249757.
nickdesaulniers added a comment.

- remove isUnspecified(), was partially committed from refactoring I changed my 
mind on


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1528,13 +1528,13 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = 

[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:937
+case AQ_goto: return "goto";
+case AQ_unspecified:;
+  }

aaron.ballman wrote:
> This looks wrong to me -- it flows through to an unreachable despite being 
> reachable. I think this should `return "unspecified";`.
This method is only called for printing; it seems weird to return "unspecified" 
when it's kind of an invariant that that should never happen.  Maybe an assert 
here would be better?

I've updated the implementation slightly, but leaving this comment thread open 
for more feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-11 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Ping


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

https://reviews.llvm.org/D73245



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


[PATCH] D75406: Avoid including FileManager.h from SourceManager.h

2020-03-11 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe08464fb4504: Avoid including FileManager.h from 
SourceManager.h (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D75406?vs=247479=249752#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75406

Files:
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/ModuleMap.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/Basic/SanitizerBlacklist.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Basic/XRayLists.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Index/CommentToXML.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPCallbacks.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/tools/clang-refactor/TestSupport.cpp
  clang/tools/libclang/CXSourceLocation.cpp
  clang/unittests/Frontend/ASTUnitTest.cpp
  clang/unittests/Frontend/CompilerInstanceTest.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp

Index: lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
===
--- lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
+++ lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
@@ -13,6 +13,7 @@
 #include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/StreamString.h"
 
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringSet.h"
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
@@ -9,6 +9,7 @@
 #include "ClangExpressionSourceCode.h"
 
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringRef.h"
Index: clang/unittests/Frontend/CompilerInstanceTest.cpp
===
--- clang/unittests/Frontend/CompilerInstanceTest.cpp
+++ clang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/FileSystem.h"
Index: clang/unittests/Frontend/ASTUnitTest.cpp
===
--- clang/unittests/Frontend/ASTUnitTest.cpp
+++ clang/unittests/Frontend/ASTUnitTest.cpp
@@ -8,6 +8,7 @@
 
 #include 
 
+#include "clang/Basic/FileManager.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
Index: clang/tools/libclang/CXSourceLocation.cpp
===
--- clang/tools/libclang/CXSourceLocation.cpp
+++ clang/tools/libclang/CXSourceLocation.cpp
@@ -10,13 +10,14 @@
 //
 //===--===//
 
-#include "clang/Frontend/ASTUnit.h"
+#include "CXSourceLocation.h"
 #include "CIndexer.h"
 #include "CLog.h"
 #include "CXLoadedDiagnostic.h"
-#include "CXSourceLocation.h"
 #include "CXString.h"
 #include "CXTranslationUnit.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Frontend/ASTUnit.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Format.h"
 
Index: clang/tools/clang-refactor/TestSupport.cpp
===
--- clang/tools/clang-refactor/TestSupport.cpp
+++ 

[PATCH] D75310: [CUDA, clang-cl] Filter out unsupported arguments for device-side compilation.

2020-03-11 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0c06a389e593: [CUDA,clang-cl] Filter out unsupported 
arguments for device-side compilation. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75310

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.cu


Index: clang/test/Driver/cl-options.cu
===
--- /dev/null
+++ clang/test/Driver/cl-options.cu
@@ -0,0 +1,27 @@
+// Verify that we don't pass unwanted options to device-side compilation when
+// clang-cl is used for CUDA compilation.
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// -stack-protector should not be passed to device-side CUDA compilation
+// RUN: %clang_cl -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck 
-check-prefix=GS-default %s
+// GS-default: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// GS-default-NOT: "-stack-protector"
+// GS-default: "-cc1" "-triple"
+// GS-default: "-stack-protector" "2"
+
+// -exceptions should be passed to device-side compilation.
+// RUN: %clang_cl /c /GX -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck 
-check-prefix=GX %s
+// GX: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// GX-NOT: "-fcxx-exceptions"
+// GX-NOT: "-fexceptions"
+// GX: "-cc1" "-triple"
+// GX: "-fcxx-exceptions" "-fexceptions"
+
+// /Gd should not override default calling convention on device side.
+// RUN: %clang_cl /c /Gd -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck 
-check-prefix=Gd %s
+// Gd: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// Gd-NOT: "-fcxx-exceptions"
+// Gd-NOT: "-fdefault-calling-conv=cdecl"
+// Gd: "-cc1" "-triple"
+// Gd: "-fdefault-calling-conv=cdecl"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6396,6 +6396,7 @@
codegenoptions::DebugInfoKind *DebugInfoKind,
bool *EmitCodeView) const {
   unsigned RTOptionID = options::OPT__SLASH_MT;
+  bool isNVPTX = getToolChain().getTriple().isNVPTX();
 
   if (Args.hasArg(options::OPT__SLASH_LDd))
 // The /LDd option implies /MTd. The dependent lib part can be overridden,
@@ -6463,8 +6464,8 @@
 
   // This controls whether or not we emit stack-protector instrumentation.
   // In MSVC, Buffer Security Check (/GS) is on by default.
-  if (Args.hasFlag(options::OPT__SLASH_GS, options::OPT__SLASH_GS_,
-   /*Default=*/true)) {
+  if (!isNVPTX && Args.hasFlag(options::OPT__SLASH_GS, options::OPT__SLASH_GS_,
+   /*Default=*/true)) {
 CmdArgs.push_back("-stack-protector");
 CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
   }
@@ -6484,7 +6485,7 @@
 
   const Driver  = getToolChain().getDriver();
   EHFlags EH = parseClangCLEHFlags(D, Args);
-  if (EH.Synch || EH.Asynch) {
+  if (!isNVPTX && (EH.Synch || EH.Asynch)) {
 if (types::isCXX(InputType))
   CmdArgs.push_back("-fcxx-exceptions");
 CmdArgs.push_back("-fexceptions");
@@ -6553,7 +6554,7 @@
   options::OPT__SLASH_Gregcall)) {
 unsigned DCCOptId = CCArg->getOption().getID();
 const char *DCCFlag = nullptr;
-bool ArchSupported = true;
+bool ArchSupported = !isNVPTX;
 llvm::Triple::ArchType Arch = getToolChain().getArch();
 switch (DCCOptId) {
 case options::OPT__SLASH_Gd:


Index: clang/test/Driver/cl-options.cu
===
--- /dev/null
+++ clang/test/Driver/cl-options.cu
@@ -0,0 +1,27 @@
+// Verify that we don't pass unwanted options to device-side compilation when
+// clang-cl is used for CUDA compilation.
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// -stack-protector should not be passed to device-side CUDA compilation
+// RUN: %clang_cl -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
+// GS-default: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// GS-default-NOT: "-stack-protector"
+// GS-default: "-cc1" "-triple"
+// GS-default: "-stack-protector" "2"
+
+// -exceptions should be passed to device-side compilation.
+// RUN: %clang_cl /c /GX -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck -check-prefix=GX %s
+// GX: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// GX-NOT: "-fcxx-exceptions"
+// GX-NOT: "-fexceptions"
+// GX: "-cc1" "-triple"
+// GX: "-fcxx-exceptions" "-fexceptions"
+
+// /Gd should not override default calling convention on device side.
+// RUN: %clang_cl /c /Gd -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck -check-prefix=Gd %s
+// Gd: "-cc1" "-triple" 

[PATCH] D75784: Avoid including Module.h from ExternalASTSource.h

2020-03-11 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
rnk marked an inline comment as done.
Closed by commit rGc915cb957dc3: Avoid including Module.h from 
ExternalASTSource.h (authored by rnk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75784

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/ExternalASTSource.h
  clang/include/clang/Basic/Module.h
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExternalASTSource.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Basic/Module.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -40,6 +40,10 @@
 class DWARFASTParserClang;
 class PDBASTParser;
 
+namespace clang {
+class FileManager;
+}
+
 namespace lldb_private {
 
 class ClangASTMetadata;
Index: lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
 #define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
 
+#include "clang/Basic/Module.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/MultiplexExternalSemaSource.h"
 #include "clang/Sema/Sema.h"
@@ -71,7 +72,7 @@
 return m_Source->getModule(ID);
   }
 
-  llvm::Optional
+  llvm::Optional
   getSourceDescriptor(unsigned ID) override {
 return m_Source->getSourceDescriptor(ID);
   }
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1968,8 +1968,8 @@
 
 void ASTDeclReader::VisitImportDecl(ImportDecl *D) {
   VisitDecl(D);
-  D->ImportedAndComplete.setPointer(readModule());
-  D->ImportedAndComplete.setInt(Record.readInt());
+  D->ImportedModule = readModule();
+  D->setImportComplete(Record.readInt());
   auto *StoredLocs = D->getTrailingObjects();
   for (unsigned I = 0, N = Record.back(); I != N; ++I)
 StoredLocs[I] = readSourceLocation();
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8491,10 +8491,10 @@
   return (I - PCHModules.end()) << 1;
 }
 
-llvm::Optional
+llvm::Optional
 ASTReader::getSourceDescriptor(unsigned ID) {
   if (const Module *M = getSubmodule(ID))
-return ExternalASTSource::ASTSourceDescriptor(*M);
+return ASTSourceDescriptor(*M);
 
   // If there is only a single PCH, return it instead.
   // Chained PCH are not supported.
@@ -8503,8 +8503,8 @@
 ModuleFile  = ModuleMgr.getPrimaryModule();
 StringRef ModuleName = llvm::sys::path::filename(MF.OriginalSourceFileName);
 StringRef FileName = llvm::sys::path::filename(MF.FileName);
-return ASTReader::ASTSourceDescriptor(ModuleName, MF.OriginalDir, FileName,
-  MF.Signature);
+return ASTSourceDescriptor(ModuleName, MF.OriginalDir, FileName,
+   MF.Signature);
   }
   return None;
 }
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -20,6 +20,7 @@
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/CodeGenOptions.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
@@ -60,7 +61,7 @@
   llvm::DIBuilder DBuilder;
   llvm::DICompileUnit *TheCU = nullptr;
   ModuleMap *ClangModuleMap = nullptr;
-  ExternalASTSource::ASTSourceDescriptor PCHDescriptor;
+  ASTSourceDescriptor PCHDescriptor;
   SourceLocation CurLoc;
   llvm::MDNode *CurInlinedAt = nullptr;
   llvm::DIType *VTablePtrType = nullptr;
@@ -379,9 +380,7 @@
   /// When generating debug information for a clang module or
   /// precompiled header, this module map will be used to determine
   /// the module of origin of each Decl.
-  void setPCHDescriptor(ExternalASTSource::ASTSourceDescriptor PCH) {
-PCHDescriptor = PCH;
-  }
+  void 

[PATCH] D75784: Avoid including Module.h from ExternalASTSource.h

2020-03-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks!

In D75784#1917181 , @aprantl wrote:

> To avoid bot breakage, I would recommend testing -DLLVM_ENABLE_MODULES=1 
> stage2 build works before landing this, as it is notoriously sensitive to 
> header reshuffling.


Good idea, I confirmed this passed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75784



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


[PATCH] D75998: [ARM,MVE] Add intrinsics and isel for MVE fused multiply-add.

2020-03-11 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen 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/D75998/new/

https://reviews.llvm.org/D75998



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


[clang] e08464f - Avoid including FileManager.h from SourceManager.h

2020-03-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-11T13:53:12-07:00
New Revision: e08464fb450456881733c885267b32dc7339cf11

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

LOG: Avoid including FileManager.h from SourceManager.h

Most clients of SourceManager.h need to do things like turning source
locations into file & line number pairs, but this doesn't require
bringing in FileManager.h and LLVM's FS headers.

The main code change here is to sink SM::createFileID into the cpp file.
I reason that this is not performance critical because it doesn't happen
on the diagnostic path, it happens along the paths of macro expansion
(could be hot) and new includes (less hot).

Saves some includes:
309 -
/usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileManager.h
272 -
/usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileSystemOptions.h
271 -
/usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/VirtualFileSystem.h
267 -
/usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/FileSystem.h
266 -
/usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Chrono.h

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

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
clang-tools-extra/clangd/Format.cpp
clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Frontend/CompilerInstance.h
clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
clang/include/clang/Lex/DirectoryLookup.h
clang/include/clang/Lex/ModuleMap.h
clang/include/clang/Lex/PPCallbacks.h
clang/lib/AST/ExternalASTSource.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/Basic/SanitizerBlacklist.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Basic/XRayLists.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/PrecompiledPreamble.cpp
clang/lib/Index/CommentToXML.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Lex/PPCallbacks.cpp
clang/lib/Lex/PPLexerChange.cpp
clang/lib/Parse/Parser.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
clang/tools/clang-import-test/clang-import-test.cpp
clang/tools/clang-refactor/TestSupport.cpp
clang/tools/libclang/CXSourceLocation.cpp
clang/unittests/Frontend/ASTUnitTest.cpp
clang/unittests/Frontend/CompilerInstanceTest.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
index ed1bc2f490ae..0f6ebbf2e23b 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
@@ -10,6 +10,7 @@
 #include "HeaderMapCollector.h"
 #include "PathConfig.h"
 #include "SymbolInfo.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/MacroInfo.h"

diff  --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp 
b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 483177454527..7e5501ccc60a 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "ExpandModularHeadersPPCallbacks.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Serialization/ASTReader.h"

diff  --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h 
b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
index 30c8236e7f91..fe1b00b4680a 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
@@ -13,6 +13,13 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/DenseSet.h"
 
+namespace llvm {
+namespace vfs {
+class OverlayFileSystem;
+class 

[clang] 526a4f2 - Fix formatting after Module.h include adjustment, NFC

2020-03-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-11T13:52:47-07:00
New Revision: 526a4f2ac365a5babbc80e0f7c17be310728a538

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

LOG: Fix formatting after Module.h include adjustment, NFC

Forgot to implement code review comments.

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h 
b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
index 90976c433a83..8f0c7edc58b4 100644
--- a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -11,9 +11,9 @@
 
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/SetVector.h"
 #include 
 #include 
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 985130905df3..e50d1d608397 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1616,7 +1616,8 @@ void ASTContext::getOverriddenMethods(
 }
 
 void ASTContext::addedLocalImportDecl(ImportDecl *Import) {
-  assert(!Import->getNextLocalImport() && "Import declaration already in the 
chain");
+  assert(!Import->getNextLocalImport() &&
+ "Import declaration already in the chain");
   assert(!Import->isFromASTFile() && "Non-local import declaration");
   if (!FirstLocalImport) {
 FirstLocalImport = Import;



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


[clang] 0c06a38 - [CUDA,clang-cl] Filter out unsupported arguments for device-side compilation.

2020-03-11 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-03-11T13:42:16-07:00
New Revision: 0c06a389e5937895579effd5e608c79bc6332e53

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

LOG: [CUDA,clang-cl] Filter out unsupported arguments for device-side 
compilation.

Device-side compilation does not support some features and we need to
filter them out when command line options enable them for the host.

We're already doing this in various places in the regular clang driver,
but clang-cl mode constructs cc1 options independently and needs to
implement the filtering, too.

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

Added: 
clang/test/Driver/cl-options.cu

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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5b85a5197f58..cb993e75b88c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6396,6 +6396,7 @@ void Clang::AddClangCLArgs(const ArgList , types::ID 
InputType,
codegenoptions::DebugInfoKind *DebugInfoKind,
bool *EmitCodeView) const {
   unsigned RTOptionID = options::OPT__SLASH_MT;
+  bool isNVPTX = getToolChain().getTriple().isNVPTX();
 
   if (Args.hasArg(options::OPT__SLASH_LDd))
 // The /LDd option implies /MTd. The dependent lib part can be overridden,
@@ -6463,8 +6464,8 @@ void Clang::AddClangCLArgs(const ArgList , types::ID 
InputType,
 
   // This controls whether or not we emit stack-protector instrumentation.
   // In MSVC, Buffer Security Check (/GS) is on by default.
-  if (Args.hasFlag(options::OPT__SLASH_GS, options::OPT__SLASH_GS_,
-   /*Default=*/true)) {
+  if (!isNVPTX && Args.hasFlag(options::OPT__SLASH_GS, options::OPT__SLASH_GS_,
+   /*Default=*/true)) {
 CmdArgs.push_back("-stack-protector");
 CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
   }
@@ -6484,7 +6485,7 @@ void Clang::AddClangCLArgs(const ArgList , types::ID 
InputType,
 
   const Driver  = getToolChain().getDriver();
   EHFlags EH = parseClangCLEHFlags(D, Args);
-  if (EH.Synch || EH.Asynch) {
+  if (!isNVPTX && (EH.Synch || EH.Asynch)) {
 if (types::isCXX(InputType))
   CmdArgs.push_back("-fcxx-exceptions");
 CmdArgs.push_back("-fexceptions");
@@ -6553,7 +6554,7 @@ void Clang::AddClangCLArgs(const ArgList , types::ID 
InputType,
   options::OPT__SLASH_Gregcall)) {
 unsigned DCCOptId = CCArg->getOption().getID();
 const char *DCCFlag = nullptr;
-bool ArchSupported = true;
+bool ArchSupported = !isNVPTX;
 llvm::Triple::ArchType Arch = getToolChain().getArch();
 switch (DCCOptId) {
 case options::OPT__SLASH_Gd:

diff  --git a/clang/test/Driver/cl-options.cu b/clang/test/Driver/cl-options.cu
new file mode 100644
index ..7597970af160
--- /dev/null
+++ b/clang/test/Driver/cl-options.cu
@@ -0,0 +1,27 @@
+// Verify that we don't pass unwanted options to device-side compilation when
+// clang-cl is used for CUDA compilation.
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// -stack-protector should not be passed to device-side CUDA compilation
+// RUN: %clang_cl -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck 
-check-prefix=GS-default %s
+// GS-default: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// GS-default-NOT: "-stack-protector"
+// GS-default: "-cc1" "-triple"
+// GS-default: "-stack-protector" "2"
+
+// -exceptions should be passed to device-side compilation.
+// RUN: %clang_cl /c /GX -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck 
-check-prefix=GX %s
+// GX: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// GX-NOT: "-fcxx-exceptions"
+// GX-NOT: "-fexceptions"
+// GX: "-cc1" "-triple"
+// GX: "-fcxx-exceptions" "-fexceptions"
+
+// /Gd should not override default calling convention on device side.
+// RUN: %clang_cl /c /Gd -### -nocudalib -nocudainc -- %s 2>&1 | FileCheck 
-check-prefix=Gd %s
+// Gd: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// Gd-NOT: "-fcxx-exceptions"
+// Gd-NOT: "-fdefault-calling-conv=cdecl"
+// Gd: "-cc1" "-triple"
+// Gd: "-fdefault-calling-conv=cdecl"



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


[clang] c915cb9 - Avoid including Module.h from ExternalASTSource.h

2020-03-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-11T13:37:41-07:00
New Revision: c915cb957dc37275ce1ca1a0b993239c82f12692

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

LOG: Avoid including Module.h from ExternalASTSource.h

Module.h takes 86ms to parse, mostly parsing the class itself. Avoid it
if possible. ASTContext.h depends on ExternalASTSource.h.

A few NFC changes were needed to make this possible:

- Move ASTSourceDescriptor to Module.h. This needs Module to be
  complete, and seems more related to modules and AST files than
  external AST sources.
- Move "import complete" bit from Module* pointer int pair to
  NextLocalImport pointer. Required because PointerIntPair
  requires Module to be complete, and now it may not be.

Reviewed By: aaron.ballman, hans

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

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/ExternalASTSource.h
clang/include/clang/Basic/Module.h
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ExternalASTSource.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Basic/Module.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 92e5921fa375..75ab911d2459 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -121,6 +121,7 @@ class Preprocessor;
 class Stmt;
 class StoredDeclsMap;
 class TargetAttr;
+class TargetInfo;
 class TemplateDecl;
 class TemplateParameterList;
 class TemplateTemplateParmDecl;
@@ -881,7 +882,7 @@ class ASTContext : public RefCountedBase {
   void addedLocalImportDecl(ImportDecl *Import);
 
   static ImportDecl *getNextLocalImport(ImportDecl *Import) {
-return Import->NextLocalImport;
+return Import->getNextLocalImport();
   }
 
   using import_range = llvm::iterator_range;
@@ -909,13 +910,7 @@ class ASTContext : public RefCountedBase {
 
   /// Get the additional modules in which the definition \p Def has
   /// been merged.
-  ArrayRef getModulesWithMergedDefinition(const NamedDecl *Def) {
-auto MergedIt =
-MergedDefModules.find(cast(Def->getCanonicalDecl()));
-if (MergedIt == MergedDefModules.end())
-  return None;
-return MergedIt->second;
-  }
+  ArrayRef getModulesWithMergedDefinition(const NamedDecl *Def);
 
   /// Add a declaration to the list of declarations that are initialized
   /// for a module. This will typically be a global variable (with internal

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index b31cbab50222..bc7676534175 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4340,17 +4340,18 @@ class ImportDecl final : public Decl,
   friend class ASTReader;
   friend TrailingObjects;
 
-  /// The imported module, along with a bit that indicates whether
-  /// we have source-location information for each identifier in the module
-  /// name.
-  ///
-  /// When the bit is false, we only have a single source location for the
-  /// end of the import declaration.
-  llvm::PointerIntPair ImportedAndComplete;
+  /// The imported module.
+  Module *ImportedModule = nullptr;
 
   /// The next import in the list of imports local to the translation
   /// unit being parsed (not loaded from an AST file).
-  ImportDecl *NextLocalImport = nullptr;
+  ///
+  /// Includes a bit that indicates whether we have source-location information
+  /// for each identifier in the module name.
+  ///
+  /// When the bit is false, we only have a single source location for the
+  /// end of the import declaration.
+  llvm::PointerIntPair NextLocalImportAndComplete;
 
   ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported,
  ArrayRef IdentifierLocs);
@@ -4360,6 +4361,20 @@ class ImportDecl final : public Decl,
 
   ImportDecl(EmptyShell Empty) : Decl(Import, Empty) {}
 
+  bool isImportComplete() const { return NextLocalImportAndComplete.getInt(); }
+
+  void setImportComplete(bool C) { NextLocalImportAndComplete.setInt(C); }
+
+  /// The next import in the list of imports local to the translation
+  /// unit being parsed (not loaded from an AST file).
+  ImportDecl *getNextLocalImport() const {
+return NextLocalImportAndComplete.getPointer();
+  }
+
+  void setNextLocalImport(ImportDecl 

[PATCH] D71219: Fix conflict value for metadata "Objective-C Garbage Collection" in the mix of swift and Objective-C bitcode

2020-03-11 Thread Jin Lin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0cacb60549f: Fix conflict value for metadata 
Objective-C Garbage Collection in the mix of… (authored by jinlin).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71219

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/test/CodeGenObjC/image-info.m
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/test/Bitcode/upgrade-garbage-collection-for-objc.ll
  llvm/test/Bitcode/upgrade-garbage-collection-for-swift.ll
  llvm/test/Linker/Inputs/empty-objc.ll
  llvm/test/Linker/empty-swift.ll
  llvm/test/Object/objc-swift-mixed-imageinfo-macho.ll

Index: llvm/test/Object/objc-swift-mixed-imageinfo-macho.ll
===
--- /dev/null
+++ llvm/test/Object/objc-swift-mixed-imageinfo-macho.ll
@@ -0,0 +1,46 @@
+; RUN: llc -mtriple x86_64-apple-ios -filetype asm -o - %s | FileCheck %s
+; REQUIRES: x86-registered-target
+
+; It checks whether the backend generates IMAGE_INFO from Swift ABI version + major + minor + "Objective-C Garbage Collection".
+
+target triple = "x86_64-apple-macosx10.15.0"
+
+@llvm.used = appending global [1 x i8*] [i8* bitcast (i16* @__swift_reflection_version to i8*)], section "llvm.metadata", align 8
+@__swift_reflection_version = linkonce_odr hidden constant i16 3
+
+define i32 @main(i32 %0, i8** %1) #0 {
+  %3 = bitcast i8** %1 to i8*
+  ret i32 0
+}
+
+attributes #0 = { "frame-pointer"="all" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" }
+
+!swift.module.flags = !{!0}
+!llvm.linker.options = !{!1, !2, !3}
+!llvm.asan.globals = !{!4}
+!llvm.module.flags = !{!5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16}
+!llvm.ident = !{!17}
+
+!0 = !{!"standard-library", i1 false}
+!1 = !{!"-lswiftSwiftOnoneSupport"}
+!2 = !{!"-lswiftCore"}
+!3 = !{!"-lobjc"}
+!4 = !{[1 x i8*]* @llvm.used, null, null, i1 false, i1 true}
+!5 = !{i32 2, !"SDK Version", [2 x i32] [i32 10, i32 15]}
+!6 = !{i32 1, !"Objective-C Version", i32 2}
+!7 = !{i32 1, !"Objective-C Image Info Version", i32 0}
+!8 = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"}
+!9 = !{i32 1, !"Objective-C Garbage Collection", i8 0}
+!10 = !{i32 1, !"Objective-C Class Properties", i32 64}
+!11 = !{i32 1, !"wchar_size", i32 4}
+!12 = !{i32 7, !"PIC Level", i32 2}
+!13 = !{i32 1, !"Swift Version", i32 7}
+!14 = !{i32 1, !"Swift ABI Version", i32 7}
+!15 = !{i32 1, !"Swift Major Version", i8 5}
+!16 = !{i32 1, !"Swift Minor Version", i8 1}
+!17 = !{!"Apple clang version 11.0.0 (clang-1100.0.33.12)"}
+
+; CHECK: .section	__DATA,__objc_imageinfo,regular,no_dead_strip
+; CHECK: L_OBJC_IMAGE_INFO:
+; CHECK:   .long 0
+; CHECK:   .long 83953472
Index: llvm/test/Linker/empty-swift.ll
===
--- /dev/null
+++ llvm/test/Linker/empty-swift.ll
@@ -0,0 +1,42 @@
+; RUN: llvm-link %s %p/Inputs/empty-objc.ll -S | FileCheck %s
+
+; It tests whether Swift bitcode can be successfully linked with Objecitive-C bitcode.
+; During the process, the IRUpgrader turns a i32 type "Objective-C Garbage Collection"
+; into i8 value. If the higher bits are set, it adds the module flag for swift info.
+
+target triple = "x86_64-apple-macosx10.15.0"
+
+@__swift_reflection_version = linkonce_odr hidden constant i16 3
+@llvm.used = appending global [1 x i8*] [i8* bitcast (i16* @__swift_reflection_version to i8*)], section "llvm.metadata", align 8
+
+define i32 @main(i32 %0, i8** %1) #0 {
+  %3 = bitcast i8** %1 to i8*
+  ret i32 0
+}
+
+attributes #0 = { "frame-pointer"="all" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" }
+
+!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
+!swift.module.flags = !{!9}
+!llvm.linker.options = !{!10, !11, !12}
+!llvm.asan.globals = !{!13}
+
+!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 10, i32 15]}
+!1 = !{i32 1, !"Objective-C Version", i32 2}
+!2 = !{i32 1, !"Objective-C Image Info Version", i32 0}
+!3 = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"}
+!4 = !{i32 4, !"Objective-C Garbage Collection", i32 83953408}
+!5 = !{i32 1, !"Objective-C Class Properties", i32 64}
+!6 = !{i32 1, !"wchar_size", i32 4}
+!7 = !{i32 7, !"PIC Level", i32 2}
+!8 = !{i32 1, !"Swift Version", i32 7}
+!9 = !{!"standard-library", i1 false}
+!10 = !{!"-lswiftSwiftOnoneSupport"}
+!11 = !{!"-lswiftCore"}
+!12 = !{!"-lobjc"}
+!13 = !{[1 x i8*]* @llvm.used, null, null, i1 false, i1 true}
+
+; CHECK: !{{[0-9]+}} = !{i32 1, !"Objective-C Garbage Collection", i8 0}
+; CHECK: !{{[0-9]+}} = !{i32 1, !"Swift ABI Version", i32 7}
+; CHECK: !{{[0-9]+}} = !{i32 1, !"Swift Major 

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-03-11 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar reopened this revision.
mitchell-stellar added a comment.
This revision is now accepted and ready to land.

Reverted this commit due to an unexpected test failure:

   TEST 'Clang :: Format/dump-config-objc.h' FAILED 

  Script:
  --
  : 'RUN: at line 1';   /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang-format 
-dump-config 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/dump-config-objc.h | 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/dump-config-objc.h
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/dump-config-objc.h:3:11:
 error: CHECK: expected string not found in input
  // CHECK: Language: ObjC
^
  :1:1: note: scanning from here
  ---
  ^
  :2:1: note: possible intended match here
  Language: Cpp
  ^
  
  --
  
  

I don't know enough about this patch in order to determine what the issue is, 
or how to proceed further. Perhaps @MyDeveloperDay will chime in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72326



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


[PATCH] D75655: [Docs] Document -lto-whole-program-visibility

2020-03-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75655



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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-11 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added a comment.

In D75791#1917837 , @MyDeveloperDay 
wrote:

> your patch seems to be missing the other files


Which other files? I made a new commit and did the full context diff, now sure 
why it's only showing the documentation update.

I've never committed to Clang before, I don't know this process exactly.




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1088
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock) {
-  parseBlock(/*MustBeDeclaration=*/true);
-} else {
+if (Style.BraceWrapping.AfterExternBlock == true &&
+Style.IndentExternBlock == true) {

MyDeveloperDay wrote:
> something here looks abit odd? there is too much repetition around you 
> option, I think you doing something at the wrong level.
I agree that the parseBlock function is doing too much, but it's written that 
way to begin with.

The parseBlock function takes 3 parameters and has defaults for two of them, I 
just changed the value for those defaults on the IndentExternBlock == false 
versions to default to not indenting; that way the AfterExternBlock option only 
handles bracewrapping extern blocks, without indenting as well.


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

https://reviews.llvm.org/D75791



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


[PATCH] D74386: [SVE] Update API ConstantVector::getSplat() to use ElementCount.

2020-03-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:4497
 Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C) {
-  unsigned nElts = V->getType()->getVectorNumElements();
-  Value* SV = llvm::ConstantVector::getSplat(nElts, C);
+  auto EC = V->getType()->getVectorElementCount();
+  Value *SV = llvm::ConstantVector::getSplat(EC, C);

Please write out the type ElementCOunt.



Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:6542
 
-unsigned End = getTransitionType()->getVectorNumElements();
+auto EC = getTransitionType()->getVectorElementCount();
 if (UseSplat)

Please write out the type ElementCount.

This is unfortunately turning the explicit assertion if the type is scalable 
into a later verifier failure in the case where it isn't a splat.  Please 
either fix it properly, or change it so the non-splat codepath still asserts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74386



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


[clang] a0cacb6 - Fix conflict value for metadata "Objective-C Garbage Collection" in the mix of swift and Objective-C bitcode

2020-03-11 Thread Jin Lin via cfe-commits

Author: Jin Lin
Date: 2020-03-11T13:26:06-07:00
New Revision: a0cacb60549f2346f7addf9205cd32720afc8fb4

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

LOG: Fix conflict value for metadata "Objective-C Garbage Collection" in the 
mix of swift and Objective-C bitcode

Summary:
The change is to fix conflict value for metadata "Objective-C Garbage 
Collection" in the mix of swift and Objective-C bitcode.
The purpose is to provide the support of LTO for swift and Objective-C mixed 
project.

Reviewers: rjmccall, ahatanak, steven_wu

Reviewed By: rjmccall, steven_wu

Subscribers: manmanren, mehdi_amini, hiraditya, dexonsmith, llvm-commits, jinlin

Tags: #llvm

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

Added: 
llvm/test/Bitcode/upgrade-garbage-collection-for-objc.ll
llvm/test/Bitcode/upgrade-garbage-collection-for-swift.ll
llvm/test/Linker/Inputs/empty-objc.ll
llvm/test/Linker/empty-swift.ll
llvm/test/Object/objc-swift-mixed-imageinfo-macho.ll

Modified: 
clang/lib/CodeGen/CGObjCMac.cpp
clang/test/CodeGenObjC/image-info.m
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/IR/AutoUpgrade.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 0ab4fd8e224c..44c14a745a98 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -5159,15 +5159,18 @@ void CGObjCCommonMac::EmitImageInfo() {
   Mod.addModuleFlag(llvm::Module::Error, "Objective-C Image Info Section",
 llvm::MDString::get(VMContext, Section));
 
+  auto Int8Ty = llvm::Type::getInt8Ty(VMContext);
   if (CGM.getLangOpts().getGC() == LangOptions::NonGC) {
 // Non-GC overrides those files which specify GC.
-Mod.addModuleFlag(llvm::Module::Override,
-  "Objective-C Garbage Collection", (uint32_t)0);
+Mod.addModuleFlag(llvm::Module::Error,
+  "Objective-C Garbage Collection",
+  llvm::ConstantInt::get(Int8Ty,0));
   } else {
 // Add the ObjC garbage collection value.
 Mod.addModuleFlag(llvm::Module::Error,
   "Objective-C Garbage Collection",
-  eImageInfo_GarbageCollected);
+  llvm::ConstantInt::get(Int8Ty,
+(uint8_t)eImageInfo_GarbageCollected));
 
 if (CGM.getLangOpts().getGC() == LangOptions::GCOnly) {
   // Add the ObjC GC Only value.
@@ -5178,7 +5181,7 @@ void CGObjCCommonMac::EmitImageInfo() {
   llvm::Metadata *Ops[2] = {
   llvm::MDString::get(VMContext, "Objective-C Garbage Collection"),
   llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
-  llvm::Type::getInt32Ty(VMContext), 
eImageInfo_GarbageCollected))};
+  Int8Ty, eImageInfo_GarbageCollected))};
   Mod.addModuleFlag(llvm::Module::Require, "Objective-C GC Only",
 llvm::MDNode::get(VMContext, Ops));
 }

diff  --git a/clang/test/CodeGenObjC/image-info.m 
b/clang/test/CodeGenObjC/image-info.m
index 37156ed039e4..2b9af900354b 100644
--- a/clang/test/CodeGenObjC/image-info.m
+++ b/clang/test/CodeGenObjC/image-info.m
@@ -8,10 +8,10 @@
 // CHECK-FRAGILE:  !{{[0-9]+}} = !{i32 1, !"Objective-C Version", i32 1}
 // CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info 
Version", i32 0}
 // CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info 
Section", !"__OBJC,__image_info,regular"}
-// CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 4, !"Objective-C Garbage 
Collection", i32 0}
+// CHECK-FRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Garbage 
Collection", i8 0}
 
 // CHECK-NONFRAGILE:  !llvm.module.flags = !{{{.*}}}
 // CHECK-NONFRAGILE:  !{{[0-9]+}} = !{i32 1, !"Objective-C Version", i32 2}
 // CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info 
Version", i32 0}
 // CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info 
Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"}
-// CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 4, !"Objective-C Garbage 
Collection", i32 0}
+// CHECK-NONFRAGILE-NEXT: !{{[0-9]+}} = !{i32 1, !"Objective-C Garbage 
Collection", i8 0}

diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp 
b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index d36d04e42cbe..2ce285c85672 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -84,6 +84,15 @@ static void GetObjCImageInfo(Module , unsigned , 
unsigned ,
 } else if (Key == "Objective-C Image Info Section") {
   Section = cast(MFE.Val)->getString();
 }
+// Backend generates L_OBJC_IMAGE_INFO from Swift ABI version + major + 
minor +
+// 

[clang] c5c487f - Revert "[clang-format] Add option to specify explicit config file"

2020-03-11 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2020-03-11T16:14:42-04:00
New Revision: c5c487f0d4c6720f4384f670490086e723f5fe32

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

LOG: Revert "[clang-format] Add option to specify explicit config file"
There were a number of unexpected test failures.

This reverts commit 10b1a87ba35d386b718f0e83c1d750631705b220.

Added: 


Modified: 
clang/docs/ClangFormat.rst
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 633cffa55537..1138b2332670 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -75,10 +75,6 @@ to format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code.
  .clang-format file located in one of the 
parent
  directories of the source file (or current
  directory for stdin).
- Use -style=file: to load 
style
- configuration from a format file located at
- . This path can be absolute 
or
- relative to the working directory.
  Use -style="{key: value, ...}" to set specific
  parameters, e.g.:
-style="{BasedOnStyle: llvm, IndentWidth: 
8}"

diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 99a6a7df790b..50b4ff5d9010 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -24,10 +24,6 @@ try to find the ``.clang-format`` file located in the 
closest parent directory
 of the input file. When the standard input is used, the search is started from
 the current directory.
 
-When using ``-style=file:, :program:`clang-format` for 
-each input file will use the format file located at ``.
-The path may be absolute or relative to the working directory.
-
 The ``.clang-format`` file uses YAML format:
 
 .. code-block:: yaml

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce15513c1c8c..664ae4e4167c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -253,10 +253,6 @@ clang-format
   bar();
 });
 
-- The command line argument `-style=` has been extended so that a 
specific
-  format file at location  can be selected. This is supported
-  via the syntax: `-style=file:`.
-
 libclang
 
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8c1cb6ea3986..d4f76c87c14e 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2476,7 +2476,6 @@ extern const char *DefaultFallbackStyle;
 /// * "file" - Load style configuration from a file called ``.clang-format``
 /// located in one of the parent directories of ``FileName`` or the current
 /// directory if ``FileName`` is empty.
-/// * "file:" to explicitly specify the configuration file to use.
 ///
 /// \param[in] StyleName Style name to interpret according to the description
 /// above.

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 4c20eb2941ba..031312bd16d8 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2640,8 +2640,6 @@ const char *StyleOptionHelpDescription =
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
-"Use -style=file: to explicitly specify"
-"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2687,29 +2685,6 @@ FormatStyle::LanguageKind guessLanguage(StringRef 
FileName, StringRef Code) {
   return GuessedLanguage;
 }
 
-/// Attempts to load a format file
-llvm::Expected LoadConfigFile(StringRef ConfigFile,
-   llvm::vfs::FileSystem *FS,
-   bool *IsSuitable) {
-  FormatStyle Style = getLLVMStyle();
-  *IsSuitable = true;
-
-  llvm::ErrorOr> Text =
-  FS->getBufferForFile(ConfigFile.str());
-  if (std::error_code EC = Text.getError())
-return make_string_error(EC.message());
-  std::error_code ParserErrorCode =
-  parseConfiguration(Text.get()->getBuffer(), );
-  if (ParserErrorCode == ParseError::Unsuitable) {
-*IsSuitable = false;
-return Style;
-  } else if (ParserErrorCode != ParseError::Success) {
- 

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-03-11 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10b1a87ba35d: [clang-format] Add option to specify explicit 
config file Summary: This diff… (authored by mitchell-stellar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72326

Files:
  clang/docs/ClangFormat.rst
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14912,6 +14912,61 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", );
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9: explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style8 = getStyle("file:/e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", );
+  ASSERT_TRUE((bool)Style8);
+  ASSERT_EQ(*Style8, getGoogleStyle());
+
+  // Test 10: relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style9 = getStyle("file:../../e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", );
+  ASSERT_TRUE((bool)Style9);
+  ASSERT_EQ(*Style9, getGoogleStyle());
+
+  // Test 11: missing explicit format file
+  auto Style10 = getStyle("file:/e/missing.clang-format",
+  "/e/sub/sub/sub/test.cpp", "LLVM", "", );
+  ASSERT_FALSE((bool)Style10);
+  llvm::consumeError(Style10.takeError());
+
+  // Test 12: format file from the filesystem
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile(
+  "FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT =
+  llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  auto Style11 = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE((bool)Style11);
+  ASSERT_EQ(*Style11, getGoogleStyle());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2640,6 +2640,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2685,6 +2687,29 @@
   return GuessedLanguage;
 }
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile,
+   llvm::vfs::FileSystem *FS,
+   bool *IsSuitable) {
+  FormatStyle Style = getLLVMStyle();
+  *IsSuitable = true;
+
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  if (std::error_code EC = Text.getError())
+return make_string_error(EC.message());
+  std::error_code ParserErrorCode =
+  parseConfiguration(Text.get()->getBuffer(), );
+  if (ParserErrorCode == ParseError::Unsuitable) {
+*IsSuitable = false;
+return Style;
+  } else if (ParserErrorCode != ParseError::Success) {
+return make_string_error("Error reading " + ConfigFile + ": " +
+ ParserErrorCode.message());
+  }
+  return Style;
+}
+
 const char *DefaultFormatStyle = "file";
 
 const char *DefaultFallbackStyle = "LLVM";
@@ -2709,6 +2734,21 @@
 return Style;
   }
 
+  llvm::SmallVector FilesToLookFor;
+  // User provided clang-format file using 

[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-11 Thread Warren Ristow via Phabricator via cfe-commits
wristow added a comment.

Revisiting this patch.  I think that before fixing the `-ffp-contract=off` 
problem I originally raised here, there are two questions that have come up in 
this discussion that we should first resolve.  Specifically:

(1)  Do we want to enable FMA transformations by default (at appropriate 
optimization levels), like GCC does?  That is, should FMA be done for targets 
that support it with a command as simple as the following?

  clang -O2 -c test.c

FTR, currently we don't do FMA with simply `-O2`.  We do enable FMA if 
`-ffast-math` is added, or (of course) if FMA is explicitly enabled via 
`-ffp-contract=fast`.  Also note that with GCC, FMA is completely orthogonal to 
`-ffast-math`.  For example:

  gcc -O2 -ffp-contract=off -ffast-math test.c  # '-ffast-math' does not turn 
FMA "back on"

(2)  Under what conditions do we want to predefine the `__FAST_MATH__` macro?  
That is, should we continue with our current policy (essentially, define it 
when "all the fast-math-flags are enabled"), or do we want to do precisely what 
GCC does (define it when some particular subset of the fast-math-flags are 
enabled)?

My vote for (1) is yes.  To add to this, I would make the `-ffp-contract` 
setting independent of `-ffast-math`, as GCC does.  But to be explicit, 
enabling FMA at `-O2` is a change in behavior that may be unexpected for some 
users -- so I can imagine some users objecting to this change.

My vote for (2) is to keep our current behavior.  This approach seems more 
sensible to me than the GCC behavior.  And we're not boxing ourselves into 
anything by keeping the current behavior (that is, we can just as easily change 
this in the future if we find the GCC behavior is better for some reason).  
Among other things, this means that whether we define `__FAST_MATH__` will 
continue to not be impacted by the `-ffp-contract` setting -- that makes sense 
to me, especially if we make FMA orthogonal to `-ffast-math`, as discussed in 
(1).

One related point.  Our documentation (UsersManual.rst) for 
`-ffp-model=precise` says:

//Disables optimizations that are not value-safe on floating-point data, 
although FP contraction (FMA) is enabled (``-ffp-contract=fast``).  This is the 
default behavior.//

So this explicitly says that FMA is enabled by default (consistent with GCC in 
this regard).  However, that doesn't match our implementation, as we have FMA 
disabled by default, as noted in this discussion.  Concretely, the following 
two commands are not equivalent:

  clang -c -O2 test.c # FMA is disabled
  clang -c -O2 -ffp-model=precise test.c  # FMA is enabled

If we decide to enable FMA by default (that is, if we agree on "yes" for (1)), 
then the current `-ffp-model=precise` description will become correct.  But if 
we decide to continue to disable FMA by default, then we'll need to change the 
above description (possibly add another value to `-ffp-model=` that will 
//really // be the default).


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

https://reviews.llvm.org/D72675



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-11 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Shiva, I see a warning always  being printed:

'+small-data-limit=' is not a recognized feature for this target (ignoring 
feature)

This is because it is being passed down as a target feature.

Might be good to add a test case to make sure the SmallDataLimit module flag is 
created, no target feature is passed, and that no warnings are printed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-11 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

your patch seems to be missing the other files


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

https://reviews.llvm.org/D75791



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


[clang] 10b1a87 - [clang-format] Add option to specify explicit config file

2020-03-11 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2020-03-11T15:56:44-04:00
New Revision: 10b1a87ba35d386b718f0e83c1d750631705b220

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

LOG: [clang-format] Add option to specify explicit config file
Summary:
This diff extends the -style=file option to allow a config file to be specified 
explicitly. This is useful (for instance) when adding IDE commands to reformat 
code to a personal style.

Reviewers: djasper, ioeric, krasimir, MyDeveloperDay

Reviewed by: MyDeveloperDay

Contributed by: tnorth

Subscribers: cfe-commits, lebedev.ri, MyDeveloperDay, klimek, sammccall, 
mitchell-stellar

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/docs/ClangFormat.rst
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 1138b2332670..633cffa55537 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -75,6 +75,10 @@ to format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code.
  .clang-format file located in one of the 
parent
  directories of the source file (or current
  directory for stdin).
+ Use -style=file: to load 
style
+ configuration from a format file located at
+ . This path can be absolute 
or
+ relative to the working directory.
  Use -style="{key: value, ...}" to set specific
  parameters, e.g.:
-style="{BasedOnStyle: llvm, IndentWidth: 
8}"

diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 50b4ff5d9010..99a6a7df790b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -24,6 +24,10 @@ try to find the ``.clang-format`` file located in the 
closest parent directory
 of the input file. When the standard input is used, the search is started from
 the current directory.
 
+When using ``-style=file:, :program:`clang-format` for 
+each input file will use the format file located at ``.
+The path may be absolute or relative to the working directory.
+
 The ``.clang-format`` file uses YAML format:
 
 .. code-block:: yaml

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 664ae4e4167c..ce15513c1c8c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -253,6 +253,10 @@ clang-format
   bar();
 });
 
+- The command line argument `-style=` has been extended so that a 
specific
+  format file at location  can be selected. This is supported
+  via the syntax: `-style=file:`.
+
 libclang
 
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d4f76c87c14e..8c1cb6ea3986 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2476,6 +2476,7 @@ extern const char *DefaultFallbackStyle;
 /// * "file" - Load style configuration from a file called ``.clang-format``
 /// located in one of the parent directories of ``FileName`` or the current
 /// directory if ``FileName`` is empty.
+/// * "file:" to explicitly specify the configuration file to use.
 ///
 /// \param[in] StyleName Style name to interpret according to the description
 /// above.

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 031312bd16d8..4c20eb2941ba 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2640,6 +2640,8 @@ const char *StyleOptionHelpDescription =
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2685,6 +2687,29 @@ FormatStyle::LanguageKind guessLanguage(StringRef 
FileName, StringRef Code) {
   return GuessedLanguage;
 }
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile,
+   llvm::vfs::FileSystem *FS,
+   bool *IsSuitable) {
+  FormatStyle Style = getLLVMStyle();
+  *IsSuitable = true;
+
+  llvm::ErrorOr> Text =
+  

[PATCH] D76015: [clang-tidy] Mock system headers for portability-restrict-system-includes tests.

2020-03-11 Thread Paula Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1736f7a2a66: [clang-tidy] Mock system headers for 
portability-restrict-system-includes tests. (authored by PaulkaToast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76015

Files:
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/float.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stddef.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stdint.h
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
@@ -1,5 +1,6 @@
 // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
-// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '-*,std*.h'}]}"
+// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '-*,std*.h'}]}" \
+// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system
 
 // Test glob functionality: disallow all headers except those that match
 // pattern "std*.h".
Index: 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
@@ -1,5 +1,6 @@
 // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
-// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '-*,stddef.h'}]}"
+// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '-*,stddef.h'}]}" \
+// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system
 
 // Test allow-list functionality: disallow all but stddef.h.
 
Index: 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
@@ -1,5 +1,6 @@
 // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
-// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '*,-stddef.h'}]}"
+// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '*,-stddef.h'}]}" \
+// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system
 
 // Test block-list functionality: allow all but stddef.h.
 


Index: clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp
@@ -1,5 +1,6 @@
 // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
-// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,std*.h'}]}"
+// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,std*.h'}]}" \
+// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system
 
 // Test glob functionality: disallow all headers except those that match
 // pattern "std*.h".
Index: clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
===
--- 

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-11 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 249717.
oontvoo added a comment.

Wrong name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1253,60 +1253,21 @@
   // Get information about this file.
   HeaderFileInfo  = getFileInfo(File);
 
-  // FIXME: this is a workaround for the lack of proper modules-aware support
-  // for #import / #pragma once
-  auto TryEnterImported = [&]() -> bool {
-if (!ModulesEnabled)
-  return false;
-// Ensure FileInfo bits are up to date.
-ModMap.resolveHeaderDirectives(File);
-// Modules with builtins are special; multiple modules use builtins as
-// modular headers, example:
-//
-//module stddef { header "stddef.h" export * }
-//
-// After module map parsing, this expands to:
-//
-//module stddef {
-//  header "/path_to_builtin_dirs/stddef.h"
-//  textual "stddef.h"
-//}
-//
-// It's common that libc++ and system modules will both define such
-// submodules. Make sure cached results for a builtin header won't
-// prevent other builtin modules to potentially enter the builtin header.
-// Note that builtins are header guarded and the decision to actually
-// enter them is postponed to the controlling macros logic below.
-bool TryEnterHdr = false;
-if (FileInfo.isCompilingModuleHeader && FileInfo.isModuleHeader)
-  TryEnterHdr = File->getDir() == ModMap.getBuiltinDir() &&
-ModuleMap::isBuiltinHeader(
-llvm::sys::path::filename(File->getName()));
-
-// Textual headers can be #imported from different modules. Since ObjC
-// headers find in the wild might rely only on #import and do not contain
-// controlling macros, be conservative and only try to enter textual headers
-// if such macro is present.
-if (!FileInfo.isModuleHeader &&
-FileInfo.getControllingMacro(ExternalLookup))
-  TryEnterHdr = true;
-return TryEnterHdr;
-  };
-
   // If this is a #import directive, check that we have not already imported
   // this header.
   if (isImport) {
 // If this has already been imported, don't import it again.
 FileInfo.isImport = true;
+  }
 
-// Has this already been #import'ed or #include'd?
-if (FileInfo.NumIncludes && !TryEnterImported())
-  return false;
-  } else {
-// Otherwise, if this is a #include of a file that was previously #import'd
-// or if this is the second #include of a #pragma once file, ignore it.
-if (FileInfo.isImport && !TryEnterImported())
-  return false;
+  if (FileInfo.isPragmaOnce || FileInfo.isImport){
+if (FileInfo.isModuleHeader && M != nullptr){
+  if (PP.isIncludeVisibleInLocalModule(File, M)) return false;
+  else  PP.setIncludeVisibleForModule(File, M);
+} else {
+  if(PP.isIncludeVisible(File)) return false;
+  else PP.setIncludeVisible(File);
+}
   }
 
   // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -743,6 +744,9 @@
 /// The set of modules that are visible within the submodule.
 VisibleModuleSet VisibleModules;
 
+/// The included header for the submodule.
+std::set IncludedFiles;
+
 // FIXME: CounterValue?
 // FIXME: PragmaPushMacroInfo?
   };
@@ -1038,6 +1042,32 @@
 OnToken = std::move(F);
   }
 
+  void setIncludeVisible(const FileEntry *File) {
+CurSubmoduleState->IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisible(const FileEntry *File) {
+return CurSubmoduleState->IncludedFiles.find(File)
+!= CurSubmoduleState->IncludedFiles.end();
+  }
+
+  void setIncludeVisibleForModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+// Can't find the module. Maybe something is wrong.
+if (SubmoduleIter == Submodules.end()) return;
+
+SubmoduleIter->second.IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisibleInLocalModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+if (SubmoduleIter == Submodules.end()) return false;
+
+return SubmoduleIter->second.IncludedFiles.find(File)
+!= SubmoduleIter->second.IncludedFiles.end();
+  }
+
+
   bool isMacroDefined(StringRef Id) {
 return isMacroDefined((Id));
   }
___
cfe-commits mailing list

[clang-tools-extra] f1736f7 - [clang-tidy] Mock system headers for portability-restrict-system-includes tests.

2020-03-11 Thread Paula Toth via cfe-commits

Author: Paula Toth
Date: 2020-03-11T12:13:27-07:00
New Revision: f1736f7a2a660944c24aac45e24cdf1ea6c6effa

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

LOG: [clang-tidy] Mock system headers for portability-restrict-system-includes 
tests.

Summary: Didn't realize that headers such as stddef.h may not exist on all 
systems. This patch mocks the headers so that the check's tests work on all 
systems.  (:

Reviewers: RKSimon, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/float.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stddef.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stdint.h

Modified: 

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp

clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp

Removed: 

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h



diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/float.h
similarity index 100%
rename from 
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h
rename to 
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/float.h

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h
deleted file mode 100644
index e69de29bb2d1..

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stddef.h
similarity index 100%
rename from 
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h
rename to 
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stddef.h

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stdint.h
similarity index 100%
rename from 
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h
rename to 
clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stdint.h

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
index e3a9376a8638..a74b94b604ac 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
@@ -1,5 +1,6 @@
 // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \
-// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '*,-stddef.h'}]}"
+// RUN: -- -config="{CheckOptions: [{key: 
portability-restrict-system-includes.Includes, value: '*,-stddef.h'}]}" \
+// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system
 
 // Test block-list functionality: allow all but stddef.h.
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
index f73cbbfc816d..1d1e8a4e6706 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
@@ -1,5 +1,6 @@
 // RUN: %check_clang_tidy %s 

[PATCH] D75569: [clang-tidy] New check for methods marked __attribute__((unavailable)) that do not override a method from a superclass.

2020-03-11 Thread Michael Wyman via Phabricator via cfe-commits
mwyman marked 3 inline comments as done.
mwyman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp:34
+// Matches Objective-C methods that are not overriding a superclass method.
+AST_MATCHER(ObjCMethodDecl, isNotOverriding) { return !Node.isOverriding(); }
+

njames93 wrote:
> Not a point for this patch, but maybe this should be made into an actual 
> matcher, though not complimented, or better yet the `CXXMethodDecl` 
> `isOverride` matcher be extended for `ObjCMethodDecl`
I agree, and also that it's probably best left to a later patch. Not sure how 
to deal with the making one that works for both `CXXMethodDecl` and 
`ObjCMethodDecl`.



Comment at: 
clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp:63
+  }
+  return FixItHint::CreateRemoval(MD->getSourceRange());
+}

aaron.ballman wrote:
> I'm not an ObjC expert, so I apologize if this is a dumb question, but why is 
> the fix-it removing the entire method as opposed to just the attribute?
> 
> Also, are you sure that the source range for the method declaration is 
> sufficient to remove without breaking code? e.g., what about the definition 
> of the method? Or can there be any trailing bits after the method that are 
> not accounted for in the source range (such as trailing attributes, if those 
> are possible in ObjC)?
Removing the attribute is undesirable, as that would make the compiler allow 
calling the method, when it has explicitly been marked unavailable. In my 
experience the majority of the cases in Objective-C for using this attribute 
are to mark a superclass method unavailable (e.g. a designated initializer that 
shouldn't be called on the subclass, even just -init, favoring its own declared 
designated initializer instead), but it can also be used to mark a 
previously-deprecated-now-removed method with a message to point updaters what 
method to migrate to.

Which brings up an interesting point that if a message is provided, it could be 
that an API has finally finished allowing a deprecated method to be called and 
removed it entirely, and so if a message is provided it may be indicating that 
and telling what new API to use, rather than overriding the availability of a 
superclass method. But a method being marked unavailable without any message 
doesn't really provide much help on that versus the method just not existing. 
Perhaps if a message is provided this check shouldn't complain at all.

I've removed the fix-it entirely, and replaced it with a different warning 
message.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst:29
+
+  Comma-separated list of names of macros that can define the unavailable
+  attribute for which fixes should be suggested. The default is an empty list.

aaron.ballman wrote:
> This looks wrong to me -- it's a semicolon-delimited list, isn't it?
Obsolete, deleted.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m:34
+// Verify check when using a macro that expands to the unavailable attribute.
+- (void)methodC NS_UNAVAILABLE;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodC' is marked 
unavailable but does not override a superclass method 
[objc-method-unavailable-not-override]

aaron.ballman wrote:
> mwyman wrote:
> > njames93 wrote:
> > > Generally we are cautious about modifying MACRO usages in clang_tidy as 
> > > we don't know if its definition can change based on configuration, 
> > > perhaps its safer to just warn instead of providing a fix it
> > Sounds reasonable; I made this the default behavior.
> > 
> > However for Objective-C, it's quite common for developers to use a macro 
> > from the Apple SDKs like NS_UNAVAILABLE that are unconditional in any 
> > situations I know of. I added a config option to allow whitelisting macros 
> > that should have fix-its provided.
> If the common practice is to use macros like NS_UNAVAILABLE, should that be 
> on the default list of options (along with any other common-use macro names 
> that do the same thing)?
Obsolete, fix-it deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75569



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


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-11 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 249712.
oontvoo added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1253,60 +1253,21 @@
   // Get information about this file.
   HeaderFileInfo  = getFileInfo(File);
 
-  // FIXME: this is a workaround for the lack of proper modules-aware support
-  // for #import / #pragma once
-  auto TryEnterImported = [&]() -> bool {
-if (!ModulesEnabled)
-  return false;
-// Ensure FileInfo bits are up to date.
-ModMap.resolveHeaderDirectives(File);
-// Modules with builtins are special; multiple modules use builtins as
-// modular headers, example:
-//
-//module stddef { header "stddef.h" export * }
-//
-// After module map parsing, this expands to:
-//
-//module stddef {
-//  header "/path_to_builtin_dirs/stddef.h"
-//  textual "stddef.h"
-//}
-//
-// It's common that libc++ and system modules will both define such
-// submodules. Make sure cached results for a builtin header won't
-// prevent other builtin modules to potentially enter the builtin header.
-// Note that builtins are header guarded and the decision to actually
-// enter them is postponed to the controlling macros logic below.
-bool TryEnterHdr = false;
-if (FileInfo.isCompilingModuleHeader && FileInfo.isModuleHeader)
-  TryEnterHdr = File->getDir() == ModMap.getBuiltinDir() &&
-ModuleMap::isBuiltinHeader(
-llvm::sys::path::filename(File->getName()));
-
-// Textual headers can be #imported from different modules. Since ObjC
-// headers find in the wild might rely only on #import and do not contain
-// controlling macros, be conservative and only try to enter textual headers
-// if such macro is present.
-if (!FileInfo.isModuleHeader &&
-FileInfo.getControllingMacro(ExternalLookup))
-  TryEnterHdr = true;
-return TryEnterHdr;
-  };
-
   // If this is a #import directive, check that we have not already imported
   // this header.
   if (isImport) {
 // If this has already been imported, don't import it again.
 FileInfo.isImport = true;
+  }
 
-// Has this already been #import'ed or #include'd?
-if (FileInfo.NumIncludes && !TryEnterImported())
-  return false;
-  } else {
-// Otherwise, if this is a #include of a file that was previously #import'd
-// or if this is the second #include of a #pragma once file, ignore it.
-if (FileInfo.isImport && !TryEnterImported())
-  return false;
+  if (FileInfo.isPragmaOnce || FileInfo.isImport){
+if (FileInfo.isModuleHeader && M != nullptr){
+  if (PP.isIncludeVisibleInLocalModule(File, M)) return false;
+  else  PP.setIncludeVisibleForHeader(File, M);
+} else {
+  if(PP.isIncludeVisible(File)) return false;
+  else PP.setIncludeVisible(File);
+}
   }
 
   // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -743,6 +744,9 @@
 /// The set of modules that are visible within the submodule.
 VisibleModuleSet VisibleModules;
 
+/// The included header for the submodule.
+std::set IncludedFiles;
+
 // FIXME: CounterValue?
 // FIXME: PragmaPushMacroInfo?
   };
@@ -1038,6 +1042,32 @@
 OnToken = std::move(F);
   }
 
+  void setIncludeVisible(const FileEntry *File) {
+CurSubmoduleState->IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisible(const FileEntry *File) {
+return CurSubmoduleState->IncludedFiles.find(File)
+!= CurSubmoduleState->IncludedFiles.end();
+  }
+
+  void setIncludeVisibleForModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+// Can't find the module. Maybe something is wrong.
+if (SubmoduleIter == Submodules.end()) return;
+
+SubmoduleIter->second.IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisibleInLocalModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+if (SubmoduleIter == Submodules.end()) return false;
+
+return SubmoduleIter->second.IncludedFiles.find(File)
+!= SubmoduleIter->second.IncludedFiles.end();
+  }
+
+
   bool isMacroDefined(StringRef Id) {
 return isMacroDefined((Id));
   }
___
cfe-commits mailing list

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-11 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 249711.
oontvoo added a comment.

More typo correction


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1253,60 +1253,21 @@
   // Get information about this file.
   HeaderFileInfo  = getFileInfo(File);
 
-  // FIXME: this is a workaround for the lack of proper modules-aware support
-  // for #import / #pragma once
-  auto TryEnterImported = [&]() -> bool {
-if (!ModulesEnabled)
-  return false;
-// Ensure FileInfo bits are up to date.
-ModMap.resolveHeaderDirectives(File);
-// Modules with builtins are special; multiple modules use builtins as
-// modular headers, example:
-//
-//module stddef { header "stddef.h" export * }
-//
-// After module map parsing, this expands to:
-//
-//module stddef {
-//  header "/path_to_builtin_dirs/stddef.h"
-//  textual "stddef.h"
-//}
-//
-// It's common that libc++ and system modules will both define such
-// submodules. Make sure cached results for a builtin header won't
-// prevent other builtin modules to potentially enter the builtin header.
-// Note that builtins are header guarded and the decision to actually
-// enter them is postponed to the controlling macros logic below.
-bool TryEnterHdr = false;
-if (FileInfo.isCompilingModuleHeader && FileInfo.isModuleHeader)
-  TryEnterHdr = File->getDir() == ModMap.getBuiltinDir() &&
-ModuleMap::isBuiltinHeader(
-llvm::sys::path::filename(File->getName()));
-
-// Textual headers can be #imported from different modules. Since ObjC
-// headers find in the wild might rely only on #import and do not contain
-// controlling macros, be conservative and only try to enter textual headers
-// if such macro is present.
-if (!FileInfo.isModuleHeader &&
-FileInfo.getControllingMacro(ExternalLookup))
-  TryEnterHdr = true;
-return TryEnterHdr;
-  };
-
   // If this is a #import directive, check that we have not already imported
   // this header.
   if (isImport) {
 // If this has already been imported, don't import it again.
 FileInfo.isImport = true;
+  }
 
-// Has this already been #import'ed or #include'd?
-if (FileInfo.NumIncludes && !TryEnterImported())
-  return false;
-  } else {
-// Otherwise, if this is a #include of a file that was previously #import'd
-// or if this is the second #include of a #pragma once file, ignore it.
-if (FileInfo.isImport && !TryEnterImported())
-  return false;
+  if (FileInfo.isPragmaOnce || FileInfo.isImport){
+if (FileInfo.isModuleHeader && M != nullptr){
+  if (PP.isIncludeVisibleInLocalModule(File, M)) return false;
+  else  PP.setIncludeVisibleForHeader(File, M);
+} else {
+  if(PP.isIncludeVisible(File)) return false;
+  else PP.setIncludeVisible(File);
+}
   }
 
   // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -743,6 +744,9 @@
 /// The set of modules that are visible within the submodule.
 VisibleModuleSet VisibleModules;
 
+/// The included header for the submodule.
+std::set IncludedFiles;
+
 // FIXME: CounterValue?
 // FIXME: PragmaPushMacroInfo?
   };
@@ -1038,6 +1042,32 @@
 OnToken = std::move(F);
   }
 
+  void setIncludeVisible(const FileEntry *File) {
+CurSubmoduleState.IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisible(const FileEntry *File) {
+return CurSubmoduleState->IncludedFiles.find(File)
+!= CurSubmoduleState->IncludedFiles.end();
+  }
+
+  void setIncludeVisibleForModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+// Can't find the module. Maybe something is wrong.
+if (SubmoduleIter == Submodules.end()) return;
+
+SubmoduleIter->second.IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisibleInLocalModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+if (SubmoduleIter == Submodules.end()) return false;
+
+return SubmoduleIter->second.IncludedFiles.find(File)
+!= SubmoduleIter->second.IncludedFiles.end();
+  }
+
+
   bool isMacroDefined(StringRef Id) {
 return isMacroDefined((Id));
   }
___
cfe-commits 

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-11 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 249708.
oontvoo added a comment.

Updated typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1253,60 +1253,21 @@
   // Get information about this file.
   HeaderFileInfo  = getFileInfo(File);
 
-  // FIXME: this is a workaround for the lack of proper modules-aware support
-  // for #import / #pragma once
-  auto TryEnterImported = [&]() -> bool {
-if (!ModulesEnabled)
-  return false;
-// Ensure FileInfo bits are up to date.
-ModMap.resolveHeaderDirectives(File);
-// Modules with builtins are special; multiple modules use builtins as
-// modular headers, example:
-//
-//module stddef { header "stddef.h" export * }
-//
-// After module map parsing, this expands to:
-//
-//module stddef {
-//  header "/path_to_builtin_dirs/stddef.h"
-//  textual "stddef.h"
-//}
-//
-// It's common that libc++ and system modules will both define such
-// submodules. Make sure cached results for a builtin header won't
-// prevent other builtin modules to potentially enter the builtin header.
-// Note that builtins are header guarded and the decision to actually
-// enter them is postponed to the controlling macros logic below.
-bool TryEnterHdr = false;
-if (FileInfo.isCompilingModuleHeader && FileInfo.isModuleHeader)
-  TryEnterHdr = File->getDir() == ModMap.getBuiltinDir() &&
-ModuleMap::isBuiltinHeader(
-llvm::sys::path::filename(File->getName()));
-
-// Textual headers can be #imported from different modules. Since ObjC
-// headers find in the wild might rely only on #import and do not contain
-// controlling macros, be conservative and only try to enter textual headers
-// if such macro is present.
-if (!FileInfo.isModuleHeader &&
-FileInfo.getControllingMacro(ExternalLookup))
-  TryEnterHdr = true;
-return TryEnterHdr;
-  };
-
   // If this is a #import directive, check that we have not already imported
   // this header.
   if (isImport) {
 // If this has already been imported, don't import it again.
 FileInfo.isImport = true;
+  }
 
-// Has this already been #import'ed or #include'd?
-if (FileInfo.NumIncludes && !TryEnterImported())
-  return false;
-  } else {
-// Otherwise, if this is a #include of a file that was previously #import'd
-// or if this is the second #include of a #pragma once file, ignore it.
-if (FileInfo.isImport && !TryEnterImported())
-  return false;
+  if (FileInfo.isPragmaOnce || FileInfo.isImport){
+if (FileInfo.isModuleHeader && M != nullptr){
+  if (PP.isIncludeVisibleInLocalModule(File, M)) return false;
+  else  PP.setIncludeVisibleForHeader(File, M);
+} else {
+  if(PP.isIncludeVisible(File)) return false;
+  else PP.setIncludeVisible(File);
+}
   }
 
   // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -743,6 +744,9 @@
 /// The set of modules that are visible within the submodule.
 VisibleModuleSet VisibleModules;
 
+/// The included header for the submodule.
+std::set IncludedFiles;
+
 // FIXME: CounterValue?
 // FIXME: PragmaPushMacroInfo?
   };
@@ -1038,6 +1042,32 @@
 OnToken = std::move(F);
   }
 
+  void setIncludeVisible(const FileEntry *File) {
+CurSubmoduleState.IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisible(const FileEntry *File) {
+return CurSubmoduleState.IncludedFiles.find(File)
+!= CurSubmoduleState.IncludedFiles.end();
+  }
+
+  void setIncludeVisibleForModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+// Can't find the module. Maybe something is wrong.
+if (SubmoduleIter == Submodules.end()) return;
+
+SubmoduleIter->second.IncludedFiles.insert(File);
+  }
+
+  bool isIncludeVisibleInLocalModule(const FileEntry *File, Module *M) {
+auto SubmoduleIter = Submodules.find(M);
+if (SubmoduleIter == Submodules.end()) return false;
+
+return SubmoduleIter->second.IncludedFiles.find(File)
+!= SubmoduleIter->second.IncludedFiles.end();
+  }
+
+
   bool isMacroDefined(StringRef Id) {
 return isMacroDefined((Id));
   }
___
cfe-commits mailing list

[PATCH] D75569: [clang-tidy] New check for methods marked __attribute__((unavailable)) that do not override a method from a superclass.

2020-03-11 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 249709.
mwyman marked 5 inline comments as done.
mwyman added a comment.

After some discussion, have decided to remove the fix-it entirely and update 
the diagnostic message; removing the method altogether may not be the correct 
behavior, as previously deprecated methods that have since been removed may 
want to have an unavailable attribute attached with a message explaining what 
to use instead, even though they don't override a superclass method.

But in general still feel like non-overriding, non-messaged attributes are 
probably reasonable to flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75569

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
  
clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
@@ -0,0 +1,43 @@
+// RUN: %check_clang_tidy %s objc-method-unavailable-not-override %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN: {key: objc-method-unavailable-not-override.FixMacroNames, \
+// RUN:  value: "UNAVAILABLE_FIXIT"} \
+// RUN: ]}' --
+
+__attribute__((objc_root_class))
+@interface Object
+- (instancetype)init;
+@end
+
+@interface MyObject : Object
+- (instancetype)init __attribute__((unavailable));
+
+// A new method that is not overriding, and is available, should not trigger.
+- (void)notOverridingMethod;
+
+- (void)methodA __attribute__((unavailable)); // methodA
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: methods marked unavailable should either override a superclass method or explain why they are unavailable; consider adding a message to the unavailable attribute, or simply deleting 'methodA'. [objc-method-unavailable-not-override]
+
+// Verify check does NOT show when the unavailable attribute has a message.
+- (void)methodB __attribute__((unavailable("use methodE"))); // methodB
+
+#define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable))
+#define UNAVAILABLE UNAVAILABLE_ATTRIBUTE
+
+// Verify check flags a macro that expands to the unavailable attribute.
+- (void)methodC UNAVAILABLE; // methodC
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: methods marked unavailable should either override a superclass method or explain why they are unavailable; consider adding a message to the unavailable attribute, or simply deleting 'methodC'. [objc-method-unavailable-not-override]
+
+@end
+
+
+@implementation MyObject
+
+- (void)notOverridingMethod {}
+
+// Should not flag implementations for methods declared unavailable; sometimes
+// implemementations are provided that assert, to catch such codepaths that
+// lead to those calls during development.
+- (void)methodA {}
+
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - objc-method-unavailable-not-override
+
+objc-method-unavailable-not-override
+
+
+Checks that a method marked with ``__attribute__((unavailable))`` is overriding
+a method declaration from a superclass, or has a message explaining why it's
+unavailable.
+
+.. code-block:: objc
+
+   @interface ClassA : NSObject
+   // Neither ClassA nor any superclasses define method -foo.
+   @end
+
+   @interface ClassB : ClassA
+   - (void)foo __attribute__((unavailable));
+   @end
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
@@ -236,6 +236,7 @@
`objc-avoid-nserror-init `_,
`objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
+   `objc-method-unavailable-not-override `_, "Yes"
`objc-missing-hash `_,
`objc-property-declaration `_, "Yes"
`objc-super-self `_, "Yes"
@@ -283,7 +284,7 @@
`readability-redundant-member-init `_, "Yes"
`readability-redundant-preprocessor `_,
`readability-redundant-smartptr-get `_, "Yes"
-   `readability-redundant-string-cstr `_,
+   `readability-redundant-string-cstr `_, "Yes"
`readability-redundant-string-init `_, "Yes"

[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-11 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!




Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp:66-67
+const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  SmallString<128> CompilerIncudeDir =
+  StringRef(PP->getHeaderSearchInfo().getHeaderSearchOpts().ResourceDir);
+  llvm::sys::path::append(CompilerIncudeDir, "include");

PaulkaToast wrote:
> aaron.ballman wrote:
> > The user can control this path -- is that an issue? You're using it to 
> > determine what a compiler-provided header file is, and this seems like an 
> > escape hatch for users to get around that. If that's reasonable to you, 
> > then I'm okay with it, but you had mentioned you want to remove human error 
> > as a factor and this seems like it could be a subtle human error situation.
> Ah, thanks for pointing this out! I didn't consider this. I feel like 
> scenario is a more unlikely then situations I mentioned. Probably not 
> something to be too concerned about unless you know of a way to get the 
> default resource path?
I also don't think it's particularly likely people will want to use this just 
to silence diagnostics, so I think it's fine as-is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332



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


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-03-11 Thread Manman Ren via Phabricator via cfe-commits
manmanren added a comment.

There are a few concerns about the approach:
1> Compile time: dumping AST as string then hashing the string. Alex measured 
it on a synthetic benchmark, it shows insignificant impact.
2> Stability: from my understanding, the main goal of this patch is to increase 
stability of the symbol name so it will not change if the relevant code for the 
block is not changing. It may not be as stable when the compiler version 
changes.
Using per-function ID improves the stability compared to per-module ID. 
@alexbdv do you have rough ideas on how much better the proposed approach is in 
terms of stability, comparing to per-function ID?
3> Using a compiler flag may slow down the adoption.

@dexonsmith: How can we move this forward? Do you have any other suggestion?

Thanks!
Manman




Comment at: clang/lib/AST/Mangle.cpp:52
+
+  // Dump the statement IR to a text stream for hasing
+  stmt->dump(strStmtStream);

Should it be AST instead of IR in the comment here?



Comment at: clang/lib/AST/Mangle.cpp:56
+
+  // Strip out addresses
+  char *ptr = [1];

Is this needed to have deterministic behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74813



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


[clang] 0197eac - Temporarily re-apply https://reviews.llvm.org/D74347

2020-03-11 Thread Sergej Jaskiewicz via cfe-commits

Author: Sergej Jaskiewicz
Date: 2020-03-11T21:35:14+03:00
New Revision: 0197eac3330c04a49519f3e4dac38c4de605c654

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

LOG: Temporarily re-apply https://reviews.llvm.org/D74347

It was reverted in 35367e06b84618e21945674aa22e7cfda1957ea4
because it broke the buildbot due to missing libc++abi headers.

https://reviews.llvm.org/D75991 improves the diagnostics, so I hope
the build log will be more informative.

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 50957b153328..7a6af734f0de 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -83,6 +83,9 @@ set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${CMAKE_SOURCE_DIR}/../libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${CMAKE_C_COMPILER_TARGET}/c++" CACHE PATH "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")



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


RE: [PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-03-11 Thread Blower, Melanie I via cfe-commits
Sorry I don't understand. I have to add "final" onto BinaryOperator in order to 
use Trailing storage. But when I do that I can't derive 
CompoundAssignmentOperator from BinaryOperator.  So I think I must fold these 2 
classes together. Is there another way?

> -Original Message-
> From: John McCall via Phabricator 
> Sent: Wednesday, March 11, 2020 2:19 PM
> To: Blower, Melanie I ; Kaylor, Andrew
> ; kevin.n...@sas.com; rjmcc...@gmail.com;
> sepavl...@gmail.com; ane...@apple.com; matthew.arsena...@amd.com;
> syaghm...@apple.com
> Cc: rekanikol...@gmail.com; wei.di...@amd.com; wuz...@cn.ibm.com;
> lebedev...@gmail.com; nemanja.i@gmail.com;
> jv...@scarletmail.rutgers.edu; kit.bar...@gmail.com; Wang, Pengfei
> ; cfe-commits@lists.llvm.org; llvm-
> comm...@lists.llvm.org; mlek...@skidmore.edu; blitzrak...@gmail.com;
> shen...@google.com; t.p.northo...@gmail.com; paul.robin...@sony.com;
> david.gr...@arm.com; t...@google.com; 1.in...@gmail.com
> Subject: [PATCH] D72841: [RFC] Add support for pragma float_control, to
> control precision and exception behavior at the source level
> 
> rjmccall added a comment.
> 
> In D72841#1917340 , @mibintc
> wrote:
> 
> > @rjmccall Since CompoundAssignmentOperator derives from
> BinaryOperator, it's not simple to add Trailing storage here.  I think I will 
> have to
> fold CompoundAssignmentOperator into BinaryOperator and then add the 2
> extra fields needed by CompoundAssignmentOperator into Trailing storage.  Can
> you think of a better way?  I worked on Trailing storage for UnaryOperator 
> first
> and that wasn't too bad, but Binary is a different story.
> 
> 
> It's something we deal with occasionally, but it's definitely annoying.  You
> basically have to test for which concrete class you have and then ask that 
> class
> for its trailing storage.
> 
> Collapsing the types might be okay but could get involved.
> 
> 
> Repository:
>   rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D72841/new/
> 
> https://reviews.llvm.org/D72841
> 
> 

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


[PATCH] D76015: [clang-tidy] Mock system headers for portability-restrict-system-includes tests.

2020-03-11 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/D76015/new/

https://reviews.llvm.org/D76015



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


  1   2   3   >