r332448 - [diagtool] Add diagtool to install target.

2018-05-16 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed May 16 03:23:25 2018
New Revision: 332448

URL: http://llvm.org/viewvc/llvm-project?rev=332448&view=rev
Log:
[diagtool] Add diagtool to install target.

Although not very well known, diagtool is an incredibly convenient
utility for dealing with diagnostics.
Particularly useful are the "tree" and "show-enabled" commands:

 - The former prints the hierarchy of diagnostic (warning) flags and
   which of them are enabled by default.
 - The latter can be used to replace an invocation to clang and will
   print which diagnostics are disabled, warnings or errors.
   For instance: `diagtool show-enabled -Wall -Werror /tmp/test.c` will
   print that -Wunused-variable (warn_unused_variable) will be treated as
   an error.

This patch adds them to the install target so it gets shipped with the
LLVM release. It also adds a very basic man page and mentions this
change in the release notes.

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

Added:
cfe/trunk/docs/CommandGuide/diagtool.rst
Modified:
cfe/trunk/docs/CommandGuide/index.rst
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/tools/diagtool/CMakeLists.txt

Added: cfe/trunk/docs/CommandGuide/diagtool.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/diagtool.rst?rev=332448&view=auto
==
--- cfe/trunk/docs/CommandGuide/diagtool.rst (added)
+++ cfe/trunk/docs/CommandGuide/diagtool.rst Wed May 16 03:23:25 2018
@@ -0,0 +1,52 @@
+diagtool - clang diagnostics tool
+=
+
+SYNOPSIS
+
+
+:program:`diagtool` *command* [*args*]
+
+DESCRIPTION
+---
+
+:program:`diagtool` is a combination of four tool for dealing with diagnostics 
in :program:`clang`.
+
+SUBCOMMANDS
+---
+
+:program:`diagtool` is separated into several subcommands each tailored to a
+different purpose. A brief summary of each command follows, with more detail in
+the sections that follow.
+
+  * :ref:`find_diagnostic_id` - Print the id of the given diagnostic.
+  * :ref:`list_warnings` - List warnings and their corresponding flags.
+  * :ref:`show_enabled` - Show which warnings are enabled for a given command 
line.
+  * :ref:`tree` - Show warning flags in a tree view.
+
+.. _find_diagnostic_id:
+
+find-diagnostic-id
+~~
+
+:program:`diagtool` find-diagnostic-id *diagnostic-name*
+
+.. _list_warnings:
+
+list-warnings
+~
+
+:program:`diagtool` list-warnings
+
+.. _show_enabled:
+
+show-enabled
+
+
+:program:`diagtool` show-enabled [*options*] *filename ...*
+
+.. _tree:
+
+tree
+
+
+:program:`diagtool` tree [*diagnostic-group*]

Modified: cfe/trunk/docs/CommandGuide/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/index.rst?rev=332448&r1=332447&r2=332448&view=diff
==
--- cfe/trunk/docs/CommandGuide/index.rst (original)
+++ cfe/trunk/docs/CommandGuide/index.rst Wed May 16 03:23:25 2018
@@ -15,3 +15,4 @@ Basic Commands
:maxdepth: 1
 
clang
+   diagtool

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=332448&r1=332447&r2=332448&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed May 16 03:23:25 2018
@@ -93,6 +93,11 @@ Non-comprehensive list of changes in thi
   behavior can be restored by setting ``-fclang-abi-compat`` to ``6`` or
   lower.
 
+- An existing tool named ``diagtool`` has been added to the release. As the
+  name suggests, it helps with dealing with diagnostics in ``clang``, such as
+  finding out the warning hierarchy, and which of them are enabled by default
+  or for a particular compiler invocation.
+
 - ...
 
 New Compiler Flags

Modified: cfe/trunk/tools/diagtool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/CMakeLists.txt?rev=332448&r1=332447&r2=332448&view=diff
==
--- cfe/trunk/tools/diagtool/CMakeLists.txt (original)
+++ cfe/trunk/tools/diagtool/CMakeLists.txt Wed May 16 03:23:25 2018
@@ -17,3 +17,15 @@ target_link_libraries(diagtool
   clangBasic
   clangFrontend
   )
+
+if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+  install(TARGETS diagtool
+COMPONENT diagtool
+RUNTIME DESTINATION bin)
+
+  if (NOT CMAKE_CONFIGURATION_TYPES)
+add_llvm_install_targets(install-diagtool
+  DEPENDS diagtool
+  COMPONENT diagtool)
+  endif()
+endif()


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


r337717 - [DebugInfo] Error out when enabling -fdebug-types-section on non-ELF target.

2018-07-23 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Jul 23 10:50:15 2018
New Revision: 337717

URL: http://llvm.org/viewvc/llvm-project?rev=337717&view=rev
Log:
[DebugInfo] Error out when enabling -fdebug-types-section on non-ELF target.

Currently, support for debug_types is only present for ELF and trying to
pass -fdebug-types-section for other targets results in a crash in the
backend. Until this is fixed, we should emit a diagnostic in the front
end when the option is passed for non-linux targets.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=337717&r1=337716&r2=337717&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Jul 23 10:50:15 2018
@@ -3028,6 +3028,11 @@ static void RenderDebugOptions(const Too
 
   if (Args.hasFlag(options::OPT_fdebug_types_section,
options::OPT_fno_debug_types_section, false)) {
+if (!T.isOSBinFormatELF())
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << Args.getLastArg(options::OPT_fdebug_types_section)
+ ->getAsString(Args)
+  << T.getTriple();
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-generate-type-units");
   }

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=337717&r1=337716&r2=337717&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Mon Jul 23 10:50:15 2018
@@ -139,12 +139,18 @@
 //
 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s
 //
-// RUN: %clang -### -fdebug-types-section %s 2>&1 \
+// RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 
\
 // RUN:| FileCheck -check-prefix=FDTS %s
 //
-// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \
+// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target 
x86_64-unknown-linux %s 2>&1 \
 // RUN:| FileCheck -check-prefix=NOFDTS %s
 //
+// RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \
+// RUN:| FileCheck -check-prefix=FDTSE %s
+//
+// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target 
x86_64-apple-darwin %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NOFDTSE %s
+//
 // RUN: %clang -### -g -gno-column-info %s 2>&1 \
 // RUN:| FileCheck -check-prefix=NOCI %s
 //
@@ -229,8 +235,10 @@
 // GARANGE: -generate-arange-section
 //
 // FDTS: "-mllvm" "-generate-type-units"
+// FDTSE: error: unsupported option '-fdebug-types-section' for target 
'x86_64-apple-darwin'
 //
 // NOFDTS-NOT: "-mllvm" "-generate-type-units"
+// NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 
'x86_64-apple-darwin'
 //
 // CI: "-dwarf-column-info"
 //


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


r326081 - [Support] Replace HashString with djbHash.

2018-02-26 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Feb 26 03:30:13 2018
New Revision: 326081

URL: http://llvm.org/viewvc/llvm-project?rev=326081&view=rev
Log:
[Support] Replace HashString with djbHash.

This removes the HashString function from StringExtraces and replaces
its uses with calls to djbHash from DJB.h

This is *almost* NFC. While the algorithm is identical, the djbHash
implementation in StringExtras used 0 as its seed while the
implementation in DJB uses 5381. The latter has been shown to result in
less collisions and improved avalanching.

https://reviews.llvm.org/D43615
(cherry picked from commit 77f7f965bc9499a9ae768a296ca5a1f7347d1d2c)

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CacheTokens.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=326081&r1=326080&r2=326081&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Feb 26 03:30:13 2018
@@ -35,9 +35,9 @@
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/CrashRecoveryContext.h"
+#include "llvm/Support/DJB.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Mutex.h"
@@ -185,7 +185,7 @@ static std::atomic ActiveASTUn
 ASTUnit::ASTUnit(bool _MainFileIsAST)
   : Reader(nullptr), HadModuleLoaderFatalFailure(false),
 OnlyLocalDecls(false), CaptureDiagnostics(false),
-MainFileIsAST(_MainFileIsAST), 
+MainFileIsAST(_MainFileIsAST),
 TUKind(TU_Complete), WantTiming(getenv("LIBCLANG_TIMING")),
 OwnsRemappedFileBuffers(true),
 NumStoredDiagnosticsFromDriver(0),
@@ -196,7 +196,7 @@ ASTUnit::ASTUnit(bool _MainFileIsAST)
 CompletionCacheTopLevelHashValue(0),
 PreambleTopLevelHashValue(0),
 CurrentTopLevelHashValue(0),
-UnsafeToFree(false) { 
+UnsafeToFree(false) {
   if (getenv("LIBCLANG_OBJTRACKING"))
 fprintf(stderr, "+++ %u translation units\n", ++ActiveASTUnitObjects);
 }
@@ -219,8 +219,8 @@ ASTUnit::~ASTUnit() {
   delete RB.second;
   }
 
-  ClearCachedCompletionResults();  
-  
+  ClearCachedCompletionResults();
+
   if (getenv("LIBCLANG_OBJTRACKING"))
 fprintf(stderr, "--- %u translation units\n", --ActiveASTUnitObjects);
 }
@@ -229,20 +229,20 @@ void ASTUnit::setPreprocessor(std::share
   this->PP = std::move(PP);
 }
 
-/// \brief Determine the set of code-completion contexts in which this 
+/// \brief Determine the set of code-completion contexts in which this
 /// declaration should be shown.
 static unsigned getDeclShowContexts(const NamedDecl *ND,
 const LangOptions &LangOpts,
 bool &IsNestedNameSpecifier) {
   IsNestedNameSpecifier = false;
-  
+
   if (isa(ND))
 ND = dyn_cast(ND->getUnderlyingDecl());
   if (!ND)
 return 0;
-  
+
   uint64_t Contexts = 0;
-  if (isa(ND) || isa(ND) || 
+  if (isa(ND) || isa(ND) ||
   isa(ND) || isa(ND) ||
   isa(ND)) {
 // Types can appear in these contexts.
@@ -257,12 +257,12 @@ static unsigned getDeclShowContexts(cons
 // In C++, types can appear in expressions contexts (for functional casts).
 if (LangOpts.CPlusPlus)
   Contexts |= (1LL << CodeCompletionContext::CCC_Expression);
-
+
 // In Objective-C, message sends can send interfaces. In Objective-C++,
 // all types are available due to functional casts.
 if (LangOpts.CPlusPlus || isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_ObjCMessageReceiver);
-
+
 // In Objective-C, you can only be a subclass of another Objective-C class
 if (const auto *ID = dyn_cast(ND)) {
   // Objective-C interfaces can be used in a class property expression.
@@ -274,7 +274,7 @@ static unsigned getDeclShowContexts(cons
 // Deal with tag names.
 if (isa(ND)) {
   Contexts |= (1LL << CodeCompletionContext::CCC_EnumTag);
-  
+
   // Part of the nested-name-specifier in C++0x.
   if (LangOpts.CPlusPlus11)
 IsNestedNameSpecifier = true;
@@ -283,7 +283,7 @@ static unsigned getDeclShowContexts(cons
 Contexts |= (1LL << CodeCompletionContext::CCC_UnionTag);
   else
 Contexts |= (1LL << CodeCompletionContext::CCC_ClassOrStructTag);
-  
+
   if (LangOpts.CPlusPlus)
 IsNestedNameSpecifier = true;
 } else if (isa(ND))
@@ -300,24 +300,24 @@ static unsigned getDeclShowContexts(cons
 Contexts = (1LL << CodeCompletionContext::CCC_ObjCCategoryName);
   } else if (i

r326082 - Revert "[Support] Replace HashString with djbHash."

2018-02-26 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Feb 26 04:05:18 2018
New Revision: 326082

URL: http://llvm.org/viewvc/llvm-project?rev=326082&view=rev
Log:
Revert "[Support] Replace HashString with djbHash."

It looks like some of our tests depend on the ordering of hashed values.
I'm reverting my changes while I try to reproduce and fix this locally.

Failing builds:

  lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/18388
  lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/6743
  
lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/15607

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CacheTokens.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=326082&r1=326081&r2=326082&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Feb 26 04:05:18 2018
@@ -35,9 +35,9 @@
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/CrashRecoveryContext.h"
-#include "llvm/Support/DJB.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Mutex.h"
@@ -185,7 +185,7 @@ static std::atomic ActiveASTUn
 ASTUnit::ASTUnit(bool _MainFileIsAST)
   : Reader(nullptr), HadModuleLoaderFatalFailure(false),
 OnlyLocalDecls(false), CaptureDiagnostics(false),
-MainFileIsAST(_MainFileIsAST),
+MainFileIsAST(_MainFileIsAST), 
 TUKind(TU_Complete), WantTiming(getenv("LIBCLANG_TIMING")),
 OwnsRemappedFileBuffers(true),
 NumStoredDiagnosticsFromDriver(0),
@@ -196,7 +196,7 @@ ASTUnit::ASTUnit(bool _MainFileIsAST)
 CompletionCacheTopLevelHashValue(0),
 PreambleTopLevelHashValue(0),
 CurrentTopLevelHashValue(0),
-UnsafeToFree(false) {
+UnsafeToFree(false) { 
   if (getenv("LIBCLANG_OBJTRACKING"))
 fprintf(stderr, "+++ %u translation units\n", ++ActiveASTUnitObjects);
 }
@@ -219,8 +219,8 @@ ASTUnit::~ASTUnit() {
   delete RB.second;
   }
 
-  ClearCachedCompletionResults();
-
+  ClearCachedCompletionResults();  
+  
   if (getenv("LIBCLANG_OBJTRACKING"))
 fprintf(stderr, "--- %u translation units\n", --ActiveASTUnitObjects);
 }
@@ -229,20 +229,20 @@ void ASTUnit::setPreprocessor(std::share
   this->PP = std::move(PP);
 }
 
-/// \brief Determine the set of code-completion contexts in which this
+/// \brief Determine the set of code-completion contexts in which this 
 /// declaration should be shown.
 static unsigned getDeclShowContexts(const NamedDecl *ND,
 const LangOptions &LangOpts,
 bool &IsNestedNameSpecifier) {
   IsNestedNameSpecifier = false;
-
+  
   if (isa(ND))
 ND = dyn_cast(ND->getUnderlyingDecl());
   if (!ND)
 return 0;
-
+  
   uint64_t Contexts = 0;
-  if (isa(ND) || isa(ND) ||
+  if (isa(ND) || isa(ND) || 
   isa(ND) || isa(ND) ||
   isa(ND)) {
 // Types can appear in these contexts.
@@ -257,12 +257,12 @@ static unsigned getDeclShowContexts(cons
 // In C++, types can appear in expressions contexts (for functional casts).
 if (LangOpts.CPlusPlus)
   Contexts |= (1LL << CodeCompletionContext::CCC_Expression);
-
+
 // In Objective-C, message sends can send interfaces. In Objective-C++,
 // all types are available due to functional casts.
 if (LangOpts.CPlusPlus || isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_ObjCMessageReceiver);
-
+
 // In Objective-C, you can only be a subclass of another Objective-C class
 if (const auto *ID = dyn_cast(ND)) {
   // Objective-C interfaces can be used in a class property expression.
@@ -274,7 +274,7 @@ static unsigned getDeclShowContexts(cons
 // Deal with tag names.
 if (isa(ND)) {
   Contexts |= (1LL << CodeCompletionContext::CCC_EnumTag);
-
+  
   // Part of the nested-name-specifier in C++0x.
   if (LangOpts.CPlusPlus11)
 IsNestedNameSpecifier = true;
@@ -283,7 +283,7 @@ static unsigned getDeclShowContexts(cons
 Contexts |= (1LL << CodeCompletionContext::CCC_UnionTag);
   else
 Contexts |= (1LL << CodeCompletionContext::CCC_ClassOrStructTag);
-
+  
   if (LangOpts.CPlusPlus)
 IsNestedNameSpecifier = true;
 } else if (isa(ND))
@@ -300,24 +300,24 @@ static unsigned getDeclShowContexts(cons
 Contexts = (1LL << CodeCompletionContext::CCC_ObjCCategoryName);
   } else if (isa(ND) || isa(ND)) {
 Contexts = (1LL << CodeCompl

r326091 - Re-land: "[Support] Replace HashString with djbHash."

2018-02-26 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Feb 26 07:16:42 2018
New Revision: 326091

URL: http://llvm.org/viewvc/llvm-project?rev=326091&view=rev
Log:
Re-land: "[Support] Replace HashString with djbHash."

This patch removes the HashString function from StringExtraces and
replaces its uses with calls to djbHash from DJB.h.

This change is *almost* NFC. While the algorithm is identical, the
djbHash implementation in StringExtras used 0 as its default seed while
the implementation in DJB uses 5381. The latter has been shown to result
in less collisions and improved avalanching and is used by the DWARF
accelerator tables.

Because some test were implicitly relying on the hash order, I've
reverted to using zero as a seed for the following two files:

  lld/include/lld/Core/SymbolTable.h
  llvm/lib/Support/StringMap.cpp

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

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CacheTokens.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=326091&r1=326090&r2=326091&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Feb 26 07:16:42 2018
@@ -35,9 +35,9 @@
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/CrashRecoveryContext.h"
+#include "llvm/Support/DJB.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Mutex.h"
@@ -185,7 +185,7 @@ static std::atomic ActiveASTUn
 ASTUnit::ASTUnit(bool _MainFileIsAST)
   : Reader(nullptr), HadModuleLoaderFatalFailure(false),
 OnlyLocalDecls(false), CaptureDiagnostics(false),
-MainFileIsAST(_MainFileIsAST), 
+MainFileIsAST(_MainFileIsAST),
 TUKind(TU_Complete), WantTiming(getenv("LIBCLANG_TIMING")),
 OwnsRemappedFileBuffers(true),
 NumStoredDiagnosticsFromDriver(0),
@@ -196,7 +196,7 @@ ASTUnit::ASTUnit(bool _MainFileIsAST)
 CompletionCacheTopLevelHashValue(0),
 PreambleTopLevelHashValue(0),
 CurrentTopLevelHashValue(0),
-UnsafeToFree(false) { 
+UnsafeToFree(false) {
   if (getenv("LIBCLANG_OBJTRACKING"))
 fprintf(stderr, "+++ %u translation units\n", ++ActiveASTUnitObjects);
 }
@@ -219,8 +219,8 @@ ASTUnit::~ASTUnit() {
   delete RB.second;
   }
 
-  ClearCachedCompletionResults();  
-  
+  ClearCachedCompletionResults();
+
   if (getenv("LIBCLANG_OBJTRACKING"))
 fprintf(stderr, "--- %u translation units\n", --ActiveASTUnitObjects);
 }
@@ -229,20 +229,20 @@ void ASTUnit::setPreprocessor(std::share
   this->PP = std::move(PP);
 }
 
-/// \brief Determine the set of code-completion contexts in which this 
+/// \brief Determine the set of code-completion contexts in which this
 /// declaration should be shown.
 static unsigned getDeclShowContexts(const NamedDecl *ND,
 const LangOptions &LangOpts,
 bool &IsNestedNameSpecifier) {
   IsNestedNameSpecifier = false;
-  
+
   if (isa(ND))
 ND = dyn_cast(ND->getUnderlyingDecl());
   if (!ND)
 return 0;
-  
+
   uint64_t Contexts = 0;
-  if (isa(ND) || isa(ND) || 
+  if (isa(ND) || isa(ND) ||
   isa(ND) || isa(ND) ||
   isa(ND)) {
 // Types can appear in these contexts.
@@ -257,12 +257,12 @@ static unsigned getDeclShowContexts(cons
 // In C++, types can appear in expressions contexts (for functional casts).
 if (LangOpts.CPlusPlus)
   Contexts |= (1LL << CodeCompletionContext::CCC_Expression);
-
+
 // In Objective-C, message sends can send interfaces. In Objective-C++,
 // all types are available due to functional casts.
 if (LangOpts.CPlusPlus || isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_ObjCMessageReceiver);
-
+
 // In Objective-C, you can only be a subclass of another Objective-C class
 if (const auto *ID = dyn_cast(ND)) {
   // Objective-C interfaces can be used in a class property expression.
@@ -274,7 +274,7 @@ static unsigned getDeclShowContexts(cons
 // Deal with tag names.
 if (isa(ND)) {
   Contexts |= (1LL << CodeCompletionContext::CCC_EnumTag);
-  
+
   // Part of the nested-name-specifier in C++0x.
   if (LangOpts.CPlusPlus11)
 IsNestedNameSpecifier = true;
@@ -283,7 +283,7 @@ static unsigned getDeclShowContexts(cons
 Contexts |= (1LL << CodeCompletionContext::CCC_UnionTag);
   else
 Contexts |= (1LL << CodeCompletionContext::CCC_ClassOrStructTag);
-  
+
   if (L

r321090 - [clang] -foptimization-record-file= should imply -fsave-optimization-record

2017-12-19 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Dec 19 09:16:45 2017
New Revision: 321090

URL: http://llvm.org/viewvc/llvm-project?rev=321090&view=rev
Log:
[clang] -foptimization-record-file= should imply -fsave-optimization-record

The Clang option -foptimization-record-file= controls which file an
optimization record is output to. Optimization records are output if you
use the Clang option -fsave-optimization-record. If you specify the
first option without the second, you get a warning that the command line
argument was unused. Passing -foptimization-record-file= should imply
-fsave-optimization-record.

This fixes PR33670

Patch by: Dmitry Venikov 

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=321090&r1=321089&r2=321090&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Dec 19 09:16:45 2017
@@ -4389,6 +4389,7 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-fapple-pragma-pack");
 
   if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_foptimization_record_file_EQ,
options::OPT_fno_save_optimization_record, false)) {
 CmdArgs.push_back("-opt-record-file");
 

Modified: cfe/trunk/test/Driver/opt-record.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opt-record.c?rev=321090&r1=321089&r2=321090&view=diff
==
--- cfe/trunk/test/Driver/opt-record.c (original)
+++ cfe/trunk/test/Driver/opt-record.c Tue Dec 19 09:16:45 2017
@@ -9,6 +9,8 @@
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc 
-nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O 
-check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib 
%s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -S -o FOO -fsave-optimization-record 
-foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt 
-fno-save-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-FOPT-DISABLE
 
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
@@ -20,3 +22,4 @@
 // CHECK-EQ: "-cc1"
 // CHECK-EQ: "-opt-record-file" "BAR.txt"
 
+// CHECK-FOPT-DISABLE-NOT: "-fno-save-optimization-record"


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


r327790 - [dsymutil] Rename llvm-dsymutil -> dsymutil

2018-03-18 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Sun Mar 18 04:38:41 2018
New Revision: 327790

URL: http://llvm.org/viewvc/llvm-project?rev=327790&view=rev
Log:
[dsymutil] Rename llvm-dsymutil -> dsymutil

Now that almost all functionality of Apple's dsymutil has been
upstreamed, the open source variant can be used as a drop in
replacement. Hence we feel it's no longer necessary to have the llvm
prefix.

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

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake
cfe/trunk/cmake/caches/BaremetalARM.cmake
cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=327790&r1=327789&r2=327790&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Sun Mar 18 04:38:41 2018
@@ -47,7 +47,7 @@ set(LLVM_CREATE_XCODE_TOOLCHAIN ON CACHE
 # setup toolchain
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
-  llvm-dsymutil
+  dsymutil
   llvm-cov
   llvm-dwarfdump
   llvm-profdata

Modified: cfe/trunk/cmake/caches/BaremetalARM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/BaremetalARM.cmake?rev=327790&r1=327789&r2=327790&view=diff
==
--- cfe/trunk/cmake/caches/BaremetalARM.cmake (original)
+++ cfe/trunk/cmake/caches/BaremetalARM.cmake Sun Mar 18 04:38:41 2018
@@ -24,11 +24,11 @@ set(BUILTINS_armv7em-none-eabi_COMPILER_
 
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
+  dsymutil
   llc
   llvm-ar
   llvm-cxxfilt
   llvm-dwarfdump
-  llvm-dsymutil
   llvm-nm
   llvm-objdump
   llvm-ranlib

Modified: cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/DistributionExample-stage2.cmake?rev=327790&r1=327789&r2=327790&view=diff
==
--- cfe/trunk/cmake/caches/DistributionExample-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/DistributionExample-stage2.cmake Sun Mar 18 04:38:41 
2018
@@ -10,7 +10,7 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3
 # setup toolchain
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
-  llvm-dsymutil
+  dsymutil
   llvm-cov
   llvm-dwarfdump
   llvm-profdata

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=327790&r1=327789&r2=327790&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Sun Mar 18 04:38:41 2018
@@ -57,12 +57,12 @@ endforeach()
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
+  dsymutil
   llc
   llvm-ar
   llvm-cov
   llvm-cxxfilt
   llvm-dwarfdump
-  llvm-dsymutil
   llvm-lib
   llvm-nm
   llvm-objcopy


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


[clang-tools-extra] r333673 - PrintEscapedString -> printEscapedString

2018-05-31 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Thu May 31 10:36:31 2018
New Revision: 333673

URL: http://llvm.org/viewvc/llvm-project?rev=333673&view=rev
Log:
PrintEscapedString -> printEscapedString

Update PrintEscapedString after renaming it in ADT.

Modified:
clang-tools-extra/trunk/clangd/Protocol.cpp

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=333673&r1=333672&r2=333673&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu May 31 10:36:31 2018
@@ -137,7 +137,7 @@ json::Expr toJSON(const TextEdit &P) {
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TextEdit &TE) {
   OS << TE.range << " => \"";
-  PrintEscapedString(TE.newText, OS);
+  printEscapedString(TE.newText, OS);
   return OS << '"';
 }
 


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


[clang-tools-extra] r344140 - Lift VFS from clang to llvm (NFC)

2018-10-10 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Oct 10 06:27:25 2018
New Revision: 344140

URL: http://llvm.org/viewvc/llvm-project?rev=344140&view=rev
Log:
Lift VFS from clang to llvm (NFC)

This patch moves the virtual file system form clang to llvm so it can be
used by more projects.

Concretely the patch:
 - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support.
 - Moves the corresponding unit test from clang to llvm.
 - Moves the vfs namespace from clang::vfs to llvm::vfs.
 - Formats the lines affected by this change, mostly this is the result of
   the added llvm namespace.

RFC on the mailing list:
http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/Compiler.cpp
clang-tools-extra/trunk/clangd/Compiler.h
clang-tools-extra/trunk/clangd/FS.cpp
clang-tools-extra/trunk/clangd/FS.h
clang-tools-extra/trunk/clangd/FSProvider.h
clang-tools-extra/trunk/clangd/Headers.h
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
clang-tools-extra/trunk/unittests/clangd/FSTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
clang-tools-extra/trunk/unittests/clangd/TestFS.h
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=344140&r1=344139&r2=344140&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Oct 10 06:27:25 2018
@@ -96,7 +96,7 @@ private:
 class ErrorReporter {
 public:
   ErrorReporter(ClangTidyContext &Context, bool ApplyFixes,
-llvm::IntrusiveRefCntPtr BaseFS)
+llvm::IntrusiveRefCntPtr BaseFS)
   : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
@@ -503,7 +503,7 @@ getCheckOptions(const ClangTidyOptions &
 void runClangTidy(clang::tidy::ClangTidyContext &Context,
   const CompilationDatabase &Compilations,
   ArrayRef InputFiles,
-  llvm::IntrusiveRefCntPtr BaseFS,
+  llvm::IntrusiveRefCntPtr BaseFS,
   bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
   ClangTool Tool(Compilations, InputFiles,
  std::make_shared(), BaseFS);
@@ -590,9 +590,9 @@ void runClangTidy(clang::tidy::ClangTidy
 
 void handleErrors(ClangTidyContext &Context, bool Fix,
   unsigned &WarningsAsErrorsCount,
-  llvm::IntrusiveRefCntPtr BaseFS) {
+  llvm::IntrusiveRefCntPtr BaseFS) {
   ErrorReporter Reporter(Context, Fix, BaseFS);
-  vfs::FileSystem &FileSystem =
+  llvm::vfs::FileSystem &FileSystem =
   *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
   auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
   if (!InitialWorkingDir)

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=344140&r1=344139&r2=344140&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Wed Oct 10 06:27:25 2018
@@ -233,7 +233,7 @@ getCheckOptions(const ClangTidyOptions &
 void runClangTidy(clang::tidy::ClangTidyContext &Context,
   const tooling::CompilationDatabase &Compilations,
   ArrayRef InputFiles,
-  llvm::IntrusiveRefCntPtr BaseFS,
+  llvm::IntrusiveRefCntPtr BaseFS,
   bool EnableCheckProfile = false,
   llvm::StringRef StoreCheckProfile = StringRef());
 
@@ -245,7 +245,7 @@ void runClangTidy(clang::tidy::ClangTidy
 /// clang-format configuration file is found, the given \P FormatStyle is used.
 void handleErrors(ClangTidyContext &Context, bool Fix,
   unsigned &War

r352605 - [ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC)

2019-01-29 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Jan 29 22:26:26 2019
New Revision: 352605

URL: http://llvm.org/viewvc/llvm-project?rev=352605&view=rev
Log:
[ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC)

Use the real_path implementation from llvm::sys::fs::real_path instead
of having a custom implementation in the ModuleDependencyCollector.

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

Modified:
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=352605&r1=352604&r2=352605&view=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Tue Jan 29 22:26:26 
2019
@@ -98,24 +98,6 @@ struct ModuleDependencyMMCallbacks : pub
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl &RealPath) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -130,7 +112,7 @@ void ModuleDependencyCollector::attachTo
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -140,7 +122,7 @@ static bool isCaseSensitivePath(StringRe
   // already expects when sensitivity isn't setup.
   for (auto &C : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -186,7 +168,7 @@ bool ModuleDependencyCollector::getRealP
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if (llvm::sys::fs::real_path(Dir, RealPath))
   return false;
 SymLinkMap[Dir] = RealPath.str();
   } else {


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


r346601 - Pass the function type instead of the return type to FunctionDecl::Create

2018-11-10 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Sat Nov 10 16:56:15 2018
New Revision: 346601

URL: http://llvm.org/viewvc/llvm-project?rev=346601&view=rev
Log:
Pass the function type instead of the return type to FunctionDecl::Create

Fix places where the return type of a FunctionDecl was being used in
place of the function type

FunctionDecl::Create() takes as its T parameter the type of function
that should be created, not the return type. Passing in the return type
looks to have been copypasta'd around a bit, but the number of correct
usages outweighs the incorrect ones so I've opted for keeping what T is
the same and fixing up the call sites instead.

This fixes a crash in Clang when attempting to compile the following
snippet of code with -fblocks -fsanitize=function -x objective-c++ (my
original repro case):

  void g(void(^)());
  void f()
  {
  __block int a = 0;
g(^(){ a++; });
  }

as well as the following which only requires -fsanitize=function -x c++:

  void f(char * buf)
  {
  __builtin_os_log_format(buf, "");
  }

Patch by: Ben (bobsayshilol)

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

Added:
cfe/trunk/test/CodeGenObjCXX/crash-function-type.mm
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=346601&r1=346600&r2=346601&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Nov 10 16:56:15 2018
@@ -2652,6 +2652,7 @@ FunctionDecl::FunctionDecl(Kind DK, ASTC
  StartLoc),
   DeclContext(DK), redeclarable_base(C), ODRHash(0),
   EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {
+  assert(T.isNull() || T->isFunctionType());
   setStorageClass(S);
   setInlineSpecified(isInlineSpecified);
   setExplicitSpecified(false);

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=346601&r1=346600&r2=346601&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Sat Nov 10 16:56:15 2018
@@ -2008,16 +2008,16 @@ CodeGenFunction::GenerateCopyHelperFunct
 
   ASTContext &C = getContext();
 
+  QualType ReturnTy = C.VoidTy;
+
   FunctionArgList args;
-  ImplicitParamDecl DstDecl(getContext(), C.VoidPtrTy,
-ImplicitParamDecl::Other);
+  ImplicitParamDecl DstDecl(C, C.VoidPtrTy, ImplicitParamDecl::Other);
   args.push_back(&DstDecl);
-  ImplicitParamDecl SrcDecl(getContext(), C.VoidPtrTy,
-ImplicitParamDecl::Other);
+  ImplicitParamDecl SrcDecl(C, C.VoidPtrTy, ImplicitParamDecl::Other);
   args.push_back(&SrcDecl);
 
   const CGFunctionInfo &FI =
-CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args);
+  CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args);
 
   // FIXME: it would be nice if these were mergeable with things with
   // identical semantics.
@@ -2027,20 +2027,20 @@ CodeGenFunction::GenerateCopyHelperFunct
 llvm::Function::Create(LTy, llvm::GlobalValue::LinkOnceODRLinkage,
FuncName, &CGM.getModule());
 
-  IdentifierInfo *II
-= &CGM.getContext().Idents.get(FuncName);
+  IdentifierInfo *II = &C.Idents.get(FuncName);
 
-  FunctionDecl *FD = FunctionDecl::Create(C,
-  C.getTranslationUnitDecl(),
-  SourceLocation(),
-  SourceLocation(), II, C.VoidTy,
-  nullptr, SC_Static,
-  false,
-  false);
+  SmallVector ArgTys;
+  ArgTys.push_back(C.VoidPtrTy);
+  ArgTys.push_back(C.VoidPtrTy);
+  QualType FunctionTy = C.getFunctionType(ReturnTy, ArgTys, {});
+
+  FunctionDecl *FD = FunctionDecl::Create(
+  C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
+  FunctionTy, nullptr, SC_Static, false, false);
 
   setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI,
  CGM);
-  StartFunction(FD, C.VoidTy, Fn, FI, args);
+  StartFunction(FD, ReturnTy, Fn, FI, args);
   ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getBeginLoc()};
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 
@@ -2201,13 +2201,14 @@ CodeGenFunction::GenerateDestroyHelperFu
 
   ASTContext &C = getContext();
 
+  QualType

r346675 - Revert "Make clang-based tools find libc++ on MacOS"

2018-11-12 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Nov 12 08:59:50 2018
New Revision: 346675

URL: http://llvm.org/viewvc/llvm-project?rev=346675&view=rev
Log:
Revert "Make clang-based tools find libc++ on MacOS"

This breaks the LLDB bots.

Removed:
cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
Modified:
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Nov 12 08:59:50 2018
@@ -108,13 +108,6 @@ public:
   /// etc.).
   std::string ResourceDir;
 
-  /// Compiler install dir as detected by the Driver.
-  /// This is typically the directory that contains the clang executable, i.e.
-  /// the 'bin/' subdir of a clang distribution.
-  /// Only used to add include dirs for libc++ on Darwin. Please avoid relying
-  /// on this field for other purposes.
-  std::string InstallDir;
-
   /// The directory used for the module cache.
   std::string ModuleCachePath;
 

Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Mon Nov 12 
08:59:50 2018
@@ -11,18 +11,17 @@
 //
 
//===--===//
 
+#include "clang/Frontend/Utils.h"
 #include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/Action.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/Utils.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Host.h"
-#include "llvm/Support/Path.h"
 using namespace clang;
 using namespace llvm::opt;
 
@@ -103,8 +102,5 @@ std::unique_ptr clan
  CCArgs.size(),
  *Diags))
 return nullptr;
-  // Patch up the install dir, so we find the same standard library as the
-  // original compiler on MacOS.
-  CI->getHeaderSearchOpts().InstallDir = TheDriver.getInstalledDir();
   return CI;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Nov 12 08:59:50 2018
@@ -476,9 +476,14 @@ void InitHeaderSearch::AddDefaultInclude
   if (triple.isOSDarwin()) {
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-if (!HSOpts.InstallDir.empty()) {
-  // Get from foo/bin to foo.
-  SmallString<128> P(llvm::sys::path::parent_path(HSOpts.InstallDir));
+if (!HSOpts.ResourceDir.empty()) {
+  // Remove version from foo/lib/clang/version
+  StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir);
+  // Remove clang from foo/lib/clang
+  StringRef Lib = llvm::sys::path::parent_path(NoVer);
+  // Remove lib from foo/lib
+  SmallString<128> P = llvm::sys::path::parent_path(Lib);
+
   // Get foo/include/c++/v1
   llvm::sys::path::append(P, "include", "c++", "v1");
   AddUnmappedPath(P, CXXSystem, false);

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=346675&r1=346674&r2=346675&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Mon Nov 12 08:59:50 2018
@@ -327,9 +327,6 @@ bool ToolInvocation::run() {
 Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(),
   Input.release());
   }
-  // Patch up the install dir, so we find the same standard library as the
-  // original compiler on MacOS.
-  In

Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-07 Thread Jonas Devlieghere via cfe-commits
Hi Leonard,

It appears that your patch is still triggering an assertion on GreenDragon:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c

Can you please have a look?

Thanks,
Jonas


On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: leonardchan
> Date: Mon May  6 20:20:17 2019
> New Revision: 360109
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev
> Log:
> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an
> attribute declaration"
>
> Updated with fix for read of uninitialized memory.
>
> Added:
> cfe/trunk/test/Frontend/macro_defined_type.cpp
> cfe/trunk/test/Sema/address_space_print_macro.c
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/AST/TypeLoc.h
> cfe/trunk/include/clang/AST/TypeNodes.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/ParsedAttr.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ASTDiagnostic.cpp
> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/AST/TypePrinter.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Sema/address_spaces.c
> cfe/trunk/test/SemaObjC/externally-retained.m
> cfe/trunk/test/SemaObjC/gc-attributes.m
> cfe/trunk/test/SemaObjC/mrc-weak.m
> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
> cfe/trunk/tools/libclang/CIndex.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109&r1=360108&r2=360109&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  6 20:20:17 2019
> @@ -1441,6 +1441,9 @@ public:
>
>QualType getParenType(QualType NamedType) const;
>
> +  QualType getMacroQualifiedType(QualType UnderlyingTy,
> + const IdentifierInfo *MacroII) const;
> +
>QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
>   NestedNameSpecifier *NNS, QualType NamedType,
>   TagDecl *OwnedTagDecl = nullptr) const;
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=360109&r1=360108&r2=360109&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon May  6 20:20:17
> 2019
> @@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType,
>
>  DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
>
> +DEF_TRAVERSE_TYPE(MacroQualifiedType,
> +  { TRY_TO(TraverseType(T->getUnderlyingType())); })
> +
>  DEF_TRAVERSE_TYPE(ElaboratedType, {
>if (T->getQualifier()) {
>  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
> @@ -1308,6 +1311,9 @@ DEF_TRAVERSE_TYPELOC(InjectedClassNameTy
>
>  DEF_TRAVERSE_TYPELOC(ParenType, {
> TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
>
> +DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
> + { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
> +
>  DEF_TRAVERSE_TYPELOC(AttributedType,
>   { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
>
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=360109&r1=360108&r2=360109&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Mon May  6 20:20:17 2019
> @@ -4184,6 +4184,41 @@ public:
>static bool classof(const Type *T) { return T->getTypeClass() ==
> Typedef; }
>  };
>
> +/// Sugar type that represents a type that was qualified by a qualifier
> written
> +/// as a macro invocation.
> +class MacroQualifiedType : public Type {
> +  friend class ASTContext; // ASTContext creates these.
> +
> +  QualType UnderlyingTy;
> +  const IdentifierInfo *Ma

Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-07 Thread Jonas Devlieghere via cfe-commits
Hi Leonard,

The test that is asserting is part of the debuginfo test. (
https://github.com/llvm-project/debuginfo-tests)
The reason that it's only failing on the non-incremental bot is because the
incremental one isn't running those, I believe.

RA stands for Release/Asserts.

Hope that helps!

Cheers,
Jonas

On Tue, May 7, 2019 at 9:44 AM Leonard Chan  wrote:

> Yup, sorry for the delay. I submitted it overnight thinking it would be
> fixed this time. I have one more way that I think should fix it, but before
> trying it out, do you know any tips on how I can try to reproduce this
> locally? I see that you're running these on an x64 mac, but I can't seem to
> trigger this on our own mac builders. Also as a side question, do you what
> RA stands for in "Clang Stage 1: cmake, incremental RA, using system
> compiler
> "?
> It seems that I'm only breaking the non-incremental RA jobs, bit the
> incremental one still works fine with my change.
>
> Thanks,
> Leonard
>
> On Tue, May 7, 2019, 09:26 Jonas Devlieghere 
> wrote:
>
>> Hi Leonard,
>>
>> It appears that your patch is still triggering an assertion on
>> GreenDragon:
>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c
>>
>> Can you please have a look?
>>
>> Thanks,
>> Jonas
>>
>>
>> On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: leonardchan
>>> Date: Mon May  6 20:20:17 2019
>>> New Revision: 360109
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev
>>> Log:
>>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is
>>> an attribute declaration"
>>>
>>> Updated with fix for read of uninitialized memory.
>>>
>>> Added:
>>> cfe/trunk/test/Frontend/macro_defined_type.cpp
>>> cfe/trunk/test/Sema/address_space_print_macro.c
>>> Modified:
>>> cfe/trunk/include/clang/AST/ASTContext.h
>>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>>> cfe/trunk/include/clang/AST/Type.h
>>> cfe/trunk/include/clang/AST/TypeLoc.h
>>> cfe/trunk/include/clang/AST/TypeNodes.def
>>> cfe/trunk/include/clang/Parse/Parser.h
>>> cfe/trunk/include/clang/Sema/ParsedAttr.h
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
>>> cfe/trunk/lib/AST/ASTContext.cpp
>>> cfe/trunk/lib/AST/ASTDiagnostic.cpp
>>> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
>>> cfe/trunk/lib/AST/ItaniumMangle.cpp
>>> cfe/trunk/lib/AST/Type.cpp
>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaStmt.cpp
>>> cfe/trunk/lib/Sema/SemaType.cpp
>>> cfe/trunk/lib/Sema/TreeTransform.h
>>> cfe/trunk/lib/Serialization/ASTReader.cpp
>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>> cfe/trunk/test/Sema/address_spaces.c
>>> cfe/trunk/test/SemaObjC/externally-retained.m
>>> cfe/trunk/test/SemaObjC/gc-attributes.m
>>> cfe/trunk/test/SemaObjC/mrc-weak.m
>>> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
>>> cfe/trunk/tools/libclang/CIndex.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109&r1=360108&r2=360109&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>>> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  6 20:20:17 2019
>>> @@ -1441,6 +1441,9 @@ public:
>>>
>>>QualType getParenType(QualType NamedType) const;
>>>
>>> +  QualType getMacroQualifiedType(QualType UnderlyingTy,
>>> + const IdentifierInfo *MacroII) const;
>>> +
>>>QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
>>>   NestedNameSpecifier *NNS, QualType
>>> NamedType,
>>>   TagDecl *OwnedTagDecl = nullptr) const;
>>>
>>> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=360109&r1=360108&r2=360109&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
>>> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon May  6
>>> 20:20:17 2019
>>> @@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType,
>>>
>>>  DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType()));
>>> })
>>>
>>> +DEF_TRAVERSE_TYPE(MacroQualifiedType,
>>> +  { TRY_TO(TraverseType(T->getUnderlying

r360192 - Revert "[OpenMP][Clang] Support for target math functions"

2019-05-07 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue May  7 14:08:15 2019
New Revision: 360192

URL: http://llvm.org/viewvc/llvm-project?rev=360192&view=rev
Log:
Revert "[OpenMP][Clang] Support for target math functions"

This commit appears to be breaking stage-2 builds on GreenDragon. The
OpenMP wrappers for cmath and math.h are copied into the root of the
resource directory and cause a cyclic dependency in module 'Darwin':
Darwin -> std -> Darwin. This blows up when CMake is testing for modules
support and breaks all stage 2 module builds, including the ThinLTO bot
and all LLDB bots.

CMake Error at cmake/modules/HandleLLVMOptions.cmake:497 (message):
  LLVM_ENABLE_MODULES is not supported by this compiler

Removed:
cfe/trunk/lib/Headers/openmp_wrappers/
cfe/trunk/test/Headers/Inputs/include/cmath
cfe/trunk/test/Headers/Inputs/include/limits
cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions.c
cfe/trunk/test/Headers/nvptx_device_math_functions.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/__clang_cuda_cmath.h
cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
cfe/trunk/lib/Headers/__clang_cuda_libdevice_declares.h
cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
cfe/trunk/test/Driver/openmp-offload-gpu.c
cfe/trunk/test/Headers/Inputs/include/math.h

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=360192&r1=360191&r2=360192&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue May  7 14:08:15 2019
@@ -1151,21 +1151,6 @@ void Clang::AddPreprocessingOptions(Comp
   if (JA.isOffloading(Action::OFK_Cuda))
 getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 
-  // If we are offloading to a target via OpenMP we need to include the
-  // openmp_wrappers folder which contains alternative system headers.
-  if (JA.isDeviceOffloading(Action::OFK_OpenMP) &&
-  getToolChain().getTriple().isNVPTX()){
-if (!Args.hasArg(options::OPT_nobuiltininc)) {
-  // Add openmp_wrappers/* to our system include path.  This lets us wrap
-  // standard library headers.
-  SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, "include");
-  llvm::sys::path::append(P, "openmp_wrappers");
-  CmdArgs.push_back("-internal-isystem");
-  CmdArgs.push_back(Args.MakeArgString(P));
-}
-  }
-
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=360192&r1=360191&r2=360192&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Tue May  7 14:08:15 2019
@@ -33,9 +33,6 @@ set(files
   avxintrin.h
   bmi2intrin.h
   bmiintrin.h
-  openmp_wrappers/math.h
-  openmp_wrappers/cmath
-  openmp_wrappers/__clang_openmp_math.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_cmath.h
   __clang_cuda_complex_builtins.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=360192&r1=360191&r2=360192&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Tue May  7 14:08:15 2019
@@ -30,11 +30,7 @@
 // implementation.  Declaring in the global namespace and pulling into 
namespace
 // std covers all of the known knowns.
 
-#ifdef _OPENMP
-#define __DEVICE__ static __attribute__((always_inline))
-#else
 #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline))
-#endif
 
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
@@ -51,8 +47,6 @@ __DEVICE__ float exp(float __x) { return
 __DEVICE__ float fabs(float __x) { return ::fabsf(__x); }
 __DEVICE__ float floor(float __x) { return ::floorf(__x); }
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
-// TODO: remove when variant is supported
-#ifndef _OPENMP
 __DEVICE__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
@@ -61,7 +55,6 @@ __DEVICE__ int fpclassify(double __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZER

Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

2019-05-07 Thread Jonas Devlieghere via cfe-commits
Hi Leonard,

My personal rule of thumb is that if I can fix it in something like 30
minutes or less, I'll leave the bot red and commit a fix. Otherwise I'll
revert my change. The problem with leaving the bot red is that if something
else breaks, that person doesn't get a signal, and issue start to pile up.

When I see a bot is red and it's blocking me, I will usually send an e-mail
and wait about the same time for a reply, before reverting the change
myself.

Cheers,
Jonas

On Tue, May 7, 2019 at 11:20 AM Leonard Chan  wrote:

> Thanks! It turns out that we weren't running debuginfo-tests. Trying to
> find a mac I can ssh into to reproduce this.
>
> Another side question: is there usually an etiquette for how long a
> greendragon bot is allowed to stay broken? I don't want to leave it that
> way for too long while working on my fix if it bothers others too much.
>
> Thanks,
> Leonard
>
> On Tue, May 7, 2019 at 10:13 AM Jonas Devlieghere 
> wrote:
>
>> Hi Leonard,
>>
>> The test that is asserting is part of the debuginfo test. (
>> https://github.com/llvm-project/debuginfo-tests)
>> The reason that it's only failing on the non-incremental bot is because
>> the incremental one isn't running those, I believe.
>>
>> RA stands for Release/Asserts.
>>
>> Hope that helps!
>>
>> Cheers,
>> Jonas
>>
>> On Tue, May 7, 2019 at 9:44 AM Leonard Chan 
>> wrote:
>>
>>> Yup, sorry for the delay. I submitted it overnight thinking it would be
>>> fixed this time. I have one more way that I think should fix it, but before
>>> trying it out, do you know any tips on how I can try to reproduce this
>>> locally? I see that you're running these on an x64 mac, but I can't seem to
>>> trigger this on our own mac builders. Also as a side question, do you what
>>> RA stands for in "Clang Stage 1: cmake, incremental RA, using system
>>> compiler
>>> "?
>>> It seems that I'm only breaking the non-incremental RA jobs, bit the
>>> incremental one still works fine with my change.
>>>
>>> Thanks,
>>> Leonard
>>>
>>> On Tue, May 7, 2019, 09:26 Jonas Devlieghere 
>>> wrote:
>>>
 Hi Leonard,

 It appears that your patch is still triggering an assertion on
 GreenDragon:
 http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c

 Can you please have a look?

 Thanks,
 Jonas


 On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: leonardchan
> Date: Mon May  6 20:20:17 2019
> New Revision: 360109
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev
> Log:
> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is
> an attribute declaration"
>
> Updated with fix for read of uninitialized memory.
>
> Added:
> cfe/trunk/test/Frontend/macro_defined_type.cpp
> cfe/trunk/test/Sema/address_space_print_macro.c
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/AST/TypeLoc.h
> cfe/trunk/include/clang/AST/TypeNodes.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/ParsedAttr.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ASTDiagnostic.cpp
> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/AST/TypePrinter.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Sema/address_spaces.c
> cfe/trunk/test/SemaObjC/externally-retained.m
> cfe/trunk/test/SemaObjC/gc-attributes.m
> cfe/trunk/test/SemaObjC/mrc-weak.m
> cfe/trunk/test/SemaObjCXX/gc-attributes.mm
> cfe/trunk/tools/libclang/CIndex.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109&r1=360108&r2=360109&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  6 20:20

r353882 - Make ModuleDependencyCollector's method virtual (NFC)

2019-02-12 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Feb 12 13:45:14 2019
New Revision: 353882

URL: http://llvm.org/viewvc/llvm-project?rev=353882&view=rev
Log:
Make ModuleDependencyCollector's method virtual (NFC)

For reproducers in LLDB we want to hook up into the existing clang
infrastructure. To make that happen we need to be able to override the
ModuleDependencyCollector's methods.

The alternative was to inherit from the DependencyCollector directly,
but that would mean re-implementing the ModuleDependencyListener and the
ModuleDependencyPPCallbacks and ModuleDependencyMMCallbacks.

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

Modified:
cfe/trunk/include/clang/Frontend/Utils.h

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=353882&r1=353881&r2=353882&view=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Tue Feb 12 13:45:14 2019
@@ -145,18 +145,18 @@ public:
   ~ModuleDependencyCollector() override { writeFileMap(); }
 
   StringRef getDest() { return DestDir; }
-  bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
-  void addFile(StringRef Filename, StringRef FileDst = {});
+  virtual bool insertSeen(StringRef Filename) { return 
Seen.insert(Filename).second; }
+  virtual void addFile(StringRef Filename, StringRef FileDst = {});
 
-  void addFileMapping(StringRef VPath, StringRef RPath) {
+  virtual void addFileMapping(StringRef VPath, StringRef RPath) {
 VFSWriter.addFileMapping(VPath, RPath);
   }
 
   void attachToPreprocessor(Preprocessor &PP) override;
   void attachToASTReader(ASTReader &R) override;
 
-  void writeFileMap();
-  bool hasErrors() { return HasErrors; }
+  virtual void writeFileMap();
+  virtual bool hasErrors() { return HasErrors; }
 };
 
 /// AttachDependencyGraphGen - Create a dependency graph generator, and attach


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


r312545 - [NFC] Loop modernization in diagtool

2017-09-05 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Sep  5 11:04:34 2017
New Revision: 312545

URL: http://llvm.org/viewvc/llvm-project?rev=312545&view=rev
Log:
[NFC] Loop modernization in diagtool

Precommit for https://reviews.llvm.org/D37390

Modified:
cfe/trunk/tools/diagtool/DiagnosticNames.cpp
cfe/trunk/tools/diagtool/DiagnosticNames.h
cfe/trunk/tools/diagtool/ListWarnings.cpp
cfe/trunk/tools/diagtool/ShowEnabledWarnings.cpp
cfe/trunk/tools/diagtool/TreeView.cpp

Modified: cfe/trunk/tools/diagtool/DiagnosticNames.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/DiagnosticNames.cpp?rev=312545&r1=312544&r2=312545&view=diff
==
--- cfe/trunk/tools/diagtool/DiagnosticNames.cpp (original)
+++ cfe/trunk/tools/diagtool/DiagnosticNames.cpp Tue Sep  5 11:04:34 2017
@@ -84,6 +84,11 @@ GroupRecord::subgroup_iterator GroupReco
   return nullptr;
 }
 
+llvm::iterator_range
+GroupRecord::subgroups() const {
+  return llvm::make_range(subgroup_begin(), subgroup_end());
+}
+
 GroupRecord::diagnostics_iterator GroupRecord::diagnostics_begin() const {
   return DiagArrays + Members;
 }
@@ -92,6 +97,11 @@ GroupRecord::diagnostics_iterator GroupR
   return nullptr;
 }
 
+llvm::iterator_range
+GroupRecord::diagnostics() const {
+  return llvm::make_range(diagnostics_begin(), diagnostics_end());
+}
+
 llvm::ArrayRef diagtool::getDiagnosticGroups() {
   return llvm::makeArrayRef(OptionTable);
 }

Modified: cfe/trunk/tools/diagtool/DiagnosticNames.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/DiagnosticNames.h?rev=312545&r1=312544&r2=312545&view=diff
==
--- cfe/trunk/tools/diagtool/DiagnosticNames.h (original)
+++ cfe/trunk/tools/diagtool/DiagnosticNames.h Tue Sep  5 11:04:34 2017
@@ -20,7 +20,7 @@ namespace diagtool {
 const char *NameStr;
 short DiagID;
 uint8_t NameLen;
-
+
 llvm::StringRef getName() const {
   return llvm::StringRef(NameStr, NameLen);
 }
@@ -80,7 +80,7 @@ namespace diagtool {
   bool operator==(group_iterator &Other) const {
 return CurrentID == Other.CurrentID;
   }
-  
+
   bool operator!=(group_iterator &Other) const {
 return CurrentID != Other.CurrentID;
   }
@@ -89,10 +89,12 @@ namespace diagtool {
 typedef group_iterator subgroup_iterator;
 subgroup_iterator subgroup_begin() const;
 subgroup_iterator subgroup_end() const;
+llvm::iterator_range subgroups() const;
 
 typedef group_iterator diagnostics_iterator;
 diagnostics_iterator diagnostics_begin() const;
 diagnostics_iterator diagnostics_end() const;
+llvm::iterator_range diagnostics() const;
 
 bool operator<(llvm::StringRef Other) const {
   return getName() < Other;

Modified: cfe/trunk/tools/diagtool/ListWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/ListWarnings.cpp?rev=312545&r1=312544&r2=312545&view=diff
==
--- cfe/trunk/tools/diagtool/ListWarnings.cpp (original)
+++ cfe/trunk/tools/diagtool/ListWarnings.cpp Tue Sep  5 11:04:34 2017
@@ -23,7 +23,7 @@
 DEF_DIAGTOOL("list-warnings",
  "List warnings and their corresponding flags",
  ListWarnings)
-  
+
 using namespace clang;
 using namespace diagtool;
 
@@ -31,20 +31,19 @@ namespace {
 struct Entry {
   llvm::StringRef DiagName;
   llvm::StringRef Flag;
-  
+
   Entry(llvm::StringRef diagN, llvm::StringRef flag)
 : DiagName(diagN), Flag(flag) {}
-  
+
   bool operator<(const Entry &x) const { return DiagName < x.DiagName; }
 };
 }
 
 static void printEntries(std::vector &entries, llvm::raw_ostream &out) {
-  for (std::vector::iterator it = entries.begin(), ei = entries.end();
-   it != ei; ++it) {
-out << "  " << it->DiagName;
-if (!it->Flag.empty())
-  out << " [-W" << it->Flag << "]";
+  for (const Entry &E : entries) {
+out << "  " << E.DiagName;
+if (!E.Flag.empty())
+  out << " [-W" << E.Flag << "]";
 out << '\n';
   }
 }
@@ -52,23 +51,18 @@ static void printEntries(std::vector Flagged, Unflagged;
   llvm::StringMap > flagHistogram;
-  
-  ArrayRef AllDiagnostics = getBuiltinDiagnosticsByName();
 
-  for (ArrayRef::iterator di = AllDiagnostics.begin(),
-de = AllDiagnostics.end();
-   di != de; ++di) {
-unsigned diagID = di->DiagID;
-
+  for (const DiagnosticRecord &DR : getBuiltinDiagnosticsByName()) {
+const unsigned diagID = DR.DiagID;
+
 if (DiagnosticIDs::isBuiltinNote(diagID))
   continue;
-
+
 if (!DiagnosticIDs::isBuiltinWarningOrExtension(diagID))
   continue;
-  
-Entry entry(di->getName(),
-DiagnosticIDs::getWarningOptionForDiag(diagID));
-
+
+Entry entry(DR.getName(), DiagnosticIDs::getWarningOptionForD

r312546 - [diagtool] Change default tree behavior to print only flags

2017-09-05 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Sep  5 11:04:40 2017
New Revision: 312546

URL: http://llvm.org/viewvc/llvm-project?rev=312546&view=rev
Log:
[diagtool] Change default tree behavior to print only flags

This patch changes the default behavior of `diagtool tree` to only
display warning flags and not the internal warnings flags. The latter is
an implementation detail of the compiler and usually not what the users
wants.

Furthermore, flags that are enabled by default are now also printed in
green. Originally, this was only the case for the diagnostic names.

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

Modified:
cfe/trunk/test/Misc/warning-flags-tree.c
cfe/trunk/tools/diagtool/TreeView.cpp

Modified: cfe/trunk/test/Misc/warning-flags-tree.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags-tree.c?rev=312546&r1=312545&r2=312546&view=diff
==
--- cfe/trunk/test/Misc/warning-flags-tree.c (original)
+++ cfe/trunk/test/Misc/warning-flags-tree.c Tue Sep  5 11:04:40 2017
@@ -1,6 +1,6 @@
-// RUN: diagtool tree | FileCheck -strict-whitespace %s
-// RUN: diagtool tree -Weverything | FileCheck -strict-whitespace %s
-// RUN: diagtool tree everything | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal -Weverything | FileCheck -strict-whitespace %s
+// RUN: diagtool tree --internal everything | FileCheck -strict-whitespace %s
 //
 // These three ways of running diagtool tree are the same:
 // they produce a tree for every top-level diagnostic flag.
@@ -29,8 +29,7 @@
 
 // RUN: not diagtool tree -Wthis-is-not-a-valid-flag
 
-
-// RUN: diagtool tree -Wgnu | FileCheck -strict-whitespace -check-prefix 
CHECK-GNU %s
+// RUN: diagtool tree --internal -Wgnu | FileCheck -strict-whitespace 
-check-prefix CHECK-GNU %s
 // CHECK-GNU: -Wgnu
 // CHECK-GNU:   -Wgnu-designator
 // CHECK-GNU: ext_gnu_array_range
@@ -40,7 +39,7 @@
 // CHECK-GNU: ext_vla
 // There are more GNU extensions but we don't need to check them all.
 
-// RUN: diagtool tree --flags-only -Wgnu | FileCheck -check-prefix 
CHECK-FLAGS-ONLY %s
+// RUN: diagtool tree -Wgnu | FileCheck -check-prefix CHECK-FLAGS-ONLY %s
 // CHECK-FLAGS-ONLY: -Wgnu
 // CHECK-FLAGS-ONLY:   -Wgnu-designator
 // CHECK-FLAGS-ONLY-NOT: ext_gnu_array_range

Modified: cfe/trunk/tools/diagtool/TreeView.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/TreeView.cpp?rev=312546&r1=312545&r2=312546&view=diff
==
--- cfe/trunk/tools/diagtool/TreeView.cpp (original)
+++ cfe/trunk/tools/diagtool/TreeView.cpp Tue Sep  5 11:04:40 2017
@@ -32,10 +32,10 @@ class TreePrinter {
 public:
   llvm::raw_ostream &out;
   const bool ShowColors;
-  bool FlagsOnly;
+  bool Internal;
 
   TreePrinter(llvm::raw_ostream &out)
-  : out(out), ShowColors(hasColors(out)), FlagsOnly(false) {}
+  : out(out), ShowColors(hasColors(out)), Internal(false) {}
 
   void setColor(llvm::raw_ostream::Colors Color) {
 if (ShowColors)
@@ -54,10 +54,28 @@ public:
 return Diags.isIgnored(DiagID, SourceLocation());
   }
 
+  static bool enabledByDefault(const GroupRecord &Group) {
+for (const DiagnosticRecord &DR : Group.diagnostics()) {
+  if (isIgnored(DR.DiagID))
+return false;
+}
+
+for (const GroupRecord &GR : Group.subgroups()) {
+  if (!enabledByDefault(GR))
+return false;
+}
+
+return true;
+  }
+
   void printGroup(const GroupRecord &Group, unsigned Indent = 0) {
 out.indent(Indent * 2);
 
-setColor(llvm::raw_ostream::YELLOW);
+if (enabledByDefault(Group))
+  setColor(llvm::raw_ostream::GREEN);
+else
+  setColor(llvm::raw_ostream::YELLOW);
+
 out << "-W" << Group.getName() << "\n";
 resetColor();
 
@@ -66,7 +84,7 @@ public:
   printGroup(GR, Indent);
 }
 
-if (!FlagsOnly) {
+if (Internal) {
   for (const DiagnosticRecord &DR : Group.diagnostics()) {
 if (ShowColors && !isIgnored(DR.DiagID))
   setColor(llvm::raw_ostream::GREEN);
@@ -132,16 +150,16 @@ public:
 };
 
 static void printUsage() {
-  llvm::errs() << "Usage: diagtool tree [--flags-only] []\n";
+  llvm::errs() << "Usage: diagtool tree [--internal] []\n";
 }
 
 int TreeView::run(unsigned int argc, char **argv, llvm::raw_ostream &out) {
   // First check our one flag (--flags-only).
-  bool FlagsOnly = false;
+  bool Internal = false;
   if (argc > 0) {
 StringRef FirstArg(*argv);
-if (FirstArg.equals("--flags-only")) {
-  FlagsOnly = true;
+if (FirstArg.equals("--internal")) {
+  Internal = true;
   --argc;
   ++argv;
 }
@@ -168,7 +186,7 @@ int TreeView::run(unsigned int argc, cha
   }
 
   TreePrinter TP(out);
-  TP.FlagsOnly = FlagsOnly;
+  TP.Internal = Internal;
   TP.showKey();
   return ShowAll ? TP.showAll(

r366447 - [CMake] Don't set Python_ADDITIONAL_VERSIONS

2019-07-18 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Thu Jul 18 08:17:42 2019
New Revision: 366447

URL: http://llvm.org/viewvc/llvm-project?rev=366447&view=rev
Log:
[CMake] Don't set Python_ADDITIONAL_VERSIONS

Until recently, Python_ADDITIONAL_VERSIONS was used to limit LLVM's
Python support to 2.7. Now that both LLVM and LLDB both support Python
3, there's no longer a need to put an arbitrary limit on this.

However, instead of removing the variable, r365692 expanded the list,
which has the (presumably unintentional) side-effect of expression
preference for Python 3.

Instead, as Michal proposed in the original code review, we should just
not set the list at all, and let CMake pick whatever Python interpreter
you have in your path.

This patch removes the Python_ADDITIONAL_VERSIONS variable in llvm,
clang and lld. I've also updated the docs with the default behavior and
how to force a different Python version to be used.

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

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=366447&r1=366446&r2=366447&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Jul 18 08:17:42 2019
@@ -129,7 +129,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-set(Python_ADDITIONAL_VERSIONS 2.7)
 include(FindPythonInterp)
 if(NOT PYTHONINTERP_FOUND)
   message(FATAL_ERROR


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


r367271 - [DependencyCollector] Make maybeAddDependency virtual (NFC)

2019-07-29 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Jul 29 16:02:11 2019
New Revision: 367271

URL: http://llvm.org/viewvc/llvm-project?rev=367271&view=rev
Log:
[DependencyCollector] Make maybeAddDependency virtual (NFC)

Make DependencyCollector::maybeAddDependency, just like its other
methods, which I made virtual a while ago. The motivation for this
change is still the LLDB reproducer.

Modified:
cfe/trunk/include/clang/Frontend/Utils.h

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=367271&r1=367270&r2=367271&view=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Mon Jul 29 16:02:11 2019
@@ -99,11 +99,11 @@ public:
   /// Return true if system files should be passed to sawDependency().
   virtual bool needSystemDependencies() { return false; }
 
-  // implementation detail
   /// Add a dependency \p Filename if it has not been seen before and
   /// sawDependency() returns true.
-  void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem,
-  bool IsModuleFile, bool IsMissing);
+  virtual void maybeAddDependency(StringRef Filename, bool FromModule,
+  bool IsSystem, bool IsModuleFile,
+  bool IsMissing);
 
 protected:
   /// Return true if the filename was added to the list of dependencies, false


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


Re: r368459 - Fix a build bot failure and multiple warnings instances for range base for loops

2019-08-09 Thread Jonas Devlieghere via cfe-commits
I think this is causing a stage2 failure:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/124/consoleFull#-95886206949ba4694-19c4-4d7e-bec5-911270d8a58c

On Fri, Aug 9, 2019 at 10:41 AM Gabor Horvath via cfe-commits
 wrote:
>
> Author: xazax
> Date: Fri Aug  9 10:42:41 2019
> New Revision: 368459
>
> URL: http://llvm.org/viewvc/llvm-project?rev=368459&view=rev
> Log:
> Fix a build bot failure and multiple warnings instances for range base for 
> loops
>
> Modified:
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaInit.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=368459&r1=368458&r2=368459&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Aug  9 10:42:41 2019
> @@ -6616,7 +6616,7 @@ static void handleGslAnnotatedTypes(Indi
>  return;
>} else if (auto *OCE = dyn_cast(Call)) {
>  FunctionDecl *Callee = OCE->getDirectCallee();
> -if (Callee->isCXXInstanceMember() &&
> +if (Callee && Callee->isCXXInstanceMember() &&
>  shouldTrackImplicitObjectArg(cast(Callee)))
>VisitPointerArg(Callee, OCE->getArg(0));
>  return;
> @@ -7070,8 +7070,11 @@ static SourceRange nextPathEntryRange(co
>// supporting lifetime extension.
>break;
>
> -case IndirectLocalPathEntry::DefaultInit:
>  case IndirectLocalPathEntry::VarInit:
> +  if (cast(Path[I].D)->isImplicit())
> +return SourceRange();
> +  LLVM_FALLTHROUGH;
> +case IndirectLocalPathEntry::DefaultInit:
>return Path[I].E->getSourceRange();
>  }
>}
> @@ -7133,7 +7136,7 @@ void Sema::checkInitializerLifetime(cons
>  return false;
>}
>
> -  if (IsGslPtrInitWithGslTempOwner) {
> +  if (IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) {
>  Diag(DiagLoc, diag::warn_dangling_lifetime_pointer) << DiagRange;
>  return false;
>}
>
> Modified: cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp?rev=368459&r1=368458&r2=368459&view=diff
> ==
> --- cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp (original)
> +++ cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp Fri Aug  9 10:42:41 
> 2019
> @@ -201,6 +201,13 @@ void danglingReferenceFromTempOwner() {
>  std::vector getTempVec();
>  std::optional> getTempOptVec();
>
> +void testLoops() {
> +  for (auto i : getTempVec()) // ok
> +;
> +  for (auto i : *getTempOptVec()) // expected-warning {{object backing the 
> pointer will be destroyed at the end of the full-expression}}
> +;
> +}
> +
>  int &usedToBeFalsePositive(std::vector &v) {
>std::vector::iterator it = v.begin();
>int& value = *it;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r368459 - Fix a build bot failure and multiple warnings instances for range base for loops

2019-08-09 Thread Jonas Devlieghere via cfe-commits
The bot is a little special in that it has modules enabled. Maybe that
explains it? Let me know if that doesn't work and I can try
reproducing locally.

On Fri, Aug 9, 2019 at 12:02 PM Gábor Horváth  wrote:
>
> I reverted but I cannot reproduce this locally on a linux box. Is there any 
> way to get more information from the build bot (like preprocessed files?)?
>
> On Fri, 9 Aug 2019 at 11:38, Gábor Horváth  wrote:
>>
>> Hmm, strange. Looking into it! If I do not manage to find the root cause in 
>> a few minutes I will revert!
>>
>> On Fri, 9 Aug 2019 at 11:32, Jonas Devlieghere  wrote:
>>>
>>> I think this is causing a stage2 failure:
>>> http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/124/consoleFull#-95886206949ba4694-19c4-4d7e-bec5-911270d8a58c
>>>
>>> On Fri, Aug 9, 2019 at 10:41 AM Gabor Horvath via cfe-commits
>>>  wrote:
>>> >
>>> > Author: xazax
>>> > Date: Fri Aug  9 10:42:41 2019
>>> > New Revision: 368459
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=368459&view=rev
>>> > Log:
>>> > Fix a build bot failure and multiple warnings instances for range base 
>>> > for loops
>>> >
>>> > Modified:
>>> > cfe/trunk/lib/Sema/SemaInit.cpp
>>> > cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
>>> >
>>> > Modified: cfe/trunk/lib/Sema/SemaInit.cpp
>>> > URL: 
>>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=368459&r1=368458&r2=368459&view=diff
>>> > ==
>>> > --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
>>> > +++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Aug  9 10:42:41 2019
>>> > @@ -6616,7 +6616,7 @@ static void handleGslAnnotatedTypes(Indi
>>> >  return;
>>> >} else if (auto *OCE = dyn_cast(Call)) {
>>> >  FunctionDecl *Callee = OCE->getDirectCallee();
>>> > -if (Callee->isCXXInstanceMember() &&
>>> > +if (Callee && Callee->isCXXInstanceMember() &&
>>> >  shouldTrackImplicitObjectArg(cast(Callee)))
>>> >VisitPointerArg(Callee, OCE->getArg(0));
>>> >  return;
>>> > @@ -7070,8 +7070,11 @@ static SourceRange nextPathEntryRange(co
>>> >// supporting lifetime extension.
>>> >break;
>>> >
>>> > -case IndirectLocalPathEntry::DefaultInit:
>>> >  case IndirectLocalPathEntry::VarInit:
>>> > +  if (cast(Path[I].D)->isImplicit())
>>> > +return SourceRange();
>>> > +  LLVM_FALLTHROUGH;
>>> > +case IndirectLocalPathEntry::DefaultInit:
>>> >return Path[I].E->getSourceRange();
>>> >  }
>>> >}
>>> > @@ -7133,7 +7136,7 @@ void Sema::checkInitializerLifetime(cons
>>> >  return false;
>>> >}
>>> >
>>> > -  if (IsGslPtrInitWithGslTempOwner) {
>>> > +  if (IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) {
>>> >  Diag(DiagLoc, diag::warn_dangling_lifetime_pointer) << DiagRange;
>>> >  return false;
>>> >}
>>> >
>>> > Modified: cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
>>> > URL: 
>>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp?rev=368459&r1=368458&r2=368459&view=diff
>>> > ==
>>> > --- cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp (original)
>>> > +++ cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp Fri Aug  9 
>>> > 10:42:41 2019
>>> > @@ -201,6 +201,13 @@ void danglingReferenceFromTempOwner() {
>>> >  std::vector getTempVec();
>>> >  std::optional> getTempOptVec();
>>> >
>>> > +void testLoops() {
>>> > +  for (auto i : getTempVec()) // ok
>>> > +;
>>> > +  for (auto i : *getTempOptVec()) // expected-warning {{object backing 
>>> > the pointer will be destroyed at the end of the full-expression}}
>>> > +;
>>> > +}
>>> > +
>>> >  int &usedToBeFalsePositive(std::vector &v) {
>>> >std::vector::iterator it = v.begin();
>>> >int& value = *it;
>>> >
>>> >
>>> > ___
>>> > cfe-commits mailing list
>>> > cfe-commits@lists.llvm.org
>>> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r368954 - [NFC] Update doc comment to fix warning.

2019-08-14 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Aug 14 20:59:30 2019
New Revision: 368954

URL: http://llvm.org/viewvc/llvm-project?rev=368954&view=rev
Log:
[NFC] Update doc comment to fix warning.

This fixes the warning: parameter 'EnableNullFPSuppression' not found in
the function declaration [-Wdocumentation]

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h?rev=368954&r1=368953&r2=368954&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
Wed Aug 14 20:59:30 2019
@@ -143,8 +143,6 @@ public:
 
   /// \param V We're searching for the store where \c R received this value.
   /// \param R The region we're tracking.
-  /// \param EnableNullFPSuppression Whether we should employ false positive
-  /// suppression (inlined defensive checks, returned null).
   /// \param TKind May limit the amount of notes added to the bug report.
   /// \param OriginSFC Only adds notes when the last store happened in a
   ///different stackframe to this one. Disregarded if the tracking kind


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


r371813 - Revert "For PR17164: split -fno-lax-vector-conversion into three different"

2019-09-12 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Thu Sep 12 22:16:59 2019
New Revision: 371813

URL: http://llvm.org/viewvc/llvm-project?rev=371813&view=rev
Log:
Revert "For PR17164: split -fno-lax-vector-conversion into three different"

This breaks the LLDB build. I tried reaching out to Richard, but haven't
gotten a reply yet.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGen/builtins-systemz-vector.c
cfe/trunk/test/CodeGen/builtins-systemz-vector2.c
cfe/trunk/test/CodeGen/builtins-systemz-vector3.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector2-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c
cfe/trunk/test/CodeGen/builtins-wasm.c
cfe/trunk/test/CodeGenCXX/builtins-systemz-zvector.cpp
cfe/trunk/test/Headers/altivec-header.c
cfe/trunk/test/Headers/arm-neon-header.c
cfe/trunk/test/Headers/x86-intrinsics-headers-clean.cpp
cfe/trunk/test/Headers/x86-intrinsics-headers.c
cfe/trunk/test/Headers/x86intrin-2.c
cfe/trunk/test/Headers/x86intrin.c
cfe/trunk/test/Sema/ext_vector_casts.c
cfe/trunk/test/Sema/typedef-retain.c
cfe/trunk/test/Sema/zvector.c
cfe/trunk/test/Sema/zvector2.c
cfe/trunk/test/SemaCXX/altivec.cpp
cfe/trunk/test/SemaCXX/vector-no-lax.cpp
cfe/trunk/test/SemaCXX/vector.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=371813&r1=371812&r2=371813&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Sep 12 22:16:59 2019
@@ -119,8 +119,7 @@ LANGOPT(AppleKext , 1, 0, "Apple
 BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
 LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
-ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
- LaxVectorConversionKind::All, "lax vector conversions")
+LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")
 LANGOPT(Exceptions, 1, 0, "exception handling")

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=371813&r1=371812&r2=371813&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Thu Sep 12 22:16:59 2019
@@ -184,16 +184,6 @@ public:
 FEA_On
   };
 
-  enum class LaxVectorConversionKind {
-/// Permit no implicit vector bitcasts.
-None,
-/// Permit vector bitcasts between integer vectors with different numbers
-/// of elements but the same total bit-width.
-Integer,
-/// Permit vector bitcasts between all vectors with the same total
-/// bit-width.
-All,
-  };
 
 public:
   /// Set of enabled sanitizers.

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=371813&r1=371812&r2=371813&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Sep 12 22:16:59 2019
@@ -1274,10 +1274,7 @@ def fno_fine_grained_bitfield_accesses :
   HelpText<"Use large-integer access for consecutive bitfield runs.">;
 
 def flat__namespace : Flag<["-"], "flat_namespace">;
-def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, 
Group,
-  HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, 
Flags<[CC1Option]>;
-def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group,
-  Alias, AliasArgs<["integer"]>;
+def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, 
Group;
 def fapple_link_rtlib : Flag<["-"], "fapple-link-rtlib">, Group,
   HelpText<"Force linking the clang builtins runtime library">;
@@ -1451,7 +1448,7 @@ def fno_experimental_new_pass_manager :
 def fveclib : Joined<["-"], "fveclib=">, Group, Flags<[CC1Option]>,
 HelpText<"Use the given vector functions library">, 
Values<"

r372672 - Revert "Support for DWARF-5 C++ language tags."

2019-09-23 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Sep 23 16:49:36 2019
New Revision: 372672

URL: http://llvm.org/viewvc/llvm-project?rev=372672&view=rev
Log:
Revert "Support for DWARF-5 C++ language tags."

This reverts commit bf9c8ffb54943c6d77398adbedddf05ef9724007.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/JSONNodeDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaModule.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=372672&r1=372671&r2=372672&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Sep 23 16:49:36 2019
@@ -42,7 +42,6 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/iterator_range.h"
-#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
@@ -2942,10 +2941,8 @@ public:
   /// ensure a stable ABI for this, we choose the DW_LANG_ encodings
   /// from the dwarf standard.
   enum LanguageIDs {
-lang_c = llvm::dwarf::DW_LANG_C,
-lang_cxx = llvm::dwarf::DW_LANG_C_plus_plus,
-lang_cxx_11 = llvm::dwarf::DW_LANG_C_plus_plus_11,
-lang_cxx_14 = llvm::dwarf::DW_LANG_C_plus_plus_14
+lang_c = /* DW_LANG_C */ 0x0002,
+lang_cxx = /* DW_LANG_C_plus_plus */ 0x0004
   };
 
 private:

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=372672&r1=372671&r2=372672&view=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Sep 23 16:49:36 2019
@@ -1001,19 +1001,12 @@ void DeclPrinter::VisitCXXRecordDecl(CXX
 
 void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
   const char *l;
-  switch (D->getLanguage()) {
-  case LinkageSpecDecl::lang_c:
+  if (D->getLanguage() == LinkageSpecDecl::lang_c)
 l = "C";
-break;
-  case LinkageSpecDecl::lang_cxx_14:
-l = "C++14";
-break;
-  case LinkageSpecDecl::lang_cxx_11:
-l = "C++11";
-break;
-  case LinkageSpecDecl::lang_cxx:
+  else {
+assert(D->getLanguage() == LinkageSpecDecl::lang_cxx &&
+   "unknown language in linkage specification");
 l = "C++";
-break;
   }
 
   Out << "extern \"" << l << "\" ";

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=372672&r1=372671&r2=372672&view=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Mon Sep 23 16:49:36 2019
@@ -850,12 +850,6 @@ void JSONNodeDumper::VisitLinkageSpecDec
   switch (LSD->getLanguage()) {
   case LinkageSpecDecl::lang_c: Lang = "C"; break;
   case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
-  case LinkageSpecDecl::lang_cxx_11:
-Lang = "C++11";
-break;
-  case LinkageSpecDecl::lang_cxx_14:
-Lang = "C++14";
-break;
   }
   JOS.attribute("language", Lang);
   attributeOnlyIfTrue("hasBraces", LSD->hasBraces());

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=372672&r1=372671&r2=372672&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Mon Sep 23 16:49:36 2019
@@ -1766,12 +1766,6 @@ void TextNodeDumper::VisitLinkageSpecDec
   case LinkageSpecDecl::lang_cxx:
 OS << " C++";
 break;
-  case LinkageSpecDecl::lang_cxx_11:
-OS << " C++11";
-break;
-  case LinkageSpecDecl::lang_cxx_14:
-OS << " C++14";
-break;
   }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=372672&r1=372671&r2=372672&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 23 16:49:36 2019
@@ -561,10 +561,6 @@ void CGDebugInfo::CreateCompileUnit() {
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14)
-  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
-  LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
   } else if (LO.ObjC) {
@@ -882,

r335757 - [DebugInfo] Emit ObjC methods as part of interface

2018-06-27 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Jun 27 10:31:59 2018
New Revision: 335757

URL: http://llvm.org/viewvc/llvm-project?rev=335757&view=rev
Log:
[DebugInfo] Emit ObjC methods as part of interface

As brought up during the discussion of the DWARF5 accelerator tables,
there is currently no way to associate Objective-C methods with the
interface they belong to, other than the .apple_objc accelerator table.

After due consideration we came to the conclusion that it makes more
sense to follow Pavel's suggestion of just emitting this information in
the .debug_info section. One concern was that categories were
emitted in the .apple_names as well, but it turns out that LLDB doesn't
rely on the accelerator tables for this information.

This patch changes the codegen behavior to emit subprograms for
structure types, like we do for C++. This will result in the
DW_TAG_subprogram being nested as a child under its
DW_TAG_structure_type. This behavior is only enabled for DWARF5 and
later, so we can have a unique code path in LLDB with regards to
obtaining the class methods.

This was tested on the LLDB side and doesn't lead to a regression.
There's already code in place to deal with member functions in C++,
which deals with this transparently.

For more background please refer to the discussion on the mailing list:
http://lists.llvm.org/pipermail/llvm-dev/2018-June/123986.html

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

Added:
cfe/trunk/test/CodeGenObjC/debug-info-category.m
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=335757&r1=335756&r2=335757&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jun 27 10:31:59 2018
@@ -3346,6 +3346,27 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Starting with DWARF V5 method declarations are emitted as children of
+// the interface type.
+if (const auto *OMD = dyn_cast_or_null(D)) {
+  const ObjCInterfaceDecl *ID = OMD->getClassInterface();
+  QualType QTy(ID->getTypeForDecl(), 0);
+  auto It = TypeCache.find(QTy.getAsOpaquePtr());
+  if (It != TypeCache.end()) {
+llvm::DICompositeType *InterfaceDecl =
+cast(It->second);
+llvm::DISubprogram *FD = DBuilder.createFunction(
+InterfaceDecl, Name, LinkageName, Unit, LineNo,
+getOrCreateFunctionType(D, FnType, Unit), Fn->hasLocalLinkage(),
+false /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize,
+TParamsArray.get());
+DBuilder.finalizeSubprogram(FD);
+ObjCMethodCache[ID].push_back(FD);
+  }
+}
+  }
+
   // Push the function onto the lexical block stack.
   LexicalBlockStack.emplace_back(SP);
 
@@ -4213,6 +4234,29 @@ void CGDebugInfo::finalize() {
 DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty);
   }
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Add methods to interface.
+for (auto P : ObjCMethodCache) {
+  if (P.second.empty())
+continue;
+
+  QualType QTy(P.first->getTypeForDecl(), 0);
+  auto It = TypeCache.find(QTy.getAsOpaquePtr());
+  assert(It != TypeCache.end());
+
+  llvm::DICompositeType *InterfaceDecl =
+  cast(It->second);
+
+  SmallVector EltTys;
+  auto CurrenetElts = InterfaceDecl->getElements();
+  EltTys.append(CurrenetElts.begin(), CurrenetElts.end());
+  for (auto &MD : P.second)
+EltTys.push_back(MD);
+  llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
+  DBuilder.replaceArrays(InterfaceDecl, Elements);
+}
+  }
+
   for (auto p : ReplaceMap) {
 assert(p.second);
 auto *Ty = cast(p.second);

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=335757&r1=335756&r2=335757&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Jun 27 10:31:59 2018
@@ -98,6 +98,10 @@ class CGDebugInfo {
   /// Cache of previously constructed interfaces which may change.
   llvm::SmallVector ObjCInterfaceCache;
 
+  /// Cache of forward declarations for methods belonging to the interface.
+  llvm::DenseMap>
+  ObjCMethodCache;
+
   /// Cache of references to clang modules and precompiled headers.
   llvm::DenseMap ModuleCache;
 

Added: cfe/trunk/test/CodeGenObjC/debug-info-category.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-category.m?rev=335757&view=auto
===

r335834 - [DebugInfo] Follow-up commit to improve consistency. NFC

2018-06-28 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Thu Jun 28 03:56:40 2018
New Revision: 335834

URL: http://llvm.org/viewvc/llvm-project?rev=335834&view=rev
Log:
[DebugInfo] Follow-up commit to improve consistency. NFC

Follow-up commit for r335757 to address some inconsistencies.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=335834&r1=335833&r2=335834&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun 28 03:56:40 2018
@@ -289,8 +289,7 @@ StringRef CGDebugInfo::getObjCMethodName
  << OC->getIdentifier()->getNameStart() << ')';
 }
   } else if (const auto *OCD = dyn_cast(DC)) {
-OS << OCD->getClassInterface()->getName() << '('
-   << OCD->getName() << ')';
+OS << OCD->getClassInterface()->getName() << '(' << OCD->getName() << ')';
   } else if (isa(DC)) {
 // We can extract the type of the class from the self pointer.
 if (ImplicitParamDecl *SelfDecl = OMD->getSelfDecl()) {
@@ -385,7 +384,8 @@ CGDebugInfo::computeChecksum(FileID FID,
   return llvm::DIFile::CSK_MD5;
 }
 
-Optional CGDebugInfo::getSource(const SourceManager &SM, FileID 
FID) {
+Optional CGDebugInfo::getSource(const SourceManager &SM,
+   FileID FID) {
   if (!CGM.getCodeGenOpts().EmbedSource)
 return None;
 
@@ -412,11 +412,11 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
 
   // Cache the results.
   const char *fname = PLoc.getFilename();
-  auto it = DIFileCache.find(fname);
+  auto It = DIFileCache.find(fname);
 
-  if (it != DIFileCache.end()) {
+  if (It != DIFileCache.end()) {
 // Verify that the information still exists.
-if (llvm::Metadata *V = it->second)
+if (llvm::Metadata *V = It->second)
   return cast(V);
   }
 
@@ -427,10 +427,9 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
 
-  llvm::DIFile *F = DBuilder.createFile(remapDIPath(PLoc.getFilename()),
-remapDIPath(getCurrentDirname()),
-CSInfo,
-getSource(SM, SM.getFileID(Loc)));
+  llvm::DIFile *F = DBuilder.createFile(
+  remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), 
CSInfo,
+  getSource(SM, SM.getFileID(Loc)));
 
   DIFileCache[fname].reset(F);
   return F;
@@ -438,8 +437,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFi
 
 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
   return DBuilder.createFile(
-  remapDIPath(TheCU->getFilename()),
-  remapDIPath(TheCU->getDirectory()),
+  remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()),
   TheCU->getFile()->getChecksum(),
   CGM.getCodeGenOpts().EmbedSource ? TheCU->getSource() : None);
 }
@@ -574,8 +572,7 @@ void CGDebugInfo::CreateCompileUnit() {
   TheCU = DBuilder.createCompileUnit(
   LangTag,
   DBuilder.createFile(remapDIPath(MainFileName),
-  remapDIPath(getCurrentDirname()),
-  CSInfo,
+  remapDIPath(getCurrentDirname()), CSInfo,
   getSource(SM, SM.getMainFileID())),
   CGOpts.EmitVersionIdentMetadata ? Producer : "",
   LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
@@ -640,14 +637,13 @@ llvm::DIType *CGDebugInfo::CreateType(co
 return SelTy;
   }
 
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-  case BuiltinType::Id: \
-return getOrCreateStructPtrType("opencl_" #ImgType "_" #Suffix "_t", \
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   
\
+  case BuiltinType::Id:
\
+return getOrCreateStructPtrType("opencl_" #ImgType "_" #Suffix "_t",   
\
 SingletonId);
 #include "clang/Basic/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
-return getOrCreateStructPtrType("opencl_sampler_t",
-OCLSamplerDITy);
+return getOrCreateStructPtrType("opencl_sampler_t", OCLSamplerDITy);
   case BuiltinType::OCLEvent:
 return getOrCreateStructPtrType("opencl_event_t", OCLEventDITy);
   case BuiltinType::OCLClkEvent:
@@ -830,8 +826,7 @@ static bool hasCXXMangling(const TagDecl
 }
 
 // Determines if the tag declaration will require a type identifier.
-static bool needsTypeIdentifier(const TagDecl *TD,
-CodeGenModule& CGM,
+static bool needsTypeIdentifier(const TagDecl *TD, CodeGenModule &CGM,
 llvm::DICompileUnit *TheCU) {
   // We only add a type identifier for types with C++ name mangling.
   if (!hasCXXMangling(TD, TheCU))
@@

[clang] a94e08d - [StaticAnalyzer] Fix non-virtual destructor warning

2020-05-26 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-05-26T11:32:02-07:00
New Revision: a94e08d2e840a0e7ce032f59e9344bc49b5a54a1

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

LOG: [StaticAnalyzer] Fix non-virtual destructor warning

Ficed warning: 'clang::ento::ExprEngine' has virtual functions but non-virtual 
destructor [-
Wnon-virtual-dtor]
  ~ExprEngine() = default;

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
index a94c847f35ee..b32302cfc337 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -177,7 +177,7 @@ class ExprEngine {
  SetOfConstDecls *VisitedCalleesIn,
  FunctionSummariesTy *FS, InliningModes HowToInlineIn);
 
-  ~ExprEngine() = default;
+  virtual ~ExprEngine() = default;
 
   /// Returns true if there is still simulation state on the worklist.
   bool ExecuteWorkList(const LocationContext *L, unsigned Steps = 15) {



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


[clang] 70ad03d - Revert "Set the captures on a CXXRecordDecl representing a lambda closure type"

2020-06-04 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-06-04T23:45:36-07:00
New Revision: 70ad03d93818532ef19f149f8ff89bcd8af80163

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

LOG: Revert "Set the captures on a CXXRecordDecl representing a lambda closure 
type"

This reverts commit c13dd74e311d2ac70dd3ea663d800307d1aa5b6b.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 856717fa0abb..3a400a778e53 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -999,9 +999,6 @@ class CXXRecordDecl : public RecordDecl {
 return static_cast(getLambdaData().CaptureDefault);
   }
 
-  /// Set the captures for this lambda closure type.
-  void setCaptures(ArrayRef Captures);
-
   /// For a closure type, retrieve the mapping from captured
   /// variables and \c this to the non-static data members that store the
   /// values or references of the captures.
@@ -1033,8 +1030,6 @@ class CXXRecordDecl : public RecordDecl {
   : nullptr;
   }
 
-  unsigned capture_size() const { return getLambdaData().NumCaptures; }
-
   using conversion_iterator = UnresolvedSetIterator;
 
   conversion_iterator conversion_begin() const {

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 56b27d57bd5c..272ad138d14a 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1862,9 +1862,10 @@ class LambdaExpr final : public Expr,
   /// Construct a lambda expression.
   LambdaExpr(QualType T, SourceRange IntroducerRange,
  LambdaCaptureDefault CaptureDefault,
- SourceLocation CaptureDefaultLoc, bool ExplicitParams,
- bool ExplicitResultType, ArrayRef CaptureInits,
- SourceLocation ClosingBrace, bool 
ContainsUnexpandedParameterPack);
+ SourceLocation CaptureDefaultLoc, ArrayRef 
Captures,
+ bool ExplicitParams, bool ExplicitResultType,
+ ArrayRef CaptureInits, SourceLocation ClosingBrace,
+ bool ContainsUnexpandedParameterPack);
 
   /// Construct an empty lambda expression.
   LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
@@ -1887,9 +1888,9 @@ class LambdaExpr final : public Expr,
   static LambdaExpr *
   Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange 
IntroducerRange,
  LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc,
- bool ExplicitParams, bool ExplicitResultType,
- ArrayRef CaptureInits, SourceLocation ClosingBrace,
- bool ContainsUnexpandedParameterPack);
+ ArrayRef Captures, bool ExplicitParams,
+ bool ExplicitResultType, ArrayRef CaptureInits,
+ SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack);
 
   /// Construct a new lambda expression that will be deserialized from
   /// an external source.

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index a2a712e6b6ca..10035162299e 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1890,19 +1890,6 @@ Error ASTNodeImporter::ImportDefinition(
 // set in CXXRecordDecl::CreateLambda.  We must import the contained
 // decls here and finish the definition.
 (To->isLambda() && shouldForceImportDeclContext(Kind))) {
-  if (To->isLambda()) {
-auto *FromCXXRD = cast(From);
-SmallVector ToCaptures;
-ToCaptures.reserve(FromCXXRD->capture_size());
-for (const auto &FromCapture : FromCXXRD->captures()) {
-  if (auto ToCaptureOrErr = import(FromCapture))
-ToCaptures.push_back(*ToCaptureOrErr);
-  else
-return ToCaptureOrErr.takeError();
-}
-cast(To)->setCaptures(ToCaptures);
-  }
-
   Error Result = ImportDeclContext(From, /*ForceImport=*/true);
   // Finish the definition of the lambda, set isBeingDefined to false.
   if (To->isLambda())
@@ -7601,6 +7588,15 @@ ExpectedStmt ASTNodeImporter::VisitLambdaExpr(LambdaExpr 
*E) {
   if (!ToCallOpOrErr)
 return ToCallOpOrErr.takeError();
 
+  SmallVector ToCaptures;
+  ToCaptures.reserve(E->capture_size());
+  for (const auto &FromCapture : E->captures()) {
+if (auto ToCaptureOrErr = import(FromCapture))
+  ToCaptures.push_back(*ToCaptureOrErr);
+else
+  return ToCaptureOrErr.takeError();
+  }
+
   SmallVector ToCaptureInits(E->capture_size());
   if (Error Err = ImportContainerChecked(E->capture_inits(), ToCaptureInits))
 retu

Re: [clang] c13dd74 - Set the captures on a CXXRecordDecl representing a lambda closure type

2020-06-04 Thread Jonas Devlieghere via cfe-commits
Hey Richard,

It appears this broke the lldb bots:

http://lab.llvm.org:8011/builders/lldb-x86_64-debian
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/20549/

It's hitting an assertion in
llvm-project/clang/include/clang/AST/DeclCXX.h:887:

Assertion `(data().DefaultedCopyAssignmentIsDeleted ||
needsOverloadResolutionForCopyAssignment()) && "copy assignment should not
be deleted"' failed.

I've reverted this commit and the subsequent one
(c57f8a3a20540fcf9fbf98c0a73f381ec32fce2a) to turn the bots green again
overnight. Could you please take a look tomorrow?

Thanks,
Jonas



On Thu, Jun 4, 2020 at 7:25 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Richard Smith
> Date: 2020-06-04T19:19:01-07:00
> New Revision: c13dd74e311d2ac70dd3ea663d800307d1aa5b6b
>
> URL:
> https://github.com/llvm/llvm-project/commit/c13dd74e311d2ac70dd3ea663d800307d1aa5b6b
> DIFF:
> https://github.com/llvm/llvm-project/commit/c13dd74e311d2ac70dd3ea663d800307d1aa5b6b.diff
>
> LOG: Set the captures on a CXXRecordDecl representing a lambda closure type
> before marking it complete.
>
> No functionality change intended.
>
> Added:
>
>
> Modified:
> clang/include/clang/AST/DeclCXX.h
> clang/include/clang/AST/ExprCXX.h
> clang/lib/AST/ASTImporter.cpp
> clang/lib/AST/DeclCXX.cpp
> clang/lib/AST/ExprCXX.cpp
> clang/lib/Sema/SemaLambda.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/AST/DeclCXX.h
> b/clang/include/clang/AST/DeclCXX.h
> index 3a400a778e53..856717fa0abb 100644
> --- a/clang/include/clang/AST/DeclCXX.h
> +++ b/clang/include/clang/AST/DeclCXX.h
> @@ -999,6 +999,9 @@ class CXXRecordDecl : public RecordDecl {
>  return
> static_cast(getLambdaData().CaptureDefault);
>}
>
> +  /// Set the captures for this lambda closure type.
> +  void setCaptures(ArrayRef Captures);
> +
>/// For a closure type, retrieve the mapping from captured
>/// variables and \c this to the non-static data members that store the
>/// values or references of the captures.
> @@ -1030,6 +1033,8 @@ class CXXRecordDecl : public RecordDecl {
>: nullptr;
>}
>
> +  unsigned capture_size() const { return getLambdaData().NumCaptures; }
> +
>using conversion_iterator = UnresolvedSetIterator;
>
>conversion_iterator conversion_begin() const {
>
> diff  --git a/clang/include/clang/AST/ExprCXX.h
> b/clang/include/clang/AST/ExprCXX.h
> index 272ad138d14a..56b27d57bd5c 100644
> --- a/clang/include/clang/AST/ExprCXX.h
> +++ b/clang/include/clang/AST/ExprCXX.h
> @@ -1862,10 +1862,9 @@ class LambdaExpr final : public Expr,
>/// Construct a lambda expression.
>LambdaExpr(QualType T, SourceRange IntroducerRange,
>   LambdaCaptureDefault CaptureDefault,
> - SourceLocation CaptureDefaultLoc, ArrayRef
> Captures,
> - bool ExplicitParams, bool ExplicitResultType,
> - ArrayRef CaptureInits, SourceLocation ClosingBrace,
> - bool ContainsUnexpandedParameterPack);
> + SourceLocation CaptureDefaultLoc, bool ExplicitParams,
> + bool ExplicitResultType, ArrayRef CaptureInits,
> + SourceLocation ClosingBrace, bool
> ContainsUnexpandedParameterPack);
>
>/// Construct an empty lambda expression.
>LambdaExpr(EmptyShell Empty, unsigned NumCaptures)
> @@ -1888,9 +1887,9 @@ class LambdaExpr final : public Expr,
>static LambdaExpr *
>Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange
> IntroducerRange,
>   LambdaCaptureDefault CaptureDefault, SourceLocation
> CaptureDefaultLoc,
> - ArrayRef Captures, bool ExplicitParams,
> - bool ExplicitResultType, ArrayRef CaptureInits,
> - SourceLocation ClosingBrace, bool
> ContainsUnexpandedParameterPack);
> + bool ExplicitParams, bool ExplicitResultType,
> + ArrayRef CaptureInits, SourceLocation ClosingBrace,
> + bool ContainsUnexpandedParameterPack);
>
>/// Construct a new lambda expression that will be deserialized from
>/// an external source.
>
> diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
> index 10035162299e..a2a712e6b6ca 100644
> --- a/clang/lib/AST/ASTImporter.cpp
> +++ b/clang/lib/AST/ASTImporter.cpp
> @@ -1890,6 +1890,19 @@ Error ASTNodeImporter::ImportDefinition(
>  // set in CXXRecordDecl::CreateLambda.  We must import the
> contained
>  // decls here and finish the definition.
>  (To->isLambda() && shouldForceImportDeclContext(Kind))) {
> +  if (To->isLambda()) {
> +auto *FromCXXRD = cast(From);
> +SmallVector ToCaptures;
> +ToCaptures.reserve(FromCXXRD->capture_size());
> +for (const auto &FromCapture : FromCXXRD->captures()) {
> +  if (auto ToCaptureOrErr = import(FromCapture))
> +ToCaptures.push_back(*ToCaptureOrErr);
> +

[clang] df53f09 - Revert "PR46209: properly determine whether a copy assignment operator is"

2020-06-04 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-06-04T23:45:36-07:00
New Revision: df53f09056b0f6a91029cae5f1cdc941c21b

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

LOG: Revert "PR46209: properly determine whether a copy assignment operator is"

This reverts commit c57f8a3a20540fcf9fbf98c0a73f381ec32fce2a.

Added: 


Modified: 
clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/AST/ast-dump-decl-context-json.cpp
clang/test/AST/ast-dump-decl.cpp
clang/test/AST/ast-dump-expr-json.cpp
clang/test/AST/ast-dump-record-definition-data-json.cpp
clang/test/AST/ast-dump-records-json.cpp
clang/test/AST/ast-dump-records.cpp
clang/test/AST/ast-dump-special-member-functions.cpp
clang/test/AST/ast-dump-template-decls-json.cpp
clang/test/SemaCXX/type-traits.cpp
clang/test/SemaObjCXX/arc-0x.mm
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def 
b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
index 33e65f8ebf44..bd4d8247aeca 100644
--- a/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
+++ b/clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
@@ -140,7 +140,6 @@ FIELD(HasInheritedAssignment, 1, NO_MERGE)
 /// @{
 FIELD(NeedOverloadResolutionForCopyConstructor, 1, NO_MERGE)
 FIELD(NeedOverloadResolutionForMoveConstructor, 1, NO_MERGE)
-FIELD(NeedOverloadResolutionForCopyAssignment, 1, NO_MERGE)
 FIELD(NeedOverloadResolutionForMoveAssignment, 1, NO_MERGE)
 FIELD(NeedOverloadResolutionForDestructor, 1, NO_MERGE)
 /// @}
@@ -150,7 +149,6 @@ FIELD(NeedOverloadResolutionForDestructor, 1, NO_MERGE)
 /// @{
 FIELD(DefaultedCopyConstructorIsDeleted, 1, NO_MERGE)
 FIELD(DefaultedMoveConstructorIsDeleted, 1, NO_MERGE)
-FIELD(DefaultedCopyAssignmentIsDeleted, 1, NO_MERGE)
 FIELD(DefaultedMoveAssignmentIsDeleted, 1, NO_MERGE)
 FIELD(DefaultedDestructorIsDeleted, 1, NO_MERGE)
 /// @}

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2b8d7e879a0a..856717fa0abb 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -712,13 +712,6 @@ class CXXRecordDecl : public RecordDecl {
!data().DefaultedMoveConstructorIsDeleted;
   }
 
-  /// \c true if we know for sure that this class has a single,
-  /// accessible, unambiguous copy assignment operator that is not deleted.
-  bool hasSimpleCopyAssignment() const {
-return !hasUserDeclaredCopyAssignment() &&
-   !data().DefaultedCopyAssignmentIsDeleted;
-  }
-
   /// \c true if we know for sure that this class has a single,
   /// accessible, unambiguous move assignment operator that is not deleted.
   bool hasSimpleMoveAssignment() const {
@@ -879,15 +872,6 @@ class CXXRecordDecl : public RecordDecl {
 return data().UserDeclaredSpecialMembers & SMF_CopyAssignment;
   }
 
-  /// Set that we attempted to declare an implicit copy assignment
-  /// operator, but overload resolution failed so we deleted it.
-  void setImplicitCopyAssignmentIsDeleted() {
-assert((data().DefaultedCopyAssignmentIsDeleted ||
-needsOverloadResolutionForCopyAssignment()) &&
-   "copy assignment should not be deleted");
-data().DefaultedCopyAssignmentIsDeleted = true;
-  }
-
   /// Determine whether this class needs an implicit copy
   /// assignment operator to be lazily declared.
   bool needsImplicitCopyAssignment() const {
@@ -897,16 +881,7 @@ class CXXRecordDecl : public RecordDecl {
   /// Determine whether we need to eagerly declare a defaulted copy
   /// assignment operator for this class.
   bool needsOverloadResolutionForCopyAssignment() const {
-// C++20 [class.copy.assign]p2:
-//   If the class definition declares a move constructor or move assignment
-//   operator, the implicitly declared copy assignment operator is defined
-//   as deleted.
-// In MSVC mode, sometimes a declared move constructor does not delete an
-// implicit copy assignment, so defer this choice to Sema.
-if (data().UserDeclaredSpecialMembers &
-(SMF_MoveConstructor | SMF_MoveAssignment))
-  return true;
-return data().NeedOverloadResolutionForCopyAssignment;
+return data().HasMutableFields;
   }
 
   /// Determine whether an implicit copy assignment operator for this

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 8b96e20e374d..a2a712e6b6ca 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -2795,7 

[clang] a1f4e48 - [clang][docs] Add note about using `-flto` with `-g` on macOS

2020-06-30 Thread Jonas Devlieghere via cfe-commits

Author: Philippe Blain
Date: 2020-06-30T09:33:20-07:00
New Revision: a1f4e48c4aca8c7339be2018926baf860a562f13

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

LOG: [clang][docs] Add note about using `-flto` with `-g` on macOS

If -Wl,object_path_lto,.o is not passed at link time
when compiling and linking in separate steps with -flto and -g, the
temporary file used for Link Time Optimization is deleted by the linker,
so the executable is missing debug symbols and can't be easily debugged,
and dsymutil can't be run.

Document this behaviour.

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

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index de0e0eda9097..5978650c3288 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -474,6 +474,16 @@ Code Generation Options
   optimization. With "thin", :doc:`ThinLTO <../ThinLTO>`
   compilation is invoked instead.
 
+  .. note::
+
+ On Darwin, when using :option:`-flto` along with :option:`-g` and
+ compiling and linking in separate steps, you also need to pass
+ ``-Wl,-object_path_lto,.o`` at the linking step to instruct 
the
+ ld64 linker not to delete the temporary object file generated during Link
+ Time Optimization (this flag is automatically passed to the linker by 
Clang
+ if compilation and linking are done in a single step). This allows 
debugging
+ the executable as well as generating the ``.dSYM`` bundle using 
:manpage:`dsymutil(1)`.
+
 Driver Options
 ~~
 



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


Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-09-19 Thread Jonas Devlieghere via cfe-commits
JDevlieghere updated this revision to Diff 71835.
JDevlieghere added a comment.
Herald added subscribers: mgorny, beanz.

Still working on comment #2 from Alex but wanted to update my diff since it's 
been a while and I haven't gotten around to looking into it further. So no need 
to review yet.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,156 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void *dest, int ch, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+void fill(ForwardIt first, ForwardIt last, const T &value);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t count);
+void *memset(void *dest, int ch, size_t count);
+
+namespace alternative_std {
+using ::memcpy;
+using ::memset;
+}
+
+namespace awful {
+void memcpy(int, int, int);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t size);
+
+void a() {
+  char foo[] = "foo", bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  alternative_std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  void *baz = bar;
+  std::memcpy(baz, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+
+  memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  alternative_std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+
+  std::fill(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof(dest))
+void c() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+}
+
+void d() {
+  typedef char foo_t;
+  typedef char bar_t;
+  foo_t foo[] = "foo";
+  bar_t bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void e() {
+  typedef const char *foo_t;
+  typedef const char *bar_t;
+  foo_t foo[] = {"foo", "bar"};
+  bar_t bar[2];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void f() {
+  typedef int some_type;
+  typedef some_type *const *volatile *foo_ptr;
+
+  typedef int *const some_other_type;
+  typedef some_other_type *volatile *bar_ptr;
+
+  foo_ptr foo[4];
+  bar_ptr bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void g() {
+  int foo[3][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}};
+  int bar[2][4];
+
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MES

[clang] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)

2023-10-27 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/70512

>From 1c6a604df93b833c3bb9c7d34f4f27415592dbe5 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Thu, 5 Oct 2023 12:39:02 -0700
Subject: [PATCH] [LLVM][DWARF] Add support for monolithic types in
 .debug_names

Enable Type Units with DWARF5 accelerator tables for monolithic DWARF.
Implementation relies on linker to tombstone offset in LocalTU list to -1 when
it deduplciates type units using COMDAT.
---
 llvm/include/llvm/CodeGen/AccelTable.h|  64 +--
 llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp| 173 --
 .../lib/CodeGen/AsmPrinter/DwarfCompileUnit.h |   2 +-
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp|  37 +++-
 llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h  |  12 +-
 llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp |   4 +
 llvm/lib/CodeGen/AsmPrinter/DwarfFile.h   |  20 ++
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp |   6 +
 llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h   |  15 ++
 llvm/lib/DWARFLinker/DWARFStreamer.cpp|  18 +-
 .../DWARFLinkerParallel/DWARFEmitterImpl.cpp  |  13 +-
 .../test/DebugInfo/X86/accel-tables-dwarf5.ll |   1 -
 .../test/DebugInfo/X86/debug-names-dwarf64.ll |   8 +-
 .../X86/debug-names-types-monolithic.ll   | 163 +
 .../DebugInfo/X86/debug-names-types-split.ll  |  57 ++
 .../ARM/dwarf5-dwarf4-combination-macho.test  |  14 +-
 16 files changed, 503 insertions(+), 104 deletions(-)
 create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll
 create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-split.ll

diff --git a/llvm/include/llvm/CodeGen/AccelTable.h 
b/llvm/include/llvm/CodeGen/AccelTable.h
index d4e21b2ac8e7ebc..d948b7d82b85979 100644
--- a/llvm/include/llvm/CodeGen/AccelTable.h
+++ b/llvm/include/llvm/CodeGen/AccelTable.h
@@ -16,7 +16,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/CodeGen/DIE.h"
@@ -104,10 +103,13 @@
 namespace llvm {
 
 class AsmPrinter;
-class DwarfCompileUnit;
+class DwarfUnit;
 class DwarfDebug;
+class DwarfTypeUnit;
 class MCSymbol;
 class raw_ostream;
+struct TypeUnitMetaInfo;
+using TUVectorTy = SmallVector;
 
 /// Interface which the different types of accelerator table data have to
 /// conform. It serves as a base class for different values of the template
@@ -197,6 +199,9 @@ template  class AccelTable : public 
AccelTableBase {
 
   template 
   void addName(DwarfStringPoolEntryRef Name, Types &&... Args);
+  void clear() { Entries.clear(); }
+  void addEntries(AccelTable &Table);
+  const StringEntries getEntries() const { return Entries; }
 };
 
 template 
@@ -250,11 +255,21 @@ class AppleAccelTableData : public AccelTableData {
 /// emitDWARF5AccelTable function.
 class DWARF5AccelTableData : public AccelTableData {
 public:
+  struct AttributeEncoding {
+dwarf::Index Index;
+dwarf::Form Form;
+  };
   static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); }
 
-  DWARF5AccelTableData(const DIE &Die, const DwarfCompileUnit &CU);
-  DWARF5AccelTableData(uint64_t DieOffset, unsigned DieTag, unsigned CUIndex)
-  : OffsetVal(DieOffset), DieTag(DieTag), UnitID(CUIndex) {}
+  DWARF5AccelTableData(const DIE &Die, const DwarfUnit &CU,
+   const bool IsTU = false);
+  DWARF5AccelTableData(const uint64_t DieOffset, const unsigned DieTag,
+   const unsigned Index, const bool IsTU = false)
+  : OffsetVal(DieOffset) {
+Data.DieTag = DieTag;
+Data.UnitID = Index;
+Data.IsTU = IsTU;
+  }
 
 #ifndef NDEBUG
   void print(raw_ostream &OS) const override;
@@ -265,18 +280,25 @@ class DWARF5AccelTableData : public AccelTableData {
"Accessing DIE Offset before normalizing.");
 return std::get(OffsetVal);
   }
-  unsigned getDieTag() const { return DieTag; }
-  unsigned getUnitID() const { return UnitID; }
+  unsigned getDieTag() const { return Data.DieTag; }
+  unsigned getUnitID() const { return Data.UnitID; }
+  bool isTU() const { return Data.IsTU; }
   void normalizeDIEToOffset() {
 assert(std::holds_alternative(OffsetVal) &&
"Accessing offset after normalizing.");
 OffsetVal = std::get(OffsetVal)->getOffset();
   }
+  bool isNormalized() const {
+return std::holds_alternative(OffsetVal);
+  }
 
 protected:
   std::variant OffsetVal;
-  unsigned DieTag;
-  unsigned UnitID;
+  struct MetaData {
+uint32_t DieTag : 16;
+uint32_t UnitID : 15;
+uint32_t IsTU : 1;
+  } Data;
 
   uint64_t order() const override { return getDieOffset(); }
 };
@@ -288,7 +310,19 @@ class DWARF5AccelTable : public 
AccelTable {
   void convertDieToOffset() {
 for (auto &Entry : Entries) {
   for (AccelTableData *Value : Entry.second.Values) {
-static_cast(Value)->norma

[clang] [mlir] [llvm] [compiler-rt] [lldb] [clang-tools-extra] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-06 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/77216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [compiler-rt] [llvm] [mlir] [clang-tools-extra] [clang] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-06 Thread Jonas Devlieghere via cfe-commits


@@ -108,13 +108,9 @@ else()
   linux/HostInfoLinux.cpp
   linux/LibcGlue.cpp
   linux/Support.cpp
+  android/HostInfoAndroid.cpp
+  android/LibcGlue.cpp
   )
-if (CMAKE_SYSTEM_NAME MATCHES "Android")

JDevlieghere wrote:

While Android might be Linux, the inverse isn't true. Amongst other things, 
this change would result in all Linux hosts reporting that they support Android 
triples. 

https://github.com/llvm/llvm-project/pull/77216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [clang-tools-extra] [compiler-rt] [mlir] [llvm] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-06 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/77216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang-tools-extra] [lldb] [clang] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)

2024-01-08 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere approved this pull request.


https://github.com/llvm/llvm-project/pull/73067
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f51d7e4 - Fix the implicit module build

2022-03-14 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2022-03-14T09:24:17-07:00
New Revision: f51d7e4bae9e861e711ad9711599456fc2f1bbca

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

LOG: Fix the implicit module build

This fixes the implicit module build after b1b4b6f36695 broke the LLDB
build: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/42084/

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsVE.def
llvm/include/llvm/CodeGen/MachinePipeliner.h

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsVE.def 
b/clang/include/clang/Basic/BuiltinsVE.def
index 1cb5250893819..29b2bd203ef0f 100644
--- a/clang/include/clang/Basic/BuiltinsVE.def
+++ b/clang/include/clang/Basic/BuiltinsVE.def
@@ -11,7 +11,12 @@
 //
 
//===--===//
 
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // Use generated BUILTIN definitions
 #include "clang/Basic/BuiltinsVEVL.gen.def"
 
 #undef BUILTIN
+#undef TARGET_BUILTIN

diff  --git a/llvm/include/llvm/CodeGen/MachinePipeliner.h 
b/llvm/include/llvm/CodeGen/MachinePipeliner.h
index 7e7fa57d80da6..63024562bd2d3 100644
--- a/llvm/include/llvm/CodeGen/MachinePipeliner.h
+++ b/llvm/include/llvm/CodeGen/MachinePipeliner.h
@@ -40,6 +40,7 @@
 #ifndef LLVM_CODEGEN_MACHINEPIPELINER_H
 #define LLVM_CODEGEN_MACHINEPIPELINER_H
 
+#include "llvm/ADT/SetVector.h"
 #include "llvm/CodeGen/MachineDominators.h"
 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
 #include "llvm/CodeGen/RegisterClassInfo.h"



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


[clang] df6fcef - Fix the implicit module build (2/2)

2022-03-14 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2022-03-14T09:43:13-07:00
New Revision: df6fcef2b8330afd08a3c76e6a01cb5ada6b1aa9

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

LOG: Fix the implicit module build (2/2)

This fixes the implicit module build after b1b4b6f36695 broke the LLDB
build: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/42084/

My previous commit didn't have the modulemap change staged.

Added: 


Modified: 
clang/include/clang/module.modulemap

Removed: 




diff  --git a/clang/include/clang/module.modulemap 
b/clang/include/clang/module.modulemap
index 981f32aa25a10..aca4d5ab919a0 100644
--- a/clang/include/clang/module.modulemap
+++ b/clang/include/clang/module.modulemap
@@ -51,6 +51,7 @@ module Clang_Basic {
   textual header "Basic/BuiltinsSVE.def"
   textual header "Basic/BuiltinsSystemZ.def"
   textual header "Basic/BuiltinsVE.def"
+  textual header "Basic/BuiltinsVEVL.gen.def"
   textual header "Basic/BuiltinsWebAssembly.def"
   textual header "Basic/BuiltinsX86.def"
   textual header "Basic/BuiltinsX86_64.def"



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


[clang] c7fd751 - Revert "[C++20][Modules] Update handling of implicit inlines [P1779R3]"

2022-07-11 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2022-07-11T13:59:41-07:00
New Revision: c7fd7512a5c5b133665bfecbe2e9748c0607286e

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

LOG: Revert "[C++20][Modules] Update handling of implicit inlines [P1779R3]"

This reverts commit ef0fa9f0ef3e as a follow up to b19d3ee7120b which
reverted commit ac507102d258. See https://reviews.llvm.org/D126189 for
more details.

Added: 


Modified: 
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/AST/ast-dump-constant-expr.cpp
clang/test/AST/ast-dump-lambda.cpp

Removed: 
clang/test/CXX/class/class.friend/p7-cxx20.cpp
clang/test/CXX/class/class.mfct/p1-cxx20.cpp



diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 22643d4edbecb..79e9fa6ab86fc 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1720,9 +1720,6 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl 
*D) {
 }
   }
 
-  if (!D->isInlineSpecified() && D->isInlined()) {
-OS << " implicit-inline";
-  }
   // Since NumParams comes from the FunctionProtoType of the FunctionDecl and
   // the Params are set later, it is possible for a dump during debugging to
   // encounter a FunctionDecl that has been created but hasn't been assigned

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c5005accc6961..927d81826425b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9405,25 +9405,15 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
 NewFD->setLocalExternDecl();
 
   if (getLangOpts().CPlusPlus) {
-// The rules for implicit inlines changed in C++20 for methods and friends
-// with an in-class definition (when such a definition is not attached to
-// the global module).  User-specified 'inline' overrides this (set when
-// the function decl is created above).
-bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlus20 ||
-   !NewFD->getOwningModule() ||
-   NewFD->getOwningModule()->isGlobalModule();
 bool isInline = D.getDeclSpec().isInlineSpecified();
 bool isVirtual = D.getDeclSpec().isVirtualSpecified();
 bool hasExplicit = D.getDeclSpec().hasExplicitSpecifier();
 isFriend = D.getDeclSpec().isFriendSpecified();
 if (isFriend && !isInline && D.isFunctionDefinition()) {
-  // Pre-C++20 [class.friend]p5
+  // C++ [class.friend]p5
   //   A function can be defined in a friend declaration of a
   //   class . . . . Such a function is implicitly inline.
-  // Post C++20 [class.friend]p7
-  //   Such a function is implicitly an inline function if it is attached
-  //   to the global module.
-  NewFD->setImplicitlyInline(ImplicitInlineCXX20);
+  NewFD->setImplicitlyInline();
 }
 
 // If this is a method defined in an __interface, and is not a constructor
@@ -9706,14 +9696,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
 }
 
 if (isa(NewFD) && DC == CurContext &&
-D.isFunctionDefinition() && !isInline) {
-  // Pre C++20 [class.mfct]p2:
+D.isFunctionDefinition()) {
+  // C++ [class.mfct]p2:
   //   A member function may be defined (8.4) in its class definition, in
   //   which case it is an inline member function (7.1.2)
-  // Post C++20 [class.mfct]p1:
-  //   If a member function is attached to the global module and is defined
-  //   in its class definition, it is inline.
-  NewFD->setImplicitlyInline(ImplicitInlineCXX20);
+  NewFD->setImplicitlyInline();
 }
 
 if (SC == SC_Static && isa(NewFD) &&

diff  --git a/clang/test/AST/ast-dump-constant-expr.cpp 
b/clang/test/AST/ast-dump-constant-expr.cpp
index 302f562eadd96..79cdfc639af5b 100644
--- a/clang/test/AST/ast-dump-constant-expr.cpp
+++ b/clang/test/AST/ast-dump-constant-expr.cpp
@@ -58,7 +58,7 @@ struct Test {
 
 // CHECK:Dumping Test:
 // CHECK-NEXT:CXXRecordDecl {{.*}} <{{.*}}ast-dump-constant-expr.cpp:43:1, 
line:57:1> line:43:8 struct Test definition
-// CHECK:|-CXXMethodDecl {{.*}}  line:44:8 test 'void 
()' implicit-inline
+// CHECK:|-CXXMethodDecl {{.*}}  line:44:8 test 'void ()'
 // CHECK-NEXT:| `-CompoundStmt {{.*}} 
 // CHECK-NEXT:|   |-CStyleCastExpr {{.*}}  'void' 
 // CHECK-NEXT:|   | `-ConstantExpr {{.*}}  'int'
@@ -90,4 +90,4 @@ struct Test {
 // CHECK-NEXT:|   `-CallExpr {{.*}}  '__int128'
 // CHECK-NEXT:| `-ImplicitCastExpr {{.*}}  '__int128 (*)()' 

 // CHECK-NEXT:|   `-DeclRefExpr {{.*}}  '__int128 ()' lvalue 
Function {{.*}} 'test_Int128' '__int128 ()'
-// CHECK-NEXT:`-CXXMethodDecl {{.*}}  col:18 consteval 
consteval_method 'vo

[clang] a262f4d - Revert "[Clang] Add a warning on invalid UTF-8 in comments."

2022-07-12 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2022-07-12T15:22:29-07:00
New Revision: a262f4dbd78fc68609d230f3e9c5ca2b1d1d9437

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

LOG: Revert "[Clang] Add a warning on invalid UTF-8 in comments."

This reverts commit cc309721d20c8e544ae7a10a66735ccf4981a11c because it
breaks the following tests on GreenDragon:

  TestDataFormatterObjCCF.py
  TestDataFormatterObjCExpr.py
  TestDataFormatterObjCKVO.py
  TestDataFormatterObjCNSBundle.py
  TestDataFormatterObjCNSData.py
  TestDataFormatterObjCNSError.py
  TestDataFormatterObjCNSNumber.py
  TestDataFormatterObjCNSURL.py
  TestDataFormatterObjCPlain.py
  TestDataFormatterObjNSException.py

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45288/

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/Lexer.cpp
clang/test/SemaCXX/static-assert.cpp
llvm/include/llvm/Support/ConvertUTF.h
llvm/lib/Support/ConvertUTF.cpp

Removed: 
clang/test/Lexer/comment-invalid-utf8.c
clang/test/Lexer/comment-utf8.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f8977d5ac720b..e09a4a7c91b78 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -284,11 +284,9 @@ Improvements to Clang's diagnostics
   unevaluated operands of a ``typeid`` expression, as they are now
   modeled correctly in the CFG. This fixes
   `Issue 21668 `_.
-- ``-Wself-assign``, ``-Wself-assign-overloaded`` and ``-Wself-move`` will
+- ``-Wself-assign``, ``-Wself-assign-overloaded`` and ``-Wself-move`` will 
   suggest a fix if the decl being assigned is a parameter that shadows a data
   member of the contained class.
-- Added ``-Winvalid-utf8`` which diagnoses invalid UTF-8 code unit sequences in
-  comments.
 
 Non-comprehensive list of changes in this release
 -
@@ -615,7 +613,7 @@ AST Matchers
 
 - Added ``forEachTemplateArgument`` matcher which creates a match every
   time a ``templateArgument`` matches the matcher supplied to it.
-
+  
 - Added ``objcStringLiteral`` matcher which matches ObjectiveC String
   literal expressions.
 

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 38ee022e5f04c..ac86076140c58 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -113,8 +113,6 @@ def warn_four_char_character_literal : Warning<
 // Unicode and UCNs
 def err_invalid_utf8 : Error<
   "source file is not valid UTF-8">;
-def warn_invalid_utf8_in_comment : Extension<
-  "invalid UTF-8 in comment">, InGroup>;
 def err_character_not_allowed : Error<
   "unexpected character ">;
 def err_character_not_allowed_identifier : Error<

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 221ec2721fe00..6820057642bea 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2392,37 +2392,13 @@ bool Lexer::SkipLineComment(Token &Result, const char 
*CurPtr,
   //
   // This loop terminates with CurPtr pointing at the newline (or end of 
buffer)
   // character that ends the line comment.
-
-  // C++23 [lex.phases] p1
-  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
-  // diagnostic only once per entire ill-formed subsequence to avoid
-  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
-  bool UnicodeDecodingAlreadyDiagnosed = false;
-
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (isASCII(C) && C != 0 &&   // Potentially EOF.
-   C != '\n' && C != '\r') { // Newline or DOS-style newline.
+while (C != 0 &&// Potentially EOF.
+   C != '\n' && C != '\r')  // Newline or DOS-style newline.
   C = *++CurPtr;
-  UnicodeDecodingAlreadyDiagnosed = false;
-}
-
-if (!isASCII(C)) {
-  unsigned Length = llvm::getUTF8SequenceSize(
-  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
-  if (Length == 0) {
-if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
-  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
-UnicodeDecodingAlreadyDiagnosed = true;
-++CurPtr;
-  } else {
-UnicodeDecodingAlreadyDiagnosed = false;
-CurPtr += Length;
-  }
-  continue;
-}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2689,12 +2665,6 @@ bool Lexer::SkipBlockComment(Token &Result, const char 
*CurPtr,
   if (C == '/')
 C = *CurPtr++;
 
-  // C++23 [lex.phases] p1
-  // Diagnose invalid UTF-8 if the corresponding warn

[clang] [clang] Upstream visionOS Availability & DarwinSDKInfo APIs (PR #84279)

2024-03-07 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/84279
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [flang] [clang] [libc] [lldb] [clang-tools-extra] [llvm] LLDB Debuginfod usage tests (with fixes) (PR #79181)

2024-01-26 Thread Jonas Devlieghere via cfe-commits


@@ -0,0 +1,65 @@
+# Tests for basic Debuginfod functionality
+
+Because the Debuginfod protocol is a simple HTTP path-based system, one can
+mimic a Debuginfod server by setting up a directory structure to reflect the
+protocol properly. That's how all these tests operate. We override the default
+`DEBUGINFOD_URLS` property with a `file://` URL and populate it with the symbol
+files we need for testing.
+
+## What's being tested
+
+- For assumption validation, the `*-no-locator` tests verify that lldb works as
+  the test expects when files that Debuginfod should provide (`.dwp` files,
+  `.gnu.debuglink`'ed files, etc...) are _already_ there.
+- The `*-negative` tests validate that symbols _aren't_ found without
+  Debuginfod, to ensure they haven't been cached from previous runs (in the
+  hopes of preventing false positive testing).
+- The `*-positive*` tests check that the Debuginfod symbol locator is providing
+  the expected symbols when the debugger doesn't already have them available.
+
+### Symbol file variations tested
+
+There are 5 variations of symbol data where Debuginfod provides value:
+
+1. The `strip` build variation is a binary built with debug information (`-g`),
+   but stripped for deployment. The Debuginfod service can then host the
+   unstripped binary (as either `executable` or `debuginfo`).
+2. The `okdstrip` build variation is a binary build with `-g`, stripped for
+   deployment, where the Debuginfod service is hosting the output of
+   `objcopy --only-keep-debug` (which should also be linked to the stripped 
file
+   using `--add-gnu-debuglink`). Again, the file could be hosted as either
+   `executable` or `debuginfo`.
+3. The `split` build variation is a binary built with `-gsplit-dwarf` that
+   produces `.dwo` which are subsequently linked together (using `llvm-dwp`)
+   into a single `.dwp` file. The Debuginfod service hosts the `.dwp` file as
+   `debuginfo`.
+4. The `split-strip` build variation is a binary built with `-gsplit-dwarf`,
+   then stripped in the same manner as variation #1. For this variation,
+   Debuginfod hosts the unstripped binary as `executable` and the `.dwp` file 
as
+   `debuginfo`.
+5. The `split-okdstrip` build variation is the combination of variations 2 and
+   3, where Debuginfod hosts the `.gnu.debuglink`'ed file as `executable` and
+   the `.dwp` as `debuginfo`.
+
+### Lack of clarity/messy capabilities from Debuginfod
+
+The [debuginfod protocol](https://sourceware.org/elfutils/Debuginfod.html) is
+underspecified for some variations of symbol file deployment. The protocol
+itself is quite simple: query an HTTP server with the path
+`buildid/{.note.gnu.build-id hash}/debuginfo` or
+`buildid/{.note.gnu.build-id hash}/executable` to acquire "symbol data" or "the
+executable". Where there is lack of clarity, I prefer requesting `debuginfo`
+first, then falling back to `executable` (Scenarios #1 & #2). For Scenario #5,
+I've chosen to expect the stripped (i.e. not full) executable, which contains a
+number of sections necessary to correctly symbolicate will be hosted from the
+`executable` API. Depending upon how Debuginfod hosting services choose to
+support `.dwp` paired with stripped files, these assumptions may need to be
+revisited.
+
+I've also chosen to simply treat the `.dwp` file as `debuginfo` and the
+"only-keep-debug" stripped binary as `executable`. This scenario doesn't appear
+to work at all in GDB. Supporting it how I did seems more straight forward than
+trying to extend the protocol. The protocol _does_ support querying for section
+contents by name for a given build ID, but adding support for that in LLDB
+looks...well beyond my current capability (and LLVM's Debuginfod library 
doesn't
+support it at this writing, anyway).

JDevlieghere wrote:

Most of this document is written in a passive voice. Let's do the same for this 
section or use "we" (i.e. the developers) instead of "I". 

https://github.com/llvm/llvm-project/pull/79181
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [clang] [flang] [libc] [llvm] [clang-tools-extra] [compiler-rt] LLDB Debuginfod usage tests (with fixes) (PR #79181)

2024-01-26 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/79181
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [clang-tools-extra] [compiler-rt] [llvm] [clang] [flang] [libc] LLDB Debuginfod usage tests (with fixes) (PR #79181)

2024-01-26 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere commented:

I'm wondering if shell test are really the best way to test this. For more 
complex scenarios like are being tested here, we generally prefer [1] API tests 
because they're more expressive and allow you to build more complicated test 
binaries with our Makefile system. Things like stripping a binary and 
generating split DWARF all seems like things that could be done that way, to 
avoid checking in a (yaml-ized) binary. 

Did you consider/evaluate writing API tests for this? 

[1] https://lldb.llvm.org/resources/test.html



https://github.com/llvm/llvm-project/pull/79181
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Upstream XROS support in Clang (PR #78392)

2024-01-16 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/78392

Upstream XROS support in the clang frontend and driver.

>From 1e65420f87eed1f7f4380496f96eef2560a15cb0 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 16 Jan 2024 20:36:47 -0800
Subject: [PATCH] [clang] Upstream XROS support in Clang

Upstream XROS support in the clang frontend and driver.
---
 clang/lib/Basic/Targets/OSTargets.h   |  6 ++-
 clang/lib/CodeGen/CGObjC.cpp  |  5 ++
 clang/lib/Driver/Driver.cpp   |  1 +
 clang/lib/Driver/ToolChains/Arch/AArch64.cpp  |  5 ++
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  5 +-
 clang/lib/Driver/ToolChains/Darwin.cpp| 49 +--
 clang/lib/Driver/ToolChains/Darwin.h  | 14 +-
 .../Checkers/CheckSecuritySyntaxOnly.cpp  |  2 +
 clang/test/Driver/xros-driver.c   | 41 
 clang/test/Frontend/xros-version.c|  3 ++
 10 files changed, 124 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Driver/xros-driver.c
 create mode 100644 clang/test/Frontend/xros-version.c

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7bc..4366c1149e40530 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -74,7 +74,8 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public 
OSTargetInfo {
 this->TLSSupported = !Triple.isOSVersionLT(3);
 } else if (Triple.isDriverKit()) {
   // No TLS on DriverKit.
-}
+} else if (Triple.isXROS())
+  this->TLSSupported = true;
 
 this->MCountName = "\01mcount";
   }
@@ -109,6 +110,9 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::WatchOS: // Earliest supporting version is 5.0.0.
   MinVersion = llvm::VersionTuple(5U);
   break;
+case llvm::Triple::XROS:
+  MinVersion = llvm::VersionTuple(0);
+  break;
 default:
   // Conservatively return 8 bytes if OS is unknown.
   return 64;
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index acc85165a470be7..03fc0ec7ff54e1c 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -3941,6 +3941,8 @@ static unsigned getBaseMachOPlatformID(const llvm::Triple 
&TT) {
 return llvm::MachO::PLATFORM_TVOS;
   case llvm::Triple::WatchOS:
 return llvm::MachO::PLATFORM_WATCHOS;
+  case llvm::Triple::XROS:
+return llvm::MachO::PLATFORM_XROS;
   case llvm::Triple::DriverKit:
 return llvm::MachO::PLATFORM_DRIVERKIT;
   default:
@@ -4024,6 +4026,9 @@ static bool isFoundationNeededForDarwinAvailabilityCheck(
   case llvm::Triple::MacOSX:
 FoundationDroppedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/15);
 break;
+  case llvm::Triple::XROS:
+// XROS doesn't need Foundation.
+return false;
   case llvm::Triple::DriverKit:
 // DriverKit doesn't need Foundation.
 return false;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 1889ea28079df10..35d563b9a87fac4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6213,6 +6213,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
+case llvm::Triple::XROS:
 case llvm::Triple::DriverKit:
   TC = std::make_unique(*this, Target, Args);
   break;
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 912df79417ae21e..e73ffcfa4e343af 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -53,6 +53,11 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
 return "apple-m1";
   }
 
+  if (Triple.isXROS()) {
+// The xrOS simulator runs on M1 as well, it should have been covered 
above.
+assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like");
+return "apple-a12";
+  }
   // arm64e requires v8.3a and only runs on apple-a12 and later CPUs.
   if (Triple.isArm64e())
 return "apple-a12";
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 25470db2b6cebd7..e6ee2f88a84edf2 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -367,6 +367,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple 
&Triple) {
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llvm::Triple::DriverKit:
+  case llvm::Triple::XROS:
 // Darwin defaults to "softfp" for v6 and v7.
 if (Triple.isWatchABI())
   return FloatABI::Hard;
@@ -836,8 +837,8 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
 if (A->getOption().matches(options::OPT_mlong_calls))
   Features.push_back("+long-calls");
   } else if (KernelOrKext && (!Triple.is

[lldb] [clang] [clang] Upstream XROS support in Clang (PR #78392)

2024-01-17 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/78392

>From 6f6d93b6cc413d54dbdec05f30ede00ffdb4 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 10 Jan 2024 17:35:47 -0800
Subject: [PATCH 1/2] [lldb] Upstream xros support in lldb

Upstream support for debugging xros applications through LLDB.
---
 lldb/include/lldb/Utility/XcodeSDK.h  |   2 +
 .../Host/macosx/objcxx/HostInfoMacOSX.mm  |   3 +
 .../DynamicLoaderDarwinKernel.cpp |   1 +
 .../MacOSX-DYLD/DynamicLoaderMacOS.cpp|   1 +
 .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp   |   1 +
 .../Instruction/ARM/EmulateInstructionARM.cpp |   1 +
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp |  11 +-
 .../Plugins/Platform/MacOSX/CMakeLists.txt|   1 +
 .../MacOSX/PlatformAppleSimulator.cpp |  37 +
 .../Platform/MacOSX/PlatformDarwin.cpp|  17 +-
 .../Platform/MacOSX/PlatformMacOSX.cpp|   3 +
 .../Platform/MacOSX/PlatformRemoteAppleXR.cpp | 157 ++
 .../Platform/MacOSX/PlatformRemoteAppleXR.h   |  38 +
 ...PlatformiOSSimulatorCoreSimulatorSupport.h |   3 +-
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |   1 +
 .../GDBRemoteCommunicationClient.cpp  |   3 +-
 .../MacOSX/SystemRuntimeMacOSX.cpp|   1 +
 lldb/source/Utility/XcodeSDK.cpp  |  23 +++
 .../debugserver/source/MacOSX/MachProcess.mm  |  12 ++
 lldb/tools/debugserver/source/RNBRemote.cpp   |  11 +-
 lldb/unittests/Utility/XcodeSDKTest.cpp   |  22 +++
 21 files changed, 340 insertions(+), 9 deletions(-)
 create mode 100644 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.cpp
 create mode 100644 lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.h

diff --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index f8528995d549c9..673ea578ffce85 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -34,6 +34,8 @@ class XcodeSDK {
 AppleTVOS,
 WatchSimulator,
 watchOS,
+XRSimulator,
+XROS,
 bridgeOS,
 Linux,
 unknown = -1
diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 110a01732b2473..f96e2cf80c5fac 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -276,6 +276,9 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 #elif defined(TARGET_OS_WATCHOS) && TARGET_OS_WATCHOS == 1
 arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
 arch_64.GetTriple().setOS(llvm::Triple::WatchOS);
+#elif defined(TARGET_OS_XR) && TARGET_OS_XR == 1
+arch_32.GetTriple().setOS(llvm::Triple::XROS);
+arch_64.GetTriple().setOS(llvm::Triple::XROS);
 #elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
 arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
 arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
diff --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 7df917d03ceeda..4128ac1cdf1bba 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -166,6 +166,7 @@ DynamicLoader 
*DynamicLoaderDarwinKernel::CreateInstance(Process *process,
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
+case llvm::Triple::XROS:
 // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
   if (triple_ref.getVendor() != llvm::Triple::Apple) {
 return nullptr;
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 4451d8c7689a28..261592558095b4 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -55,6 +55,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process 
*process,
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llvm::Triple::WatchOS:
+  case llvm::Triple::XROS:
   // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
 create = triple_ref.getVendor() == llvm::Triple::Apple;
 break;
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 0bd465aba2d8a2..7e589b0d7af2c7 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -75,6 +75,7 @@ DynamicLoader 
*DynamicLoaderMacOSXDYLD::CreateInstance(Process *process,
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case

[clang] [clang] Upstream XROS support in Clang (PR #78392)

2024-01-17 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/78392

>From d7c431e0fbc0ad006b9d37a4e3a43c61ce1f50b7 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 16 Jan 2024 20:36:47 -0800
Subject: [PATCH] [clang] Upstream XROS support in Clang

Upstream XROS support in the clang frontend and driver.
---
 clang/lib/Basic/Targets/OSTargets.h   |  6 +-
 clang/lib/CodeGen/CGObjC.cpp  |  5 ++
 clang/lib/Driver/Driver.cpp   |  1 +
 clang/lib/Driver/ToolChains/Arch/AArch64.cpp  |  5 ++
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  5 +-
 clang/lib/Driver/ToolChains/Darwin.cpp| 56 ++-
 clang/lib/Driver/ToolChains/Darwin.h  | 14 -
 .../Checkers/CheckSecuritySyntaxOnly.cpp  |  2 +
 clang/test/Driver/xros-driver.c   | 41 ++
 clang/test/Frontend/xros-version.c|  3 +
 10 files changed, 131 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Driver/xros-driver.c
 create mode 100644 clang/test/Frontend/xros-version.c

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7bc..4366c1149e40530 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -74,7 +74,8 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public 
OSTargetInfo {
 this->TLSSupported = !Triple.isOSVersionLT(3);
 } else if (Triple.isDriverKit()) {
   // No TLS on DriverKit.
-}
+} else if (Triple.isXROS())
+  this->TLSSupported = true;
 
 this->MCountName = "\01mcount";
   }
@@ -109,6 +110,9 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::WatchOS: // Earliest supporting version is 5.0.0.
   MinVersion = llvm::VersionTuple(5U);
   break;
+case llvm::Triple::XROS:
+  MinVersion = llvm::VersionTuple(0);
+  break;
 default:
   // Conservatively return 8 bytes if OS is unknown.
   return 64;
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index acc85165a470be7..03fc0ec7ff54e1c 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -3941,6 +3941,8 @@ static unsigned getBaseMachOPlatformID(const llvm::Triple 
&TT) {
 return llvm::MachO::PLATFORM_TVOS;
   case llvm::Triple::WatchOS:
 return llvm::MachO::PLATFORM_WATCHOS;
+  case llvm::Triple::XROS:
+return llvm::MachO::PLATFORM_XROS;
   case llvm::Triple::DriverKit:
 return llvm::MachO::PLATFORM_DRIVERKIT;
   default:
@@ -4024,6 +4026,9 @@ static bool isFoundationNeededForDarwinAvailabilityCheck(
   case llvm::Triple::MacOSX:
 FoundationDroppedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/15);
 break;
+  case llvm::Triple::XROS:
+// XROS doesn't need Foundation.
+return false;
   case llvm::Triple::DriverKit:
 // DriverKit doesn't need Foundation.
 return false;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 1889ea28079df10..35d563b9a87fac4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6213,6 +6213,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
+case llvm::Triple::XROS:
 case llvm::Triple::DriverKit:
   TC = std::make_unique(*this, Target, Args);
   break;
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 85f053dc8b6eab7..0cf96bb5c9cb02b 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -53,6 +53,11 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
 return "apple-m1";
   }
 
+  if (Triple.isXROS()) {
+// The xrOS simulator runs on M1 as well, it should have been covered 
above.
+assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like");
+return "apple-a12";
+  }
   // arm64e requires v8.3a and only runs on apple-a12 and later CPUs.
   if (Triple.isArm64e())
 return "apple-a12";
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 25470db2b6cebd7..e6ee2f88a84edf2 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -367,6 +367,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple 
&Triple) {
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llvm::Triple::DriverKit:
+  case llvm::Triple::XROS:
 // Darwin defaults to "softfp" for v6 and v7.
 if (Triple.isWatchABI())
   return FloatABI::Hard;
@@ -836,8 +837,8 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
 if (A->getOption().matches(options::OPT_mlong_calls))
   Features.push_back("+long-calls");
   } else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
- !Triple.isW

[clang] [clang] Upstream XROS support in Clang (PR #78392)

2024-01-17 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/78392

>From 52ff81ffbce596fd89b296e7f4199be13f9402ff Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 16 Jan 2024 20:36:47 -0800
Subject: [PATCH 1/2] [clang] Upstream XROS support in Clang

Upstream XROS support in the clang frontend and driver.
---
 clang/lib/Basic/Targets/OSTargets.h   |  6 +-
 clang/lib/CodeGen/CGObjC.cpp  |  5 ++
 clang/lib/Driver/Driver.cpp   |  1 +
 clang/lib/Driver/ToolChains/Arch/AArch64.cpp  |  5 ++
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  5 +-
 clang/lib/Driver/ToolChains/Darwin.cpp| 56 ++-
 clang/lib/Driver/ToolChains/Darwin.h  | 14 -
 .../Checkers/CheckSecuritySyntaxOnly.cpp  |  2 +
 clang/test/Driver/xros-driver.c   | 41 ++
 clang/test/Frontend/xros-version.c|  3 +
 10 files changed, 131 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Driver/xros-driver.c
 create mode 100644 clang/test/Frontend/xros-version.c

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..4366c1149e4053 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -74,7 +74,8 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public 
OSTargetInfo {
 this->TLSSupported = !Triple.isOSVersionLT(3);
 } else if (Triple.isDriverKit()) {
   // No TLS on DriverKit.
-}
+} else if (Triple.isXROS())
+  this->TLSSupported = true;
 
 this->MCountName = "\01mcount";
   }
@@ -109,6 +110,9 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::WatchOS: // Earliest supporting version is 5.0.0.
   MinVersion = llvm::VersionTuple(5U);
   break;
+case llvm::Triple::XROS:
+  MinVersion = llvm::VersionTuple(0);
+  break;
 default:
   // Conservatively return 8 bytes if OS is unknown.
   return 64;
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index acc85165a470be..03fc0ec7ff54e1 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -3941,6 +3941,8 @@ static unsigned getBaseMachOPlatformID(const llvm::Triple 
&TT) {
 return llvm::MachO::PLATFORM_TVOS;
   case llvm::Triple::WatchOS:
 return llvm::MachO::PLATFORM_WATCHOS;
+  case llvm::Triple::XROS:
+return llvm::MachO::PLATFORM_XROS;
   case llvm::Triple::DriverKit:
 return llvm::MachO::PLATFORM_DRIVERKIT;
   default:
@@ -4024,6 +4026,9 @@ static bool isFoundationNeededForDarwinAvailabilityCheck(
   case llvm::Triple::MacOSX:
 FoundationDroppedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/15);
 break;
+  case llvm::Triple::XROS:
+// XROS doesn't need Foundation.
+return false;
   case llvm::Triple::DriverKit:
 // DriverKit doesn't need Foundation.
 return false;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 1889ea28079df1..35d563b9a87fac 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6213,6 +6213,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
+case llvm::Triple::XROS:
 case llvm::Triple::DriverKit:
   TC = std::make_unique(*this, Target, Args);
   break;
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 85f053dc8b6eab..0cf96bb5c9cb02 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -53,6 +53,11 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
 return "apple-m1";
   }
 
+  if (Triple.isXROS()) {
+// The xrOS simulator runs on M1 as well, it should have been covered 
above.
+assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like");
+return "apple-a12";
+  }
   // arm64e requires v8.3a and only runs on apple-a12 and later CPUs.
   if (Triple.isArm64e())
 return "apple-a12";
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 25470db2b6cebd..e6ee2f88a84edf 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -367,6 +367,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple 
&Triple) {
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llvm::Triple::DriverKit:
+  case llvm::Triple::XROS:
 // Darwin defaults to "softfp" for v6 and v7.
 if (Triple.isWatchABI())
   return FloatABI::Hard;
@@ -836,8 +837,8 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
 if (A->getOption().matches(options::OPT_mlong_calls))
   Features.push_back("+long-calls");
   } else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
- !Triple.isWatchOS

[flang] [llvm] [compiler-rt] [lldb] [clang] [libcxx] [mlir] [lld] [clang-tools-extra] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. (PR #77932)

2024-01-17 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/77932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [lldb] [lld] [libcxx] [mlir] [compiler-rt] [clang-tools-extra] [llvm] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. (PR #77932)

2024-01-17 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere approved this pull request.

Before this patch, the DWARFLinker was the one responsible for creating the 
streamer, which meant that both the classic and parallel implementation needed 
to conform to the same interface. After this patch, the concrete 
implementations instantiate their own streamer, which means that the classic 
linker can support the Swift sections while the parallel implementation can 
ignore them for now. 

Makes sense to me. LGTM! 

https://github.com/llvm/llvm-project/pull/77932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [clang-tools-extra] [flang] [llvm] [lldb] [mlir] [clang] [lld] [libcxx] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. (PR #77932)

2024-01-17 Thread Jonas Devlieghere via cfe-commits


@@ -30,6 +30,20 @@ using namespace llvm;
 using namespace dwarf_linker;
 using namespace dwarf_linker::classic;
 
+Expected> DwarfStreamer::createStreamer(
+const Triple &TheTriple, DWARFLinkerBase::OutputFileType FileType,
+raw_pwrite_stream &OutFile, DWARFLinkerBase::TranslatorFuncTy Translator,
+DWARFLinkerBase::MessageHandlerTy Warning) {
+  DwarfStreamer *Streamer =
+  new DwarfStreamer(FileType, OutFile, Translator, Warning);
+  if (Error Err = Streamer->init(TheTriple, "__DWARF")) {
+delete Streamer;
+return std::move(Err);
+  }
+
+  return std::unique_ptr(Streamer);

JDevlieghere wrote:

Can we use `make_unique` above and avoid the naked `delete`? 

https://github.com/llvm/llvm-project/pull/77932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Upstream XROS support in Clang (PR #78392)

2024-01-17 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/78392
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fc53bd6 - [clang] Replace call to private ctor with ElementCount::getScalable

2020-08-19 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-08-19T09:35:08-07:00
New Revision: fc53bd610ff95d2824617095bcf4976035b4cb9a

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

LOG: [clang] Replace call to private ctor with ElementCount::getScalable

Update the code for D86120 which made the constructors of `ElementCount`
private.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c51629ecfd53..48ed637e737b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3714,7 +3714,7 @@ QualType ASTContext::getIncompleteArrayType(QualType 
elementType,
 ASTContext::BuiltinVectorTypeInfo
 ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
 #define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS)  
\
-  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount(ELTS, true),
\
+  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), 
\
NUMVECTORS};
 
 #define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) 
\



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


[clang] 6b742cc - [clang] Replace call to private ctor with ElementCount::getScalable (2/2)

2020-08-19 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-08-19T09:40:46-07:00
New Revision: 6b742cc48d91f35bfa98844d5add3655f33f8326

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

LOG: [clang] Replace call to private ctor with ElementCount::getScalable (2/2)

Update the code for D86120 which made the constructors of `ElementCount`
private. Apparently I missed another instance in the macro just below.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 48ed637e737b..a9cab40247df 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3718,7 +3718,7 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType 
*Ty) const {
NUMVECTORS};
 
 #define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) 
\
-  {ELTTY, llvm::ElementCount(ELTS, true), NUMVECTORS};
+  {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS};
 
   switch (Ty->getKind()) {
   default:



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


[clang] ba2dff0 - Revert "PR47792: Include the type of a pointer or reference non-type template"

2020-10-11 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-10-11T20:16:46-07:00
New Revision: ba2dff0159fcd1d2349bc610331914618ca9bc30

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

LOG: Revert "PR47792: Include the type of a pointer or reference non-type 
template"

This reverts commit 849c60541b630ddf8cabf9179fa771b3f4207ec8 because it
results in a stage 2 build failure:

llvm-project/clang/include/clang/AST/ExternalASTSource.h:409:20: error:
definition with same mangled name
'_ZN5clang25LazyGenerationalUpdatePtrIPKNS_4DeclEPS1_XadL_ZNS_17ExternalASTSource19CompleteRedeclChainES3_EEE9makeValueERKNS_10ASTContextES4_'
as another definition

  static ValueType makeValue(const ASTContext &Ctx, T Value);

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/AST/TemplateBase.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7c96038629fb..a82d95461bb9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5890,7 +5890,7 @@ ASTContext::getCanonicalTemplateArgument(const 
TemplateArgument &Arg) const {
 
 case TemplateArgument::Declaration: {
   auto *D = cast(Arg.getAsDecl()->getCanonicalDecl());
-  return TemplateArgument(D, getCanonicalType(Arg.getParamTypeForDecl()));
+  return TemplateArgument(D, Arg.getParamTypeForDecl());
 }
 
 case TemplateArgument::NullPtr:

diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index e4303fdb7731..a9113720fd45 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -244,8 +244,7 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
 break;
 
   case Declaration:
-ID.AddPointer(getAsDecl() ? getAsDecl()->getCanonicalDecl() : nullptr);
-getParamTypeForDecl().Profile(ID);
+ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : nullptr);
 break;
 
   case Template:
@@ -295,8 +294,7 @@ bool TemplateArgument::structurallyEquals(const 
TemplateArgument &Other) const {
 return TypeOrValue.V == Other.TypeOrValue.V;
 
   case Declaration:
-return getAsDecl() == Other.getAsDecl() &&
-   getParamTypeForDecl() == Other.getParamTypeForDecl();
+return getAsDecl() == Other.getAsDecl();
 
   case Integral:
 return getIntegralType() == Other.getIntegralType() &&

diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
index 6949a2eaad48..7538de330902 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -459,23 +459,3 @@ namespace PR46637 {
   X y;
   int n = y.call(); // expected-error {{cannot initialize a variable of type 
'int' with an rvalue of type 'void *'}}
 }
-
-namespace PR47792 {
-  using I = int;
-
-  template int a;
-  const int n = 0;
-  const I n2 = 0;
-  static_assert(&a == &a<0>, "both should have type 'int'");
-  static_assert(&a == &a<0>, "both should have type 'int'");
-
-  // FIXME: We will need to mangle these cases 
diff erently too!
-  int m;
-  const int &r1 = m;
-  int &r2 = m;
-  static_assert(&a != &a, "should have 
diff erent types");
-
-  const I &r3 = m;
-  static_assert(&a == &a, "should have 
diff erent types");
-  static_assert(&a != &a, "should have 
diff erent types");
-}



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


Re: [clang] 849c605 - PR47792: Include the type of a pointer or reference non-type template

2020-10-11 Thread Jonas Devlieghere via cfe-commits
I've reverted this in ba2dff0159fcd1d2349bc610331914618ca9bc30 because it
also caused a build failure when building a stage 2 clang:

http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/24177/console

FAILED: tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o
/Users/buildslave/jenkins/workspace/lldb-cmake@2/host-compiler/bin/clang++
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/clang/lib/AST
-I/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/clang/lib/AST
-I/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/clang/include
-Itools/clang/include -Iinclude
-I/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/llvm/include
-Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time
-Werror=unguarded-availability-new -fmodules
-fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake@2/lldb-build/module.cache
-fcxx-modules -Xclang -fmodules-local-submodule-visibility -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wmissing-field-initializers -pedantic -Wno-long-long
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override
-Wstring-conversion -fdiagnostics-color -fno-common -Woverloaded-virtual
-Wno-nested-anon-types -O3 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
-fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o -MF
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o.d -o
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTContext.cpp.o -c
'/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/clang/lib/AST/ASTContext.cpp'
In module 'Clang_AST' imported from
/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/clang/lib/AST/ASTContext.cpp:13:
/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/clang/include/clang/AST/ExternalASTSource.h:409:20:
error: definition with same mangled name
'_ZN5clang25LazyGenerationalUpdatePtrIPKNS_4DeclEPS1_XadL_ZNS_17ExternalASTSource19CompleteRedeclChainES3_EEE9makeValueERKNS_10ASTContextES4_'
as another definition static ValueType makeValue(const ASTContext &Ctx, T
Value);



On Sun, Oct 11, 2020 at 6:27 PM Hubert Tong via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> The bots don't seem happy building with a Clang that incorporates this
> change:
> ```
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm-project/clang/lib/ASTMatchers/ASTMatchersInternal.cpp:943:5:
> error: redefinition of 'hasAnyName' with a different type: 'const
> VariadicFunction<...>' vs 'const VariadicFunction<...>'
> hasAnyName = {};
> ^
> /b/sanitizer-x86_64-linux-bootstrap/build/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h:2771:5:
> note: previous declaration is here
> hasAnyName;
> ^
> ```
> (from
> http://lab.llvm.org:8011/#/builders/99/builds/49/steps/2/logs/build_clang_asan
> )
>
> On Sun, Oct 11, 2020 at 7:00 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Richard Smith
>> Date: 2020-10-11T15:59:49-07:00
>> New Revision: 849c60541b630ddf8cabf9179fa771b3f4207ec8
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8.diff
>>
>> LOG: PR47792: Include the type of a pointer or reference non-type template
>> parameter in its notion of template argument identity.
>>
>> We already did this for all the other kinds of non-type template
>> argument. We're still missing the type from the mangling, so we continue
>> to be able to see collisions at link time; that's an open ABI issue.
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/AST/ASTContext.cpp
>> clang/lib/AST/TemplateBase.cpp
>> clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
>> index a82d95461bb9..7c96038629fb 100644
>> --- a/clang/lib/AST/ASTContext.cpp
>> +++ b/clang/lib/AST/ASTContext.cpp
>> @@ -5890,7 +5890,7 @@ ASTContext::getCanonicalTemplateArgument(const
>> TemplateArgument &Arg) const {
>>
>>  case TemplateArgument::Declaration: {
>>auto *D = cast(Arg.getAsDecl()->getCanonicalDecl());
>> -  return TemplateArgument(D, Arg.getParamTypeForDecl());
>> +  return TemplateArgument(D,
>> getCanonicalType(Arg.getParamTypeForDecl()));
>>  }
>>
>>  case TemplateArgument::NullPtr:
>>
>> diff  --git a/clang/lib/AST/TemplateBase.cpp
>> b/clang/lib/AST/TemplateBase.cpp
>> index a9113720fd45..e4303fdb7731 100644
>> --- a/clang/lib/AST/TemplateBase.cpp
>> +++ b/clang/lib/AST/TemplateBase.cpp
>> @@ -244,7 +244,8 @@ void Template

[clang] 27a909a - [Apple-stage2] Install FileCheck and yaml2obj in the toolchain

2020-10-20 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-10-20T13:46:44-07:00
New Revision: 27a909a24f99d4de40c4ce6553b9cd420b11c056

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

LOG: [Apple-stage2] Install FileCheck and yaml2obj in the toolchain

rdar://70274446

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

Added: 


Modified: 
clang/cmake/caches/Apple-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Apple-stage2.cmake 
b/clang/cmake/caches/Apple-stage2.cmake
index b24ec558c071..ff9c612b9808 100644
--- a/clang/cmake/caches/Apple-stage2.cmake
+++ b/clang/cmake/caches/Apple-stage2.cmake
@@ -58,6 +58,13 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-size
   CACHE STRING "")
 
+set(LLVM_BUILD_UTILS ON CACHE BOOL "")
+set(LLVM_INSTALL_UTILS ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_UTILITIES
+  FileCheck
+  yaml2obj
+  CACHE STRING "")
+
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   LTO
@@ -66,6 +73,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   cxx-headers
   Remarks
   ${LLVM_TOOLCHAIN_TOOLS}
+  ${LLVM_TOOLCHAIN_UTILITIES}
   CACHE STRING "")
 
 # test args



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


[clang] 97b9130 - [clang] Disable assertion that can "easily happen"

2022-10-19 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2022-10-19T15:08:56-07:00
New Revision: 97b91307b00e958bc1d511c93a8a6bef510485ac

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

LOG: [clang] Disable assertion that can "easily happen"

Disable the assertion for getting a module ID for non-local,
non-imported module. According to the FIXME this can "easily happen" and
indeed, we're hitting this assertion regularly. Disable it until it can
be properly investigated.

rdar://99352728

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

Added: 


Modified: 
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 6bfbf0b57f5b8..4dcc5ee0a1c86 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2669,12 +2669,12 @@ unsigned ASTWriter::getLocalOrImportedSubmoduleID(const 
Module *Mod) {
 }
 
 unsigned ASTWriter::getSubmoduleID(Module *Mod) {
+  unsigned ID = getLocalOrImportedSubmoduleID(Mod);
   // FIXME: This can easily happen, if we have a reference to a submodule that
   // did not result in us loading a module file for that submodule. For
   // instance, a cross-top-level-module 'conflict' declaration will hit this.
-  unsigned ID = getLocalOrImportedSubmoduleID(Mod);
-  assert((ID || !Mod) &&
- "asked for module ID for non-local, non-imported module");
+  // assert((ID || !Mod) &&
+  //"asked for module ID for non-local, non-imported module");
   return ID;
 }
 



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


[clang] [llvm] Use XMACROS for MachO platforms. (PR #69262)

2023-10-16 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere approved this pull request.

I like how this centralizes everything in a single place and the def file 
format seems like a natural fit for the platforms. 

https://github.com/llvm/llvm-project/pull/69262
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Documentation] Replace recommonmark by myst-parser (PR #65664)

2023-09-08 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere review_requested 
https://github.com/llvm/llvm-project/pull/65664
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 56abcfa - Revert "[analyzer][NFC] Tie CheckerRegistry to CheckerManager, allow CheckerManager to be constructed for non-analysis purposes"

2020-03-23 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-03-23T12:09:24-07:00
New Revision: 56abcfad70ee679ad95ab41d934491ebcaebdf7d

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

LOG: Revert "[analyzer][NFC] Tie CheckerRegistry to CheckerManager, allow 
CheckerManager to be constructed for non-analysis purposes"

Temporarily reverting this patch because it breaks the modules build.

Added: 
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
clang/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
clang/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Removed: 
clang/include/clang/StaticAnalyzer/Frontend/AnalyzerHelpFlags.h
clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp



diff  --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index 6faf0f2e0afd..4454d7603b27 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -14,11 +14,9 @@
 #define LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
 
 #include "clang/Analysis/ProgramPoint.h"
-#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
-#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -42,6 +40,7 @@ class BugReporter;
 class CallEvent;
 class CheckerBase;
 class CheckerContext;
+class CheckerRegistry;
 class ExplodedGraph;
 class ExplodedNode;
 class ExplodedNodeSet;
@@ -122,42 +121,14 @@ enum class ObjCMessageVisitKind {
 };
 
 class CheckerManager {
-  ASTContext *Context;
+  ASTContext &Context;
   const LangOptions LangOpts;
   AnalyzerOptions &AOptions;
   CheckerNameRef CurrentCheckerName;
-  DiagnosticsEngine &Diags;
-  CheckerRegistry Registry;
 
 public:
-  CheckerManager(
-  ASTContext &Context, AnalyzerOptions &AOptions,
-  ArrayRef plugins,
-  ArrayRef> checkerRegistrationFns)
-  : Context(&Context), LangOpts(Context.getLangOpts()), AOptions(AOptions),
-Diags(Context.getDiagnostics()),
-Registry(plugins, Context.getDiagnostics(), AOptions,
- checkerRegistrationFns) {
-Registry.initializeRegistry(*this);
-Registry.initializeManager(*this);
-finishedCheckerRegistration();
-  }
-
-  /// Constructs a CheckerManager that ignores all non TblGen-generated
-  /// checkers. Useful for unit testing, unless the checker infrastructure
-  /// itself is tested.
   CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions)
-  : CheckerManager(Context, AOptions, {}, {}) {}
-
-  /// Constructs a CheckerManager without requiring an AST. No checker
-  /// registration will take place. Only useful for retrieving the
-  /// CheckerRegistry and print for help flags where the AST is unavalaible.
-  CheckerManager(AnalyzerOptions &AOptions, const LangOptions &LangOpts,
- DiagnosticsEngine &Diags, ArrayRef plugins)
-  : LangOpts(LangOpts), AOptions(AOptions), Diags(Diags),
-Registry(plugins, Diags, AOptions) {
-Registry.initializeRegistry(*this);
-  }
+  : Context(Context), LangOpts(Context.getLangOpts()), AOptions(AOptions) 
{}
 
   ~CheckerManager();
 
@@ -170,12 +141,7 @@ class CheckerManager {
 
   const LangOptions &getLangOpts() const { return LangOpts; }
   AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
-  const CheckerRegistry &getCheckerRegistry() const { return Registry; }
-  DiagnosticsEngine &getDiagnostics() const { return Diags; }
-  ASTContext &getASTContext() const {
-assert(Context);
-return *Context;
-  }
+  ASTContext &getASTContext() const { return Context; }
 
   /// Emits an error through a DiagnosticsEngine about an invalid user supplied
   /// checker option value.

diff  --git a/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h 
b/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
index bcc29a60ad70..2d24e6a9586b 100644
--- a/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
+++ b/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h

[clang-tools-extra] 45e2c6d - [clang-tools-extra/clang-tidy] Mark modernize-make-shared as offering fixes

2020-03-05 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-03-05T21:45:20-08:00
New Revision: 45e2c6d956141618683d31a683d762aaf0e7168d

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

LOG: [clang-tools-extra/clang-tidy] Mark modernize-make-shared as offering fixes

The list incorrectly states that modernize-make-shared does not offer
fixes, which is incorrect. Just like modernize-make-unique it does.

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 3b9d12ec56ad..05741385615a 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -207,7 +207,7 @@ Clang-Tidy Checks
`modernize-deprecated-headers `_, "Yes"
`modernize-deprecated-ios-base-aliases 
`_, "Yes"
`modernize-loop-convert `_, "Yes"
-   `modernize-make-shared `_,
+   `modernize-make-shared `_, "Yes"
`modernize-make-unique `_, "Yes"
`modernize-pass-by-value `_, "Yes"
`modernize-raw-string-literal `_, "Yes"



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


[clang] 00d834e - Fix more implicit conversions

2020-01-28 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-01-28T15:19:27-08:00
New Revision: 00d834e08719c994f12b216c7eb17bbc0c976714

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

LOG: Fix more implicit conversions

Added: 


Modified: 
clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
llvm/tools/dsymutil/SymbolMap.cpp

Removed: 




diff  --git a/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp 
b/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
index 7a60369a4da0..88bab18169a8 100644
--- a/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ b/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -173,7 +173,7 @@ FSEventStreamRef createFSEventStream(
   if (::realpath(P.begin(), Buffer) != nullptr)
 RealPath = Buffer;
   else
-RealPath = Path;
+RealPath = Path.str();
 }
 
 FSEventStreamContext Context;

diff  --git a/llvm/tools/dsymutil/SymbolMap.cpp 
b/llvm/tools/dsymutil/SymbolMap.cpp
index 7ee078cd9f93..6a13efdf8e95 100644
--- a/llvm/tools/dsymutil/SymbolMap.cpp
+++ b/llvm/tools/dsymutil/SymbolMap.cpp
@@ -96,7 +96,7 @@ SymbolMapTranslator SymbolMapLoader::Load(StringRef InputFile,
   StringRef UUID(CFStringGetCStringPtr(OldUUID, 
kCFStringEncodingUTF8));
   SmallString<256> BCSymbolMapPath(SymbolMapPath);
   sys::path::append(BCSymbolMapPath, UUID.str() + ".bcsymbolmap");
-  SymbolMapPath = BCSymbolMapPath.str();
+  SymbolMapPath = BCSymbolMapPath.str().str();
 }
 CFRelease(plist);
   }



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


[clang] 43a1c80 - Fix another implicit conversion in the directory watcher

2020-01-28 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-01-28T15:28:22-08:00
New Revision: 43a1c80508d17fa42c78b690d426105eaa84c539

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

LOG: Fix another implicit conversion in the directory watcher

Added: 


Modified: 
clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp

Removed: 




diff  --git a/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp 
b/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
index 88bab18169a8..2cae847e7657 100644
--- a/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ b/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -221,7 +221,7 @@ llvm::Expected> 
clang::DirectoryWatcher::creat
 
   // We need to copy the data so the lifetime is ok after a const copy is made
   // for the block.
-  const std::string CopiedPath = Path;
+  const std::string CopiedPath = Path.str();
 
   auto InitWork = ^{
 // We need to start watching the directory before we start scanning in 
order



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


[clang] 509e21a - [clang] Replace SmallStr.str().str() with std::string conversion operator.

2020-01-29 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2020-01-29T21:27:46-08:00
New Revision: 509e21a1b9debc7fcbfb3eaf56a5dcf57de55e0e

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

LOG: [clang] Replace SmallStr.str().str() with std::string conversion operator.

Use the std::string conversion operator introduced in
d7049213d0fcda691c9e79f9b41e357198d99738.

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/tools/clang-refactor/TestSupport.cpp
clang/unittests/Driver/SanitizerArgsTest.cpp
clang/unittests/Frontend/FrontendActionTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index a0d11ee9982f..51d29aef3267 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -856,7 +856,7 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const 
Decl *CurrentDecl) {
 
 Out << Proto;
 
-return Name.str().str();
+return std::string(Name);
   }
   if (const CapturedDecl *CD = dyn_cast(CurrentDecl)) {
 for (const DeclContext *DC = CD->getParent(); DC; DC = DC->getParent())
@@ -887,7 +887,7 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const 
Decl *CurrentDecl) {
 MD->getSelector().print(Out);
 Out <<  ']';
 
-return Name.str().str();
+return std::string(Name);
   }
   if (isa(CurrentDecl) && IK == PrettyFunction) {
 // __PRETTY_FUNCTION__ -> "top level", the others produce an empty string.

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index bdecff39c88f..ee85694f043a 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1282,7 +1282,7 @@ std::string normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::fs::make_absolute(Path);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  return Path.str().str();
+  return std::string(Path);
 }
 
 } // end anonymous namespace

diff  --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index f182f5c2cb4d..d138985c57fd 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,7 +149,7 @@ parseCrossTUIndex(StringRef IndexPath, StringRef 
CrossTUDir) {
   StringRef FileName = LineRef.substr(Pos + 1);
   SmallString<256> FilePath = CrossTUDir;
   llvm::sys::path::append(FilePath, FileName);
-  Result[LookupName] = FilePath.str().str();
+  Result[LookupName] = std::string(FilePath);
 } else
   return llvm::make_error(
   index_error_code::invalid_index_format, IndexPath.str(), LineNo);

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0813146406ad..6db791ab8333 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4650,7 +4650,7 @@ std::string Driver::GetFilePath(StringRef Name, const 
ToolChain &TC) const {
   SmallString<128> P(Dir[0] == '=' ? SysRoot + Dir.substr(1) : Dir);
   llvm::sys::path::append(P, Name);
   if (llvm::sys::fs::exists(Twine(P)))
-return P.str().str();
+return std::string(P);
 }
 return None;
   };

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ff9272ec3e1a..73c02d7f6e6d 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -159,7 +159,7 @@ std::string 
HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
 llvm::sys::fs::make_absolute(Result);
 llvm::sys::path::append(Result, ModuleName + ".pcm");
 if (getFileMgr().getFile(Result.str()))
-  return Result.str().str();
+  return std::string(Result);
   }
   return {};
 }

diff  --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp 
b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
index fb7758bfbd2a..a415ed32c05a 100644
--- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -106,7 +106,7 @@ static std::string fileNameToURI(StringRef Filename) {
 }
   });
 
-  return Ret.str().str();
+  return std::string(Ret);
 }
 
 static json::Object createArtifactLocation(const FileEntry &FE) {

diff  --git a/clang/tools/clang-refactor/TestSupport.cpp 
b/clang/tools/clang-refactor/TestSupport.cpp
index 617a671d1271..02b816d5235c 100644
--- a/clang/tools/clang-refactor/TestSupport.cpp
+++ b/clang/tools/clang-refactor/TestSupport.cpp
@@ -190,7 +190,7 @@ bool TestRefactoringResultConsumer::handleAllResults() {
   const PartialDiagnosticAt &Diag = 

r328196 - [CodeGen] Emit DWARF "constructor" calling convention

2018-03-22 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Thu Mar 22 06:53:30 2018
New Revision: 328196

URL: http://llvm.org/viewvc/llvm-project?rev=328196&view=rev
Log:
[CodeGen] Emit DWARF "constructor" calling convention

Now that LLVM has support for emitting calling conventions in DWARF (see
r328191) have clang emit them.

Patch by: Adrien Guinet

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

Added:
cfe/trunk/test/CodeGen/debug-info-cc.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=328196&r1=328195&r2=328196&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Mar 22 06:53:30 2018
@@ -1000,20 +1000,28 @@ static unsigned getDwarfCC(CallingConv C
 return llvm::dwarf::DW_CC_LLVM_vectorcall;
   case CC_X86Pascal:
 return llvm::dwarf::DW_CC_BORLAND_pascal;
-
-  // FIXME: Create new DW_CC_ codes for these calling conventions.
   case CC_Win64:
+return llvm::dwarf::DW_CC_LLVM_Win64;
   case CC_X86_64SysV:
+return llvm::dwarf::DW_CC_LLVM_X86_64SysV;
   case CC_AAPCS:
+return llvm::dwarf::DW_CC_LLVM_AAPCS;
   case CC_AAPCS_VFP:
+return llvm::dwarf::DW_CC_LLVM_AAPCS_VFP;
   case CC_IntelOclBicc:
+return llvm::dwarf::DW_CC_LLVM_IntelOclBicc;
   case CC_SpirFunction:
+return llvm::dwarf::DW_CC_LLVM_SpirFunction;
   case CC_OpenCLKernel:
+return llvm::dwarf::DW_CC_LLVM_OpenCLKernel;
   case CC_Swift:
+return llvm::dwarf::DW_CC_LLVM_Swift;
   case CC_PreserveMost:
+return llvm::dwarf::DW_CC_LLVM_PreserveMost;
   case CC_PreserveAll:
+return llvm::dwarf::DW_CC_LLVM_PreserveAll;
   case CC_X86RegCall:
-return 0;
+return llvm::dwarf::DW_CC_LLVM_X86RegCall;
   }
   return 0;
 }

Added: cfe/trunk/test/CodeGen/debug-info-cc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-cc.c?rev=328196&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-cc.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-cc.c Thu Mar 22 06:53:30 2018
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -o - -emit-llvm 
-debug-info-kind=limited %s | FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -o - -emit-llvm 
-debug-info-kind=limited %s | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -o - -emit-llvm 
-debug-info-kind=limited %s | FileCheck %s --check-prefix=LINUX32
+// RUN: %clang_cc1 -triple armv7--linux-gnueabihf -o - -emit-llvm 
-debug-info-kind=limited %s | FileCheck %s --check-prefix=ARM
+
+//  enum CallingConv {
+//CC_C,   // __attribute__((cdecl))
+//CC_X86StdCall,  // __attribute__((stdcall))
+//CC_X86FastCall, // __attribute__((fastcall))
+//CC_X86ThisCall, // __attribute__((thiscall))
+//CC_X86VectorCall, // __attribute__((vectorcall))
+//CC_X86Pascal,   // __attribute__((pascal))
+//CC_Win64,   // __attribute__((ms_abi))
+//CC_X86_64SysV,  // __attribute__((sysv_abi))
+//CC_X86RegCall, // __attribute__((regcall))
+//CC_AAPCS,   // __attribute__((pcs("aapcs")))
+//CC_AAPCS_VFP,   // __attribute__((pcs("aapcs-vfp")))
+//CC_IntelOclBicc, // __attribute__((intel_ocl_bicc))
+//CC_SpirFunction, // default for OpenCL functions on SPIR target
+//CC_OpenCLKernel, // inferred for OpenCL kernels
+//CC_Swift,// __attribute__((swiftcall))
+//CC_PreserveMost, // __attribute__((preserve_most))
+//CC_PreserveAll,  // __attribute__((preserve_all))
+//  };
+
+#ifdef __x86_64__
+
+#ifdef __linux__
+// LINUX: !DISubprogram({{.*}}"add_msabi", {{.*}}type: ![[FTY:[0-9]+]]
+// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_Win64,
+__attribute__((ms_abi)) int add_msabi(int a, int b) {
+  return a+b;
+}
+
+// LINUX: !DISubprogram({{.*}}"add_regcall", {{.*}}type: ![[FTY:[0-9]+]]
+// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_X86RegCall,
+__attribute__((regcall)) int add_regcall(int a, int b) {
+  return a+b;
+}
+
+// LINUX: !DISubprogram({{.*}}"add_preserve_most", {{.*}}type: ![[FTY:[0-9]+]]
+// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_PreserveMost,
+__attribute__((preserve_most)) int add_preserve_most(int a, int b) {
+  return a+b;
+}
+
+// LINUX: !DISubprogram({{.*}}"add_preserve_all", {{.*}}type: ![[FTY:[0-9]+]]
+// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_PreserveAll,
+__attribute__((preserve_all)) int add_preserve_all(int a, int b) {
+  return a+b;
+}
+
+// LINUX: !DISubprogram({{.*}}"add_swiftcall", {{.*}}type: ![[FTY:[0-9]+]]
+// LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_Swift,
+__attribute__((swiftcall)) int add_swiftcall(int a, int b) {
+  return a+b;
+}
+
+// LINUX: !DISubprogram({{.*}}"add_intel

[clang] e0d5729 - [DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platforms

2023-06-14 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2023-06-14T13:03:31-07:00
New Revision: e0d57295bf6a3c04f2901d9c70f529d570f48b65

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

LOG: [DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platforms

On Apple platforms, we generate .apple_names, .apple_types,
.apple_namespaces and .apple_objc Apple accelerator tables for DWARF 4
and earlier. For DWARF 5 we should generate .debug_names, but instead we
get no accelerator tables at all.

In the backend we are correctly determining that we should be emitting
.debug_names instead of .apple_names. However, when we get to the point
of emitting the section, if the CU debug name table kind is not
"default", the accelerator table emission is skipped.

This patch sets the DebugNameTableKind to Apple in the frontend when
target an Apple target. That way we know that the CU was compiled with
the intent of emitting accelerator tables. For DWARF 4 and earlier, that
means Apple accelerator tables. For DWARF 5 and later, that means .debug
names.

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

Added: 
llvm/test/DebugInfo/Inputs/name-table-kind-apple-4.ll
llvm/test/DebugInfo/Inputs/name-table-kind-apple-5.ll
llvm/test/DebugInfo/accel-tables-apple.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/debug-info-names.c
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/IR/DebugInfoMetadata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index edef27bdf377c..2fd2227720a2a 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -637,17 +637,21 @@ void CGDebugInfo::CreateCompileUnit() {
   SDK = *It;
   }
 
+  llvm::DICompileUnit::DebugNameTableKind NameTableKind =
+  static_cast(
+  CGOpts.DebugNameTable);
+  if (CGM.getTarget().getTriple().isNVPTX())
+NameTableKind = llvm::DICompileUnit::DebugNameTableKind::None;
+  else if (CGM.getTarget().getTriple().getVendor() == llvm::Triple::Apple)
+NameTableKind = llvm::DICompileUnit::DebugNameTableKind::Apple;
+
   // Create new compile unit.
   TheCU = DBuilder.createCompileUnit(
   LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "",
   LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
   CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.SplitDwarfFile, EmissionKind,
   DwoId, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,
-  CGM.getTarget().getTriple().isNVPTX()
-  ? llvm::DICompileUnit::DebugNameTableKind::None
-  : static_cast(
-CGOpts.DebugNameTable),
-  CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
+  NameTableKind, CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {

diff  --git a/clang/test/CodeGen/debug-info-names.c 
b/clang/test/CodeGen/debug-info-names.c
index 841387d50fd44..a807fb8c06696 100644
--- a/clang/test/CodeGen/debug-info-names.c
+++ b/clang/test/CodeGen/debug-info-names.c
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -gpubnames | 
FileCheck --check-prefix=DEFAULT %s
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -ggnu-pubnames 
| FileCheck --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck --check-prefix=APPLE %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - -gpubnames | FileCheck --check-prefix=DEFAULT 
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - -ggnu-pubnames | FileCheck --check-prefix=GNU 
%s
 
 // CHECK: !DICompileUnit({{.*}}, nameTableKind: None
 // DEFAULT-NOT: !DICompileUnit({{.*}}, nameTableKind:
 // GNU: !DICompileUnit({{.*}}, nameTableKind: GNU
+// APPLE: !DICompileUnit({{.*}}, nameTableKind: Apple
 
 void f1(void) {
 }

diff  --git a/llvm/include/llvm/IR/DebugInfoMetadata.h 
b/llvm/include/llvm/IR/DebugInfoMetadata.h
index defd1d5c2a1ea..6561224052097 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1377,7 +1377,8 @@ class DICompileUnit : public DIScope {
 Default = 0,
 GNU = 1,
 None = 2,
-LastDebugNameTableKind = None
+Apple = 3,
+LastDebugNameTableKind = Apple
   };
 
   

[clang] 04c0161 - Revert "[DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platforms"

2023-06-14 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2023-06-14T14:16:16-07:00
New Revision: 04c0161c027676119fdc617f5b883dbda97c8549

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

LOG: Revert "[DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple 
platforms"

This reverts commit e0d57295bf6a3c04f2901d9c70f529d570f48b65 because the
accel-tables-apple.ll test is failing on a few buildbots.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/debug-info-names.c
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/IR/DebugInfoMetadata.cpp

Removed: 
llvm/test/DebugInfo/Inputs/name-table-kind-apple-4.ll
llvm/test/DebugInfo/Inputs/name-table-kind-apple-5.ll
llvm/test/DebugInfo/accel-tables-apple.ll



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 2fd2227720a2a..edef27bdf377c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -637,21 +637,17 @@ void CGDebugInfo::CreateCompileUnit() {
   SDK = *It;
   }
 
-  llvm::DICompileUnit::DebugNameTableKind NameTableKind =
-  static_cast(
-  CGOpts.DebugNameTable);
-  if (CGM.getTarget().getTriple().isNVPTX())
-NameTableKind = llvm::DICompileUnit::DebugNameTableKind::None;
-  else if (CGM.getTarget().getTriple().getVendor() == llvm::Triple::Apple)
-NameTableKind = llvm::DICompileUnit::DebugNameTableKind::Apple;
-
   // Create new compile unit.
   TheCU = DBuilder.createCompileUnit(
   LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "",
   LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
   CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.SplitDwarfFile, EmissionKind,
   DwoId, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,
-  NameTableKind, CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
+  CGM.getTarget().getTriple().isNVPTX()
+  ? llvm::DICompileUnit::DebugNameTableKind::None
+  : static_cast(
+CGOpts.DebugNameTable),
+  CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {

diff  --git a/clang/test/CodeGen/debug-info-names.c 
b/clang/test/CodeGen/debug-info-names.c
index a807fb8c06696..841387d50fd44 100644
--- a/clang/test/CodeGen/debug-info-names.c
+++ b/clang/test/CodeGen/debug-info-names.c
@@ -1,12 +1,10 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck --check-prefix=APPLE %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - -gpubnames | FileCheck --check-prefix=DEFAULT 
%s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - -ggnu-pubnames | FileCheck --check-prefix=GNU 
%s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -gpubnames | 
FileCheck --check-prefix=DEFAULT %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -ggnu-pubnames 
| FileCheck --check-prefix=GNU %s
 
 // CHECK: !DICompileUnit({{.*}}, nameTableKind: None
 // DEFAULT-NOT: !DICompileUnit({{.*}}, nameTableKind:
 // GNU: !DICompileUnit({{.*}}, nameTableKind: GNU
-// APPLE: !DICompileUnit({{.*}}, nameTableKind: Apple
 
 void f1(void) {
 }

diff  --git a/llvm/include/llvm/IR/DebugInfoMetadata.h 
b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 6561224052097..defd1d5c2a1ea 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1377,8 +1377,7 @@ class DICompileUnit : public DIScope {
 Default = 0,
 GNU = 1,
 None = 2,
-Apple = 3,
-LastDebugNameTableKind = Apple
+LastDebugNameTableKind = None
   };
 
   static std::optional getEmissionKind(StringRef Str);

diff  --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index 7568fd43e1d08..23a7b4481110c 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -944,8 +944,7 @@ lltok::Kind LLLexer::LexIdentifier() {
 return lltok::EmissionKind;
   }
 
-  if (Keyword == "GNU" || Keyword == "Apple" || Keyword == "None" ||
-  Keyword == "Default") {
+  if (Keyword == "GNU" || Keyword == "None" || Keyword == "Default") {
 StrVal.assign(Keyword.begin(), Keyword.end());
 return lltok::NameTableKind;
   }

diff  --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp 
b/llvm/lib/CodeGen/AsmPrinter/AccelTable

[clang] fc60bf2 - [DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platforms

2023-06-14 Thread Jonas Devlieghere via cfe-commits

Author: Jonas Devlieghere
Date: 2023-06-14T15:28:33-07:00
New Revision: fc60bf2de11149d2c027d63e7ad5a98afa6fab80

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

LOG: [DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platforms

On Apple platforms, we generate .apple_names, .apple_types,
.apple_namespaces and .apple_objc Apple accelerator tables for DWARF 4
and earlier. For DWARF 5 we should generate .debug_names, but instead we
get no accelerator tables at all.

In the backend we are correctly determining that we should be emitting
.debug_names instead of .apple_names. However, when we get to the point
of emitting the section, if the CU debug name table kind is not
"default", the accelerator table emission is skipped.

This patch sets the DebugNameTableKind to Apple in the frontend when
target an Apple target. That way we know that the CU was compiled with
the intent of emitting accelerator tables. For DWARF 4 and earlier, that
means Apple accelerator tables. For DWARF 5 and later, that means .debug
names.

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

Added: 
llvm/test/DebugInfo/Inputs/name-table-kind-apple-4.ll
llvm/test/DebugInfo/Inputs/name-table-kind-apple-5.ll
llvm/test/DebugInfo/accel-tables-apple.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/debug-info-names.c
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/IR/DebugInfoMetadata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index edef27bdf377c..2fd2227720a2a 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -637,17 +637,21 @@ void CGDebugInfo::CreateCompileUnit() {
   SDK = *It;
   }
 
+  llvm::DICompileUnit::DebugNameTableKind NameTableKind =
+  static_cast(
+  CGOpts.DebugNameTable);
+  if (CGM.getTarget().getTriple().isNVPTX())
+NameTableKind = llvm::DICompileUnit::DebugNameTableKind::None;
+  else if (CGM.getTarget().getTriple().getVendor() == llvm::Triple::Apple)
+NameTableKind = llvm::DICompileUnit::DebugNameTableKind::Apple;
+
   // Create new compile unit.
   TheCU = DBuilder.createCompileUnit(
   LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "",
   LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
   CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.SplitDwarfFile, EmissionKind,
   DwoId, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,
-  CGM.getTarget().getTriple().isNVPTX()
-  ? llvm::DICompileUnit::DebugNameTableKind::None
-  : static_cast(
-CGOpts.DebugNameTable),
-  CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
+  NameTableKind, CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {

diff  --git a/clang/test/CodeGen/debug-info-names.c 
b/clang/test/CodeGen/debug-info-names.c
index 841387d50fd44..a807fb8c06696 100644
--- a/clang/test/CodeGen/debug-info-names.c
+++ b/clang/test/CodeGen/debug-info-names.c
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -gpubnames | 
FileCheck --check-prefix=DEFAULT %s
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -ggnu-pubnames 
| FileCheck --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -emit-llvm 
-debug-info-kind=limited %s -o - | FileCheck --check-prefix=APPLE %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - -gpubnames | FileCheck --check-prefix=DEFAULT 
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm 
-debug-info-kind=limited %s -o - -ggnu-pubnames | FileCheck --check-prefix=GNU 
%s
 
 // CHECK: !DICompileUnit({{.*}}, nameTableKind: None
 // DEFAULT-NOT: !DICompileUnit({{.*}}, nameTableKind:
 // GNU: !DICompileUnit({{.*}}, nameTableKind: GNU
+// APPLE: !DICompileUnit({{.*}}, nameTableKind: Apple
 
 void f1(void) {
 }

diff  --git a/llvm/include/llvm/IR/DebugInfoMetadata.h 
b/llvm/include/llvm/IR/DebugInfoMetadata.h
index defd1d5c2a1ea..6561224052097 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1377,7 +1377,8 @@ class DICompileUnit : public DIScope {
 Default = 0,
 GNU = 1,
 None = 2,
-LastDebugNameTableKind = None
+Apple = 3,
+LastDebugNameTableKind = Apple
   };
 
   

[clang-tools-extra] r299461 - [clangd] Link against clangSema

2017-04-04 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Apr  4 14:42:29 2017
New Revision: 299461

URL: http://llvm.org/viewvc/llvm-project?rev=299461&view=rev
Log:
[clangd] Link against clangSema

Fixes linking issue introduced by rL299421 when building LLVM with
shared libraries.

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=299461&r1=299460&r2=299461&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Apr  4 14:42:29 2017
@@ -12,6 +12,7 @@ target_link_libraries(clangd
   clangBasic
   clangFormat
   clangFrontend
+  clangSema
   clangTooling
   clangToolingCore
   LLVMSupport


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


[clang-tools-extra] r307040 - [clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive

2017-07-03 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Jul  3 09:46:46 2017
New Revision: 307040

URL: http://llvm.org/viewvc/llvm-project?rev=307040&view=rev
Log:
[clang-tidy] Resolve cppcoreguidelines-pro-type-member-init false positive

Summary: https://bugs.llvm.org/show_bug.cgi?id=33557

Reviewers: Eugene.Zelenko, alexfh, aaron.ballman, hokein

Reviewed By: aaron.ballman, hokein

Subscribers: cfe-commits, nemanjai, xazax.hun, kbarton

Tags: #clang-tools-extra

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

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=307040&r1=307039&r2=307040&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Mon Jul  3 09:46:46 2017
@@ -449,6 +449,9 @@ void ProTypeMemberInitCheck::checkMissin
 
   // Remove any bases that were explicitly written in the initializer list.
   if (Ctor) {
+if (Ctor->isImplicit())
+  return;
+
 for (const CXXCtorInitializer *Init : Ctor->inits()) {
   if (Init->isBaseInitializer() && Init->isWritten())
 BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=307040&r1=307039&r2=307040&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Mon Jul  3 09:46:46 2017
@@ -473,3 +473,16 @@ struct NegativeInitializedBitfieldMember
   unsigned F : 5;
   unsigned G : 5;
 };
+
+struct NegativeImplicitInheritedCtorBase {
+  NegativeImplicitInheritedCtorBase(unsigned F) : F(F) {}
+  unsigned F;
+};
+
+struct NegativeImplicitInheritedCtor : NegativeImplicitInheritedCtorBase {
+  using NegativeImplicitInheritedCtorBase::NegativeImplicitInheritedCtorBase;
+};
+
+void Bug33557() {
+  NegativeImplicitInheritedCtor I(5);
+}


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


[clang-tools-extra] r295199 - [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-02-15 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Feb 15 11:06:06 2017
New Revision: 295199

URL: http://llvm.org/viewvc/llvm-project?rev=295199&view=rev
Log:
[clang-tidy] Add check 'modernize-return-braced-init-list'

Summary:
Replaces explicit calls to the constructor in a return with a braced
initializer list. This way the return type is not needlessly duplicated in the
return type and the return statement.

```
Foo bar() {
  Baz baz;
  return Foo(baz);
}

// transforms to:

Foo bar() {
  Baz baz;
  return {baz};
}
```

Reviewers: hokein, Prazek, aaron.ballman, alexfh

Reviewed By: Prazek, aaron.ballman, alexfh

Subscribers: malcolm.parsons, mgorny, cfe-commits

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-return-braced-init-list.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=295199&r1=295198&r2=295199&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 15 
11:06:06 2017
@@ -13,6 +13,7 @@ add_clang_library(clangTidyModernizeModu
   RawStringLiteralCheck.cpp
   RedundantVoidArgCheck.cpp
   ReplaceAutoPtrCheck.cpp
+  ReturnBracedInitListCheck.cpp
   ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=295199&r1=295198&r2=295199&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Wed 
Feb 15 11:06:06 2017
@@ -19,6 +19,7 @@
 #include "RawStringLiteralCheck.h"
 #include "RedundantVoidArgCheck.h"
 #include "ReplaceAutoPtrCheck.h"
+#include "ReturnBracedInitListCheck.h"
 #include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
@@ -53,6 +54,8 @@ public:
 "modernize-redundant-void-arg");
 CheckFactories.registerCheck(
 "modernize-replace-auto-ptr");
+CheckFactories.registerCheck(
+"modernize-return-braced-init-list");
 CheckFactories.registerCheck("modernize-shrink-to-fit");
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp?rev=295199&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp 
Wed Feb 15 11:06:06 2017
@@ -0,0 +1,97 @@
+//===--- ReturnBracedInitListCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ReturnBracedInitListCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) {
+  // Only register the matchers for C++.
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  // Skip list initialization and constructors with an initializer list.
+  auto ConstructExpr =
+  cxxConstructExpr(
+  unless(anyOf(hasDeclaration(cxxConstructorDecl(isExplicit())),
+   isListInitialization(), hasDescendant(initListExpr()),
+   isInTemplateInstantiation(
+  .bind("ctor");
+
+  auto CtorAsArgument = materializeTemporaryExpr(anyOf(
+  has(ConstructExpr), has(cxxFunctionalCastExpr(has(ConstructExpr);
+
+  Finder->addMatc

[clang-tools-extra] r295205 - Fixed indentation issue in release notes

2017-02-15 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Feb 15 11:19:44 2017
New Revision: 295205

URL: http://llvm.org/viewvc/llvm-project?rev=295205&view=rev
Log:
Fixed indentation issue in release notes

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=295205&r1=295204&r2=295205&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Feb 15 11:19:44 2017
@@ -68,7 +68,7 @@ Improvements to clang-tidy
   Finds uses of inline assembler.
 
 - New `modernize-return-braced-init-list
-
`_
 check
+  
`_
 check
 
   Finds and replaces explicit calls to the constructor in a return statement by
   a braced initializer list so that the return type is not needlessly repeated.


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


[clang-tools-extra] r295207 - [clang-tidy] Fix test modernize-return-braced-init-list

2017-02-15 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Feb 15 11:37:58 2017
New Revision: 295207

URL: http://llvm.org/viewvc/llvm-project?rev=295207&view=rev
Log:
[clang-tidy] Fix test modernize-return-braced-init-list

Modified:

clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp?rev=295207&r1=295206&r2=295207&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp 
Wed Feb 15 11:37:58 2017
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
-// -std=c++14
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- -- 
-std=c++14
 
 namespace std {
 typedef decltype(sizeof(int)) size_t;


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


r297649 - [Linker] Provide callback for internalization

2017-03-13 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Mon Mar 13 13:08:11 2017
New Revision: 297649

URL: http://llvm.org/viewvc/llvm-project?rev=297649&view=rev
Log:
[Linker] Provide callback for internalization

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

Modified:
cfe/trunk/include/clang/CodeGen/CodeGenAction.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/CodeGen/CodeGenAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenAction.h?rev=297649&r1=297648&r2=297649&view=diff
==
--- cfe/trunk/include/clang/CodeGen/CodeGenAction.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenAction.h Mon Mar 13 13:08:11 2017
@@ -36,6 +36,9 @@ private:
 /// function ourselves.
 bool PropagateAttrs;
 
+/// If true, we use LLVM module internalizer.
+bool Internalize;
+
 /// Bitwise combination of llvm::LinkerFlags used when we link the module.
 unsigned LinkFlags;
   };

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=297649&r1=297648&r2=297649&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Mon Mar 13 13:08:11 2017
@@ -137,6 +137,8 @@ public:
 /// our CodeGenOptions, much as we set attrs on functions that we generate
 /// ourselves.
 bool PropagateAttrs = false;
+/// If true, we use LLVM module internalizer.
+bool Internalize = false;
 /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
 unsigned LinkFlags = 0;
   };

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=297649&r1=297648&r2=297649&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Mar 13 13:08:11 2017
@@ -28,6 +28,7 @@
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IRReader/IRReader.h"
@@ -38,6 +39,8 @@
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/YAMLTraits.h"
+#include "llvm/Transforms/IPO/Internalize.h"
+
 #include 
 using namespace clang;
 using namespace llvm;
@@ -168,8 +171,22 @@ namespace clang {
 Gen->CGM().AddDefaultFnAttrs(F);
 
 CurLinkModule = LM.Module.get();
-if (Linker::linkModules(*getModule(), std::move(LM.Module),
-LM.LinkFlags))
+
+bool Err;
+if (LM.Internalize) {
+  Err = Linker::linkModules(
+  *getModule(), std::move(LM.Module), LM.LinkFlags,
+  [](llvm::Module &M, const llvm::StringSet<> &GVS) {
+internalizeModule(M, [&M, &GVS](const llvm::GlobalValue &GV) {
+  return !GV.hasName() || (GVS.count(GV.getName()) == 0);
+});
+  });
+} else {
+  Err = Linker::linkModules(*getModule(), std::move(LM.Module),
+LM.LinkFlags);
+}
+
+if (Err)
   return true;
   }
   return false; // success
@@ -319,7 +336,7 @@ namespace clang {
 void OptimizationFailureHandler(
 const llvm::DiagnosticInfoOptimizationFailure &D);
   };
-  
+
   void BackendConsumer::anchor() {}
 }
 
@@ -388,7 +405,7 @@ void BackendConsumer::InlineAsmDiagHandl
   // code.
   if (LocCookie.isValid()) {
 Diags.Report(LocCookie, DiagID).AddString(Message);
-
+
 if (D.getLoc().isValid()) {
   DiagnosticBuilder B = Diags.Report(Loc, diag::note_fe_inline_asm_here);
   // Convert the SMDiagnostic ranges into SourceRange and attach them
@@ -401,7 +418,7 @@ void BackendConsumer::InlineAsmDiagHandl
 }
 return;
   }
-  
+
   // Otherwise, report the backend issue as occurring in the generated .s file.
   // If Loc is invalid, we still need to report the issue, it just gets no
   // location info.
@@ -815,8 +832,8 @@ CodeGenAction::CreateASTConsumer(Compile
 LinkModules.clear();
 return nullptr;
   }
-  LinkModules.push_back(
-  {std::move(ModuleOrErr.get()), F.PropagateAttrs, F.LinkFlags});
+  LinkModules.push_back({std::move(ModuleOrErr.get()), F.PropagateAttrs,
+ F.Internalize, F.LinkFlags});
 }
 
   CoverageSourceInfo *CoverageInfo = nullptr;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm

[PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-11-23 Thread Jonas Devlieghere via cfe-commits
JDevlieghere abandoned this revision.
JDevlieghere added a comment.

I'm abandoning this revision because I think this check is getting overly 
complex. There's still the problem of supporting arguments that can have side 
effects, and then there's also the unaddressed issue of code possibly using the 
void* return type of these two functions. Any solution to this would require 
rather inelegant and complex code that is, in my opinion, simply not warranted 
by the added value of this check.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725



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


[clang-tools-extra] r288258 - [clang-tidy] Make format style customizable

2016-11-30 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Nov 30 12:06:42 2016
New Revision: 288258

URL: http://llvm.org/viewvc/llvm-project?rev=288258&view=rev
Log:
[clang-tidy] Make format style customizable

Summary: I came across an outstanding FIXME to make the format style 
customizable. Inspired by the include fixer, I added an new option `-style` to 
configure the fallback style in case no clang-format configuration file is 
found. The default remains "llvm". 

Reviewers: Prazek, aaron.ballman, hokein, alexfh

Subscribers: cfe-commits, malcolm.parsons

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=288258&r1=288257&r2=288258&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Nov 30 12:06:42 2016
@@ -88,13 +88,13 @@ private:
 
 class ErrorReporter {
 public:
-  ErrorReporter(bool ApplyFixes)
+  ErrorReporter(bool ApplyFixes, StringRef FormatStyle)
   : Files(FileSystemOptions()), DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
   DiagPrinter),
 SourceMgr(Diags, Files), ApplyFixes(ApplyFixes), TotalFixes(0),
-AppliedFixes(0), WarningsAsErrors(0) {
+AppliedFixes(0), WarningsAsErrors(0), FormatStyle(FormatStyle) {
 DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
 DiagPrinter->BeginSourceFile(LangOpts);
   }
@@ -196,8 +196,7 @@ public:
   continue;
 }
 StringRef Code = Buffer.get()->getBuffer();
-// FIXME: Make the style customizable.
-format::FormatStyle Style = format::getStyle("file", File, "LLVM");
+format::FormatStyle Style = format::getStyle("file", File, 
FormatStyle);
 llvm::Expected CleanReplacements =
 format::cleanupAroundReplacements(Code, FileAndReplacements.second,
   Style);
@@ -248,6 +247,7 @@ private:
   unsigned TotalFixes;
   unsigned AppliedFixes;
   unsigned WarningsAsErrors;
+  StringRef FormatStyle;
 };
 
 class ClangTidyASTConsumer : public MultiplexConsumer {
@@ -538,8 +538,8 @@ runClangTidy(std::unique_ptr &Errors, bool Fix,
-  unsigned &WarningsAsErrorsCount) {
-  ErrorReporter Reporter(Fix);
+  StringRef FormatStyle, unsigned &WarningsAsErrorsCount) {
+  ErrorReporter Reporter(Fix, FormatStyle);
   vfs::FileSystem &FileSystem =
   *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
   auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=288258&r1=288257&r2=288258&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Wed Nov 30 12:06:42 2016
@@ -235,9 +235,10 @@ runClangTidy(std::unique_ptr &Errors, bool Fix,
-  unsigned &WarningsAsErrorsCount);
+  StringRef FormatStyle, unsigned &WarningsAsErrorsCount);
 
 /// \brief Serializes replacements into YAML and writes them to the specified
 /// output stream.

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=288258&r1=288257&r2=288258&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Wed Nov 30 
12:06:42 2016
@@ -49,9 +49,9 @@ Configuration files:
 
 )");
 
-const char DefaultChecks[] =  // Enable these checks by default:
-"clang-diagnostic-*," //   * compiler diagnostics
-"clang-analyzer-*";   //   * Static Analyzer checks
+const char DefaultChecks[] = // Enable these checks by default:
+"clang-diagnostic-*,"//   * compiler diagnostics
+"clang-analyzer-*";  //   * Static Analyzer checks
 
 static cl::opt Checks("checks", cl::desc(R"(
 Comma-separated list of globs with optional '-'
@@ -120,6 +120,13 @@ well.
 )"),
cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt FormatStyle("style", cl::desc(R"(
+Fallback style for reformatting a

[PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-23 Thread Jonas Devlieghere via cfe-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: alexfh.
JDevlieghere added a subscriber: cfe-commits.
JDevlieghere added a project: clang-tools-extra.

This check emits a warning when memcpy is used and suggest replacing it with a 
call to std::copy. 

Using std::copy opens up the possibility of type-aware optimizations which are 
not possible with memcpy.  

Taken from: https://llvm.org/bugs/show_bug.cgi?id=22209 

https://reviews.llvm.org/D22725

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/ReplaceMemcpyCheck.cpp
  clang-tidy/misc/ReplaceMemcpyCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-replace-memcpy.rst
  test/clang-tidy/misc-replace-memcpy.cpp

Index: test/clang-tidy/misc-replace-memcpy.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-replace-memcpy.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s misc-replace-memcpy %t
+
+#include 
+#include 
+#include 
+
+void f() {
+  char foo[] = "foo", bar[3], baz[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcyp [misc-replace-memcpy]
+  // CHECK-FIXES: std::copy(foo, (foo) + (sizeof bar), bar);
+
+  bool b = false;
+  std::memcpy(baz, b ? foo : bar, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcyp [misc-replace-memcpy]
+  // CHECK-FIXES: std::copy(b ? foo : bar, (b ? foo : bar) + (3), baz);
+
+  memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcyp [misc-replace-memcpy]
+  // CHECK-FIXES: std::copy(foo, (foo) + (sizeof bar), bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
Index: docs/clang-tidy/checks/misc-replace-memcpy.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-replace-memcpy.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - misc-replace-memcpy
+
+misc-replace-memcpy
+===
+
+Replaces ``memcpy`` with ``std::copy``. This allows the compiler to decide on
+the most performant implementationon. Parenthesis are added devensively to
+preclude the summation from taking precedence.
+
+Example:
+
+.. code:: c++
+
+std::memcpy(dest, source, sizeof dest);
+
+// transforms to:
+
+std::copy(source, (source) + (sizeof dest), dest);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -29,6 +29,7 @@
cppcoreguidelines-pro-type-static-cast-downcast
cppcoreguidelines-pro-type-union-access
cppcoreguidelines-pro-type-vararg
+   cppcoreguidelines-slicing
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
@@ -72,6 +73,7 @@
misc-non-copyable-objects
misc-pointer-and-integral-operation
misc-redundant-expression
+   misc-replace-memcpy
misc-sizeof-container
misc-sizeof-expression
misc-static-assert
Index: clang-tidy/misc/ReplaceMemcpyCheck.h
===
--- /dev/null
+++ clang-tidy/misc/ReplaceMemcpyCheck.h
@@ -0,0 +1,38 @@
+//===--- ReplaceMemcpyCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_REPLACE_MEMCPY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_REPLACE_MEMCPY_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Replaces memcpy with std::copy
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-replace-memcpy.html
+class ReplaceMemcpyCheck : public ClangTidyCheck {
+public:
+  ReplaceMemcpyCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+  static StringRef GetText(const Expr *Expression, const SourceManager &SM,
+   const LangOptions &LangOpts);
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_REPLACE_MEMCPY_H
Index: clang-tidy/misc/ReplaceMemcpyCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/ReplaceMemcpyCheck.cpp
@@ -0,0 +1,60 @@
+//===--- ReplaceMemcpyCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illino

Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-23 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D22725#493940, @aaron.ballman wrote:

> > Using std::copy opens up the possibility of type-aware optimizations which 
> > are not possible with memcpy.
>
>
> To my knowledge, those type-aware optimizations are for transforming copies 
> involving trivially-copyable types into calls to memcpy(). What other 
> optimizations does this check enable?


I might be mistaken, but I understood that a call to std::copy (whether or not 
specialized for certain types) might get inlined, while a call to memcpy is 
typically not.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-23 Thread Jonas Devlieghere via cfe-commits
JDevlieghere updated this revision to Diff 65246.
JDevlieghere added a comment.

- Added new check to release notes
- Renamed to modernize-use-copy
- Addressed comments from Prazek


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseCopyCheck.cpp
  clang-tidy/modernize/UseCopyCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-copy.rst
  test/clang-tidy/modernize-use-copy.cpp

Index: test/clang-tidy/modernize-use-copy.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-copy.cpp
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s modernize-use-copy %t
+
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+}
+
+void f() {
+  char foo[] = "foo", bar[3], baz[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy
+  // [modernize-use-copy]
+  // CHECK-FIXES: std::copy(foo, (foo) + (sizeof bar), bar);
+
+  bool b = false;
+  std::memcpy(baz, b ? foo : bar, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy
+  // [modernize-use-copy]
+  // CHECK-FIXES: std::copy(b ? foo : bar, (b ? foo : bar) + (3), baz);
+
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy
+  // [modernize-use-copy]
+  // CHECK-FIXES: std::copy(foo, (foo) + (sizeof bar), bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+#define memcpy(dest, src, len) std::memcpy((dest), (src), (len))
+void g() {
+  char foo[] = "foo", bar[3];
+  memcpy(bar, foo, sizeof bar);
+}
Index: docs/clang-tidy/checks/modernize-use-copy.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-copy.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - modernize-use-copy
+
+modernize-use-copy
+==
+
+Replaces ``memcpy`` with ``std::copy``. This makes the code cleaner and allows
+the compiler to decide on the preferred implementation.
+
+Example:
+
+.. code:: c++
+
+std::memcpy(dest, source, sizeof dest);
+
+// transforms to:
+
+std::copy(source, (source) + (sizeof dest), dest);
+
+Parenthesis are added devensively to preclude the summation from taking
+precedence over operators used in the arguments of ``memcpy``.
+
+.. code:: c++
+
+std::memcpy(baz, b ? foo : bar, 3);
+
+// transforms to:
+
+std::copy(b ? foo : bar, (b ? foo : bar) + (3), baz);
+
+// but without the parenthesis it would have become the equivalent of:
+
+std::copy(b ? foo : bar, b ? foo : (bar + 3), baz);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -29,6 +29,7 @@
cppcoreguidelines-pro-type-static-cast-downcast
cppcoreguidelines-pro-type-union-access
cppcoreguidelines-pro-type-vararg
+   cppcoreguidelines-slicing
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
@@ -103,6 +104,7 @@
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
+   modernize-use-copy
modernize-use-default
modernize-use-emplace
modernize-use-nullptr
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 +64,11 @@
 
   Flags slicing of member variables or vtable.
 
+- New `modernize-replace-memcpy
+  `_ check
+
+  Replaces calls to memcpy with std::copy.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/modernize/UseCopyCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/UseCopyCheck.h
@@ -0,0 +1,44 @@
+//===--- UseCopyCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_COPY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_COPY_H
+
+#include "../ClangTidy.h"
+#include "../utils/IncludeInserter.h"
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+/// Replaces memcpy with std::copy
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-copy.html
+clas

Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-23 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D22725#493947, @Prazek wrote:

> Thanks for the contribution. Is it your first check?


Yes, it is! :-)

> Some main issues:

> 

> 1. I think it would be much better to move this check to modernize module. I 
> think the name 'modernize-use-copy' would follow the convention, or just 
> 'modernize-replace-memcpy' also works, maybe it is even better. Your choice. 
> Use rename_check.py to rename the check.


Agreed, I moved and renamed the check.

> 2. Please add include fixer that will include  if it is not yet 
> included, so the code will compile after changes. Look at 
> DeprecatedHeadersCheck.cpp or PassByValueCheck ( or grep for 
> registerPPCallbacks)


Done

> 3. The extra parens are not ideal thing. Can you describe (with examples) in 
> which situations it would not compile/ something bad would happen if you 
> wouldn't put the parens? I think you could check it in matchers and then 
> apply parens or not.


I have included an example in the documentation with the ternary conditional 
operator. I agree that it's not ideal, but I tried to be defensive. Basically 
anything with lower precedence than the + operator might cause an issue, and 
this is quite a lot...

> 4. Have you run the check on LLVM code base? It uses std::copy in many 
> places. If after running with -fix all the memcpys will be gone (check if if 
> finds anything after second run) and the code will compile and tests will not 
> fail then it means that your check fully works!


Doing this as we speak!


Repository:
  rL LLVM

https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Jonas Devlieghere via cfe-commits
JDevlieghere removed rL LLVM as the repository for this revision.
JDevlieghere updated this revision to Diff 65273.
JDevlieghere added a comment.

- Extended check to replace memmove with std::move and memset with std::fill
- Renamed check to modernize-use-algorithm (I'd be equally fine with moving it 
to misc again)
- Added more documentation to better describe the goal of this check
- Fixed macro test and added cases for memmove and memset


https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void* dest, int ch, std::size_t count);
+void *memmove(void* dest, const void* src, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template
+void fill(ForwardIt first, ForwardIt last, const T& value);
+}
+
+void a() {
+  char foo[] = "foo", bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memmove(foo + 1, foo , 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::move instead of memmove [modernize-use-algorithm]
+  // CHECK-FIXES: std::move(foo, foo + 3, foo + 1);
+
+  std::move(foo, foo + 2, foo + 2);
+}
+
+void c() {
+  char foo[] = "foobar";
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::fill instead of memset [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 1);
+
+  std::move(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof (dest))
+void d() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+}
Index: docs/clang-tidy/checks/modernize-use-algorithm.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-algorithm.rst
@@ -0,0 +1,49 @@
+.. title:: clang-tidy - modernize-use-algorithm
+
+modernize-use-algorithm
+===
+
+Replaces calls to ``memcpy``, ``memmove`` and ``memset`` with ``std::copy``,
+``std::move`` and ``std::fill`` respectively. The advantages of using these
+algorithm functions is that they are at least as efficient, more general and
+type-aware.
+
+Furthermore, by using the algorithms the types remain intact as opposed to
+being discarded by the C-style functions. This allows the implementation to
+make use use of type information to further optimize. One example of such
+optimization is taking advantage of 64-bit alignment when copying an array of
+``std::uint64_t``.
+
+memcpy
+--
+
+.. code:: c++
+
+std::memcpy(dest, source, sizeof dest);
+
+// transforms to:
+
+std::copy(source, source + sizeof dest, dest);
+
+memmove
+---
+
+.. code:: c++
+
+std::memmove(dest, source, sizeof dest);
+
+// transforms to:
+
+std::move(source, source + sizeof dest, dest);
+
+memset
+--
+
+.. code:: c++
+
+std::memset(dest, ch, count);
+
+// transforms to:
+
+std::fill(dest, dest + count, ch)
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -29,6 +29,7 @@
cppcoreguidelines-pro-type-static-cast-downcast
cppcoreguidelines-pro-type-union-access
cppcoreguidelines-pro-type-vararg
+   cppcoreguidelines-slicing
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
@@ -103,6 +104,7 @@
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
+   modernize-use-algorithm
modernize-use-default
modernize-use-emplace
modernize-use-nullptr
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -64,6 +64,13 @@
 
   Flags slicing of member variables or vtable.
 
+- New `modernize-use-algorithm
+  `_ check
+
+  Rep

Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D22725#494074, @Prazek wrote:

> Maybe the right way would be to have check called 
> 'modernize-use-sequence-algorithm' or just 'modernize-use-algorithm' that 
> would basically do all those stuff. It would be good to not introduce 5 new 
> check that pretty much do the same thing and also the user would want to have 
> them all or none.
>  You can look how I did it with modernize-use-make-shared, it would be pretty 
> much the same.


I kept everything in modernize-use-algorithm as I agree this isn't worth 3 
different checks.

> So It should not be very hard. You would just have to check if the second or 
> third argument to memcpy is one of [list here] of the things that 

>  would make it bad. And you can probably write easy matcher for this.

>  I understand that it probably will take the double of time that you have 
> spend on this check, but this will actually is the thing here - you want your 
> check to produce the fixes that makes sense. When you will run it on llvm 
> code base, I guess you will see that over 90% of the cases didn't require 
> coma. I understand that you want to make it accurate, but the fix should not 
> also intoruce some code that is not tidy enough.

>  So I guess either fix it, or wait what Alex will say about it. It might make 
> it to upstream like this, but I hope you would fix it in some time :)


You are right. I didn't completely finish the first run on LLVM, but none of 
the occurrences it had found so far would have caused an issue. I guess that 
means that omitting the extra parens is a sensible default for now. I will look 
into excluding problematic situations once I am sure this check is fully 
functional.

> Anyway good job, hope to see some more checks from you!


Thanks, I really appreciate the feedback from everyone! :)

> > > 4. Have you run the check on LLVM code base? It uses std::copy in many 
> > > places. If after running with -fix all the memcpys will be gone (check if 
> > > if finds anything after second run) and the code will compile and tests 
> > > will not fail then it means that your check fully works!

> 

> > 

> 

> > 

> 

> > Doing this as we speak!

> 

> 

> When you will be finished just post a diff of changes after running it on 
> llvm on phabricator and add me as subscriber :)


It's running again with the changes from the last revision included. It is 
taking a very long time though but I guess that's my fault for not building in 
release mode. I'll leave it running for now as I don't want to start over again.


https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-24 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

In https://reviews.llvm.org/D22725#494167, @Prazek wrote:

> hmm It seems that I mislead you, I suck at C api - memmove source and 
> destination can overlap, but std::move can't. So I guess you have to remove 
> the memmove support. Sorry.


No problem, I wasn't aware of the issue either, so thanks for letting me know!

While running my check on the LLVM repo I ran into another issue: can't do 
pointer arithmetic when the arguments to memcpy are void pointers. I will look 
into updating my matchers to exclude this particular case.


https://reviews.llvm.org/D22725



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


Re: [llvm-dev] [RFC] Embedded bitcode and related upstream (Part II)

2016-07-25 Thread Jonas Devlieghere via cfe-commits
Hi,

I hope I'm not breaking any mailing list etiquette by replying to this
mail, but if I am then please accept my apologies.

On Fri, Jun 3, 2016 at 8:36 PM, Steven Wu via llvm-dev
 wrote:
> Hi everyone
>
> I am still in the process of upstreaming some improvements to the embed
> bitcode option. If you want more background, you can read the previous RFC
> (http://lists.llvm.org/pipermail/llvm-dev/2016-February/094851.html). This
> is part II of the discussion.
>
> Current Status:
> A basic version of -fembed-bitcode option is upstreamed and functioning.
> You can use -fembed-bitcode={off, all, bitcode, marker} option to control
> what gets embedded in the final object file output:
> off: default, nothing gets embedded.
> all: optimized bitcode and command line options gets embedded in the object
> file.
> bitcode: only optimized bitcode is embedded
> marker: only put a marker in the object file
>
> What needs to be improved:
> 1. Whitelist for command line options that can be used with bitcode:
> Current trunk implementation embeds all the cc1 command line options (that
> includes header include paths, warning flags and other front-end options) in
> the command line section. That is lot of redundant information. To re-create
> the object file from the embedded optimized bitcode, most of these options
> are useless. On the other hand, they can leak information of the source
> code. One solution will be keeping a list of all the options that can affect
> code generation but not encoded in the bitcode. I have internally prototyped
> with disallowing these options explicitly and allowed only the reminder of
> the  options to be embedded (http://reviews.llvm.org/D17394). A better
> solution might be encoding that information in "Options.td" as specific
> group.
>
> 2. Assembly input handling:
> This is a workaround to allow source code written in assembly to work with
> "-fembed-bitcode" options. When compiling assembly source code with
> "-fembed-bitcode", clang-as creates an empty section "__LLVM, __asm" in the
> object file. That is just a way to distinguish object files compiled from
> assembly source from those compiled from higher level source code but forgot
> to use "-fembed-bitcode" options. Linker can use this section to diagnose if
> "-fembed-bitcode" is consistently used on all the object files participated
> in the linking.
>
> 3. Bitcode symbol hiding:
> There was some concerns for leaking source code information when using
> bitcode feature. One approach to avoid the leak is to add a pass which
> renames all the globals and metadata strings. The also keeps a reverse map
> in case the original name needs to be recovered. The final bitcode should
> contain no more symbols or debug info than a stripped binary. To make sure
> modified bitcode can still be linked correctly, the renaming need to be
> consistent across all bitcode participated in the linking and everything
> that is external of the linkage unit need to be preserved. This means the
> pass can only be run during the linking and requires some LTO api.

Regarding the symbol map, are you planning to upstream a pass that
restores the symbols? I have been trying to do this myself in order to
reverse the "BCSymbolMap". However this turned out to be less
straightforward than I'd hoped. Any info on this would be greatly
appreciated!

> 4. Debug info strip to line-tables pass:
> As the name suggested, this pass strip down the full debug info to
> line-tables only. This is also one of the steps we took to prevent the leak
> of source code information in bitcode.
>
> Please let me know what do you think about the pieces above or if you have
> any concerns about the methodology. I will put up patches for review soon.
>
> Thanks
>
> Steven
>
> ___
> LLVM Developers mailing list
> llvm-...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Cheers,
Jonas
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-28 Thread Jonas Devlieghere via cfe-commits
JDevlieghere added a comment.

Thanks for the reviews everyone!

I'm currently still stuck on an issue I discovered when processing LLVM. I 
asked for help on the mailing list [0] but maybe someone here can help. 
Basically the issue is that sometimes pointers are passed to memcpy for which 
the types are not assignable. That's okay for memcpy because it takes its 
arguments as void pointers, but of course this causes std::copy to complain.

I want my pass to warn the user about this issue but skip the substitution, but 
I don't know how to check for this case...

[0] http://lists.llvm.org/pipermail/cfe-dev/2016-July/050105.html


https://reviews.llvm.org/D22725



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


Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-07-31 Thread Jonas Devlieghere via cfe-commits
JDevlieghere retitled this revision from "[clang-tidy] Add check 
'misc-replace-memcpy'" to "[clang-tidy] Add check 'modernize-use-algorithm'".
JDevlieghere updated the summary for this revision.
JDevlieghere set the repository for this revision to rL LLVM.
JDevlieghere updated this revision to Diff 66247.
JDevlieghere added a comment.

- Addressed concerns raised by Etienne Bergeron
- Show warning when using void pointers but don't replace
- Don't make replacement when destination is const
- Don't make replacement when types are not compatible


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,50 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void *dest, int ch, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+void fill(ForwardIt first, ForwardIt last, const T &value);
+}
+
+void a() {
+  char foo[] = "foo", bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  void* baz = bar;
+  std::memcpy(baz, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::fill instead of memset [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::fill instead of memset [modernize-use-algorithm]
+
+  std::fill(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof(dest))
+void c() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+}
Index: docs/clang-tidy/checks/modernize-use-algorithm.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-algorithm.rst
@@ -0,0 +1,37 @@
+.. title:: clang-tidy - modernize-use-algorithm
+
+modernize-use-algorithm
+===
+
+Replaces calls to ``memcpy`` and ``memset`` with ``std::copy``, and
+``std::fill`` respectively. The advantages of using these algorithm functions
+is that they are at least as efficient, more general and type-aware.
+
+Furthermore, by using the algorithms the types remain intact as opposed to
+being discarded by the C-style functions. This allows the implementation to
+make use use of type information to further optimize. One example of such
+optimization is taking advantage of 64-bit alignment when copying an array of
+``std::uint64_t``.
+
+memcpy
+--
+
+.. code:: c++
+
+std::memcpy(dest, source, sizeof dest);
+
+// transforms to:
+
+std::copy(source, source + sizeof dest, dest);
+
+memset
+--
+
+.. code:: c++
+
+std::memset(dest, ch, count);
+
+// transforms to:
+
+std::fill(dest, dest + count, ch)
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -105,6 +105,7 @@
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
+   modernize-use-algorithm
modernize-use-default
modernize-use-emplace
modernize-use-nullptr
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -69,6 +69,12 @@
 
   Flags classes where some, but not all, special member functions are user-defined.
 
+- New `modernize-use-algorithm
+  `_ check
+
+  Replaces calls to ``memcpy`` and ``memset`` with their respective algorithm
+  counterparts ``std::copy`` and ``std::fill``.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/modernize/UseAlgorithmCheck.h
===
--- /dev/null
+++ clang-tidy/modernize

Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-08-01 Thread Jonas Devlieghere via cfe-commits
JDevlieghere updated this revision to Diff 66350.
JDevlieghere added a comment.

Addressed comments from Piotr Padlewski


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,50 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void *dest, int ch, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+void fill(ForwardIt first, ForwardIt last, const T &value);
+}
+
+void a() {
+  char foo[] = "foo", bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  void* baz = bar;
+  std::memcpy(baz, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::fill instead of memset [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::fill instead of memset [modernize-use-algorithm]
+
+  std::fill(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof(dest))
+void c() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Use std::copy instead of memcpy [modernize-use-algorithm]
+}
Index: docs/clang-tidy/checks/modernize-use-algorithm.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-algorithm.rst
@@ -0,0 +1,37 @@
+.. title:: clang-tidy - modernize-use-algorithm
+
+modernize-use-algorithm
+===
+
+Replaces calls to ``memcpy`` and ``memset`` with ``std::copy``, and
+``std::fill`` respectively. The advantages of using these algorithm functions
+is that they are at least as efficient, more general and type-aware.
+
+Furthermore, by using the algorithms the types remain intact as opposed to
+being discarded by the C-style functions. This allows the implementation to
+make use use of type information to further optimize. One example of such
+optimization is taking advantage of 64-bit alignment when copying an array of
+``std::uint64_t``.
+
+memcpy
+--
+
+.. code:: c++
+
+std::memcpy(dest, source, sizeof dest);
+
+// transforms to:
+
+std::copy(source, source + sizeof dest, dest);
+
+memset
+--
+
+.. code:: c++
+
+std::memset(dest, ch, count);
+
+// transforms to:
+
+std::fill(dest, dest + count, ch)
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -105,6 +105,7 @@
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
+   modernize-use-algorithm
modernize-use-default
modernize-use-emplace
modernize-use-nullptr
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -69,6 +69,12 @@
 
   Flags classes where some, but not all, special member functions are user-defined.
 
+- New `modernize-use-algorithm
+  `_ check
+
+  Replaces calls to ``memcpy`` and ``memset`` with their respective algorithm
+  counterparts ``std::copy`` and ``std::fill``.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/modernize/UseAlgorithmCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/UseAlgorithmCheck.h
@@ -0,0 +1,42 @@
+//===--- UseAlgorithmCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLAN

Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-08-03 Thread Jonas Devlieghere via cfe-commits
JDevlieghere updated this revision to Diff 66688.
JDevlieghere marked 21 inline comments as done.
JDevlieghere added a comment.

Addresses comments from Aaron Ballman

@aaron.ballman Thanks for the thorough review! Can you check whether the tests 
I added address your concerns? Could you also elaborate on the case with the 
C-function pointer? Unless I explicitly cast it to void* the compiler rejects 
will reject it as an argument to memcpy. Am I missing a case where this could 
go wrong? I still added it to the pointer arithmetic check though, just to be 
sure.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,125 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void *dest, int ch, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+void fill(ForwardIt first, ForwardIt last, const T &value);
+}
+
+namespace awful {
+void memcpy(int, int, int);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t size);
+
+void a() {
+  char foo[] = "foo", bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  void *baz = bar;
+  std::memcpy(baz, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+
+  memcpy(bar, foo, sizeof bar);
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+
+  std::fill(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof(dest))
+void c() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+}
+
+void d() {
+  typedef char foo_t;
+  typedef char bar_t;
+  foo_t foo[] = "foo";
+  bar_t bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void e() {
+  typedef const char *foo_t;
+  typedef const char *bar_t;
+  foo_t foo[] = {"foo", "bar"};
+  bar_t bar[2];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void f() {
+  typedef int some_type;
+  typedef some_type *const *volatile *foo_ptr;
+
+  typedef int *const some_other_type;
+  typedef some_other_type *volatile *bar_ptr;
+
+  foo_ptr foo[4];
+  bar_ptr bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void g() {
+  int foo[3][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}};
+  int bar[2][4];
+
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  int baz[3][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
+  int qux[2][4];
+  std::memcpy(qux, baz, sizeof qux);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+}
+
+void h() {
+  int a = 1;
+  int b = 2;
+  int c = 3;
+
+  char foo[] = "foobar";
+  char bar[3];
+
+  std::memcpy((bar), (foo + b), (a + c - 1));
+  // CHECK-MESSAGES: :[[@LINE-

Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-08-04 Thread Jonas Devlieghere via cfe-commits
JDevlieghere updated this revision to Diff 66835.
JDevlieghere marked 9 inline comments as done.
JDevlieghere added a comment.

- Added function pointer test case
- Used placeholders for diagnostics

I extended the matchers to include `::memcpy` and `::memset` as well because 
the check otherwise does not work on my mac because the `cstring` header that 
ships with Xcode is implemented as shown below.

  _LIBCPP_BEGIN_NAMESPACE_STD
  using ::size_t;
  using ::memcpy;
  using ::memset;
  ...
  _LIBCPP_END_NAMESPACE_STD

This is annoying as I have no way to discriminate functions that have the same 
signature. Unless there's a better solution, this seems like a reasonable 
trade-off to me. Of course I'm open to suggestions!

In https://reviews.llvm.org/D22725#505739, @aaron.ballman wrote:

> The tests added mostly cover them -- I elaborated on the function pointer 
> case, which I don't *think* will go wrong with this check, but should have a 
> pathological test case for just to be sure.


I added the test case. The call is indeed replaced, which I guess is fine?

In https://reviews.llvm.org/D22725#505476, @Prazek wrote:

> Did you manage to see what was wrong in the transformation that you did on 
> LLVM?


Not yet, thought it seemed to be related to `std::copy` rather than 
`std::fill`. I'm still trying to pinpoint the culprit but it's extremely time 
consuming as I have to recompile LLVM completely in order to run the tests...


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void *dest, int ch, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+void fill(ForwardIt first, ForwardIt last, const T &value);
+}
+
+namespace awful {
+void memcpy(int, int, int);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t size);
+
+void a() {
+  char foo[] = "foo", bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  void *baz = bar;
+  std::memcpy(baz, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+
+  memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+
+  std::fill(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof(dest))
+void c() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+}
+
+void d() {
+  typedef char foo_t;
+  typedef char bar_t;
+  foo_t foo[] = "foo";
+  bar_t bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void e() {
+  typedef const char *foo_t;
+  typedef const char *bar_t;
+  foo_t foo[] = {"foo", "bar"};
+  bar_t bar[2];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void f() {
+  typedef int some_type;
+  typedef some_type *const *volatile *foo_ptr;
+
+  typedef int *const some_other_type;
+  typed

Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-08-09 Thread Jonas Devlieghere via cfe-commits
JDevlieghere updated this revision to Diff 67390.
JDevlieghere marked 5 inline comments as done.
JDevlieghere added a comment.

Fixes issues raised by Alexander and Aaron


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,160 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+// CHECK-FIXES: #include 
+
+namespace {
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void *dest, int ch, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+void fill(ForwardIt first, ForwardIt last, const T &value);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t count);
+void *memset(void *dest, int ch, size_t count);
+
+namespace alternative_std {
+using ::memcpy;
+using ::memset;
+}
+
+namespace awful {
+void memcpy(int, int, int);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t size);
+
+void a() {
+  char foo[] = "foo", bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  alternative_std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  void *baz = bar;
+  std::memcpy(baz, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+
+  memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  alternative_std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+
+  std::fill(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof(dest))
+void c() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+}
+
+void d() {
+  typedef char foo_t;
+  typedef char bar_t;
+  foo_t foo[] = "foo";
+  bar_t bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void e() {
+  typedef const char *foo_t;
+  typedef const char *bar_t;
+  foo_t foo[] = {"foo", "bar"};
+  bar_t bar[2];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void f() {
+  typedef int some_type;
+  typedef some_type *const *volatile *foo_ptr;
+
+  typedef int *const some_other_type;
+  typedef some_other_type *volatile *bar_ptr;
+
+  foo_ptr foo[4];
+  bar_ptr bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void g() {
+  int foo[3][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}};
+  int bar[2][4];
+
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use

Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-08-09 Thread Jonas Devlieghere via cfe-commits
JDevlieghere updated this revision to Diff 67391.
JDevlieghere added a comment.

Removed anonymous namespaces in test file. I was playing around with it but 
forgot to remove it before making my last diff.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

Index: test/clang-tidy/modernize-use-algorithm.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-algorithm.cpp
@@ -0,0 +1,156 @@
+// RUN: %check_clang_tidy %s modernize-use-algorithm %t
+// CHECK-FIXES: #include 
+
+namespace std {
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *src, std::size_t count);
+void *memset(void *dest, int ch, std::size_t count);
+
+template 
+OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+OutputIt move(InputIt first, InputIt last, OutputIt d_first);
+
+template 
+void fill(ForwardIt first, ForwardIt last, const T &value);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t count);
+void *memset(void *dest, int ch, size_t count);
+
+namespace alternative_std {
+using ::memcpy;
+using ::memset;
+}
+
+namespace awful {
+void memcpy(int, int, int);
+}
+
+typedef unsigned int size_t;
+void *memcpy(void *dest, const void *source, size_t size);
+
+void a() {
+  char foo[] = "foo", bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  alternative_std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  void *baz = bar;
+  std::memcpy(baz, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+
+  memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+
+  std::copy(foo, foo + sizeof bar, bar);
+}
+
+void b() {
+  char foo[] = "foobar";
+  std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  alternative_std::memset(foo, 'a', 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::fill(foo, foo + 3, 'a');
+
+  std::memset(foo, 1, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memset' reduces type-safety, consider using 'std::fill' instead [modernize-use-algorithm]
+
+  std::fill(foo, foo + 2, 'a');
+}
+
+#define MEMCPY(dest, src) std::memcpy((dest), (src), sizeof(dest))
+void c() {
+  char foo[] = "foo", bar[3];
+  MEMCPY(bar, foo);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+}
+
+void d() {
+  typedef char foo_t;
+  typedef char bar_t;
+  foo_t foo[] = "foo";
+  bar_t bar[4];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void e() {
+  typedef const char *foo_t;
+  typedef const char *bar_t;
+  foo_t foo[] = {"foo", "bar"};
+  bar_t bar[2];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void f() {
+  typedef int some_type;
+  typedef some_type *const *volatile *foo_ptr;
+
+  typedef int *const some_other_type;
+  typedef some_other_type *volatile *bar_ptr;
+
+  foo_ptr foo[4];
+  bar_ptr bar[3];
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' instead [modernize-use-algorithm]
+  // CHECK-FIXES: std::copy(foo, foo + sizeof bar, bar);
+}
+
+void g() {
+  int foo[3][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}};
+  int bar[2][4];
+
+  std::memcpy(bar, foo, sizeof bar);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' reduces type-safety, consider using 'std::copy' in

[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-04 Thread Jonas Devlieghere via cfe-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS

JDevlieghere wrote:

"tools" has a pretty specific meaning for LLVM so I think that will actually 
cause more confusion (i.e. I would expect that option to apply to 
`llvm-dwarfdump`, but not to `clang`). I'm personally fine with the current 
concise name. 

https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [driver] Make --version show if assertions, etc. are enabled (PR #87585)

2024-04-04 Thread Jonas Devlieghere via cfe-commits

https://github.com/JDevlieghere approved this pull request.

Thanks, this LGTM!

https://github.com/llvm/llvm-project/pull/87585
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)

2024-04-05 Thread Jonas Devlieghere via cfe-commits


@@ -673,6 +673,9 @@ option(LLVM_USE_OPROFILE
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
+option(LLVM_ENABLE_EXPORTED_SYMBOLS

JDevlieghere wrote:

@delcypher I was referring to the tools in `/llvm-project/llvm/tools`, which 
use `add_llvm_tool_subdirectory` and `add_llvm_tool` but maybe the distinction 
is more murky than I think it is. I'm also fine with `EXECUTABLE` in the name 👍

https://github.com/llvm/llvm-project/pull/87684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Enable LLDB tests in Linux pre-merge CI (PR #94208)

2024-06-05 Thread Jonas Devlieghere via cfe-commits

JDevlieghere wrote:

> But lldb sets itself apart in how hard it is to get a project setup going, 
> and how impactful it is.

Can you elaborate on what specifically you find hard? Building should be fairly 
straightforward, besides Python and SWIG, which are required to run the test, 
most of our dependencies are optional. Unlike the compiler, the debugger is (1) 
tied to the system it's running on, and (2) an interactive tool, so maybe 
that's what you're referring to? Either way, if there are concrete ways we can 
make LLDB easier to work on, I'd love to hear your suggestions!

https://github.com/llvm/llvm-project/pull/94208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Enable LLDB tests in Linux pre-merge CI (PR #94208)

2024-06-05 Thread Jonas Devlieghere via cfe-commits

JDevlieghere wrote:

> 1. Windows support

Windows support is definitely lacking which probably means a bunch of tests 
don't run there. We do have [one 
buildbot](https://lab.llvm.org/buildbot/#/builders/219) that runs on Windows so 
I have a hard time believing it's totally broken. The last runs are 
consistently green and based on the number of tests it seems to still cover a 
remarkable subset of the test suite. 

> 2. Build system does not support Multi-config generators. You can grep for 
> https://cmake.org/cmake/help/latest/variable/CMAKE_CFG_INTDIR.html as an 
> example.

This simply isn't true. Xcode is a multi-config build system and we have [a 
bot](https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/lldb-cmake-standalone/)
 that ensures that doesn't break. Maybe there's something different about MSVC? 

> 3. Not all tests pass and it's quite unclear when that is not your fault.

I really sympathize with this one. Most of that's boils down to how much we 
have to rely on the OS and other tools (the compiler, the linker, etc) for our 
integration tests. Having more tests written as unit tests or regression tests 
using `lldb-test` will help with that. I think we (the lldb community) can be 
more vigilant on that front in pushing for those tests. 👍

https://github.com/llvm/llvm-project/pull/94208
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >