r347035 - [clang] - Simplify tools::SplitDebugName.

2018-11-16 Thread George Rimar via cfe-commits
Author: grimar
Date: Thu Nov 15 23:59:24 2018
New Revision: 347035

URL: http://llvm.org/viewvc/llvm-project?rev=347035&view=rev
Log:
[clang] - Simplify tools::SplitDebugName.

This should be NFC change.

SplitDebugName recently started to accept the `Output` that
can be used to simplify the logic a bit, also it
seems that code in SplitDebugName that uses
OPT_fdebug_compilation_dir is simply dead.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=347035&r1=347034&r2=347035&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Nov 15 23:59:24 2018
@@ -3936,7 +3936,7 @@ void Clang::ConstructJob(Compilation &C,
   const char *SplitDWARFOut;
   if (SplitDWARF) {
 CmdArgs.push_back("-split-dwarf-file");
-SplitDWARFOut = SplitDebugName(Args, Input, Output);
+SplitDWARFOut = SplitDebugName(Args, Output);
 CmdArgs.push_back(SplitDWARFOut);
   }
 
@@ -5902,7 +5902,7 @@ void ClangAs::ConstructJob(Compilation &
   if ((getDebugFissionKind(D, Args, A) == DwarfFissionKind::Split) &&
   (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
-CmdArgs.push_back(SplitDebugName(Args, Input, Output));
+CmdArgs.push_back(SplitDebugName(Args, Output));
   }
 
   assert(Input.isFilename() && "Invalid input.");

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=347035&r1=347034&r2=347035&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Nov 15 23:59:24 2018
@@ -808,26 +808,15 @@ bool tools::areOptimizationsEnabled(cons
   return false;
 }
 
-const char *tools::SplitDebugName(const ArgList &Args, const InputInfo &Input,
+const char *tools::SplitDebugName(const ArgList &Args,
   const InputInfo &Output) {
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
 if (StringRef(A->getValue()) == "single")
   return Args.MakeArgString(Output.getFilename());
 
-  Arg *FinalOutput = Args.getLastArg(options::OPT_o);
-  if (FinalOutput && Args.hasArg(options::OPT_c)) {
-SmallString<128> T(FinalOutput->getValue());
-llvm::sys::path::replace_extension(T, "dwo");
-return Args.MakeArgString(T);
-  } else {
-// Use the compilation dir.
-SmallString<128> T(
-Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
-SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput()));
-llvm::sys::path::replace_extension(F, "dwo");
-T += F;
-return Args.MakeArgString(F);
-  }
+  SmallString<128> T(Output.getFilename());
+  llvm::sys::path::replace_extension(T, "dwo");
+  return Args.MakeArgString(T);
 }
 
 void tools::SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.h?rev=347035&r1=347034&r2=347035&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.h Thu Nov 15 23:59:24 2018
@@ -63,7 +63,7 @@ void AddHIPLinkerScript(const ToolChain
 const Tool &T);
 
 const char *SplitDebugName(const llvm::opt::ArgList &Args,
-   const InputInfo &Input, const InputInfo &Output);
+   const InputInfo &Output);
 
 void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,
 const JobAction &JA, const llvm::opt::ArgList &Args,

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=347035&r1=347034&r2=347035&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Nov 15 23:59:24 2018
@@ -817,7 +817,7 @@ void tools::gnutools::Assembler::Constru
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
   getToolChain().getTriple().isOSLinux())
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
-   SplitDebugName(Args, Inputs[0], Output));
+   SplitDebugName(Args, Output));
 }
 
 namespace {

Modif

[PATCH] D54576: [clang] - Simplify tools::SplitDebugName.

2018-11-16 Thread George Rimar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347035: [clang] - Simplify tools::SplitDebugName. (authored 
by grimar, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54576?vs=174193&id=174335#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54576

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/lib/Driver/ToolChains/MinGW.cpp


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -54,7 +54,7 @@
 
   if (Args.hasArg(options::OPT_gsplit_dwarf))
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
-   SplitDebugName(Args, Inputs[0], Output));
+   SplitDebugName(Args, Output));
 }
 
 void tools::MinGW::Linker::AddLibGCC(const ArgList &Args,
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3936,7 +3936,7 @@
   const char *SplitDWARFOut;
   if (SplitDWARF) {
 CmdArgs.push_back("-split-dwarf-file");
-SplitDWARFOut = SplitDebugName(Args, Input, Output);
+SplitDWARFOut = SplitDebugName(Args, Output);
 CmdArgs.push_back(SplitDWARFOut);
   }
 
@@ -5902,7 +5902,7 @@
   if ((getDebugFissionKind(D, Args, A) == DwarfFissionKind::Split) &&
   (T.isOSLinux() || T.isOSFuchsia())) {
 CmdArgs.push_back("-split-dwarf-file");
-CmdArgs.push_back(SplitDebugName(Args, Input, Output));
+CmdArgs.push_back(SplitDebugName(Args, Output));
   }
 
   assert(Input.isFilename() && "Invalid input.");
Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -808,26 +808,15 @@
   return false;
 }
 
-const char *tools::SplitDebugName(const ArgList &Args, const InputInfo &Input,
+const char *tools::SplitDebugName(const ArgList &Args,
   const InputInfo &Output) {
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
 if (StringRef(A->getValue()) == "single")
   return Args.MakeArgString(Output.getFilename());
 
-  Arg *FinalOutput = Args.getLastArg(options::OPT_o);
-  if (FinalOutput && Args.hasArg(options::OPT_c)) {
-SmallString<128> T(FinalOutput->getValue());
-llvm::sys::path::replace_extension(T, "dwo");
-return Args.MakeArgString(T);
-  } else {
-// Use the compilation dir.
-SmallString<128> T(
-Args.getLastArgValue(options::OPT_fdebug_compilation_dir));
-SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput()));
-llvm::sys::path::replace_extension(F, "dwo");
-T += F;
-return Args.MakeArgString(F);
-  }
+  SmallString<128> T(Output.getFilename());
+  llvm::sys::path::replace_extension(T, "dwo");
+  return Args.MakeArgString(T);
 }
 
 void tools::SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,
Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
@@ -63,7 +63,7 @@
 const Tool &T);
 
 const char *SplitDebugName(const llvm::opt::ArgList &Args,
-   const InputInfo &Input, const InputInfo &Output);
+   const InputInfo &Output);
 
 void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,
 const JobAction &JA, const llvm::opt::ArgList &Args,
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -817,7 +817,7 @@
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
   getToolChain().getTriple().isOSLinux())
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
-   SplitDebugName(Args, Inputs[0], Output));
+   SplitDebugName(Args, Output));
 }
 
 namespace {


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -54,7 +54,7 @@
 
   if (Args.hasArg(options::OPT_gsplit_dwarf))
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
-   SplitDebugName(Args, Inputs[0], Output));
+   SplitDebugName(Args, Output));
 }
 
 void tools::MinGW::Linker::AddLibGCC(const ArgLi

[clang-tools-extra] r347036 - [clangd] Initial clang-tidy diagnostics support.

2018-11-16 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Nov 16 00:32:23 2018
New Revision: 347036

URL: http://llvm.org/viewvc/llvm-project?rev=347036&view=rev
Log:
[clangd] Initial clang-tidy diagnostics support.

Summary:
This runs checks over a restricted subset of the TU:
 - preprocessor callbacks just receive the truncated PP events that
   occur when a preamble is used.
 - ASTMatchers run only over the top-level decls in the main-file

This patch just turns on one simple check (bugprone-sizeof-expression)
with no configuration. Configuration is complex enough to warrant a separate 
patch

This depends on a patch allowing traversal to be restricted to a scope.

Reviewers: hokein

Subscribers: srhines, mgorny, ilya-biryukov, ioeric, MaskRay, jkorous, 
arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=347036&r1=347035&r2=347036&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Nov 16 00:32:23 2018
@@ -64,6 +64,24 @@ add_clang_library(clangDaemon
   clangLex
   clangSema
   clangSerialization
+  clangTidy
+  clangTidyAndroidModule
+  clangTidyAbseilModule
+  clangTidyBoostModule
+  clangTidyBugproneModule
+  clangTidyCERTModule
+  clangTidyCppCoreGuidelinesModule
+  clangTidyFuchsiaModule
+  clangTidyGoogleModule
+  clangTidyHICPPModule
+  clangTidyLLVMModule
+  clangTidyMiscModule
+  clangTidyModernizeModule
+  clangTidyObjCModule
+  clangTidyPerformanceModule
+  clangTidyPortabilityModule
+  clangTidyReadabilityModule
+  clangTidyZirconModule
   clangTooling
   clangToolingCore
   clangToolingInclusions

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=347036&r1=347035&r2=347036&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Fri Nov 16 00:32:23 2018
@@ -8,6 +8,8 @@
 
//===--===//
 
 #include "ClangdUnit.h"
+#include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
+#include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "Compiler.h"
 #include "Diagnostics.h"
 #include "Logger.h"
@@ -151,6 +153,40 @@ ParsedAST::build(std::unique_ptr> CTChecks;
+  ast_matchers::MatchFinder CTFinder;
+  llvm::Optional CTContext;
+  {
+trace::Span Tracer("ClangTidyInit");
+tidy::ClangTidyCheckFactories CTFactories;
+for (const auto &E : tidy::ClangTidyModuleRegistry::entries())
+  E.instantiate()->addCheckFactories(CTFactories);
+auto CTOpts = tidy::ClangTidyOptions::getDefaults();
+// FIXME: this needs to be configurable, and we need to support .clang-tidy
+// files and other options providers.
+// These checks exercise the matcher- and preprocessor-based hooks.
+CTOpts.Checks =
+"bugprone-sizeof-expression,bugprone-macro-repeated-side-effects";
+CTContext.emplace(llvm::make_unique(
+tidy::ClangTidyGlobalOptions(), CTOpts));
+CTContext->setDiagnosticsEngine(&Clang->getDiagnostics());
+CTContext->setASTContext(&Clang->getASTContext());
+CTContext->setCurrentFile(MainInput.getFile());
+CTFactories.createChecks(CTContext.getPointer(), CTChecks);
+for (const auto &Check : CTChecks) {
+  // FIXME: the PP callbacks skip the entire preamble.
+  // Checks that want to see #includes in the main file do not see them.
+  Check->registerPPCallbacks(*Clang);
+  Check->registerMatchers(&CTFinder);
+}
+  }
+
   // Copy over the includes from the preamble, then combine with the
   // non-preamble includes below.
   auto Includes = Preamble ? Preamble->Includes : IncludeStructure{};
@@ -160,13 +196,26 @@ ParsedAST::build(std::unique_ptrExecute())
 log("Execute() failed when building AST for {0}", MainInput.getFile());
 
+  std::vector ParsedDecls = Action->takeTopLevelDecls();
+  // AST traversals should exclude the preamble, to avoid performance cliffs.
+  Clang->getASTContext().setTraversalScope(ParsedDecls);
+  {
+// Run the AST-dependent part of the clang-tidy checks.
+// (The preprocessor part ran already, via PPCallbacks).
+trace::Span Tracer("ClangTidyMatch");
+CTFinder.matchAST(Clang->getASTContext());
+  }
+
   // UnitDiagsConsumer is local, we can not store it in CompilerInstance that
   // has a longer lifetime.
   Clang->getDiagnostics().setClient(new IgnoreDiagnostics);
  

[PATCH] D54204: [clangd] Initial clang-tidy diagnostics support.

2018-11-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347036: [clangd] Initial clang-tidy diagnostics support. 
(authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54204

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
@@ -24,6 +24,7 @@
 using testing::Field;
 using testing::IsEmpty;
 using testing::Pair;
+using testing::UnorderedElementsAre;
 
 testing::Matcher WithFix(testing::Matcher FixMatcher) {
   return Field(&Diag::Fixes, ElementsAre(FixMatcher));
@@ -128,6 +129,30 @@
   WithFix(Fix(Test.range(), "int", "change return type to 'int'");
 }
 
+TEST(DiagnosticsTest, ClangTidy) {
+  Annotations Test(R"cpp(
+#define $macrodef[[SQUARE]](X) (X)*(X)
+int main() {
+  return [[sizeof]](sizeof(int));
+  int y = 4;
+  return SQUARE($macroarg[[++]]y);
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  Diag(Test.range(), "suspicious usage of 'sizeof(sizeof(...))' "
+ "[bugprone-sizeof-expression]"),
+  AllOf(
+  Diag(Test.range("macroarg"),
+   "side effects in the 1st macro argument 'X' are repeated in "
+   "macro expansion [bugprone-macro-repeated-side-effects]"),
+  WithNote(Diag(Test.range("macrodef"),
+"macro 'SQUARE' defined here "
+"[bugprone-macro-repeated-side-effects]");
+}
+
 TEST(DiagnosticsTest, Preprocessor) {
   // This looks like a preamble, but there's an #else in the middle!
   // Check that:
Index: clang-tools-extra/trunk/clangd/CMakeLists.txt
===
--- clang-tools-extra/trunk/clangd/CMakeLists.txt
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt
@@ -64,6 +64,24 @@
   clangLex
   clangSema
   clangSerialization
+  clangTidy
+  clangTidyAndroidModule
+  clangTidyAbseilModule
+  clangTidyBoostModule
+  clangTidyBugproneModule
+  clangTidyCERTModule
+  clangTidyCppCoreGuidelinesModule
+  clangTidyFuchsiaModule
+  clangTidyGoogleModule
+  clangTidyHICPPModule
+  clangTidyLLVMModule
+  clangTidyMiscModule
+  clangTidyModernizeModule
+  clangTidyObjCModule
+  clangTidyPerformanceModule
+  clangTidyPortabilityModule
+  clangTidyReadabilityModule
+  clangTidyZirconModule
   clangTooling
   clangToolingCore
   clangToolingInclusions
Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -672,8 +672,7 @@
 return {};
 
   DeducedTypeVisitor V(SourceLocationBeg);
-  for (Decl *D : AST.getLocalTopLevelDecls())
-V.TraverseDecl(D);
+  V.TraverseAST(AST.getASTContext());
   return V.getDeducedType();
 }
 
Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -8,6 +8,8 @@
 //===--===//
 
 #include "ClangdUnit.h"
+#include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
+#include "../clang-tidy/ClangTidyModuleRegistry.h"
 #include "Compiler.h"
 #include "Diagnostics.h"
 #include "Logger.h"
@@ -151,6 +153,40 @@
 return None;
   }
 
+  // Set up ClangTidy. Must happen after BeginSourceFile() so ASTContext exists.
+  // Clang-tidy has some limitiations to ensure reasonable performance:
+  //  - checks don't see all preprocessor events in the preamble
+  //  - matchers run only over the main-file top-level decls (and can't see
+  //ancestors outside this scope).
+  // In practice almost all checks work well without modifications.
+  std::vector> CTChecks;
+  ast_matchers::MatchFinder CTFinder;
+  llvm::Optional CTContext;
+  {
+trace::Span Tracer("ClangTidyInit");
+tidy::ClangTidyCheckFactories CTFactories;
+for (const auto &E : tidy::ClangTidyModuleRegistry::entries())
+  E.instantiate()->addCheckFactories(CTFactories);
+auto CTOpts = tidy::ClangTidyOptions::getDefaults();
+// FIXME: this needs to be configurable, and we need to support .clang-tidy
+// files and other options providers.
+// These checks exercise the matcher- and preprocessor-based hooks.
+CTOpts.Checks =
+"bugprone-sizeof-expre

[PATCH] D54269: Introduce shard storage to auto-index.

2018-11-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE347038: Introduce shard storage to auto-index. (authored 
by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54269?vs=174215&id=174339#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54269

Files:
  clangd/CMakeLists.txt
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/index/BackgroundIndexStorage.cpp
  unittests/clangd/BackgroundIndexTests.cpp

Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -38,6 +38,7 @@
   XRefs.cpp
 
   index/Background.cpp
+  index/BackgroundIndexStorage.cpp
   index/CanonicalIncludes.cpp
   index/FileIndex.cpp
   index/Index.cpp
Index: clangd/index/Background.h
===
--- clangd/index/Background.h
+++ clangd/index/Background.h
@@ -14,6 +14,7 @@
 #include "FSProvider.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
+#include "index/Serialization.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/SHA1.h"
@@ -27,15 +28,41 @@
 namespace clang {
 namespace clangd {
 
+// Handles storage and retrieval of index shards. Both store and load
+// operations can be called from multiple-threads concurrently.
+class BackgroundIndexStorage {
+public:
+  // Shards of the index are stored and retrieved independently, keyed by shard
+  // identifier - in practice this is a source file name
+  virtual llvm::Error storeShard(llvm::StringRef ShardIdentifier,
+ IndexFileOut Shard) const = 0;
+
+  // Tries to load shard with given identifier, returns nullptr if shard
+  // couldn't be loaded.
+  virtual std::unique_ptr
+  loadShard(llvm::StringRef ShardIdentifier) const = 0;
+
+  // The factory provides storage for each CDB.
+  // It keeps ownership of the storage instances, and should manage caching
+  // itself. Factory must be threadsafe and never returns nullptr.
+  using Factory =
+  llvm::unique_function;
+
+  // Creates an Index Storage that saves shards into disk. Index storage uses
+  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  static Factory createDiskBackedStorageFactory();
+};
+
 // Builds an in-memory index by by running the static indexer action over
 // all commands in a compilation database. Indexing happens in the background.
 // FIXME: it should also persist its state on disk for fast start.
 // FIXME: it should watch for changes to files on disk.
 class BackgroundIndex : public SwapIndex {
 public:
   // FIXME: resource-dir injection should be hoisted somewhere common.
-  BackgroundIndex(Context BackgroundContext, StringRef ResourceDir,
+  BackgroundIndex(Context BackgroundContext, llvm::StringRef ResourceDir,
   const FileSystemProvider &, ArrayRef URISchemes,
+  BackgroundIndexStorage::Factory IndexStorageFactory,
   size_t ThreadPoolSize = llvm::hardware_concurrency());
   ~BackgroundIndex(); // Blocks while the current task finishes.
 
@@ -59,25 +86,30 @@
 private:
   /// Given index results from a TU, only update files in \p FilesToUpdate.
   void update(llvm::StringRef MainFile, SymbolSlab Symbols, RefSlab Refs,
-  const llvm::StringMap &FilesToUpdate);
+  const llvm::StringMap &FilesToUpdate,
+  BackgroundIndexStorage *IndexStorage);
 
   // configuration
   std::string ResourceDir;
   const FileSystemProvider &FSProvider;
   Context BackgroundContext;
   std::vector URISchemes;
 
   // index state
-  llvm::Error index(tooling::CompileCommand);
+  llvm::Error index(tooling::CompileCommand,
+BackgroundIndexStorage *IndexStorage);
 
   FileSymbols IndexedSymbols;
   llvm::StringMap IndexedFileDigests; // Key is absolute file path.
   std::mutex DigestsMu;
 
+  BackgroundIndexStorage::Factory IndexStorageFactory;
+
   // queue management
   using Task = std::function;
   void run(); // Main loop executed by Thread. Runs tasks from Queue.
-  void enqueueLocked(tooling::CompileCommand Cmd);
+  void enqueueLocked(tooling::CompileCommand Cmd,
+ BackgroundIndexStorage *IndexStorage);
   std::mutex QueueMu;
   unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks.
   std::condition_variable QueueCV;
Index: clangd/index/Background.cpp
===
--- clangd/index/Background.cpp
+++ clangd/index/Background.cpp
@@ -24,28 +24,32 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SHA1.h"
+
+#include 
+#include 
 #include 
 #include 
 
 using namespace llvm;
 namespace clang {
 namespace clangd {
 
-BackgroundIndex::BackgroundIndex(Context BackgroundContext,
- StringRef Res

[clang-tools-extra] r347038 - Introduce shard storage to auto-index.

2018-11-16 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Fri Nov 16 01:03:56 2018
New Revision: 347038

URL: http://llvm.org/viewvc/llvm-project?rev=347038&view=rev
Log:
Introduce shard storage to auto-index.

Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, Eugene.Zelenko, ilya-biryukov, jkorous, 
arphaman, cfe-commits

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

Added:
clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/clangd/index/Background.h
clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=347038&r1=347037&r2=347038&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Fri Nov 16 01:03:56 2018
@@ -38,6 +38,7 @@ add_clang_library(clangDaemon
   XRefs.cpp
 
   index/Background.cpp
+  index/BackgroundIndexStorage.cpp
   index/CanonicalIncludes.cpp
   index/FileIndex.cpp
   index/Index.cpp

Modified: clang-tools-extra/trunk/clangd/index/Background.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=347038&r1=347037&r2=347038&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Background.cpp Fri Nov 16 01:03:56 2018
@@ -24,6 +24,9 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/SHA1.h"
+
+#include 
+#include 
 #include 
 #include 
 
@@ -31,21 +34,22 @@ using namespace llvm;
 namespace clang {
 namespace clangd {
 
-BackgroundIndex::BackgroundIndex(Context BackgroundContext,
- StringRef ResourceDir,
- const FileSystemProvider &FSProvider,
- ArrayRef URISchemes,
- size_t ThreadPoolSize)
+BackgroundIndex::BackgroundIndex(
+Context BackgroundContext, StringRef ResourceDir,
+const FileSystemProvider &FSProvider, ArrayRef URISchemes,
+BackgroundIndexStorage::Factory IndexStorageFactory, size_t ThreadPoolSize)
 : SwapIndex(make_unique()), ResourceDir(ResourceDir),
   FSProvider(FSProvider), BackgroundContext(std::move(BackgroundContext)),
-  URISchemes(URISchemes) {
+  URISchemes(URISchemes),
+  IndexStorageFactory(std::move(IndexStorageFactory)) {
   assert(ThreadPoolSize > 0 && "Thread pool size can't be zero.");
+  assert(IndexStorageFactory && "Storage factory can not be null!");
   while (ThreadPoolSize--) {
 ThreadPool.emplace_back([this] { run(); });
 // Set priority to low, since background indexing is a long running task we
 // do not want to eat up cpu when there are any other high priority 
threads.
 // FIXME: In the future we might want a more general way of handling this 
to
-// support a tasks with various priorities.
+// support tasks with various priorities.
 setThreadPriority(ThreadPool.back(), ThreadPriority::Low);
   }
 }
@@ -97,9 +101,10 @@ void BackgroundIndex::blockUntilIdleForT
 
 void BackgroundIndex::enqueue(StringRef Directory,
   tooling::CompileCommand Cmd) {
+  BackgroundIndexStorage *IndexStorage = IndexStorageFactory(Directory);
   {
 std::lock_guard Lock(QueueMu);
-enqueueLocked(std::move(Cmd));
+enqueueLocked(std::move(Cmd), IndexStorage);
   }
   QueueCV.notify_all();
 }
@@ -110,6 +115,7 @@ void BackgroundIndex::enqueueAll(StringR
   // FIXME: this function may be slow. Perhaps enqueue a task to re-read the 
CDB
   // from disk and enqueue the commands asynchronously?
   auto Cmds = CDB.getAllCompileCommands();
+  BackgroundIndexStorage *IndexStorage = IndexStorageFactory(Directory);
   SPAN_ATTACH(Tracer, "commands", int64_t(Cmds.size()));
   std::mt19937 Generator(std::random_device{}());
   std::shuffle(Cmds.begin(), Cmds.end(), Generator);
@@ -117,17 +123,18 @@ void BackgroundIndex::enqueueAll(StringR
   {
 std::lock_guard Lock(QueueMu);
 for (auto &Cmd : Cmds)
-  enqueueLocked(std::move(Cmd));
+  enqueueLocked(std::move(Cmd), IndexStorage);
   }
   QueueCV.notify_all();
 }
 
-void BackgroundIndex::enqueueLocked(tooling::CompileCommand Cmd) {
+void BackgroundIndex::enqueueLocked(tooling::CompileCommand Cmd,
+BackgroundIndexStorage *IndexStorage) {
   Queue.push_back(Bind(
-  [this](tooling::CompileCommand Cmd) {
+  [this, IndexStorage](tooling::CompileCommand Cmd) {
 std::string Filename = Cmd.Filename;
 Cmd.CommandLine.push_back("-resource-dir=" + Resource

[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-16 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

The other lost comment was regarding the functions where you're using `strcpy` 
instead of idiomatic LLVM and also creating unnecessary temporary `std::string` 
instances on the stack.


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-16 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Commented on that particular idiom, there's two instances where it's used, 
aside from variable naming issues (`pos` should be `Pos`) it's very non 
idiomatic as far as rest of LLVM code goes, don't pass string literals around 
as `const char*`, prefer `StringRef` instead, that would also save you from 
needing to resort to using `strlen` later (sorry for previous comment, I didn't 
mean `strcpy`).




Comment at: lib/Driver/Driver.cpp:400
+
+  S.replace(pos, strlen(Other), Replace);
+}

Please avoid that kind of code and avoid `strlen`, you should pass things as 
StringRef as that's the general way of doing things unless you have a good 
reason for doing so otherwise. This entire function/part that uses it should be 
rewritten, I especially don't like the temporary `std::string` on the stack. It 
may be worth considering SmallString which is a variation of SmallVector or 
just manipulating the StringRef. You very certainly don't need `strlen` 
however, StringRef provides the needed operators, same goes for using 
`std::string::find`, just use StringRef instead. 


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


[PATCH] D54553: [clangd] Fix crash hovering on non-decltype trailing return

2018-11-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54553



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


[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-16 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added inline comments.



Comment at: lib/Driver/Driver.cpp:418
+  replaceString(T, "-pc-gnu", "-pc-hurd-gnu");
+  TargetTriple = T;
+

Reference to a local variable?


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2018-11-16 Thread vit9696 via Phabricator via cfe-commits
vit9696 added a comment.

Thanks for the fix. I made a quick check of the mentioned patch, and it looks 
like it does solve the issue. However, besides the previous crash, which 
remains unfixed as of 7.0.1rc2, there is another instruction selection failure 
crash that may be caused by the change. I have not yet had a chance to properly 
research it, but here is an example if you feel interested: 
http://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_701/rc2/lib/builtins/divdc3.c

  clang -O3 -std=c11  -target powerpc-gnu-linux-eabi -ffreestanding -nostdlib 
-g -mcpu=e500 -mspe -femulated-tls -c divdc3.c -o divdc3.o
  fatal error: error in backend: Cannot select: 0x7fcb8184c270: i64 = 
build_pair 0x7fcb8184c208, 0x7fcb8184c1a0, divdc3.c:24:22
0x7fcb8184c208: i32,ch,glue = CopyFromReg 0x7fcb8184c1a0:1, Register:i32 
$r4, 0x7fcb8184c1a0:2, divdc3.c:24:22
  0x7fcb81846678: i32 = Register $r4
  0x7fcb8184c1a0: i32,ch,glue = CopyFromReg 0x7fcb8184c138, Register:i32 
$r3, 0x7fcb8184c138:1, divdc3.c:24:22
0x7fcb818465a8: i32 = Register $r3
0x7fcb8184c138: ch,glue = callseq_end 0x7fcb8184c0d0, 
TargetConstant:i32<8>, TargetConstant:i32<0>, 0x7fcb8184c0d0:1, divdc3.c:24:22
  0x7fcb81846408: i32 = TargetConstant<8>
  0x7fcb81846470: i32 = TargetConstant<0>
  0x7fcb8184c0d0: ch,glue = PPCISD::CALL 0x7fcb8184c000, 
TargetExternalSymbol:i32'fmax' [TF=1], Register:i32 $r3, Register:i32 $r4, 
Register:i32 $r5, Register:i32 $r6, RegisterMask:Untyped, 0x7fcb8184c000:1, 
divdc3.c:24:22
0x7fcb8184c068: i32 = TargetExternalSymbol'fmax' [TF=1]
0x7fcb818465a8: i32 = Register $r3
0x7fcb81846678: i32 = Register $r4
0x7fcb81849f48: i32 = Register $r5
0x7fcb8184a768: i32 = Register $r6
0x7fcb818467b0: Untyped = RegisterMask
0x7fcb8184c000: ch,glue = CopyToReg 0x7fcb8184a220, Register:i32 
$r6, 0x7fcb81842200, 0x7fcb8184a220:1, divdc3.c:24:22
  0x7fcb8184a768: i32 = Register $r6
  0x7fcb81842200: i32 = truncate 0x7fcb8184c680, divdc3.c:24:22
0x7fcb8184c680: i64,ch = load<(load 8 from %stack.7)> 
0x7fcb8184c618, FrameIndex:i32<7>, undef:i32, divdc3.c:24:22
  0x7fcb81846c28: i32 = FrameIndex<7>
  0x7fcb81842818: i32 = undef
  0x7fcb8184a220: ch,glue = CopyToReg 0x7fcb81849c70, Register:i32 
$r5, 0x7fcb8184c5b0, 0x7fcb81849c70:1, divdc3.c:24:22
0x7fcb81849f48: i32 = Register $r5
0x7fcb8184c5b0: i32 = truncate 0x7fcb8184c2d8, divdc3.c:24:22
  0x7fcb8184c2d8: i64 = srl 0x7fcb8184c680, Constant:i32<32>, 
divdc3.c:24:22
0x7fcb8184c680: i64,ch = load<(load 8 from %stack.7)> 
0x7fcb8184c618, FrameIndex:i32<7>, undef:i32, divdc3.c:24:22
  
  
0x7fcb81846fd0: i32 = Constant<32>
0x7fcb81849c70: ch,glue = CopyToReg 0x7fcb81846540, 
Register:i32 $r4, 0x7fcb818469b8, 0x7fcb81846540:1, divdc3.c:24:22
  0x7fcb81846678: i32 = Register $r4
  0x7fcb818469b8: i32 = truncate 0x7fcb8184c750, divdc3.c:24:22
0x7fcb8184c750: i64,ch = load<(load 8 from %stack.8)> 
0x7fcb818462d0, FrameIndex:i32<8>, undef:i32, divdc3.c:24:22
  
  
  0x7fcb81846540: ch,glue = CopyToReg 0x7fcb818470a0, 
Register:i32 $r3, 0x7fcb8184c6e8, divdc3.c:24:22
0x7fcb818465a8: i32 = Register $r3
0x7fcb8184c6e8: i32 = truncate 0x7fcb818463a0, 
divdc3.c:24:22
  
0x7fcb8184c1a0: i32,ch,glue = CopyFromReg 0x7fcb8184c138, Register:i32 $r3, 
0x7fcb8184c138:1, divdc3.c:24:22
  0x7fcb818465a8: i32 = Register $r3
  0x7fcb8184c138: ch,glue = callseq_end 0x7fcb8184c0d0, 
TargetConstant:i32<8>, TargetConstant:i32<0>, 0x7fcb8184c0d0:1, divdc3.c:24:22
0x7fcb81846408: i32 = TargetConstant<8>
0x7fcb81846470: i32 = TargetConstant<0>
0x7fcb8184c0d0: ch,glue = PPCISD::CALL 0x7fcb8184c000, 
TargetExternalSymbol:i32'fmax' [TF=1], Register:i32 $r3, Register:i32 $r4, 
Register:i32 $r5, Register:i32 $r6, RegisterMask:Untyped, 0x7fcb8184c000:1, 
divdc3.c:24:22
  0x7fcb8184c068: i32 = TargetExternalSymbol'fmax' [TF=1]
  0x7fcb818465a8: i32 = Register $r3
  0x7fcb81846678: i32 = Register $r4
  0x7fcb81849f48: i32 = Register $r5
  0x7fcb8184a768: i32 = Register $r6
  0x7fcb818467b0: Untyped = RegisterMask
  0x7fcb8184c000: ch,glue = CopyToReg 0x7fcb8184a220, Register:i32 $r6, 
0x7fcb81842200, 0x7fcb8184a220:1, divdc3.c:24:22
0x7fcb8184a768: i32 = Register $r6
0x7fcb81842200: i32 = truncate 0x7fcb8184c680, divdc3.c:24:22
  0x7fcb8184c680: i64,ch = load<(load 8 from %stack.7)> 
0x7fcb8184c618, FrameIndex:i32<7>, undef:i32, divdc3.c:24:22
0x7fcb81846c28: i32 = FrameIndex<7>
0x7fcb81842818: i32 = undef
0x7fcb8184a220: ch,gl

[clang-tools-extra] r347039 - [clangd] Fix a compiler warning and test crashes caused in rL347038.

2018-11-16 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Nov 16 01:41:14 2018
New Revision: 347039

URL: http://llvm.org/viewvc/llvm-project?rev=347039&view=rev
Log:
[clangd] Fix a compiler warning and test crashes caused in rL347038.

Modified:
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/clangd/index/Background.h

Modified: clang-tools-extra/trunk/clangd/index/Background.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=347039&r1=347038&r2=347039&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Background.cpp Fri Nov 16 01:41:14 2018
@@ -43,7 +43,7 @@ BackgroundIndex::BackgroundIndex(
   URISchemes(URISchemes),
   IndexStorageFactory(std::move(IndexStorageFactory)) {
   assert(ThreadPoolSize > 0 && "Thread pool size can't be zero.");
-  assert(IndexStorageFactory && "Storage factory can not be null!");
+  assert(this->IndexStorageFactory && "Storage factory can not be null!");
   while (ThreadPoolSize--) {
 ThreadPool.emplace_back([this] { run(); });
 // Set priority to low, since background indexing is a long running task we

Modified: clang-tools-extra/trunk/clangd/index/Background.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.h?rev=347039&r1=347038&r2=347039&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.h (original)
+++ clang-tools-extra/trunk/clangd/index/Background.h Fri Nov 16 01:41:14 2018
@@ -32,6 +32,8 @@ namespace clangd {
 // operations can be called from multiple-threads concurrently.
 class BackgroundIndexStorage {
 public:
+  virtual ~BackgroundIndexStorage() = default;
+
   // Shards of the index are stored and retrieved independently, keyed by shard
   // identifier - in practice this is a source file name
   virtual llvm::Error storeShard(llvm::StringRef ShardIdentifier,


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


[PATCH] D53830: [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

2018-11-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with one more comment. Please address other reviewers' comments though.




Comment at: clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp:153
+  // required so we provide only a warning.
+  std::sort(MatchedTemplateLocations.begin(), MatchedTemplateLocations.end());
+  for (SourceLocation Loc : MatchedInstantiationLocations) {

MatchedTemplateLocations can be a std::set or a 
std::unordered_set filled with SourceLocation::getRawEncoding(). Same 
for MatchedInstantiationLocations, I suppose.


https://reviews.llvm.org/D53830



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


[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-16 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added inline comments.



Comment at: lib/Driver/Driver.cpp:418
+  replaceString(T, "-pc-gnu", "-pc-hurd-gnu");
+  TargetTriple = T;
+

kristina wrote:
> Reference to a local variable?
Hm, actually this is fine I guess, just avoid `strlen` and pass literals as 
StringRefs. I would make sure the triple actually matches before you construct 
a local though, otherwise you're forcing doing it for every target, which in 
majority of the cases isn't going to be Hurd. I would still use `SmallString` 
instead of `std::string` but that's more of a nitpick.


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


[PATCH] D54379: Add Hurd toolchain support to Clang

2018-11-16 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Also, this needs unit tests and FileCheck tests.


Repository:
  rC Clang

https://reviews.llvm.org/D54379



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


[PATCH] D54604: Automatic variable initialization

2018-11-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

There is also https://reviews.llvm.org/D54473 `[sanitizers] Initial 
implementation for -fsanitize=init-locals`.


Repository:
  rC Clang

https://reviews.llvm.org/D54604



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


[PATCH] D54622: [clangd] Truncate SymbolID to 8 bytes.

2018-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.

This is our goal. It has a non-zero rick, but so far we haven't see any
collision (externally and internally).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54622

Files:
  clangd/index/Index.h
  clangd/index/Serialization.cpp
  unittests/clangd/SerializationTests.cpp


Index: unittests/clangd/SerializationTests.cpp
===
--- unittests/clangd/SerializationTests.cpp
+++ unittests/clangd/SerializationTests.cpp
@@ -27,7 +27,7 @@
 const char *YAML = R"(
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 Name:   'Foo1'
 Scope:   'clang::'
 SymInfo:
@@ -53,7 +53,7 @@
 ...
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F36
+ID: 057557CEBF6E6B2E
 Name:   'Foo2'
 Scope:   'clang::'
 SymInfo:
@@ -72,7 +72,7 @@
 CompletionSnippetSuffix:'-snippet'
 ...
 !Refs
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 References:
   - Kind: 4
 Location:
@@ -99,13 +99,13 @@
   ASSERT_TRUE(bool(ParsedYAML)) << ParsedYAML.takeError();
   ASSERT_TRUE(bool(ParsedYAML->Symbols));
   EXPECT_THAT(*ParsedYAML->Symbols,
-  UnorderedElementsAre(ID("057557CEBF6E6B2DD437FBF60CC58F35"),
-   ID("057557CEBF6E6B2DD437FBF60CC58F36")));
+  UnorderedElementsAre(ID("057557CEBF6E6B2D"),
+   ID("057557CEBF6E6B2E")));
 
   auto Sym1 = *ParsedYAML->Symbols->find(
-  cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")));
+  cantFail(SymbolID::fromStr("057557CEBF6E6B2D")));
   auto Sym2 = *ParsedYAML->Symbols->find(
-  cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F36")));
+  cantFail(SymbolID::fromStr("057557CEBF6E6B2E")));
 
   EXPECT_THAT(Sym1, QName("clang::Foo1"));
   EXPECT_EQ(Sym1.Signature, "");
@@ -131,7 +131,7 @@
   EXPECT_THAT(
   *ParsedYAML->Refs,
   UnorderedElementsAre(
-  Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")),
+  Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2D")),
testing::SizeIs(1;
   auto Ref1 = ParsedYAML->Refs->begin()->second.front();
   EXPECT_EQ(Ref1.Kind, RefKind::Reference);
Index: clangd/index/Serialization.cpp
===
--- clangd/index/Serialization.cpp
+++ clangd/index/Serialization.cpp
@@ -300,7 +300,7 @@
 
 // REFS ENCODING
 // A refs section has data grouped by Symbol. Each symbol has:
-//  - SymbolID: 16 bytes
+//  - SymbolID: 8 bytes
 //  - NumRefs: varint
 //  - Ref[NumRefs]
 // Fields of Ref are encoded in turn, see implementation.
@@ -338,7 +338,7 @@
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 6;
+constexpr static uint32_t Version = 7;
 
 Expected readRIFF(StringRef Data) {
   auto RIFF = riff::readFile(Data);
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -116,8 +116,7 @@
 
   // The stored hash is truncated to RawSize bytes.
   // This trades off memory against the number of symbols we can handle.
-  // FIXME: can we reduce this further to 8 bytes?
-  constexpr static size_t RawSize = 16;
+  constexpr static size_t RawSize = 8;
   llvm::StringRef raw() const {
 return StringRef(reinterpret_cast(HashValue.data()), 
RawSize);
   }


Index: unittests/clangd/SerializationTests.cpp
===
--- unittests/clangd/SerializationTests.cpp
+++ unittests/clangd/SerializationTests.cpp
@@ -27,7 +27,7 @@
 const char *YAML = R"(
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 Name:   'Foo1'
 Scope:   'clang::'
 SymInfo:
@@ -53,7 +53,7 @@
 ...
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F36
+ID: 057557CEBF6E6B2E
 Name:   'Foo2'
 Scope:   'clang::'
 SymInfo:
@@ -72,7 +72,7 @@
 CompletionSnippetSuffix:'-snippet'
 ...
 !Refs
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 References:
   - Kind: 4
 Location:
@@ -99,13 +99,13 @@
   ASSERT_TRUE(bool(ParsedYAML)) << ParsedYAML.takeError();
   ASSERT_TRUE(bool(ParsedYAML->Symbols));
   EXPECT_THAT(*ParsedYAML->Symbols,
-  UnorderedElementsAre(ID("057557CEBF6E6B2DD437FBF60CC58F35"),
-   ID("057557CEBF6E6B2DD437FBF60CC58F36")));
+  UnorderedElementsAre(ID("057557CEBF6E6B2D"),
+   ID("057557CEBF6E6B2E")));
 
   auto Sym1 = *ParsedYAML->Symbols->find(
-  cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")));
+  cantFail(Symbol

[PATCH] D54091: [RISCV] Add inline asm constraints I, J & K for RISC-V

2018-11-16 Thread Alex Bradbury via Phabricator via cfe-commits
asb requested changes to this revision.
asb added a comment.
This revision now requires changes to proceed.

Thanks for the patch Lewis. Could I please request the following changes:

- It would be handy to link to 
https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html in the patch 
summary, so people can easily double-check the constraint definitions for 
themselves
- Could you add tests for values outside of the expected range. AArch64 and X86 
do this in test/Sema/inline-asm-validate-{aarch64,x86}.c
- It would be worth expanding riscv-inline-asm.c to provide simple sanity 
checks for "m" and "r"


Repository:
  rC Clang

https://reviews.llvm.org/D54091



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


[clang-tools-extra] r347044 - [clangd] Truncate SymbolID to 8 bytes.

2018-11-16 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Nov 16 02:58:40 2018
New Revision: 347044

URL: http://llvm.org/viewvc/llvm-project?rev=347044&view=rev
Log:
[clangd] Truncate SymbolID to 8 bytes.

Summary:
This is our goal. It has a non-zero rick, but so far we haven't see any
collision (externally and internally).

Reviewers: sammccall

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, 
cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/Serialization.cpp
clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=347044&r1=347043&r2=347044&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Fri Nov 16 02:58:40 2018
@@ -116,8 +116,7 @@ public:
 
   // The stored hash is truncated to RawSize bytes.
   // This trades off memory against the number of symbols we can handle.
-  // FIXME: can we reduce this further to 8 bytes?
-  constexpr static size_t RawSize = 16;
+  constexpr static size_t RawSize = 8;
   llvm::StringRef raw() const {
 return StringRef(reinterpret_cast(HashValue.data()), 
RawSize);
   }

Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=347044&r1=347043&r2=347044&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Fri Nov 16 02:58:40 
2018
@@ -300,7 +300,7 @@ Symbol readSymbol(Reader &Data, ArrayRef
 
 // REFS ENCODING
 // A refs section has data grouped by Symbol. Each symbol has:
-//  - SymbolID: 16 bytes
+//  - SymbolID: 8 bytes
 //  - NumRefs: varint
 //  - Ref[NumRefs]
 // Fields of Ref are encoded in turn, see implementation.
@@ -338,7 +338,7 @@ std::pair> re
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 6;
+constexpr static uint32_t Version = 7;
 
 Expected readRIFF(StringRef Data) {
   auto RIFF = riff::readFile(Data);

Modified: clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp?rev=347044&r1=347043&r2=347044&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp Fri Nov 16 
02:58:40 2018
@@ -27,7 +27,7 @@ namespace {
 const char *YAML = R"(
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 Name:   'Foo1'
 Scope:   'clang::'
 SymInfo:
@@ -53,7 +53,7 @@ IncludeHeaders:
 ...
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F36
+ID: 057557CEBF6E6B2E
 Name:   'Foo2'
 Scope:   'clang::'
 SymInfo:
@@ -72,7 +72,7 @@ Signature:'-sig'
 CompletionSnippetSuffix:'-snippet'
 ...
 !Refs
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 References:
   - Kind: 4
 Location:
@@ -99,13 +99,13 @@ TEST(SerializationTest, YAMLConversions)
   ASSERT_TRUE(bool(ParsedYAML)) << ParsedYAML.takeError();
   ASSERT_TRUE(bool(ParsedYAML->Symbols));
   EXPECT_THAT(*ParsedYAML->Symbols,
-  UnorderedElementsAre(ID("057557CEBF6E6B2DD437FBF60CC58F35"),
-   ID("057557CEBF6E6B2DD437FBF60CC58F36")));
+  UnorderedElementsAre(ID("057557CEBF6E6B2D"),
+   ID("057557CEBF6E6B2E")));
 
   auto Sym1 = *ParsedYAML->Symbols->find(
-  cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")));
+  cantFail(SymbolID::fromStr("057557CEBF6E6B2D")));
   auto Sym2 = *ParsedYAML->Symbols->find(
-  cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F36")));
+  cantFail(SymbolID::fromStr("057557CEBF6E6B2E")));
 
   EXPECT_THAT(Sym1, QName("clang::Foo1"));
   EXPECT_EQ(Sym1.Signature, "");
@@ -131,7 +131,7 @@ TEST(SerializationTest, YAMLConversions)
   EXPECT_THAT(
   *ParsedYAML->Refs,
   UnorderedElementsAre(
-  Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")),
+  Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2D")),
testing::SizeIs(1;
   auto Ref1 = ParsedYAML->Refs->begin()->second.front();
   EXPECT_EQ(Ref1.Kind, RefKind::Reference);


___
cfe-commits mailing list
cfe

[PATCH] D54622: [clangd] Truncate SymbolID to 8 bytes.

2018-11-16 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347044: [clangd] Truncate SymbolID to 8 bytes. (authored by 
hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54622

Files:
  clang-tools-extra/trunk/clangd/index/Index.h
  clang-tools-extra/trunk/clangd/index/Serialization.cpp
  clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
@@ -27,7 +27,7 @@
 const char *YAML = R"(
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 Name:   'Foo1'
 Scope:   'clang::'
 SymInfo:
@@ -53,7 +53,7 @@
 ...
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F36
+ID: 057557CEBF6E6B2E
 Name:   'Foo2'
 Scope:   'clang::'
 SymInfo:
@@ -72,7 +72,7 @@
 CompletionSnippetSuffix:'-snippet'
 ...
 !Refs
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 References:
   - Kind: 4
 Location:
@@ -99,13 +99,13 @@
   ASSERT_TRUE(bool(ParsedYAML)) << ParsedYAML.takeError();
   ASSERT_TRUE(bool(ParsedYAML->Symbols));
   EXPECT_THAT(*ParsedYAML->Symbols,
-  UnorderedElementsAre(ID("057557CEBF6E6B2DD437FBF60CC58F35"),
-   ID("057557CEBF6E6B2DD437FBF60CC58F36")));
+  UnorderedElementsAre(ID("057557CEBF6E6B2D"),
+   ID("057557CEBF6E6B2E")));
 
   auto Sym1 = *ParsedYAML->Symbols->find(
-  cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")));
+  cantFail(SymbolID::fromStr("057557CEBF6E6B2D")));
   auto Sym2 = *ParsedYAML->Symbols->find(
-  cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F36")));
+  cantFail(SymbolID::fromStr("057557CEBF6E6B2E")));
 
   EXPECT_THAT(Sym1, QName("clang::Foo1"));
   EXPECT_EQ(Sym1.Signature, "");
@@ -131,7 +131,7 @@
   EXPECT_THAT(
   *ParsedYAML->Refs,
   UnorderedElementsAre(
-  Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")),
+  Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2D")),
testing::SizeIs(1;
   auto Ref1 = ParsedYAML->Refs->begin()->second.front();
   EXPECT_EQ(Ref1.Kind, RefKind::Reference);
Index: clang-tools-extra/trunk/clangd/index/Serialization.cpp
===
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp
@@ -300,7 +300,7 @@
 
 // REFS ENCODING
 // A refs section has data grouped by Symbol. Each symbol has:
-//  - SymbolID: 16 bytes
+//  - SymbolID: 8 bytes
 //  - NumRefs: varint
 //  - Ref[NumRefs]
 // Fields of Ref are encoded in turn, see implementation.
@@ -338,7 +338,7 @@
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 6;
+constexpr static uint32_t Version = 7;
 
 Expected readRIFF(StringRef Data) {
   auto RIFF = riff::readFile(Data);
Index: clang-tools-extra/trunk/clangd/index/Index.h
===
--- clang-tools-extra/trunk/clangd/index/Index.h
+++ clang-tools-extra/trunk/clangd/index/Index.h
@@ -116,8 +116,7 @@
 
   // The stored hash is truncated to RawSize bytes.
   // This trades off memory against the number of symbols we can handle.
-  // FIXME: can we reduce this further to 8 bytes?
-  constexpr static size_t RawSize = 16;
+  constexpr static size_t RawSize = 8;
   llvm::StringRef raw() const {
 return StringRef(reinterpret_cast(HashValue.data()), 
RawSize);
   }


Index: clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
@@ -27,7 +27,7 @@
 const char *YAML = R"(
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 Name:   'Foo1'
 Scope:   'clang::'
 SymInfo:
@@ -53,7 +53,7 @@
 ...
 ---
 !Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F36
+ID: 057557CEBF6E6B2E
 Name:   'Foo2'
 Scope:   'clang::'
 SymInfo:
@@ -72,7 +72,7 @@
 CompletionSnippetSuffix:'-snippet'
 ...
 !Refs
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
 References:
   - Kind: 4
 Location:
@@ -99,13 +99,13 @@
   ASSERT_TRUE(bool(ParsedYAML)) << ParsedYAML.takeError();
   ASSERT_TRUE(bool(ParsedYAML->Symbols));
   EXPECT_THAT(*ParsedYAML->Symbols,
-  UnorderedElementsAre(ID("057557CEBF6E6B2DD437FBF60CC58F35"),
-   ID("057

[PATCH] D54628: Extend format with AllowShortEnumsOnASingleLine option

2018-11-16 Thread Florian Kauer via Phabricator via cfe-commits
koalo created this revision.
koalo added reviewers: djasper, rsmith.
Herald added a subscriber: cfe-commits.

Before, clang-format has tried to put enums on a single line whenever possible 
(unless in styles where the opening brace was put on a seperate line anyway).
AllowShortEnumsOnASingleLine that defaults to true (matching the conventional 
behaviour) can be set to false to force enums on multiple lines.

This feature is requested from time to time, e.g. here 
,
 and should be unobtrusive for users that do not set this option to false.


Repository:
  rC Clang

https://reviews.llvm.org/D54628

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1521,6 +1521,24 @@
   verifyFormat("enum ShortEnum { A, B, C };");
   verifyGoogleFormat("enum ShortEnum { A, B, C };");
 
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum Enum {\n"
+   "};",Style);
+  verifyFormat("enum {\n"
+   "};",Style);
+  verifyFormat("enum X E {\n"
+   "} d;",Style);
+  verifyFormat("enum __attribute__((...)) E {\n"
+   "} d;",Style);
+  verifyFormat("enum __declspec__((...)) E {\n"
+   "} d;",Style);
+  verifyFormat("enum ShortEnum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "};",Style);
+
   EXPECT_EQ("enum KeepEmptyLines {\n"
 "  ONE,\n"
 "\n"
@@ -1589,6 +1607,19 @@
   verifyFormat("enum struct __attribute__((...)) E {} d;");
   verifyFormat("enum struct __declspec__((...)) E {} d;");
   verifyFormat("enum struct X f() {\n  a();\n  return 42;\n}");
+
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum struct Enum {\n"
+   "};",Style);
+  verifyFormat("enum struct {\n"
+   "};",Style);
+  verifyFormat("enum struct X E {\n"
+   "} d;",Style);
+  verifyFormat("enum struct __attribute__((...)) E {\n"
+   "} d;",Style);
+  verifyFormat("enum struct __declspec__((...)) E {\n"
+   "} d;",Style);
 }
 
 TEST_F(FormatTest, FormatsEnumClass) {
@@ -1606,6 +1637,19 @@
   verifyFormat("enum class __attribute__((...)) E {} d;");
   verifyFormat("enum class __declspec__((...)) E {} d;");
   verifyFormat("enum class X f() {\n  a();\n  return 42;\n}");
+
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum class Enum {\n"
+   "};",Style);
+  verifyFormat("enum class {\n"
+   "};",Style);
+  verifyFormat("enum class X E {\n"
+   "} d;",Style);
+  verifyFormat("enum class __attribute__((...)) E {\n"
+   "} d;",Style);
+  verifyFormat("enum class __declspec__((...)) E {\n"
+   "} d;",Style);
 }
 
 TEST_F(FormatTest, FormatsEnumTypes) {
@@ -1615,6 +1659,17 @@
"};");
   verifyFormat("enum X : int { A, B };");
   verifyFormat("enum X : std::uint32_t { A, B };");
+
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum X : int {\n"
+   "  A,\n"
+	   "  B\n"
+	   "};",Style);
+  verifyFormat("enum X : std::uint32_t {\n"
+   "  A,\n"
+	   "  B\n"
+	   "};",Style);
 }
 
 TEST_F(FormatTest, FormatsTypedefEnum) {
@@ -1641,6 +1696,16 @@
"  THREE = 3\n"
"} LongEnum;",
Style);
+
+  Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("typedef enum {\n"
+   "} EmptyEnum;",Style);
+  verifyFormat("typedef enum {\n"
+   "  A,\n"
+	   "  B,\n"
+	   "  C\n"
+	   "} ShortEnum;",Style);
 }
 
 TEST_F(FormatTest, FormatsNSEnums) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2948,6 +2948,10 @@
   }
   if (Right.is(TT_InlineASMBrace))
 return Right.HasUnescapedNewline;
+  if (isAllmanBrace(Left) && !Style.AllowShortEnumsOnASingleLine &&
+  (Line.startsWith(tok::kw_enum) ||
+   Line.startsWith(tok::kw_typedef, tok::kw_enum)))
+return true;
   if (isAllmanBrace(Left) || isAllmanBrace(Right))
 return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
(Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Form

[PATCH] D54047: Check TUScope is valid before use

2018-11-16 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Could you please add a test? I'd suggest minimizing the testcase you linked and 
placing it to `clang/test`.


Repository:
  rC Clang

https://reviews.llvm.org/D54047



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


[PATCH] D54334: [AVR] Automatically link CRT and libgcc from the system avr-gcc

2018-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:44-45
+def warn_drv_avr_family_linking_stdlibs_not_implemented: Warning<
+  "support for linking stdlibs for microcontroller '%0' is not implemented, "
+  "please file an AVR backend bug at http://bugs.llvm.org/ with your mcu 
name">,
+  InGroup;

This is novel for diagnostics -- we don't have any other diagnostics that 
recommend filing bugs. This doesn't strike me as something a naive developer 
will just happen across by accident, so I would probably drop from the comma 
onward and assume the user knows they can report bugs if they really care.



Comment at: lib/Driver/ToolChains/AVR.cpp:40
+
+const std::string PossibleAVRLibcLocations[] = {
+  "/usr/avr",

Why use `std::string` here when below you use it as a list of `StringRef`s?



Comment at: lib/Driver/ToolChains/AVR.cpp:92-94
+  if (!LinkStdlib) {
+D.Diag(diag::warn_drv_avr_stdlib_not_linked);
+  }

Elide braces.



Comment at: lib/Driver/ToolChains/AVR.cpp:130
+assert(!CPU.empty() && "CPU name must be known in order to link stdlibs");
+auto Family = FamilyName.getValue();
+

I'd drop this and inline it in the use below as `*Family`.



Comment at: lib/Driver/ToolChains/AVR.cpp:157-159
+if (llvm::sys::fs::is_directory(PossiblePath)) {
+  return Optional(std::string(PossiblePath));
+}

Elide braces.



Comment at: lib/Driver/ToolChains/AVR.cpp:162
+
+  return Optional();
+}

`return llvm::None;`



Comment at: lib/Driver/ToolChains/AVR.h:45-47
+  Linker(const llvm::Triple &Triple,
+ const ToolChain &TC,
+ bool LinkStdlib)

Did clang-format produce this? For some reason, it looks off to my eyes.


Repository:
  rC Clang

https://reviews.llvm.org/D54334



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


[PATCH] D49736: [Basic] Emit warning flag suggestion only in case there's existing flag *similar* to the unknown one

2018-11-16 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D49736



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


[PATCH] D54630: Move detection of libc++ include dirs to Driver on MacOS

2018-11-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: JDevlieghere, arphaman.
Herald added a reviewer: EricWF.
Herald added subscribers: kadircet, christof, ioeric.

The intention is to make the tools replaying compilations from 
'compile_commands.json'
(clang-tidy, clangd, etc.) find the same standard library as the original 
compiler
specified in 'compile_commands.json'.

Previously, the library detection logic was in the frontend 
(InitHeaderSearch.cpp) and relied
on the value of resource dir as an approximation of the compiler install dir. 
The new logic
uses the actual compiler install dir and is performed in the driver. This is 
consistent with
the C++ standard library detection on other platforms and allows to override 
the resource dir
in the tools using the compile_commands.json without altering the
standard library detection mechanism. The tools have to override the resource 
dir to make sure
they use a consistent version of the builtin headers.

There is still logic in InitHeaderSearch that attemps to add the absolute 
includes for the
the C++ standard library, so we keep passing the -stdlib=libc++ from the driver 
to the frontend
via cc1 args to avoid breaking that. In the long run, we should move this logic 
to the driver too,
but it could potentially break the library detection on other systems, so we 
don't tackle it in this
patch to keep its scope manageable.

This is a second attempt to fix the issue, first one was commited in r346652 
and reverted in r346675.
The original fix relied on an ad-hoc propagation (bypassing the cc1 flags) of 
the install dir from the
driver to the frontend's HeaderSearchOptions. Unsurpisingly, the propagation 
was incomplete, it broke
the libc++ detection in clang itself, which caused LLDB tests to break.

The LLDB tests pass with new fix.


Repository:
  rC Clang

https://reviews.llvm.org/D54630

Files:
  
clang-tools-extra/test/clang-tidy/Inputs/mock-libcxx/include/c++/v1/mock_vector
  clang-tools-extra/test/clang-tidy/clang-tidy-mac-libcxx.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/Driver/darwin-stdlib.cpp
  clang/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
  clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp
  clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp

Index: clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure our libTooling-based tools emulate this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// clang-check will produce an error code if the mock library is not found.
+// RUN: clang-check -p "%t" "%t/test.cpp"
+
+#include 
+vector v;
Index: clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-mac-libcxx-abspath.cpp
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure our libTooling-based tools emulate this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// clang-check will produce an error code if the mock library is not found.
+// RUN: clang-check -p "%t" "%t/test.cpp"
+
+#include 
+vector v;
Index: clang/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
===
--- /dev/null
+++ clang/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
@@ -0,0 +1 @@
+class vector {};
Index: clang/test/Driver/darwin-stdlib.cpp
===
--- clang/test/Driver/darwin-stdlib.cpp
+++ clang/test/Driver/darwin-stdlib.cpp
@@ -2,19 +2,20 @@
 // than the platform default. (see https://llvm.org/bugs/show_bug.cgi?id=30548)
 // XFAIL: default-cxx-stdlib-set
 
-// RUN: %clang -target x86_64-apple-darwin -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&

[PATCH] D51341: [HEADER] Overloadable function candidates for half/double types

2018-11-16 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd added a comment.

@Anastasia @yaxunl 
Hi, I am working on generalizing this patch and several questions have raised 
during this, so I want to discuss them with you:

1. Should #pragma OPENCL EXTENSION ext_name : begin enables the extension as 
well? For now I see it's not, as an example:

  #pragma OPENCL EXTENSION cl_khr_fp16 : enable
  half __attribute__((overloadable)) goo(half in1, half in2); // all ok
  #pragma OPENCL EXTENSION cl_khr_fp16 : disable
  
  #pragma OPENCL EXTENSION cl_khr_fp16 : begin
  half __attribute__((overloadable)) goo(half in1, half in2); // declaring 
function parameter of type 'half' is not allowed; did you forget * ?
  #pragma OPENCL EXTENSION cl_khr_fp16 : end

2. As far as I understand, when declaring an extension we shall have 1 #pragma 
begin and 1 #pragma end. But here is a test called extension-begin and it's 
header one can see this construction:

  #pragma OPENCL EXTENSION all : begin
  #pragma OPENCL EXTENSION all : end 
  
  #pragma OPENCL EXTENSION my_ext : begin
  ///some code
  #pragma OPENCL EXTENSION my_ext : end 
  #pragma OPENCL EXTENSION my_ext : end // why?
  }

so here my_ext has double ending. And in this way the test passes, but if I 
remove second ending (which is redundant from my perspective), I see following 
diagnostics: " OpenCL extension end directive mismatches begin directive - 
ignoring". Is it a bug or it's supposed to work that way?


https://reviews.llvm.org/D51341



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


[PATCH] D54334: [AVR] Automatically link CRT and libgcc from the system avr-gcc

2018-11-16 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay updated this revision to Diff 174359.
dylanmckay marked 6 inline comments as done.
dylanmckay added a comment.

- Remove link to BugZilla in diagnostic
- Use StringRef for a static string array rather than std::string
- Elide braces
- Dereference an Optional in-place rather than persisting it for one use
- Use llvm::None rather than explicit Optional() constructor


Repository:
  rC Clang

https://reviews.llvm.org/D54334

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  lib/Driver/ToolChains/AVR.cpp
  lib/Driver/ToolChains/AVR.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/avr-link-mcu-family-unimplemented.c
  test/Driver/avr-link-no-mcu-specified.c
  test/Driver/avr-link-nostdlib-nodefaultlibs.c

Index: test/Driver/avr-link-nostdlib-nodefaultlibs.c
===
--- /dev/null
+++ test/Driver/avr-link-nostdlib-nodefaultlibs.c
@@ -0,0 +1,8 @@
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 -nostdlib %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 -nodefaultlibs %s 2>&1 | FileCheck %s
+
+// nostdlib and nodefaultlibs programs should compile fine.
+
+// CHECK: main
+int main() { return 0; }
+
Index: test/Driver/avr-link-no-mcu-specified.c
===
--- /dev/null
+++ test/Driver/avr-link-no-mcu-specified.c
@@ -0,0 +1,10 @@
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps %s 2>&1 | FileCheck --check-prefix=WARN %s
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+
+// WARN: warning: no target microcontroller specified on command line, cannot link standard libraries, please pass -mmcu=
+// WARN: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+
+// NOWARN: main
+
+int main() { return 0; }
+
Index: test/Driver/avr-link-mcu-family-unimplemented.c
===
--- /dev/null
+++ test/Driver/avr-link-mcu-family-unimplemented.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=attiny13a %s 2>&1 | FileCheck --check-prefix=WARN %s
+
+// WARN: warning: support for linking stdlibs for microcontroller 'attiny13a' is not implemented
+// WARN: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+
+int main() { return 0; }
+
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1865,6 +1865,9 @@
   static const char *const ARMebHFTriples[] = {
   "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"};
 
+  static const char *const AVRLibDirs[] = {"/lib"};
+  static const char *const AVRTriples[] = {"avr"};
+
   static const char *const X86_64LibDirs[] = {"/lib64", "/lib"};
   static const char *const X86_64Triples[] = {
   "x86_64-linux-gnu",   "x86_64-unknown-linux-gnu",
@@ -2077,6 +2080,10 @@
   TripleAliases.append(begin(ARMebTriples), end(ARMebTriples));
 }
 break;
+  case llvm::Triple::avr:
+LibDirs.append(begin(AVRLibDirs), end(AVRLibDirs));
+TripleAliases.append(begin(AVRTriples), end(AVRTriples));
+break;
   case llvm::Triple::x86_64:
 LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
 TripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
@@ -2205,6 +2212,8 @@
   return false;
   } else if (isRISCV(TargetArch)) {
 findRISCVMultilibs(D, TargetTriple, Path, Args, Detected);
+  } else if (TargetArch == llvm::Triple::avr) {
+// AVR has no multilibs.
   } else if (!findBiarchMultilibs(D, TargetTriple, Path, Args,
   NeedsBiarchSuffix, Detected)) {
 return false;
Index: lib/Driver/ToolChains/AVR.h
===
--- lib/Driver/ToolChains/AVR.h
+++ lib/Driver/ToolChains/AVR.h
@@ -20,26 +20,45 @@
 namespace toolchains {
 
 class LLVM_LIBRARY_VISIBILITY AVRToolChain : public Generic_ELF {
-protected:
-  Tool *buildLinker() const override;
 public:
   AVRToolChain(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
+protected:
+  Tool *buildLinker() const override;
+
+private:
+  /// Whether libgcc, libct, and friends should be linked.
+  ///
+  /// This is not done if the user does not specify a
+  /// microcontroller on the command line.
+  bool LinkStdlib;
+
+  llvm::Optional findAVRLibcInstallation() const;
 };
 
 } // end namespace toolchains
 
 namespace tools {
 namespace AVR {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("AVR::Linker", "avr-ld", TC) {}
+ 

[PATCH] D54091: [RISCV] Add inline asm constraints I, J & K for RISC-V

2018-11-16 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 174360.
lewis-revill edited the summary of this revision.
lewis-revill added a comment.

Updated to reflect desired changes (and fix an incorrect boundary). I didn't 
add r & m to riscv-inline-asm.c as I wasn't clear what exactly was desired.


Repository:
  rC Clang

https://reviews.llvm.org/D54091

Files:
  lib/Basic/Targets/RISCV.cpp
  lib/Basic/Targets/RISCV.h
  test/CodeGen/riscv-inline-asm.c
  test/Sema/inline-asm-validate-riscv.c

Index: test/Sema/inline-asm-validate-riscv.c
===
--- /dev/null
+++ test/Sema/inline-asm-validate-riscv.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple riscv32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -fsyntax-only -verify %s
+
+void I(int i) {
+  static const int BelowMin = -2049;
+  static const int AboveMax = 2048;
+  asm volatile ("" :: "I"(i)); // expected-error{{constraint 'I' expects an integer constant expression}}
+  asm volatile ("" :: "I"(BelowMin)); // expected-error{{value '-2049' out of range for constraint 'I'}}
+  asm volatile ("" :: "I"(AboveMax)); // expected-error{{value '2048' out of range for constraint 'I'}}
+}
+
+void J(int j) {
+  static const int BelowMin = -1;
+  static const int AboveMax = 1;
+  asm volatile ("" :: "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
+  asm volatile ("" :: "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
+  asm volatile ("" :: "J"(AboveMax)); // expected-error{{value '1' out of range for constraint 'J'}}
+}
+
+void K(int k) {
+  static const int BelowMin = -1;
+  static const int AboveMax = 32;
+  asm volatile ("" :: "K"(k)); // expected-error{{constraint 'K' expects an integer constant expression}}
+  asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'K'}}
+  asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of range for constraint 'K'}}
+}
Index: test/CodeGen/riscv-inline-asm.c
===
--- /dev/null
+++ test/CodeGen/riscv-inline-asm.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Test RISC-V specific inline assembly constraints.
+
+void test_I() {
+// CHECK-LABEL: define void @test_I()
+// CHECK: call void asm sideeffect "", "I"(i32 2047)
+  asm volatile ("" :: "I"(2047));
+// CHECK: call void asm sideeffect "", "I"(i32 -2048)
+  asm volatile ("" :: "I"(-2048));
+}
+
+void test_J() {
+// CHECK-LABEL: define void @test_J()
+// CHECK: call void asm sideeffect "", "J"(i32 0)
+  asm volatile ("" :: "J"(0));
+}
+
+void test_K() {
+// CHECK-LABEL: define void @test_K()
+// CHECK: call void asm sideeffect "", "K"(i32 31)
+  asm volatile ("" :: "K"(31));
+// CHECK: call void asm sideeffect "", "K"(i32 0)
+  asm volatile ("" :: "K"(0));
+}
Index: lib/Basic/Targets/RISCV.h
===
--- lib/Basic/Targets/RISCV.h
+++ lib/Basic/Targets/RISCV.h
@@ -62,9 +62,7 @@
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
- TargetInfo::ConstraintInfo &Info) const override {
-return false;
-  }
+ TargetInfo::ConstraintInfo &Info) const override;
 
   bool hasFeature(StringRef Feature) const override;
 
Index: lib/Basic/Targets/RISCV.cpp
===
--- lib/Basic/Targets/RISCV.cpp
+++ lib/Basic/Targets/RISCV.cpp
@@ -40,6 +40,26 @@
   return llvm::makeArrayRef(GCCRegAliases);
 }
 
+bool RISCVTargetInfo::validateAsmConstraint(
+const char *&Name, TargetInfo::ConstraintInfo &Info) const {
+  switch (*Name) {
+  default:
+return false;
+  case 'I':
+// A 12-bit signed immediate.
+Info.setRequiresImmediate(-2048, 2047);
+return true;
+  case 'J':
+// Integer zero.
+Info.setRequiresImmediate(0);
+return true;
+  case 'K':
+// A 5-bit unsigned immediate for CSR access instructions.
+Info.setRequiresImmediate(0, 31);
+return true;
+  }
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54334: [AVR] Automatically link CRT and libgcc from the system avr-gcc

2018-11-16 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay updated this revision to Diff 174362.
dylanmckay marked an inline comment as done.
dylanmckay added a comment.

Run clang-format on the whole patch


Repository:
  rC Clang

https://reviews.llvm.org/D54334

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  lib/Driver/ToolChains/AVR.cpp
  lib/Driver/ToolChains/AVR.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/avr-link-mcu-family-unimplemented.c
  test/Driver/avr-link-no-mcu-specified.c
  test/Driver/avr-link-nostdlib-nodefaultlibs.c

Index: test/Driver/avr-link-nostdlib-nodefaultlibs.c
===
--- /dev/null
+++ test/Driver/avr-link-nostdlib-nodefaultlibs.c
@@ -0,0 +1,8 @@
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 -nostdlib %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 -nodefaultlibs %s 2>&1 | FileCheck %s
+
+// nostdlib and nodefaultlibs programs should compile fine.
+
+// CHECK: main
+int main() { return 0; }
+
Index: test/Driver/avr-link-no-mcu-specified.c
===
--- /dev/null
+++ test/Driver/avr-link-no-mcu-specified.c
@@ -0,0 +1,10 @@
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps %s 2>&1 | FileCheck --check-prefix=WARN %s
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+
+// WARN: warning: no target microcontroller specified on command line, cannot link standard libraries, please pass -mmcu=
+// WARN: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+
+// NOWARN: main
+
+int main() { return 0; }
+
Index: test/Driver/avr-link-mcu-family-unimplemented.c
===
--- /dev/null
+++ test/Driver/avr-link-mcu-family-unimplemented.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=attiny13a %s 2>&1 | FileCheck --check-prefix=WARN %s
+
+// WARN: warning: support for linking stdlibs for microcontroller 'attiny13a' is not implemented
+// WARN: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+
+int main() { return 0; }
+
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1865,6 +1865,9 @@
   static const char *const ARMebHFTriples[] = {
   "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"};
 
+  static const char *const AVRLibDirs[] = {"/lib"};
+  static const char *const AVRTriples[] = {"avr"};
+
   static const char *const X86_64LibDirs[] = {"/lib64", "/lib"};
   static const char *const X86_64Triples[] = {
   "x86_64-linux-gnu",   "x86_64-unknown-linux-gnu",
@@ -2077,6 +2080,10 @@
   TripleAliases.append(begin(ARMebTriples), end(ARMebTriples));
 }
 break;
+  case llvm::Triple::avr:
+LibDirs.append(begin(AVRLibDirs), end(AVRLibDirs));
+TripleAliases.append(begin(AVRTriples), end(AVRTriples));
+break;
   case llvm::Triple::x86_64:
 LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
 TripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
@@ -2205,6 +2212,8 @@
   return false;
   } else if (isRISCV(TargetArch)) {
 findRISCVMultilibs(D, TargetTriple, Path, Args, Detected);
+  } else if (TargetArch == llvm::Triple::avr) {
+// AVR has no multilibs.
   } else if (!findBiarchMultilibs(D, TargetTriple, Path, Args,
   NeedsBiarchSuffix, Detected)) {
 return false;
Index: lib/Driver/ToolChains/AVR.h
===
--- lib/Driver/ToolChains/AVR.h
+++ lib/Driver/ToolChains/AVR.h
@@ -20,26 +20,43 @@
 namespace toolchains {
 
 class LLVM_LIBRARY_VISIBILITY AVRToolChain : public Generic_ELF {
-protected:
-  Tool *buildLinker() const override;
 public:
   AVRToolChain(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
+
+protected:
+  Tool *buildLinker() const override;
+
+private:
+  /// Whether libgcc, libct, and friends should be linked.
+  ///
+  /// This is not done if the user does not specify a
+  /// microcontroller on the command line.
+  bool LinkStdlib;
+
+  llvm::Optional findAVRLibcInstallation() const;
 };
 
 } // end namespace toolchains
 
 namespace tools {
 namespace AVR {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("AVR::Linker", "avr-ld", TC) {}
+  Linker(const llvm::Triple &Triple, const ToolChain &TC, bool LinkStdlib)
+  : GnuTool("AVR::Linker", "avr-ld", TC), Triple(Triple),
+LinkStdlib(LinkStdlib) {}
+
   bool hasIntegratedCPP() const override {

[PATCH] D54334: [AVR] Automatically link CRT and libgcc from the system avr-gcc

2018-11-16 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:44-45
+def warn_drv_avr_family_linking_stdlibs_not_implemented: Warning<
+  "support for linking stdlibs for microcontroller '%0' is not implemented, "
+  "please file an AVR backend bug at http://bugs.llvm.org/ with your mcu 
name">,
+  InGroup;

aaron.ballman wrote:
> This is novel for diagnostics -- we don't have any other diagnostics that 
> recommend filing bugs. This doesn't strike me as something a naive developer 
> will just happen across by accident, so I would probably drop from the comma 
> onward and assume the user knows they can report bugs if they really care.
I agree



Comment at: lib/Driver/ToolChains/AVR.cpp:40
+
+const std::string PossibleAVRLibcLocations[] = {
+  "/usr/avr",

aaron.ballman wrote:
> Why use `std::string` here when below you use it as a list of `StringRef`s?
Good point, have fixed.



Comment at: lib/Driver/ToolChains/AVR.cpp:162
+
+  return Optional();
+}

aaron.ballman wrote:
> `return llvm::None;`
Didn't know about that, thanks!



Comment at: lib/Driver/ToolChains/AVR.h:45-47
+  Linker(const llvm::Triple &Triple,
+ const ToolChain &TC,
+ bool LinkStdlib)

aaron.ballman wrote:
> Did clang-format produce this? For some reason, it looks off to my eyes.
I have now run clang-format on the whole patch.


Repository:
  rC Clang

https://reviews.llvm.org/D54334



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


[PATCH] D51341: [HEADER] Overloadable function candidates for half/double types

2018-11-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D51341#1301047, @sidorovd wrote:

> @Anastasia @yaxunl 
>  Hi, I am working on generalizing this patch and several questions have 
> raised during this, so I want to discuss them with you:
>
> 1. Should #pragma OPENCL EXTENSION ext_name : begin enables the extension as 
> well? For now I see it's not, as an example:
>
>   ``` #pragma OPENCL EXTENSION cl_khr_fp16 : enable half 
> __attribute__((overloadable)) goo(half in1, half in2); // all ok #pragma 
> OPENCL EXTENSION cl_khr_fp16 : disable
>
>   #pragma OPENCL EXTENSION cl_khr_fp16 : begin half 
> __attribute__((overloadable)) goo(half in1, half in2); // declaring function 
> parameter of type 'half' is not allowed; did you forget * ? #pragma OPENCL 
> EXTENSION cl_khr_fp16 : end ```


#pragma OPENCL EXTENSION ext_name : begin should not enable the extension. 
There are cases that you want to declare functions and types associated with an 
extension but do not want to enable the extension.

> 2. As far as I understand, when declaring an extension we shall have 1 
> #pragma begin and 1 #pragma end. But here is a test called extension-begin 
> and in its header one can see this construction:
> 
>   ``` #pragma OPENCL EXTENSION all : begin #pragma OPENCL EXTENSION all : end
> 
>   #pragma OPENCL EXTENSION my_ext : begin ///some code #pragma OPENCL 
> EXTENSION my_ext : end #pragma OPENCL EXTENSION my_ext : end // why? } ``` so 
> here my_ext has double ending. And in this way the test passes, but if I 
> remove second ending (which is redundant from my perspective), I see 
> following diagnostics: " OpenCL extension end directive mismatches begin 
> directive - ignoring". Is it a bug or it's supposed to work that way?

It seems to be a bug.


https://reviews.llvm.org/D51341



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


[PATCH] D54334: [AVR] Automatically link CRT and libgcc from the system avr-gcc

2018-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not certain if it will be possible to devise test cases for the two 
diagnostics I pointed out or not, but otherwise, this LGTM as far as the 
implementation goes. I don't know enough about AVR to sign off on whether the 
patch logic is correct or not.




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:35
+  InGroup;
+def warn_drv_avr_gcc_not_found: Warning<
+  "no avr-gcc installation can be found on the system, "

I don't see a test case for this diagnostic.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:40
+def warn_drv_avr_libc_not_found: Warning<
+  "no avr-libc installation can be found on the system, "
+  "cannot link standard libraries">,

Or this one.


Repository:
  rC Clang

https://reviews.llvm.org/D54334



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


[PATCH] D53866: [Preamble] Fix preamble for circular #includes

2018-11-16 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

I still don't have feedback for a real world case except "unintentional 
#include". Unfortunately, in real world cases the cyclic include might be not 
obvious at all.

@ilya: As far as I understand you prefer to make the preamble generation rather 
fail as long as we don't have more information. How do you suggest to implement 
this? I see that Clang->getPreprocessor().addPPCallbacks() is called in 
PrecompiledPreamble::Build(). Adding a custom PPCallbacks there that overrides 
"void InclusionDirective()" might be enough to detect the cyclic #include and 
to set a flag that is checked before PrecompiledPreamble::Build() returns - 
BuildPreambleError could get a new enumerator. Is there a better way to do 
this? For example, it would be desirable to not only observe this case, but 
then to also stop/abort/skip all the further parsing that is done for the 
preamble only as it's pointless then.


Repository:
  rC Clang

https://reviews.llvm.org/D53866



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


[clang-tools-extra] r347053 - [clang-tidy] Expanded a test NFC

2018-11-16 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Nov 16 06:57:51 2018
New Revision: 347053

URL: http://llvm.org/viewvc/llvm-project?rev=347053&view=rev
Log:
[clang-tidy] Expanded a test NFC

Expanded the readability-inconsistent-declaration-parameter-name-macros.cpp to
check notes and added a test with pasted tokens.

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp?rev=347053&r1=347052&r2=347053&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp
 Fri Nov 16 06:57:51 2018
@@ -3,23 +3,45 @@
 // RUN:   -- -std=c++11
 
 #define MACRO() \
-  void f(int x);
+  void f(int x)
 
-struct S {
+struct S1 {
   MACRO();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'S::f' has a definition 
with different parameter names
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: function 'S1::f' has a definition 
with different parameter names
+  // CHECK-NOTES: :[[@LINE-5]]:8: note: expanded from macro 'MACRO'
+  // CHECK-NOTES: :[[@LINE+4]]:10: note: the definition seen here
+  // CHECK-NOTES: :[[@LINE-4]]:3: note: differing parameters are named here: 
('x'), in definition: ('y')
+  // CHECK-NOTES: :[[@LINE-8]]:8: note: expanded from macro 'MACRO'
 };
+void S1::f(int y) {}
 
-void S::f(int y) {
-}
+struct S2 {
+  int g() const;
+  void set_g(int g);
+  // CHECK-NOTES: :[[@LINE-1]]:8: warning: function 'S2::set_g' has a 
definition with different parameter names
+  // CHECK-NOTES: :[[@LINE+14]]:1: note: the definition seen here
+  // CHECK-NOTES: :[[@LINE+9]]:12: note: expanded from macro 'DEFINITION'
+  // This one is unfortunate, but the location this points to is in a scratch
+  // space, so it's not helpful to the user.
+  // CHECK-NOTES: {{^}}note: expanded from here{{$}}
+  // CHECK-NOTES: :[[@LINE-7]]:8: note: differing parameters are named here: 
('g'), in definition: ('w')
+};
+
+#define DEFINITION(name, parameter)\
+  int S2::name() const { return 0; }   \
+  void S2::set_##name(int parameter) { \
+(void)parameter;   \
+  }
+
+DEFINITION(g, w)
 
 //
 
 #define DECLARE_FUNCTION_WITH_PARAM_NAME(function_name, param_name) \
   void function_name(int param_name)
 
-// CHECK-MESSAGES: :[[@LINE+1]]:34: warning: function 'macroFunction' has 1 
other declaration with different parameter names 
[readability-inconsistent-declaration-parameter-name]
+// CHECK-NOTES: :[[@LINE+1]]:34: warning: function 'macroFunction' has 1 other 
declaration with different parameter names 
[readability-inconsistent-declaration-parameter-name]
 DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, a);
-// CHECK-MESSAGES: :[[@LINE+2]]:34: note: the 1st inconsistent declaration 
seen here
-// CHECK-MESSAGES: :[[@LINE+1]]:34: note: differing parameters are named here: 
('b'), in the other declaration: ('a')
+// CHECK-NOTES: :[[@LINE+2]]:34: note: the 1st inconsistent declaration seen 
here
+// CHECK-NOTES: :[[@LINE+1]]:34: note: differing parameters are named here: 
('b'), in the other declaration: ('a')
 DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, b);


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


[PATCH] D54253: [OpenCL][NFC] Improve test coverage of test/Index/opencl-types.cl

2018-11-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D54253#1300827, @AlexeySachkov wrote:

> I'm running OpenCL on an x886 and everything is fine, but there are a lot of 
> build bots which build different targets on different architectures. Since 
> there are no `target` option specified, `c-index-test` uses native target.
>
> I just realized: may be it is better to add something like `// REQUIRES: x86` 
> to the test?


Yes, it's the same for clang actually. We are solving this by adding `-triple` 
explicitly, alternatively `REQUIRES` will work too.


Repository:
  rC Clang

https://reviews.llvm.org/D54253



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


[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-16 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 174374.
gchatelet marked 13 inline comments as done.
gchatelet added a comment.

- Addressed comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488

Files:
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  test/clang-tidy/cppcoreguidelines-narrowing-conversions-long-is-32bits.cpp
  test/clang-tidy/cppcoreguidelines-narrowing-conversions-unsigned-char.cpp
  test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp

Index: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
===
--- test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
+++ test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t -config="{CheckOptions: [{key: "cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion", value: 1}]}" -- -target x86_64-unknown-linux -fsigned-char
 
 float ceil(float);
 namespace std {
@@ -9,47 +9,298 @@
 namespace floats {
 
 struct ConvertsToFloat {
-  operator float() const { return 0.5; }
+  operator float() const { return 0.5f; }
 };
 
-float operator "" _Pa(unsigned long long);
+float operator"" _float(unsigned long long);
 
-void not_ok(double d) {
+void narrow_double_to_int_not_ok(double d) {
   int i = 0;
   i = d;
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   i = 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i = static_cast(d);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i = ConvertsToFloat();
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
-  i = 15_Pa;
+  i = 15_float;
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
 }
 
-void not_ok_binary_ops(double d) {
+void narrow_double_to_int_not_ok_binary_ops(double d) {
   int i = 0;
   i += 0.5;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += d;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   // We warn on the following even though it's not dangerous because there is no
   // reason to use a double literal here.
-  // TODO(courbet): Provide an automatic fix.
+  // TODO: Provide an automatic fix if the number is exactly representable in the destination type.
   i += 2.0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += 2.0f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
 
   i *= 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i /= 0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from constant 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += (double)0.5f;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conve

[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-16 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added inline comments.



Comment at: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp:79-81
+  // TODO: Provide an automatic fix if the number is exactly representable in 
the destination type.
+  f += 2.0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 
constant 'double' to 'float' [cppcoreguidelines-narrowing-conversions]

aaron.ballman wrote:
> gchatelet wrote:
> > aaron.ballman wrote:
> > > This is not a narrowing conversion -- there should be no diagnostic here. 
> > > See [dcl.init.list]p7.
> > Thx for pointing this out.
> > I would like to keep the diagnostic (without mentioning the narrowing) 
> > because there is no reason to write `2.0` instead of `2.0f`. WDYT?
> I see no reason to warn on a literal value that isn't changed as a result of 
> the notional narrowing. The standard clearly defines the behavior, so I think 
> that would be needlessly chatty.
Done. Plus added som tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488



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


r347059 - [OpenCL] Enable address spaces for references in C++

2018-11-16 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Fri Nov 16 08:22:56 2018
New Revision: 347059

URL: http://llvm.org/viewvc/llvm-project?rev=347059&view=rev
Log:
[OpenCL] Enable address spaces for references in C++

Added references to the addr spaces deduction and enabled
CL2.0 features (program scope variables and storage class
qualifiers) to work in C++ mode too.

Fixed several address space conversion issues in CodeGen 
for references.

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


Added:
cfe/trunk/test/CodeGenOpenCLCXX/
cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=347059&r1=347058&r2=347059&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Nov 16 08:22:56 2018
@@ -9631,6 +9631,10 @@ public:
AssignmentAction Action,
CheckedConversionKind CCK);
 
+  ExprResult PerformQualificationConversion(
+  Expr *E, QualType Ty, ExprValueKind VK = VK_RValue,
+  CheckedConversionKind CCK = CCK_ImplicitConversion);
+
   /// the following "Check" methods will return a valid/converted QualType
   /// or a null QualType (indicating an error diagnostic was issued).
 

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=347059&r1=347058&r2=347059&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Nov 16 08:22:56 2018
@@ -1634,13 +1634,18 @@ bool CastExpr::CastConsistency() const {
 assert(getSubExpr()->getType()->isFunctionType());
 goto CheckNoBasePath;
 
-  case CK_AddressSpaceConversion:
-assert(getType()->isPointerType() || getType()->isBlockPointerType());
-assert(getSubExpr()->getType()->isPointerType() ||
-   getSubExpr()->getType()->isBlockPointerType());
-assert(getType()->getPointeeType().getAddressSpace() !=
-   getSubExpr()->getType()->getPointeeType().getAddressSpace());
-LLVM_FALLTHROUGH;
+  case CK_AddressSpaceConversion: {
+auto Ty = getType();
+auto SETy = getSubExpr()->getType();
+assert(getValueKindForType(Ty) == Expr::getValueKindForType(SETy));
+if (!isGLValue())
+  Ty = Ty->getPointeeType();
+if (!isGLValue())
+  SETy = SETy->getPointeeType();
+assert(!Ty.isNull() && !SETy.isNull() &&
+   Ty.getAddressSpace() != SETy.getAddressSpace());
+goto CheckNoBasePath;
+  }
   // These should not have an inheritance path.
   case CK_Dynamic:
   case CK_ToUnion:

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=347059&r1=347058&r2=347059&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Nov 16 08:22:56 2018
@@ -4163,7 +4163,6 @@ LValue CodeGenFunction::EmitCastLValue(c
   case CK_ARCReclaimReturnedObject:
   case CK_ARCExtendBlockObject:
   case CK_CopyAndAutoreleaseBlockObject:
-  case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
   case CK_FixedPointCast:
   case CK_FixedPointToBoolean:
@@ -4260,6 +4259,14 @@ LValue CodeGenFunction::EmitCastLValue(c
 return MakeAddrLValue(V, E->getType(), LV.getBaseInfo(),
   CGM.getTBAAInfoForSubobject(LV, E->getType()));
   }
+  case CK_AddressSpaceConversion: {
+LValue LV = EmitLValue(E->getSubExpr());
+QualType DestTy = getContext().getPointerType(E->getType());
+llvm::Value *V = getTargetHooks().performAddrSpaceCast(
+*this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(),
+DestTy.getAddressSpace(), ConvertType(DestTy));
+return MakeNaturalAlignPointeeAddrLValue(V, DestTy);
+  }
   case CK_ObjCObjectLValueCast: {
 LValue LV = EmitLValue(E->getSubExpr());
 Address V = Builder.CreateElementBitCast(LV.getAddress(),

Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=347059&r1=347058&r2=347059&view=diff
==
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Fri Nov 16 08:22:56 2018
@@ -566,14 +566,16 @@ bool DeclSpec::SetStorageClassSpec(Sema
   // these storage-class specifiers.
   // OpenCL v1.2 s6.8 changes this to 

[PATCH] D53764: [OpenCL] Enable address spaces for references in C++

2018-11-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347059: [OpenCL] Enable address spaces for references in C++ 
(authored by stulova, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53764?vs=174033&id=174378#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53764

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl

Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -4163,7 +4163,6 @@
   case CK_ARCReclaimReturnedObject:
   case CK_ARCExtendBlockObject:
   case CK_CopyAndAutoreleaseBlockObject:
-  case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
   case CK_FixedPointCast:
   case CK_FixedPointToBoolean:
@@ -4260,6 +4259,14 @@
 return MakeAddrLValue(V, E->getType(), LV.getBaseInfo(),
   CGM.getTBAAInfoForSubobject(LV, E->getType()));
   }
+  case CK_AddressSpaceConversion: {
+LValue LV = EmitLValue(E->getSubExpr());
+QualType DestTy = getContext().getPointerType(E->getType());
+llvm::Value *V = getTargetHooks().performAddrSpaceCast(
+*this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(),
+DestTy.getAddressSpace(), ConvertType(DestTy));
+return MakeNaturalAlignPointeeAddrLValue(V, DestTy);
+  }
   case CK_ObjCObjectLValueCast: {
 LValue LV = EmitLValue(E->getSubExpr());
 Address V = Builder.CreateElementBitCast(LV.getAddress(),
Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -1634,13 +1634,18 @@
 assert(getSubExpr()->getType()->isFunctionType());
 goto CheckNoBasePath;
 
-  case CK_AddressSpaceConversion:
-assert(getType()->isPointerType() || getType()->isBlockPointerType());
-assert(getSubExpr()->getType()->isPointerType() ||
-   getSubExpr()->getType()->isBlockPointerType());
-assert(getType()->getPointeeType().getAddressSpace() !=
-   getSubExpr()->getType()->getPointeeType().getAddressSpace());
-LLVM_FALLTHROUGH;
+  case CK_AddressSpaceConversion: {
+auto Ty = getType();
+auto SETy = getSubExpr()->getType();
+assert(getValueKindForType(Ty) == Expr::getValueKindForType(SETy));
+if (!isGLValue())
+  Ty = Ty->getPointeeType();
+if (!isGLValue())
+  SETy = SETy->getPointeeType();
+assert(!Ty.isNull() && !SETy.isNull() &&
+   Ty.getAddressSpace() != SETy.getAddressSpace());
+goto CheckNoBasePath;
+  }
   // These should not have an inheritance path.
   case CK_Dynamic:
   case CK_ToUnion:
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -7181,7 +7181,8 @@
   bool IsPointee =
   ChunkIndex > 0 &&
   (D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Pointer ||
-   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer);
+   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer ||
+   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Reference);
   bool IsFuncReturnType =
   ChunkIndex > 0 &&
   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Function;
Index: cfe/trunk/lib/Sema/DeclSpec.cpp
===
--- cfe/trunk/lib/Sema/DeclSpec.cpp
+++ cfe/trunk/lib/Sema/DeclSpec.cpp
@@ -566,14 +566,16 @@
   // these storage-class specifiers.
   // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
   // specifiers are not supported."
+  // OpenCL C++ v1.0 s2.9 restricts register.
   if (S.getLangOpts().OpenCL &&
   !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
 switch (SC) {
 case SCS_extern:
 case SCS_private_extern:
 case SCS_static:
-  if (S.getLangOpts().OpenCLVersion < 120) {
-DiagID   = diag::err_opencl_unknown_type_specifier;
+  if (S.getLangOpts().OpenCLVersion < 120 &&
+  !S.getLangOpts().OpenCLCPlusPlus) {
+DiagID = diag::err_opencl_unknown_type_specifier;
 PrevSpec = getSpecifierName(SC);
 return true;
   }
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -7352,19 +7352,23 @@
 return;
   }
 }
-// OpenCL v1.2 s6.5 - All program scope variables must be declared in t

[PATCH] D54634: [OpenCL] Fix address space deduction in template args

2018-11-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, yaxunl.

Don't deduce address spaces for non-pointer-like types in template args.

This fixes bug reported in https://bugs.llvm.org/show_bug.cgi?id=38603 and 
enables most of template functionality to work correctly.

There is still work to be done on address spaces in TreeTransforms to enable 
full functionality of address spaces with templates (hence FIXME in the test).


https://reviews.llvm.org/D54634

Files:
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/template-address-spaces.cl


Index: test/CodeGenOpenCLCXX/template-address-spaces.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/template-address-spaces.cl
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -cl-std=c++ %s -emit-llvm -o - -O0 -triple 
spir-unknown-unknown | FileCheck %s
+
+template 
+struct S{
+  T a;
+  T foo();
+};
+
+template
+T S::foo() { return a;}
+
+//CHECK: %struct.S = type { i32 }
+//CHECK: %struct.S.0 = type { i32 addrspace(4)* }
+//CHECK: %struct.S.1 = type { i32 addrspace(1)* }
+
+//CHECK: i32 @_ZN1SIiE3fooEv(%struct.S* %this)
+//CHECK: i32 addrspace(4)* @_ZN1SIPU3AS4iE3fooEv(%struct.S.0* %this)
+//CHECK: i32 addrspace(1)* @_ZN1SIPU3AS1iE3fooEv(%struct.S.1* %this)
+
+void bar(){
+  S sint;
+  S sintptr;
+  S<__global int*> sintptrgl;
+  // FIXME: Preserve AS in TreeTransform
+  //S<__global int> sintgl;
+
+  sint.foo();
+  sintptr.foo();
+  sintptrgl.foo();
+  //sintgl.foo();
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7223,7 +7223,9 @@
 if (IsPointee) {
   ImpAddr = LangAS::opencl_generic;
 } else {
-  if (D.getContext() == DeclaratorContext::FileContext) {
+  if (D.getContext() == DeclaratorContext::TemplateArgContext) {
+// Do not deduce address space for non-pointee type in template args
+  } else if (D.getContext() == DeclaratorContext::FileContext) {
 ImpAddr = LangAS::opencl_global;
   } else {
 if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||


Index: test/CodeGenOpenCLCXX/template-address-spaces.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/template-address-spaces.cl
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -cl-std=c++ %s -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
+
+template 
+struct S{
+  T a;
+  T foo();
+};
+
+template
+T S::foo() { return a;}
+
+//CHECK: %struct.S = type { i32 }
+//CHECK: %struct.S.0 = type { i32 addrspace(4)* }
+//CHECK: %struct.S.1 = type { i32 addrspace(1)* }
+
+//CHECK: i32 @_ZN1SIiE3fooEv(%struct.S* %this)
+//CHECK: i32 addrspace(4)* @_ZN1SIPU3AS4iE3fooEv(%struct.S.0* %this)
+//CHECK: i32 addrspace(1)* @_ZN1SIPU3AS1iE3fooEv(%struct.S.1* %this)
+
+void bar(){
+  S sint;
+  S sintptr;
+  S<__global int*> sintptrgl;
+  // FIXME: Preserve AS in TreeTransform
+  //S<__global int> sintgl;
+
+  sint.foo();
+  sintptr.foo();
+  sintptrgl.foo();
+  //sintgl.foo();
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7223,7 +7223,9 @@
 if (IsPointee) {
   ImpAddr = LangAS::opencl_generic;
 } else {
-  if (D.getContext() == DeclaratorContext::FileContext) {
+  if (D.getContext() == DeclaratorContext::TemplateArgContext) {
+// Do not deduce address space for non-pointee type in template args
+  } else if (D.getContext() == DeclaratorContext::FileContext) {
 ImpAddr = LangAS::opencl_global;
   } else {
 if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-11-16 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3385
+  if (IsCommonSaturated)
+CommonFixedSema.setSaturated(false);
+

ebevhan wrote:
> Can EmitFixedPointConversion not determine this on its own?
What I meant here was that rather than zeroing out the saturation mode on the 
common semantic because we know that the common conversion won't saturate, 
EmitFixedPointConversion should be able to pick up on the fact that converting 
from semantic A to semantic B shouldn't cause saturation and not emit a 
saturating conversion in that case. Then you can set the saturation on the 
common semantic properly, since the operation should be saturating.

Even for something like `sat_uf * sat_uf` with padding, where the common type 
conversion should be `(16w, 15scale, uns, sat, pad) -> (15w, 15scale, uns, sat, 
nopad)`, EmitFixedPointConversion shouldn't emit a saturation, since the number 
of integral bits hasn't changed.



Comment at: clang/test/Frontend/fixed_point_add.c:269
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = call i15 @llvm.uadd.sat.i15(i15 
[[USA_TRUNC]], i15 [[USA_SAT_TRUNC]])
+  // UNSIGNED-NEXT: [[SUM_EXT:%[a-z0-9]+]] = zext i15 [[SUM]] to i16
+  // UNSIGNED-NEXT: store i16 [[SUM_EXT]], i16* %usa_sat, align 2

This is probably a candidate for an isel optimization. This operation also 
works as an `i16 ssat.add` with a negative-clamp-to-zero afterwards, and if the 
target supports `i16 ssat.add` natively then it will likely be a lot more 
efficient than whatever an `i15 uadd.sat` produces.


Repository:
  rC Clang

https://reviews.llvm.org/D53738



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


r347062 - [AST][NFC] Pack CXXBoolLiteralExpr

2018-11-16 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Nov 16 08:54:17 2018
New Revision: 347062

URL: http://llvm.org/viewvc/llvm-project?rev=347062&view=rev
Log:
[AST][NFC] Pack CXXBoolLiteralExpr

Use the newly available space in Stmt.
This saves 8 bytes per CXXBoolLiteralExpr.


Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=347062&r1=347061&r2=347062&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Nov 16 08:54:17 2018
@@ -548,26 +548,25 @@ public:
 
 /// A boolean literal, per ([C++ lex.bool] Boolean literals).
 class CXXBoolLiteralExpr : public Expr {
-  bool Value;
-  SourceLocation Loc;
-
 public:
-  CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l)
+  CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc)
   : Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false,
- false, false),
-Value(val), Loc(l) {}
+ false, false) {
+CXXBoolLiteralExprBits.Value = Val;
+CXXBoolLiteralExprBits.Loc = Loc;
+  }
 
   explicit CXXBoolLiteralExpr(EmptyShell Empty)
   : Expr(CXXBoolLiteralExprClass, Empty) {}
 
-  bool getValue() const { return Value; }
-  void setValue(bool V) { Value = V; }
+  bool getValue() const { return CXXBoolLiteralExprBits.Value; }
+  void setValue(bool V) { CXXBoolLiteralExprBits.Value = V; }
 
-  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
-  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
+  SourceLocation getBeginLoc() const { return getLocation(); }
+  SourceLocation getEndLoc() const { return getLocation(); }
 
-  SourceLocation getLocation() const { return Loc; }
-  void setLocation(SourceLocation L) { Loc = L; }
+  SourceLocation getLocation() const { return CXXBoolLiteralExprBits.Loc; }
+  void setLocation(SourceLocation L) { CXXBoolLiteralExprBits.Loc = L; }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXBoolLiteralExprClass;

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347062&r1=347061&r2=347062&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov 16 08:54:17 2018
@@ -502,6 +502,18 @@ protected:
 
   //===--- C++ Expression bitfields classes ---===//
 
+  class CXXBoolLiteralExprBitfields {
+friend class CXXBoolLiteralExpr;
+
+unsigned : NumExprBits;
+
+/// The value of the boolean literal.
+unsigned Value : 1;
+
+/// The location of the boolean literal.
+SourceLocation Loc;
+  };
+
   class TypeTraitExprBitfields {
 friend class ASTStmtReader;
 friend class ASTStmtWriter;
@@ -600,6 +612,7 @@ protected:
 PseudoObjectExprBitfields PseudoObjectExprBits;
 
 // C++ Expressions
+CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 


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


r347063 - [AST][NFC] Pack CXXNullPtrLiteralExpr

2018-11-16 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Nov 16 08:56:49 2018
New Revision: 347063

URL: http://llvm.org/viewvc/llvm-project?rev=347063&view=rev
Log:
[AST][NFC] Pack CXXNullPtrLiteralExpr

Use the newly available space in the bit-fields of Stmt.
This saves one pointer per CXXNullPtrLiteralExpr.


Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=347063&r1=347062&r2=347063&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Nov 16 08:56:49 2018
@@ -582,22 +582,21 @@ public:
 ///
 /// Introduced in C++11, the only literal of type \c nullptr_t is \c nullptr.
 class CXXNullPtrLiteralExpr : public Expr {
-  SourceLocation Loc;
-
 public:
-  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l)
+  CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc)
   : Expr(CXXNullPtrLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false,
- false, false, false),
-Loc(l) {}
+ false, false, false) {
+CXXNullPtrLiteralExprBits.Loc = Loc;
+  }
 
   explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
   : Expr(CXXNullPtrLiteralExprClass, Empty) {}
 
-  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
-  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
+  SourceLocation getBeginLoc() const { return getLocation(); }
+  SourceLocation getEndLoc() const { return getLocation(); }
 
-  SourceLocation getLocation() const { return Loc; }
-  void setLocation(SourceLocation L) { Loc = L; }
+  SourceLocation getLocation() const { return CXXNullPtrLiteralExprBits.Loc; }
+  void setLocation(SourceLocation L) { CXXNullPtrLiteralExprBits.Loc = L; }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXNullPtrLiteralExprClass;

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347063&r1=347062&r2=347063&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov 16 08:56:49 2018
@@ -514,6 +514,15 @@ protected:
 SourceLocation Loc;
   };
 
+  class CXXNullPtrLiteralExprBitfields {
+friend class CXXNullPtrLiteralExpr;
+
+unsigned : NumExprBits;
+
+/// The location of the null pointer literal.
+SourceLocation Loc;
+  };
+
   class TypeTraitExprBitfields {
 friend class ASTStmtReader;
 friend class ASTStmtWriter;
@@ -613,6 +622,7 @@ protected:
 
 // C++ Expressions
 CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits;
+CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 


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


[PATCH] D53807: Create a diagnostic group for warn_call_to_pure_virtual_member_function_from_ctor_dtor, so it can be turned into an error using Werror

2018-11-16 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a reviewer: jkorous.
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the patch!


Repository:
  rC Clang

https://reviews.llvm.org/D53807



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


r347064 - [AST][NFC] Pack CXXThisExpr

2018-11-16 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Nov 16 09:38:35 2018
New Revision: 347064

URL: http://llvm.org/viewvc/llvm-project?rev=347064&view=rev
Log:
[AST][NFC] Pack CXXThisExpr

Use the newly available space in the bit-fields of Stmt.
This saves 8 bytes per CXXThisExpr.


Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=347064&r1=347063&r2=347064&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Nov 16 09:38:35 2018
@@ -962,29 +962,28 @@ public:
 /// };
 /// \endcode
 class CXXThisExpr : public Expr {
-  SourceLocation Loc;
-  bool Implicit : 1;
-
 public:
-  CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
-  : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary,
+  CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit)
+  : Expr(CXXThisExprClass, Ty, VK_RValue, OK_Ordinary,
  // 'this' is type-dependent if the class type of the enclosing
  // member function is dependent (C++ [temp.dep.expr]p2)
- Type->isDependentType(), Type->isDependentType(),
- Type->isInstantiationDependentType(),
- /*ContainsUnexpandedParameterPack=*/false),
-Loc(L), Implicit(isImplicit) {}
+ Ty->isDependentType(), Ty->isDependentType(),
+ Ty->isInstantiationDependentType(),
+ /*ContainsUnexpandedParameterPack=*/false) {
+CXXThisExprBits.IsImplicit = IsImplicit;
+CXXThisExprBits.Loc = L;
+  }
 
   CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
 
-  SourceLocation getLocation() const { return Loc; }
-  void setLocation(SourceLocation L) { Loc = L; }
+  SourceLocation getLocation() const { return CXXThisExprBits.Loc; }
+  void setLocation(SourceLocation L) { CXXThisExprBits.Loc = L; }
 
-  SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
-  SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
+  SourceLocation getBeginLoc() const { return getLocation(); }
+  SourceLocation getEndLoc() const { return getLocation(); }
 
-  bool isImplicit() const { return Implicit; }
-  void setImplicit(bool I) { Implicit = I; }
+  bool isImplicit() const { return CXXThisExprBits.IsImplicit; }
+  void setImplicit(bool I) { CXXThisExprBits.IsImplicit = I; }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXThisExprClass;

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347064&r1=347063&r2=347064&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov 16 09:38:35 2018
@@ -523,6 +523,18 @@ protected:
 SourceLocation Loc;
   };
 
+  class CXXThisExprBitfields {
+friend class CXXThisExpr;
+
+unsigned : NumExprBits;
+
+/// Whether this is an implicit "this".
+unsigned IsImplicit : 1;
+
+/// The location of the "this".
+SourceLocation Loc;
+  };
+
   class TypeTraitExprBitfields {
 friend class ASTStmtReader;
 friend class ASTStmtWriter;
@@ -623,6 +635,7 @@ protected:
 // C++ Expressions
 CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits;
 CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits;
+CXXThisExprBitfields CXXThisExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 


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


[PATCH] D54441: [OPENMP] Support relational-op !- (not-equal) as one of the canonical forms of random access iterator

2018-11-16 Thread Anh Tuyen Tran via Phabricator via cfe-commits
anhtuyen updated this revision to Diff 174394.
anhtuyen added a comment.

1. Correct the typo on line 3707 clang/lib/Sema/SemaOpenMP.cpp
2. Update the testcase: teams_distribute_simd_loop_messages.cpp


https://reviews.llvm.org/D54441

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/distribute_simd_loop_messages.cpp
  clang/test/OpenMP/for_loop_messages.cpp
  clang/test/OpenMP/for_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_for_ast_print.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_loop_messages.cpp
  clang/test/OpenMP/parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/simd_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp
  clang/test/OpenMP/taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
@@ -128,7 +128,7 @@
 
 #pragma omp target
 #pragma omp teams distribute simd
-// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+// Ok
   for (int i = 0; i != 1; i++)
 c[i] = a[i];
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
@@ -126,9 +126,9 @@
   for (int i = 0; !!i; i++)
 c[i] = a[i];
 
+// Ok
 #pragma omp target
 #pragma omp teams distribute parallel for simd
-// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
   for (int i = 0; i != 1; i++)
 c[i] = a[i];
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
@@ -126,9 +126,9 @@
   for (int i = 0; !!i; i++)
 c[i] = a[i];
 
+// Ok
 #pragma omp target
 #pragma omp teams distribute parallel for
-// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
   for (int i = 0; i != 1; i++)
 c[i] = a[i];
 
Index: clang/test/OpenMP/teams_distribute_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_loop_messages.cpp
@@ -126,9 +126,9 @@
   for (int i = 0; !!i; i++)
 c[i] = a[i];
 
+// Ok
 #pragma omp target
 #pragma omp teams distribute
-// expected-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
   for (int i = 0; i != 1; i++)
 c[i] = a[i];
 
Index: clang/test/OpenMP/taskloop_simd_loop_messages.cpp
===
--- clang/test/OpenMP/taskloop_simd_loop_messages.cpp
+++ clang/test/OpenMP/taskloop_simd_loop_messages.cpp
@@ -131,8 +131,8 @@
   for (int i = 0; !!i; i++)
 c[i] = a[i];
 
+// Ok
 #pragma omp parallel
-// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
 #pragma omp taskloop simd
   for (int i = 0; i != 1; i++)
 c[i] = a[i];
Index: clang/test/OpenMP/taskloop_loop_messages.cpp
===
--- clang/test/OpenMP/taskloop_loop_messages.cpp
+++ clang/test/OpenMP/taskloop_loop_messages.cpp
@@ -131,8 +131,8 @@
   for (int i = 0; !!i; i++)
 c[i] = a[i];
 
+// Ok
 #pragma omp parallel
-// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
 #pragma omp taskloop
   for (int i = 0; i != 1; i++)
 c[i] = a[i];
Index: clang/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp

[PATCH] D54547: PTH-- Remove feature entirely-

2018-11-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Would it be better to deprecate the use of PTH right now for the current 
release, so that the users will be aware that we will remove PTH support in 
LLVM 9 once they upgrade to LLVM 8? Then we can remove it right after LLVM 8 
branch is created.


https://reviews.llvm.org/D54547



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


[PATCH] D54547: PTH-- Remove feature entirely-

2018-11-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D54547#1301253, @arphaman wrote:

> Would it be better to deprecate the use of PTH right now for the current 
> release, so that the users will be aware that we will remove PTH support in 
> LLVM 9 once they upgrade to LLVM 8? Then we can remove it right after LLVM 8 
> branch is created.


I considered that.  However, it is:
A- Really broken
B- Only has 1 user
C- Only accessible by a cc1 option, users aren't supposed to use these anyway.

Because of this, I/we seem to have little sympathy for the users.


https://reviews.llvm.org/D54547



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


[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
test/clang-tidy/cppcoreguidelines-narrowing-conversions-long-is-32bits.cpp:4-10
+  int i;// i.e. int32_t
+  long l;   // i.e. int32_t
+  long long ll; // i.e. int64_t
+
+  unsigned int ui;// i.e. uint32_t
+  unsigned long ul;   // i.e. uint32_t
+  unsigned long long ull; // i.e. uint64_t

Add some `static_assert`s for these bit sizes?



Comment at: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp:42-44
   i += 2.0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 
'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 
constant 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
   i += 2.0f;

I don't think these should diagnose. They're both harmless as the literal 
values are exactly representable in the destination type.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488



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


[PATCH] D54475: [clangd] Allow observation of changes to global CDBs.

2018-11-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added inline comments.
This revision now requires changes to proceed.



Comment at: clangd/Function.h:108
+Subscription &operator=(Subscription &&Other) {
+  std::tie(Parent, ListenerID) = std::tie(Other.Parent, Other.ListenerID);
+  Other.Parent = nullptr;

We need to unsubscribe `this` in the assignment operator before overwriting 
`Parent`.
Currently we won't delete `this` from the parent's listeners.


Maybe add a test for that too?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54475



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


[PATCH] D54630: Move detection of libc++ include dirs to Driver on MacOS

2018-11-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I don't think we want to move the logic to add a libc++ path to the driver. 
`-cc1` with `-resource-dir` and `-stdlib=libc++` should still work as before. 
In this case the previous patch is better, except it should not set 
`InstalledDir` except when needed (e.g. for tooling when working with a CDB 
that has an absolute path to the compiler), so when `InstalledDir` is empty it 
should fallback to the current logic in `InitHeaderSearch.cpp`. That should 
solve the issues we had.


Repository:
  rC Clang

https://reviews.llvm.org/D54630



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


[PATCH] D53329: Generate DIFile with main program if source is not available

2018-11-16 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

In https://reviews.llvm.org/D53329#1300435, @dblaikie wrote:

> Thanks!
>
> So I can see where/how this fails now - the LLVM backend seems to require 
> that if any file has embedded source, they all do. Would you be able to/would 
> you mind adding a debug info verifier check for this? That'd help make this 
> fail sooner. (@scott.linder - perhaps you'd be able to/interested in doing 
> this - looks like you wrote the initial implementation?)
>
> Beyond that, then the question is whether this fix is the right way to 
> satisfy that requirement (I'm assuming the requirement is reasonable - though 
> I've not looked at the embedded source support & have no idea if there's a 
> way/it's reasonable to support some embedded source and some not). My big 
> question & I've tried to do some debugging to better understand this - but 
> don't have the time to dive much further into it (& haven't really figured it 
> out as yet): Why is this source not accessible through this API at this 
> point? is the fallback to the main file always accurate?
>
> (as far as I got was figuring out that SourceManager::getBufferData had an 
> SLoc with isFile == true for the header, but isFile was false for the SLocs 
> related to the .cpp file. Can't say I know why that is/what that means & 
> would like to understand that (or someone else more familiar with this stuff 
> who already knows can review this code) before approving this patch - if you 
> could help explain this, that'd be great)


I can certainly update the verifier; my initial implementation should have 
included tests for this case so I would have noticed how unpleasantly it fails. 
I might be a bit slow to get a patch up, as I'm on vacation all next week.

The decision to require "all or nothing" for embedded source came after quite a 
bit of discussion, and the original proposal does include a boolean flag (see 
http://dwarfstd.org/ShowIssue.php?issue=180201.1). LLVM is still the only 
implementation I know of, and it is not in any actual DWARF standard yet, so if 
there are strong use-cases for allowing some sources be absent this could still 
be changed.


Repository:
  rC Clang

https://reviews.llvm.org/D53329



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


[PATCH] D54638: OpenMP: remove redundant MapTypeModifierSpecified flag in ParseOpenMP.cpp

2018-11-16 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir created this revision.
saghir added reviewers: cfe-commits, ABataev, kkwli0.
saghir added a project: OpenMP.
Herald added a subscriber: guansong.

In the below statement in ParseOpenMP.cpp:

bool IsComma =
1942 (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
1943 Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
1944 (Kind == OMPC_reduction && !InvalidReductionId) ||
1945 (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
1946 (!MapTypeModifierSpecified ||
1947 Data.MapTypeModifier == OMPC_MAP_always)) ||
1948 (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);

Whenever a map type modifier is specified, the flag MapTypeModifierSpecified is 
set to true.

In the above statement,

1. when there is no map type modifier specified, !MapTypeModifierSpecified 
portion evaluates to true.
2. when the map type modifier is specified, Data.MapTypeModifier == 
OMPC_MAP_always is set to true.

So whether a modifier is specified or not, the condition (highlighted in bold) 
always evaluates to true.

Check for this condition is redundant. Consequently, declaration and all uses 
of MapTypeModifierSpecified should be removed.


Repository:
  rC Clang

https://reviews.llvm.org/D54638

Files:
  clang/lib/Parse/ParseOpenMP.cpp


Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1775,7 +1775,6 @@
 OpenMPVarListDataTy &Data) {
   UnqualifiedId UnqualifiedReductionId;
   bool InvalidReductionId = false;
-  bool MapTypeModifierSpecified = false;
 
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, 
tok::annot_pragma_openmp_end);
@@ -1878,8 +1877,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1904,8 +1901,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1942,9 +1937,7 @@
   (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
   (Kind == OMPC_reduction && !InvalidReductionId) ||
-  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
-   (!MapTypeModifierSpecified ||
-Data.MapTypeModifier == OMPC_MAP_always)) ||
+  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown) ||
   (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&


Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1775,7 +1775,6 @@
 OpenMPVarListDataTy &Data) {
   UnqualifiedId UnqualifiedReductionId;
   bool InvalidReductionId = false;
-  bool MapTypeModifierSpecified = false;
 
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
@@ -1878,8 +1877,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1904,8 +1901,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1942,9 +1937,7 @@
   (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
   (Kind == OMPC_reduction && !InvalidReductionId) ||
-  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
-   (!MapTypeModifierSpecified ||
-Data.MapTypeModifier == OMPC_MAP_always)) ||
+  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown) ||
   (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r347070 - [PowerPC] Make no-PIC default to match GCC - CLANG

2018-11-16 Thread Stefan Pintilie via cfe-commits
Author: stefanp
Date: Fri Nov 16 10:37:01 2018
New Revision: 347070

URL: http://llvm.org/viewvc/llvm-project?rev=347070&view=rev
Log:
[PowerPC] Make no-PIC default to match GCC - CLANG

Make the default -fno-PIC on Power PC.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/clang-offload-bundler.c
cfe/trunk/test/Driver/ppc-abi.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=347070&r1=347069&r2=347070&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Fri Nov 16 10:37:01 2018
@@ -2430,9 +2430,6 @@ bool Generic_GCC::isPICDefault() const {
   switch (getArch()) {
   case llvm::Triple::x86_64:
 return getTriple().isOSWindows();
-  case llvm::Triple::ppc64:
-  case llvm::Triple::ppc64le:
-return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
 return true;

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=347070&r1=347069&r2=347070&view=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Fri Nov 16 10:37:01 2018
@@ -115,7 +115,7 @@
 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLEEND__ openmp-x86_64-pc-linux-gnu
 
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLESTART__ 
host-powerpc64le-ibm-linux-gnu
-// CK-TEXTLL: @A = global i32 0
+// CK-TEXTLL: @A = dso_local global i32 0
 // CK-TEXTLL: define {{.*}}@test_func()
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLEEND__ host-powerpc64le-ibm-linux-gnu
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLESTART__ 
openmp-powerpc64le-ibm-linux-gnu

Modified: cfe/trunk/test/Driver/ppc-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-abi.c?rev=347070&r1=347069&r2=347070&view=diff
==
--- cfe/trunk/test/Driver/ppc-abi.c (original)
+++ cfe/trunk/test/Driver/ppc-abi.c Fri Nov 16 10:37:01 2018
@@ -24,10 +24,42 @@
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
 
-// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2"
+// CHECK-ELFv1: "-mrelocation-model" "static"
 // CHECK-ELFv1: "-target-abi" "elfv1"
-// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2"
+// CHECK-ELFv1-QPX: "-mrelocation-model" "static"
 // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx"
-// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2"
+// CHECK-ELFv2: "-mrelocation-model" "static"
 // CHECK-ELFv2: "-target-abi" "elfv2"
 
+// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
+// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
+// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv1-qpx | FileCheck -check-prefix=CHECK-ELFv1-QPX-PIC %s
+// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mcpu=a2q | FileCheck -check-prefix=CHECK-ELFv1-QPX-PIC %s
+// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mcpu=a2 -mqpx | FileCheck -check-prefix=CHECK-ELFv1-QPX-PIC %s
+// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mcpu=a2q -mno-qpx | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
+// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
+
+// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
+// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
+// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
+// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
+// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
+// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
+// RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
+
+// CHECK-ELFv1-PIC: "-mrelocation-model" "pic" "-pic-level" "2"
+// CHECK-ELFv1-PIC: "-target-abi" "elfv1"
+// CHECK-ELFv1-QPX-PIC: "-mrelocation-model" "pic" "-pic-level" "2"
+// CHECK-ELFv1-QPX-PIC: "-target-abi" "elfv1-qpx"
+// CHECK-ELFv2-PIC: "-mrelocation-model" "pic" "-pic-level" "2"
+// CHECK-ELFv2-PIC: "-target-abi" "elfv2"
+
+

[PATCH] D54638: [OpenMP] remove redundant MapTypeModifierSpecified flag in ParseOpenMP.cpp

2018-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG, add `NFC` to the title.


Repository:
  rC Clang

https://reviews.llvm.org/D54638



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


[PATCH] D49736: [Basic] Emit warning flag suggestion only in case there's existing flag *similar* to the unknown one

2018-11-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Thanks for working on this, some minor comments:




Comment at: Basic/DiagnosticIDs.cpp:612
   // Two matches with the same distance, don't prefer one over the other.
-  Best = "";
+  NearestOption = "";
 } else if (Distance < BestDistance) {

Do we a test case that covers this line?



Comment at: Basic/Warnings.cpp:34
+namespace {
+  constexpr unsigned MaxLevenshteinDistForWarningSuggestion = 2;
+}

It would be helpful to have a brief comment explaining the rationale behind 
using the number `2`.



Comment at: Basic/Warnings.cpp:35
+  constexpr unsigned MaxLevenshteinDistForWarningSuggestion = 2;
+}
+

NIT: Missing `//end anonymous namespace`.



Comment at: Basic/Warnings.cpp:48
+<< (!Suggestion.empty()
+  && OptToSuggestionEditDist > 0
+  && OptToSuggestionEditDist <= MaxLevenshteinDistForWarningSuggestion)

Is it ever possible to have an edit distance of `0`? Wouldn't it mean the 
strings are the same?


Repository:
  rC Clang

https://reviews.llvm.org/D49736



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


r347072 - [codeview] Expose -gcodeview-ghash for global type hashing

2018-11-16 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Nov 16 10:47:41 2018
New Revision: 347072

URL: http://llvm.org/viewvc/llvm-project?rev=347072&view=rev
Log:
[codeview] Expose -gcodeview-ghash for global type hashing

Summary:
Experience has shown that the functionality is useful. It makes linking
optimized clang with debug info for me a lot faster, 20s to 13s. The
type merging phase of PDB writing goes from 10s to 3s.

This removes the LLVM cl::opt and replaces it with a metadata flag.

After this change, users can do the following to use ghash:
- add -gcodeview-ghash to compiler flags
- replace /DEBUG with /DEBUG:GHASH in linker flags

Reviewers: zturner, hans, thakis, takuto.ikuta

Subscribers: aprantl, hiraditya, JDevlieghere, llvm-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=347072&r1=347071&r2=347072&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Nov 16 10:47:41 2018
@@ -1818,9 +1818,15 @@ def gdwarf_4 : Flag<["-"], "gdwarf-4">,
   HelpText<"Generate source-level debug information with dwarf version 4">;
 def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group,
   HelpText<"Generate source-level debug information with dwarf version 5">;
+
 def gcodeview : Flag<["-"], "gcodeview">,
   HelpText<"Generate CodeView debug information">,
   Flags<[CC1Option, CC1AsOption, CoreOption]>;
+def gcodeview_ghash : Flag<["-"], "gcodeview-ghash">,
+  HelpText<"Emit type record hashes in a .debug$H section">,
+  Flags<[CC1Option, CoreOption]>;
+def gno_codeview_ghash : Flag<["-"], "gno-codeview-ghash">, 
Flags<[CoreOption]>;
+
 // Equivalent to our default dwarf version. Forces usual dwarf emission when
 // CodeView is enabled.
 def gdwarf : Flag<["-"], "gdwarf">, Alias, Flags<[CoreOption]>;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=347072&r1=347071&r2=347072&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Nov 16 10:47:41 2018
@@ -297,6 +297,9 @@ VALUE_CODEGENOPT(DwarfVersion, 3, 0)
 /// CodeView and DWARF into the same object.
 CODEGENOPT(EmitCodeView, 1, 0)
 
+/// Whether to emit the .debug$H section containing hashes of CodeView types.
+CODEGENOPT(CodeViewGHash, 1, 0)
+
 /// The kind of inlining to perform.
 ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=347072&r1=347071&r2=347072&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Nov 16 10:47:41 2018
@@ -458,6 +458,9 @@ void CodeGenModule::Release() {
 // Indicate that we want CodeView in the metadata.
 getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
   }
+  if (CodeGenOpts.CodeViewGHash) {
+getModule().addModuleFlag(llvm::Module::Warning, "CodeViewGHash", 1);
+  }
   if (CodeGenOpts.ControlFlowGuard) {
 // We want function ID tables for Control Flow Guard.
 getModule().addModuleFlag(llvm::Module::Warning, "cfguardtable", 1);

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=347072&r1=347071&r2=347072&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Nov 16 10:47:41 2018
@@ -3198,9 +3198,16 @@ static void RenderDebugOptions(const Too
   CmdArgs.push_back("-gembed-source");
   }
 
-  if (EmitCodeView)
+  if (EmitCodeView) {
 CmdArgs.push_back("-gcodeview");
 
+// Emit codeview type hashes if requested.
+if (Args.hasFlag(options::OPT_gcodeview_ghash,
+ options::OPT_gno_codeview_ghash, false)) {
+  CmdArgs.push_back("-gcodeview-ghash");
+}
+  }
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=347072&r1=

[PATCH] D54547: PTH-- Remove feature entirely-

2018-11-16 Thread Vladimir Voskresensky via Phabricator via cfe-commits
voskresensky.vladimir added a comment.

I have some experience with PTH implementation, because had to fix it for 
Java-port of Clang (https://github.com/java-port/clank).

It was sometime ago, but making it completely workable was not hard.
As I remember the key fix was just to have PTH be EMITTED using raw-Lex mode 
(where real keyword-IDs are not used, so all Token Kinds nicely fit 8-bits).
It worked, because on token automatically became keyword by PTHLexer::Lex:
...

 // Change the kind of this identifier to the appropriate token kind, e.g.
 // turning "for" into a keyword.
  Tok.setKind(II->getTokenID());

...

We used PTH, because multiple translation units are parsed in the context of 
single run.
In this case preprocessing phase was be upto 10x faster when take token stream 
was deserialized from PTH (i.e. for all system headers lexed once).
Also it was also helpful, because we were able to parse from concurrent thread 
using the same shared immutable PTH.

I thought clang-d service is using it to speed up indexing.


https://reviews.llvm.org/D54547



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


[PATCH] D54547: PTH-- Remove feature entirely-

2018-11-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D54547#1301351, @voskresensky.vladimir wrote:

> I have some experience with PTH implementation, because had to fix it for 
> Java-port of Clang (https://github.com/java-port/clank).
>
> It was sometime ago, but making it completely workable was not hard.
>  As I remember the key fix was just to have PTH be EMITTED using raw-Lex mode 
> (where real keyword-IDs are not used, so all Token Kinds nicely fit 8-bits).
>  It worked, because on token automatically became keyword by PTHLexer::Lex:
>  ...
>
>  // Change the kind of this identifier to the appropriate token kind, e.g.
>  // turning "for" into a keyword.
>   Tok.setKind(II->getTokenID());
>
> ...
>
> We used PTH, because multiple translation units are parsed in the context of 
> single run.
>  In this case preprocessing phase was upto 10x faster when token stream was 
> deserialized from PTH (i.e. for all system headers lexed once).
>  Also it was helpful, because we were able to parse from concurrent threads 
> using the same shared immutable mmaped PTH.
>
> I thought clang-d service is using it to speed up indexing.


Presumably, I could also just make PTH use another bit or two for the TokenID 
and it would work fine.  However, when I mentioned this on IRC the general 
response was that it is a 'failed experiment'.  In your use case, I wonder why 
you couldn't just use PCH and get even further performance improvements?


https://reviews.llvm.org/D54547



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


[PATCH] D53329: Generate DIFile with main program if source is not available

2018-11-16 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

Thanks @scott.linder, actually "all or nothing" is what I wanted here. We 
really want to get the source for these remapped files.


Repository:
  rC Clang

https://reviews.llvm.org/D53329



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


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2018-11-16 Thread Anantha Keshava B S via Phabricator via cfe-commits
smilewithani added a comment.

In https://reviews.llvm.org/D28462#1257259, @mewmew wrote:

> Any update on this? There are quite a few people who got excited about this 
> change and would like to start using it with clang-format.


Same here!


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D54547: PTH-- Remove feature entirely-

2018-11-16 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

> I thought clang-d service is using it to speed up indexing.

I believe that clangd is using PCH and not PTH.
(by the highly sophisticated method of grepping for pth and pch inside clangd/)


https://reviews.llvm.org/D54547



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


Re: [llvm-dev] mips builders on LLVM buildbot?

2018-11-16 Thread Galina Kistanova via cfe-commits
Thank you! I will remove them for now.

Thanks

Galina

On Thu, Nov 15, 2018 at 9:21 PM Simon Atanasyan  wrote:

> Hi Galina,
>
> a) "llvm-mips-linux" buildbot is active now. There are some failed
> tests but I'm working to make the buildbot "green".
>
> b) For now "clang-cmake-mips" and "clang-cmake-mipsel" can be removed.
> Later we probably restore these buildbots.
>
> On Sat, Nov 3, 2018 at 11:26 AM Simon Atanasyan 
> wrote:
> >
> > I will try to find owners of these buildbots. I hope to get results on
> > the next week.
> >
> > On Sat, Nov 3, 2018 at 1:48 AM Daniel Sanders
> >  wrote:
> > >
> > > I'm sad that they appear to have been abandoned but no objections from
> me as I'm not the admin for any of these anymore. A couple of them were
> taken over by a colleague when I left but he too has left MIPS since then.
> Simon Atanasyan might be able to find the owners if there still are any.
> > >
> > > > On Nov 2, 2018, at 13:29, Galina Kistanova via llvm-dev <
> llvm-...@lists.llvm.org> wrote:
> > > >
> > > > Hello everyone,
> > > >
> > > > There are few abandoned mips builders on LLVM buildbot:
> > > >
> > > > llvm-mips-linux
> > > > clang-cmake-mipsel
> > > > clang-cmake-mips
> > > >
> > > > I am going to remove them, if anyone has any objections, please
> speak up!
>
> --
> Simon Atanasyan
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54547: PTH-- Remove feature entirely-

2018-11-16 Thread Vladimir Voskresensky via Phabricator via cfe-commits
voskresensky.vladimir added a comment.

In https://reviews.llvm.org/D54547#1301359, @erichkeane wrote:

> > I thought clang-d service is using it to speed up indexing.
>
> Presumably, I could also just make PTH use another bit or two for the TokenID 
> and it would work fine.  However, when I mentioned this on IRC the general 
> response was that it is a 'failed experiment'.  In your use case, I wonder 
> why you couldn't just use PCH and get even further performance improvements?


To be fair, I don't remember exactly. :-)
I remember we shared the same PTH for all C and C++ files and built some 
preprocessor-based features for incomplete code written in editor based on that.

Hmm... One more thing I had to fix was: lex in mode where we emit all 
preprocessor tokens there as well (like "#define MACRO A" => #, define, MACRO, 
A)

PHT was also used for rebuilding PCH, when something is changed. Because often 
single changed file can completely invalidate PCH, while PTH just contain 
pp-lexed tokens which doesn't carry semantic. So, PTHManager could skip 
providing tokens for changed file, but keep proved them for all other files.


https://reviews.llvm.org/D54547



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


[PATCH] D54630: Move detection of libc++ include dirs to Driver on MacOS

2018-11-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In https://reviews.llvm.org/D54630#1301283, @arphaman wrote:

> I don't think we want to move the logic to add a libc++ path to the driver.


My opinion is not very educated because I don't have a lot of 
experience/knowledge of Clang, but from my perspective it does make sense to 
limit how much knowledge of the standard library path the front end needs to 
have. IOW, having the driver figure it out and then pass include paths to the 
front-end just like for any other library does make sense from my limited point 
of view. Again -- this is not a practical argument, it's just from a conceptual 
perspective.


Repository:
  rC Clang

https://reviews.llvm.org/D54630



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


r347075 - Revert "[PowerPC] Make no-PIC default to match GCC - CLANG"

2018-11-16 Thread Stefan Pintilie via cfe-commits
Author: stefanp
Date: Fri Nov 16 11:21:33 2018
New Revision: 347075

URL: http://llvm.org/viewvc/llvm-project?rev=347075&view=rev
Log:
Revert "[PowerPC] Make no-PIC default to match GCC - CLANG"

This reverts commit r347070

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/clang-offload-bundler.c
cfe/trunk/test/Driver/ppc-abi.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=347075&r1=347074&r2=347075&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Fri Nov 16 11:21:33 2018
@@ -2430,6 +2430,9 @@ bool Generic_GCC::isPICDefault() const {
   switch (getArch()) {
   case llvm::Triple::x86_64:
 return getTriple().isOSWindows();
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
+return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
 return true;

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=347075&r1=347074&r2=347075&view=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Fri Nov 16 11:21:33 2018
@@ -115,7 +115,7 @@
 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLEEND__ openmp-x86_64-pc-linux-gnu
 
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLESTART__ 
host-powerpc64le-ibm-linux-gnu
-// CK-TEXTLL: @A = dso_local global i32 0
+// CK-TEXTLL: @A = global i32 0
 // CK-TEXTLL: define {{.*}}@test_func()
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLEEND__ host-powerpc64le-ibm-linux-gnu
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLESTART__ 
openmp-powerpc64le-ibm-linux-gnu

Modified: cfe/trunk/test/Driver/ppc-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-abi.c?rev=347075&r1=347074&r2=347075&view=diff
==
--- cfe/trunk/test/Driver/ppc-abi.c (original)
+++ cfe/trunk/test/Driver/ppc-abi.c Fri Nov 16 11:21:33 2018
@@ -24,42 +24,10 @@
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
 
-// CHECK-ELFv1: "-mrelocation-model" "static"
+// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1: "-target-abi" "elfv1"
-// CHECK-ELFv1-QPX: "-mrelocation-model" "static"
+// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx"
-// CHECK-ELFv2: "-mrelocation-model" "static"
+// CHECK-ELFv2: "-mrelocation-model" "pic" "-pic-level" "2"
 // CHECK-ELFv2: "-target-abi" "elfv2"
 
-// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
-// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
-// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
-// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
-// RUN:   -mabi=elfv1-qpx | FileCheck -check-prefix=CHECK-ELFv1-QPX-PIC %s
-// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
-// RUN:   -mcpu=a2q | FileCheck -check-prefix=CHECK-ELFv1-QPX-PIC %s
-// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
-// RUN:   -mcpu=a2 -mqpx | FileCheck -check-prefix=CHECK-ELFv1-QPX-PIC %s
-// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
-// RUN:   -mcpu=a2q -mno-qpx | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
-// RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
-// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
-
-// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
-// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
-// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
-// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
-// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
-// RUN: %clang -fPIC -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 
2>&1 \
-// RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2-PIC %s
-
-// CHECK-ELFv1-PIC: "-mrelocation-model" "pic" "-pic-level" "2"
-// CHECK-ELFv1-PIC: "-target-abi" "elfv1"
-// CHECK-ELFv1-QPX-PIC: "-mrelocation-model" "pic" "-pic-level" "2"
-// CHECK-ELFv1-QPX-PIC: "-target-abi" "elfv1-qpx"
-// CHECK-ELFv2-PIC: "-mrelocation-model" "pic" "-pic-level" "2"
-// CHECK-ELFv2-PIC: "-target-abi" "elfv2"
-
-


___
cfe-com

[PATCH] D54641: [compiler-rt] [cmake] Fix detecting terminfo library

2018-11-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, dberris, labath.
Herald added subscribers: Sanitizers, llvm-commits.

Copy the fix for determining the correct terminfo library from LLVM --
use distinct variables for check_library_exists() calls.  Otherwise,
the first check (for -ltinfo) populates the variable and no other checks
are performed.  Effectively, systems with other libraries than the first
one listed are presumed not to have terminfo routines at all.

This partially fixes undefined symbols when linking XRay tests.  It's
probably not the best solution to the problem there but as long
as the terminfo check stays in config-ix, I thnk it's worth fixing.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54641

Files:
  cmake/config-ix.cmake


Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -122,9 +122,11 @@
 # Look for terminfo library, used in unittests that depend on LLVMSupport.
 if(LLVM_ENABLE_TERMINFO)
   foreach(library tinfo terminfo curses ncurses ncursesw)
+string(TOUPPER ${library} library_suffix)
 check_library_exists(
-  ${library} setupterm "" COMPILER_RT_HAS_TERMINFO)
-if(COMPILER_RT_HAS_TERMINFO)
+  ${library} setupterm "" COMPILER_RT_HAS_TERMINFO_${library_suffix})
+if(COMPILER_RT_HAS_TERMINFO_${library_suffix})
+  set(COMPILER_RT_HAS_TERMINFO TRUE)
   set(COMPILER_RT_TERMINFO_LIB "${library}")
   break()
 endif()


Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -122,9 +122,11 @@
 # Look for terminfo library, used in unittests that depend on LLVMSupport.
 if(LLVM_ENABLE_TERMINFO)
   foreach(library tinfo terminfo curses ncurses ncursesw)
+string(TOUPPER ${library} library_suffix)
 check_library_exists(
-  ${library} setupterm "" COMPILER_RT_HAS_TERMINFO)
-if(COMPILER_RT_HAS_TERMINFO)
+  ${library} setupterm "" COMPILER_RT_HAS_TERMINFO_${library_suffix})
+if(COMPILER_RT_HAS_TERMINFO_${library_suffix})
+  set(COMPILER_RT_HAS_TERMINFO TRUE)
   set(COMPILER_RT_TERMINFO_LIB "${library}")
   break()
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53850: Declares __cpu_model as dso local

2018-11-16 Thread Haibo Huang via Phabricator via cfe-commits
hhb added a comment.

Anyone can have a look at this change?


Repository:
  rC Clang

https://reviews.llvm.org/D53850



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


[PATCH] D54641: [compiler-rt] [cmake] Fix detecting terminfo library

2018-11-16 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

I have got a local patch in pkgsrc-wip/llvm-netbsd:

  $NetBSD$
  
  --- cmake/config-ix.cmake.orig2017-12-08 18:50:04.615602612 +
  +++ cmake/config-ix.cmake
  @@ -153,7 +153,7 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memor
   endif()
   if(LLVM_ENABLE_TERMINFO)
 set(HAVE_TERMINFO 0)
  -  foreach(library tinfo terminfo curses ncurses ncursesw)
  +  foreach(library terminfo tinfo curses ncurses ncursesw)
   string(TOUPPER ${library} library_suffix)
   check_library_exists(${library} setupterm "" 
HAVE_TERMINFO_${library_suffix})
   if(HAVE_TERMINFO_${library_suffix})

Shouldn't we apply it here too?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54641



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


r347081 - [OPENMP][NVPTX]Emit correct reduction code for teams/parallel

2018-11-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Nov 16 11:38:21 2018
New Revision: 347081

URL: http://llvm.org/viewvc/llvm-project?rev=347081&view=rev
Log:
[OPENMP][NVPTX]Emit correct reduction code for teams/parallel
reductions.

Fixed previously committed code for the reduction support in
teams/parallel constructs taking into account new design of the NVPTX
support in the compiler. Teams reduction are not fully functional yet,
it is going to be fixed in the following patches.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=347081&r1=347080&r2=347081&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Nov 16 11:38:21 2018
@@ -188,6 +188,28 @@ enum NamedBarrier : unsigned {
   NB_Parallel = 1,
 };
 
+static const ValueDecl *getPrivateItem(const Expr *RefExpr) {
+  RefExpr = RefExpr->IgnoreParens();
+  if (const auto *ASE = dyn_cast(RefExpr)) {
+const Expr *Base = ASE->getBase()->IgnoreParenImpCasts();
+while (const auto *TempASE = dyn_cast(Base))
+  Base = TempASE->getBase()->IgnoreParenImpCasts();
+RefExpr = Base;
+  } else if (auto *OASE = dyn_cast(RefExpr)) {
+const Expr *Base = OASE->getBase()->IgnoreParenImpCasts();
+while (const auto *TempOASE = dyn_cast(Base))
+  Base = TempOASE->getBase()->IgnoreParenImpCasts();
+while (const auto *TempASE = dyn_cast(Base))
+  Base = TempASE->getBase()->IgnoreParenImpCasts();
+RefExpr = Base;
+  }
+  RefExpr = RefExpr->IgnoreParenImpCasts();
+  if (const auto *DE = dyn_cast(RefExpr))
+return cast(DE->getDecl()->getCanonicalDecl());
+  const auto *ME = cast(RefExpr);
+  return cast(ME->getMemberDecl()->getCanonicalDecl());
+}
+
 typedef std::pair VarsDataTy;
 static bool stable_sort_comparator(const VarsDataTy P1, const VarsDataTy P2) {
   return P1.first > P2.first;
@@ -394,7 +416,10 @@ class CheckVarsEscapingDeclContext final
   }
 
 public:
-  CheckVarsEscapingDeclContext(CodeGenFunction &CGF) : CGF(CGF) {}
+  CheckVarsEscapingDeclContext(CodeGenFunction &CGF,
+   ArrayRef TeamsReductions)
+  : CGF(CGF), EscapedDecls(TeamsReductions.begin(), TeamsReductions.end()) 
{
+  }
   virtual ~CheckVarsEscapingDeclContext() = default;
   void VisitDeclStmt(const DeclStmt *S) {
 if (!S)
@@ -614,8 +639,10 @@ static llvm::Value *getNVPTXNumThreads(C
 
 /// Get barrier to synchronize all threads in a block.
 static void getNVPTXCTABarrier(CodeGenFunction &CGF) {
-  CGF.EmitRuntimeCall(llvm::Intrinsic::getDeclaration(
-  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_barrier0));
+  llvm::Function *F = llvm::Intrinsic::getDeclaration(
+  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_barrier0);
+  F->addFnAttr(llvm::Attribute::Convergent);
+  CGF.EmitRuntimeCall(F);
 }
 
 /// Get barrier #ID to synchronize selected (multiple of warp size) threads in
@@ -624,9 +651,10 @@ static void getNVPTXBarrier(CodeGenFunct
 llvm::Value *NumThreads) {
   CGBuilderTy &Bld = CGF.Builder;
   llvm::Value *Args[] = {Bld.getInt32(ID), NumThreads};
-  CGF.EmitRuntimeCall(llvm::Intrinsic::getDeclaration(
-  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_barrier),
-  Args);
+  llvm::Function *F = llvm::Intrinsic::getDeclaration(
+  &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_barrier);
+  F->addFnAttr(llvm::Attribute::Convergent);
+  CGF.EmitRuntimeCall(F, Args);
 }
 
 /// Synchronize all GPU threads in a block.
@@ -1965,10 +1993,20 @@ getDistributeLastprivateVars(ASTContext
   if (!Dir)
 return;
   for (const auto *C : Dir->getClausesOfKind()) {
-for (const Expr *E : C->getVarRefs()) {
-  const auto *DE = cast(E->IgnoreParens());
-  Vars.push_back(cast(DE->getDecl()->getCanonicalDecl()));
-}
+for (const Expr *E : C->getVarRefs())
+  Vars.push_back(getPrivateItem(E));
+  }
+}
+
+/// Get list of reduction variables from the teams ... directives.
+static void
+getTeamsReductionVars(ASTContext &Ctx, const OMPExecutableDirective &D,
+  llvm::SmallVectorImpl &Vars) {
+  assert(isOpenMPTeamsDirec

[PATCH] D54634: [OpenCL] Fix address space deduction in template args

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

Makes sense.


https://reviews.llvm.org/D54634



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


[PATCH] D54641: [compiler-rt] [cmake] Fix detecting terminfo library

2018-11-16 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

Context:

> Do not return -ltinfo from llvm-config --system-libs --link-static
> 
> under NetBSD. Bump PKGREVISION
> 
> Rust language 1.20.0 uses these options and Rust build system uses it
>  as '-l tinfo' and our wrapper does not handle this.

https://github.com/NetBSD/pkgsrc/commit/2ca60b7c8cec0e6c0f3100d9439b6d126424ae2d#diff-079668572f99829ef3e9afc048ebc7a0


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54641



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


[PATCH] D54641: [compiler-rt] [cmake] Fix detecting terminfo library

2018-11-16 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

As I understand it -ltinfo vs -lterminfo is mixing native curses(3) and 
external ncurses(3) from pkgsrc, while we prefer to use entirely our native 
version for all LLVM projects.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54641



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


[PATCH] D54489: Implement -frecord-command-line (-frecord-gcc-switches)

2018-11-16 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 174429.
scott.linder added a comment.

Update documentation for new option and error in the driver when generating for 
unsupported object-file format.


https://reviews.llvm.org/D54489

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/clang_f_opts.c
  test/Driver/debug-options.c

Index: test/Driver/debug-options.c
===
--- test/Driver/debug-options.c
+++ test/Driver/debug-options.c
@@ -157,6 +157,17 @@
 // RUN: %clang -### -c -O3 -ffunction-sections -grecord-gcc-switches %s 2>&1 \
 // | FileCheck -check-prefix=GRECORD_OPT %s
 //
+// RUN: %clang -### -c -grecord-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GRECORD %s
+// RUN: %clang -### -c -gno-record-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GNO_RECORD %s
+// RUN: %clang -### -c -grecord-command-line -gno-record-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GNO_RECORD %s/
+// RUN: %clang -### -c -grecord-command-line -o - %s 2>&1 \
+// | FileCheck -check-prefix=GRECORD_O %s
+// RUN: %clang -### -c -O3 -ffunction-sections -grecord-command-line %s 2>&1 \
+// | FileCheck -check-prefix=GRECORD_OPT %s
+//
 // RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \
 // RUN:| FileCheck -check-prefix=GIGNORE %s
 //
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -538,3 +538,18 @@
 // RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
 // CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
 // CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
+
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s
+// RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s
+// Test with a couple examples of non-ELF object file formats
+// RUN: %clang -### -S -target x86_64-unknown-macosx -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s
+// RUN: %clang -### -S -target x86_64-unknown-windows -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s
+// CHECK-RECORD-GCC-SWITCHES: "-record-command-line"
+// CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line"
+// CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option '-frecord-command-line' for target
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -644,6 +644,7 @@
   Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
OPT_fno_fine_grained_bitfield_accesses, false);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
+  Opts.RecordCommandLine = Args.getLastArgValue(OPT_record_command_line);
   Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
   Opts.NoCommon = Args.hasArg(OPT_fno_common);
   Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5033,14 +5033,22 @@
 
   const char *Exec = D.getClangProgramPath();
 
-  // Optionally embed the -cc1 level arguments into the debug info, for build
-  // analysis.
+  // Optionally embed the -cc1 level arguments into the debug info or a
+

[PATCH] D53751: [ASTImporter] Added Import functions for transition to new API.

2018-11-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added subscribers: rsmith, shafik.
shafik added a comment.
Herald added a reviewer: shafik.
Herald added a subscriber: gamesh411.

I think these changes make sense at a high level but I am not sure about the 
refactoring strategy. I am especially concerned we may end up in place where 
all the effected users of the API don't get updated and we are stuck with this 
parallel API.

Tagging in @rsmith since he has reviewed a lot of recent changes involving 
ASTImpoter that I have seen recently and he will have a better feeling for how 
these types of refactoring on handled on the clang side. I am mostly focused on 
the lldb side but care about the ASTImporter since we depend on it.


Repository:
  rC Clang

https://reviews.llvm.org/D53751



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-16 Thread Hyrum Wright via Phabricator via cfe-commits
hwright marked 5 inline comments as done.
hwright added inline comments.



Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:73
+  case DurationScale::Hours:
+if (Multiplier <= 1.0 / 60.0)
+  return std::make_tuple(DurationScale::Minutes, Multiplier * 60.0);

aaron.ballman wrote:
> This doesn't seem quite right. `1.0/6000.0` is less than `1.0/60.0` but isn't 
> a `Minutes` scaling.
After spending two days chasing this down, it finally occurred to me: we don't 
actually handle this case.  Our (somewhat conservative) matchers only look for 
literal values, not division expressions like `1.0/60.0`.

And for this iteration of the tool, I think I'm fine with that, since I expect 
those kinds of things to be exceedingly rare, and probably tricky to handle, 
anyway.


https://reviews.llvm.org/D54246



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-16 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added a comment.

I think this is ready to go, please advise on next steps.


https://reviews.llvm.org/D54246



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


[PATCH] D54489: Implement -frecord-command-line (-frecord-gcc-switches)

2018-11-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: docs/ClangCommandLineReference.rst:799
+command-line. Command-lines in the section are surrounded and separated by null
+bytes. Spaces and backslashes in the command-line are escaped with backslashes.
+(ELF Only)

How about something like "After linking, the section may contain multiple 
command lines, which will be individually terminated by null bytes.  Separate 
arguments within a command line are combined with spaces; spaces and 
backslashes within an argument are escaped with backslashes."

And please write out "(ELF Only)" as something more like "This option is only 
currently supported on ELF targets."


https://reviews.llvm.org/D54489



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


r347096 - [OPENMP]Fix PR39694: do not capture `this` in non-`this` region.

2018-11-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Nov 16 13:13:33 2018
New Revision: 347096

URL: http://llvm.org/viewvc/llvm-project?rev=347096&view=rev
Log:
[OPENMP]Fix PR39694: do not capture `this` in non-`this` region.

If lambda is used inside of the OpenMP region and captures `this`, we
should recapture it in the OpenMP region also. But we should do this
only if the OpenMP region is used in the context of the same class, just
like the lambda.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=347096&r1=347095&r2=347096&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Nov 16 13:13:33 2018
@@ -1533,7 +1533,10 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
   bool SavedForceCaptureByReferenceInTargetExecutable =
   DSAStack->isForceCaptureByReferenceInTargetExecutable();
   DSAStack->setForceCaptureByReferenceInTargetExecutable(/*V=*/true);
-  if (RD->isLambda())
+  if (RD->isLambda()) {
+llvm::DenseMap Captures;
+FieldDecl *ThisCapture;
+RD->getCaptureFields(Captures, ThisCapture);
 for (const LambdaCapture &LC : RD->captures()) {
   if (LC.getCaptureKind() == LCK_ByRef) {
 VarDecl *VD = LC.getCapturedVar();
@@ -1552,9 +1555,13 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
OpenMPClauseKind) { return true; }))
   MarkVariableReferenced(LC.getLocation(), LC.getCapturedVar());
   } else if (LC.getCaptureKind() == LCK_This) {
-CheckCXXThisCapture(LC.getLocation());
+QualType ThisTy = getCurrentThisType();
+if (!ThisTy.isNull() &&
+Context.typesAreCompatible(ThisTy, ThisCapture->getType()))
+  CheckCXXThisCapture(LC.getLocation());
   }
 }
+  }
   DSAStack->setForceCaptureByReferenceInTargetExecutable(
   SavedForceCaptureByReferenceInTargetExecutable);
 }

Modified: cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp?rev=347096&r1=347095&r2=347096&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp Fri Nov 16 13:13:33 2018
@@ -20,15 +20,17 @@
 // HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 547, i64 673, i64 
562949953422096]
 // HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
 // HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 547, i64 673, i64 
562949953422096]
+// HOST-DAG: = private unnamed_addr constant [2 x i64] [i64 8, i64 8]
+// HOST-DAG: = private unnamed_addr constant [2 x i64] [i64 673, i64 
281474976711440]
 // CHECK-DAG: [[S:%.+]] = type { i32 }
 // CHECK-DAG: [[CAP1:%.+]] = type { [[S]]* }
 // CHECK-DAG: [[CAP2:%.+]] = type { i32*, i32*, i32*, i32**, i32* }
 
-// CLASS: define internal void 
@__omp_offloading_{{.*}}_{{.*}}foo{{.*}}_l63_worker()
-// CLASS: define weak void @__omp_offloading_{{.*}}_{{.*}}foo{{.*}}_l63([[S]]* 
{{%.+}}, [[CAP1]]* dereferenceable(8) {{%.+}})
+// CLASS: define internal void 
@__omp_offloading_{{.*}}_{{.*}}foo{{.*}}_l72_worker()
+// CLASS: define weak void @__omp_offloading_{{.*}}_{{.*}}foo{{.*}}_l72([[S]]* 
{{%.+}}, [[CAP1]]* dereferenceable(8) {{%.+}})
 // CLASS-NOT: getelementptr
 // CLASS: br i1 %
-// CLASS: call void @__omp_offloading_{{.*}}_{{.*}}foo{{.*}}_l63_worker()
+// CLASS: call void @__omp_offloading_{{.*}}_{{.*}}foo{{.*}}_l72_worker()
 // CLASS: br label %
 // CLASS: br i1 %
 // CLASS: call void @__kmpc_kernel_init(
@@ -41,7 +43,7 @@
 // CLASS: call i32 [[LAMBDA1:@.+foo.+]]([[CAP1]]* [[L]])
 // CLASS: ret void
 
-// CLASS: define weak void @__omp_offloading_{{.+}}foo{{.+}}_l65([[S]]* 
%{{.+}}, [[CAP1]]* dereferenceable(8) %{{.+}})
+// CLASS: define weak void @__omp_offloading_{{.+}}foo{{.+}}_l74([[S]]* 
%{{.+}}, [[CAP1]]* dereferenceable(8) %{{.+}})
 // CLASS-NOT: getelementptr
 // CLASS: call void [[PARALLEL:@.+]](i32* %{{.+}}, i32* %{{.+}}, [[S]]* 
%{{.+}}, [[CAP1]]* %{{.+}})
 // CLASS: ret void
@@ -56,6 +58,13 @@
 // CLASS: call i32 [[LAMBDA1]]([[CAP1]]* [[L]])
 // CLASS: ret void
 
+template 
+int foo(const T &t) {
+  #pragma omp target parallel
+  t();
+  return 0;
+}
+
 struct S {
   int a = 15;
   int foo() {
@@ -64,15 +73,15 @@ struct S {
 L();
 #pragma omp target parallel
 L();
-return a;
+return a + ::foo(L);
   }
 } s;
 
-// FUN: define internal void @__omp_offloading_{{.+}}_main_l125_worker()
-// FUN: define weak void @__omp_offloading_{{.+}}_main_l125(i32* 
dereferenceable(4) %{{.+}}, i32* dereferenceable(4) %{{.+}}, i32* %{{.+}}, i32* 
dereferenceabl

[PATCH] D54349: [clang-tidy] new check 'readability-redundant-preprocessor'

2018-11-16 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos updated this revision to Diff 174439.

https://reviews.llvm.org/D54349

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantPreprocessorCheck.cpp
  clang-tidy/readability/RedundantPreprocessorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-preprocessor.rst
  test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp
  test/clang-tidy/readability-redundant-preprocessor.cpp
  test/clang-tidy/readability-redundant-preprocessor.h

Index: test/clang-tidy/readability-redundant-preprocessor.h
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-preprocessor.h
@@ -0,0 +1,5 @@
+#ifndef FOO
+#ifndef FOO // this would warn, but not in a header
+void f();
+#endif
+#endif
Index: test/clang-tidy/readability-redundant-preprocessor.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-preprocessor.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s readability-redundant-preprocessor %t -- -- -I %S
+
+// Positive testing.
+#ifndef FOO
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifndef; consider removing it [readability-redundant-preprocessor]
+#ifndef FOO
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifndef was here
+void f();
+#endif
+#endif
+
+// Positive testing of inverted condition.
+#ifndef FOO
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]
+#ifdef FOO
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifndef was here
+void f2();
+#endif
+#endif
+
+// Negative testing.
+#include "readability-redundant-preprocessor.h"
+
+#ifndef BAR
+void g();
+#endif
+
+#ifndef FOO
+#ifndef BAR
+void h();
+#endif
+#endif
+
+#ifndef FOO
+#ifdef BAR
+void i();
+#endif
+#endif
+
+// Positive #if testing.
+#define FOO 4
+
+#if FOO == 4
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
+#if FOO == 4
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here
+void j();
+#endif
+#endif
+
+#if FOO == 3 + 1
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
+#if FOO == 3 + 1
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here
+void j();
+#endif
+#endif
+
+#if FOO == \
+4
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
+#if FOO == \
+4
+// CHECK-NOTES: [[@LINE-5]]:2: note: previous #if was here
+void j();
+#endif
+#endif
+
+// Negative #if testing.
+#define BAR 4
+
+#if FOO == 4
+#if BAR == 4
+void k();
+#endif
+#endif
+
+#if FOO == \
+4
+#if BAR == \
+5
+void k();
+#endif
+#endif
Index: test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy %s readability-redundant-preprocessor %t -- -- -DFOO
+
+// Positive testing.
+#ifdef FOO
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]
+#ifdef FOO
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifdef was here
+void f();
+#endif
+#endif
+
+// Positive testing of inverted condition.
+#ifdef FOO
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifndef; consider removing it [readability-redundant-preprocessor]
+#ifndef FOO
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifdef was here
+void f2();
+#endif
+#endif
+
+// Negative testing.
+#ifdef BAR
+void g();
+#endif
+
+#ifdef FOO
+#ifdef BAR
+void h();
+#endif
+#endif
+
+#ifdef FOO
+#ifndef BAR
+void i();
+#endif
+#endif
Index: docs/clang-tidy/checks/readability-redundant-preprocessor.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-preprocessor.rst
@@ -0,0 +1,61 @@
+.. title:: clang-tidy - readability-redundant-preprocessor
+
+readability-redundant-preprocessor
+==
+
+Finds potentially redundant preprocessor directives. At the moment the
+following cases are detected:
+
+* `#ifdef` .. `#endif` pairs which are nested inside an outer pair with the
+  same condition. For example:
+
+.. code-block:: c++
+
+  #ifdef FOO
+  #ifdef FOO // inner ifdef is considered redundant
+  void f();
+  #endif
+  #endif
+
+* Same for `#ifndef` .. `#endif` pairs. For example:
+
+.. code-block:: c++
+
+  #ifndef FOO
+  #ifndef FOO // inner ifndef is considered redundant
+  void f();
+  #endif
+  #endif
+
+* `#ifndef` inside an `#ifdef` with the same condition:
+
+.. code-block:: c++
+
+  #ifdef FOO
+  #ifndef FOO // inner ifndef is considered redundant
+  void f();
+  #

[PATCH] D54349: [clang-tidy] new check 'readability-redundant-preprocessor'

2018-11-16 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos marked 2 inline comments as done.
vmiklos added inline comments.



Comment at: clang-tidy/readability/RedundantPreprocessorCheck.cpp:37
+CheckMacroRedundancy(Loc, Condition, IfStack,
+ "nested redundant if; consider removing it",
+ "previous if was here", true);

aaron.ballman wrote:
> I think these diagnostics should be hoisted as private constant members of 
> the class. Something like:
> `nested redundant %select{#if|#ifdef|#ifndef}0; consider removing it"` and 
> `previous %select{#if|#ifdef|#ifndef}0 here`
Done, I've also added an enum to specify if/ifdef/ifndef to avoid hard-to-read 
0/1/2 for these.


https://reviews.llvm.org/D54349



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

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

LGTM!




Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:73
+  case DurationScale::Hours:
+if (Multiplier <= 1.0 / 60.0)
+  return std::make_tuple(DurationScale::Minutes, Multiplier * 60.0);

hwright wrote:
> aaron.ballman wrote:
> > This doesn't seem quite right. `1.0/6000.0` is less than `1.0/60.0` but 
> > isn't a `Minutes` scaling.
> After spending two days chasing this down, it finally occurred to me: we 
> don't actually handle this case.  Our (somewhat conservative) matchers only 
> look for literal values, not division expressions like `1.0/60.0`.
> 
> And for this iteration of the tool, I think I'm fine with that, since I 
> expect those kinds of things to be exceedingly rare, and probably tricky to 
> handle, anyway.
Oh jeez -- good point on not covering constant expressions from the matcher. If 
you think this is going to be exceedingly rare, I'm okay with punting until we 
need it. Thank you for looking into it!


https://reviews.llvm.org/D54246



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


[PATCH] D49736: [Basic] Emit warning flag suggestion only in case there's existing flag *similar* to the unknown one

2018-11-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Have you considered the same approach as typo correction? I.e. for the max 
allowed edit distance use percentage of the input size. For example, something 
similar to `TypoCorrectionConsumer::addName` 
.


Repository:
  rC Clang

https://reviews.llvm.org/D49736



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


[PATCH] D54047: Check TUScope is valid before use

2018-11-16 Thread Tom Rix via Phabricator via cfe-commits
trixirt added a comment.

Since the crash happens with the iwyu tool, a bit ago i added the testcase at 
the iwyu project here.
https://github.com/include-what-you-use/include-what-you-use/pull/601

I don't know if it makes sense to run iwyu from clang/test.


Repository:
  rC Clang

https://reviews.llvm.org/D54047



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


[PATCH] D54349: [clang-tidy] new check 'readability-redundant-preprocessor'

2018-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/readability-redundant-preprocessor.cpp:53
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider 
removing it [readability-redundant-preprocessor]
+#if FOO == 3 + 1
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here

I didn't describe my test scenario very well -- can you change this line to FOO 
== 4 but leave the preceding conditional check as FOO == 3 + 1? The goal is to 
test that this isn't a token-by-token check, but uses the symbolic values 
instead.


https://reviews.llvm.org/D54349



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


[PATCH] D54641: [compiler-rt] [cmake] Fix detecting terminfo library

2018-11-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Well, sure but I think changing the order should be done separately from this. 
I'm fixing a bug resulting from people deciding to customize code instead of 
keeping it in sync; so I'd rather not combine it with intentionally mis-syncing 
the code.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54641



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


[PATCH] D54641: [compiler-rt] [cmake] Fix detecting terminfo library

2018-11-16 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski accepted this revision.
krytarowski added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D54641#1301620, @mgorny wrote:

> Well, sure but I think changing the order should be done separately from 
> this. I'm fixing a bug resulting from people deciding to customize code 
> instead of keeping it in sync; so I'd rather not combine it with 
> intentionally mis-syncing the code.


It will be good to evaluate the changed order (in particular whether it still 
works fine on Linux).


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D54641



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-16 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

In https://reviews.llvm.org/D53157#1291978, @cameron.mcinally wrote:

> In https://reviews.llvm.org/D53157#1291964, @kpn wrote:
>
> > I don't expect anyone would need to switch between constrained and regular 
> > floating point at an instruction level of granularity.
>
>
> The Standard allows for this (to some degree). E.g. FENV_ACCESS can be 
> toggled between nested compound statements.
>
> Also, some AVX512 hardware instructions have explicit SAE and RM operands.


Just because FENV_ACCESS can be toggled on that granularity doesn't mean we 
have to represent it that way. We've previously agreed (I think) that if 
FENV_ACCESS is enabled anywhere in a function we will want to use the 
constrained intrinsics for all FP operations in the function, not just the ones 
in the scope where it was specified. I think this works because FENV_ACCESS ON 
needs to be respected (i.e. we need to assume that the user may change the FP 
environment) but FENV_ACCESS OFF doesn't need to be respected (i.e. we are not 
required to assume that the user will not change the environment). For 
instance, the spec does give us liberty to assume the default rounding mode in 
FENV_ACCESS OFF regions, but if we make no assumptions about the rounding mode 
that will be conservatively correct.

As for instructions that take an explicit rounding mode argument, that's a 
separate issue (and one that is relevant for multiple architectures). The 
constrained intrinsics do not enforce a rounding mode (i.e. they are 
descriptive rather than prescriptive), but if we have concrete rounding mode 
arguments for any given instruction we could use that to encode the rounding 
mode in the instruction. I'm not sure how user code would express this apart 
from use of intrinsics.


https://reviews.llvm.org/D53157



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


[PATCH] D54349: [clang-tidy] new check 'readability-redundant-preprocessor'

2018-11-16 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos marked an inline comment as done.
vmiklos added inline comments.



Comment at: test/clang-tidy/readability-redundant-preprocessor.cpp:53
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider 
removing it [readability-redundant-preprocessor]
+#if FOO == 3 + 1
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here

aaron.ballman wrote:
> I didn't describe my test scenario very well -- can you change this line to 
> FOO == 4 but leave the preceding conditional check as FOO == 3 + 1? The goal 
> is to test that this isn't a token-by-token check, but uses the symbolic 
> values instead.
That doesn't work at the moment, since `PreprocessorEntry::Condition` is just a 
string, so `3 + 1` won't equal to `4`. I think we discussed this above already, 
and you said:

> I think it requires manual work. There's a FIXME in `PPCallbacks::If()` to 
> pass a list/tree of tokens that would make implementing this reasonable. I'd 
> say it's fine as a follow-up patch.

But later you wrote:

> I agree that it's more complex, but that's why I was asking for it -- I don't 
> think the design you have currently will extend for these sort of cases, and 
> I was hoping to cover more utility with the check to hopefully shake out 
> those forward-looking design considerations. As it stands, I feel like this 
> check is a bit too simplistic to have much value, but if you covered some of 
> these other cases, it would alleviate that worry for me.

My hope is that the check with its current "feature set" already has some 
value, but let me know if I'm too optimistic. :-)

That being said, if I want to support simple cases like "realize that `3 + 1` 
and `4` is the same" -- do you imagine that would be manually handled in this 
check or there is already some reusable building block in the codebase to 
evaluate if two expressions have the same integer value? I guess doing this 
manually is a lot of work, e.g. the answer for `FOO + 4` would be "it depends", 
so that should not equal to `8`, even if FOO happens to be `4`, etc.


https://reviews.llvm.org/D54349



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


[PATCH] D54349: [clang-tidy] new check 'readability-redundant-preprocessor'

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

I think this check is in good shape for the initial commit. Additional 
functionality can be added incrementally.




Comment at: test/clang-tidy/readability-redundant-preprocessor.cpp:53
+// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider 
removing it [readability-redundant-preprocessor]
+#if FOO == 3 + 1
+// CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here

vmiklos wrote:
> aaron.ballman wrote:
> > I didn't describe my test scenario very well -- can you change this line to 
> > FOO == 4 but leave the preceding conditional check as FOO == 3 + 1? The 
> > goal is to test that this isn't a token-by-token check, but uses the 
> > symbolic values instead.
> That doesn't work at the moment, since `PreprocessorEntry::Condition` is just 
> a string, so `3 + 1` won't equal to `4`. I think we discussed this above 
> already, and you said:
> 
> > I think it requires manual work. There's a FIXME in `PPCallbacks::If()` to 
> > pass a list/tree of tokens that would make implementing this reasonable. 
> > I'd say it's fine as a follow-up patch.
> 
> But later you wrote:
> 
> > I agree that it's more complex, but that's why I was asking for it -- I 
> > don't think the design you have currently will extend for these sort of 
> > cases, and I was hoping to cover more utility with the check to hopefully 
> > shake out those forward-looking design considerations. As it stands, I feel 
> > like this check is a bit too simplistic to have much value, but if you 
> > covered some of these other cases, it would alleviate that worry for me.
> 
> My hope is that the check with its current "feature set" already has some 
> value, but let me know if I'm too optimistic. :-)
> 
> That being said, if I want to support simple cases like "realize that `3 + 1` 
> and `4` is the same" -- do you imagine that would be manually handled in this 
> check or there is already some reusable building block in the codebase to 
> evaluate if two expressions have the same integer value? I guess doing this 
> manually is a lot of work, e.g. the answer for `FOO + 4` would be "it 
> depends", so that should not equal to `8`, even if FOO happens to be `4`, etc.
That's a good point -- sorry about the mistake on my suggestion that this test 
should pass, I had a temporary lapse. :-)


https://reviews.llvm.org/D54349



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


[PATCH] D54349: [clang-tidy] new check 'readability-redundant-preprocessor'

2018-11-16 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos added a comment.

In https://reviews.llvm.org/D54349#1301663, @aaron.ballman wrote:

> I think this check is in good shape for the initial commit. Additional 
> functionality can be added incrementally.


OK, thanks. I'll lcommit this once https://reviews.llvm.org/D54450 is committed.


https://reviews.llvm.org/D54349



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


[PATCH] D54565: Introduce `-Wc++14-compat-ctad` as a subgroup of `-Wc++14-compat`

2018-11-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 174449.
Quuxplusone added a comment.

Added a test case (partly copied from `test/SemaCXX/cxx14-compat.cpp`).

On the last warning in the file, I omitted the sketchy part of the warning, 
which on Godbolt looks like this:
https://godbolt.org/z/CB4z99

  :7:5: warning: class template argument deduction is incompatible with 
C++ standards before C++17; for compatibility, use explicit type name 
'V<(lambda at :6:16)>' [-Wc++98-c++11-c++14-compat]
  V v(lam);
  ^
  1 warning generated.

This seems like a bug in the diagnostic, but fixing it is definitely not part 
of this patch, and probably above my pay grade at the moment anyway. :)


Repository:
  rC Clang

https://reviews.llvm.org/D54565

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  test/SemaCXX/cxx14-compat-ctad.cpp


Index: test/SemaCXX/cxx14-compat-ctad.cpp
===
--- /dev/null
+++ test/SemaCXX/cxx14-compat-ctad.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++14-compat-ctad -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wc++14-compat-ctad -verify %s
+
+template struct X {};
+X x; // expected-warning {{class template argument deduction is incompatible 
with C++ standards before C++17; for compatibility, use explicit type name 
'X'}}
+
+template class> struct Y {};
+Y yx; // ok, not class template argument deduction
+
+template void f(T t) {
+  X x = t; // expected-warning {{class template argument deduction is 
incompatible with C++ standards before C++17}}
+}
+
+template void g(T t) {
+  typename T::X x = t; // expected-warning {{class template argument deduction 
is incompatible with C++ standards before C++17; for compatibility, use 
explicit type name 'typename A::X' (aka 'A::X')}}
+}
+
+struct A { template struct X { X(T); }; };
+void h(A a) { g(a); } // expected-note {{in instantiation of function template 
specialization 'g'}}
+
+template struct V { V(const T&) {} };
+
+V(int) -> V;  // ok, deduction guide is not a use of class template 
argument deduction
+
+void f2() { V v('a'); } // expected-warning {{class template argument 
deduction is incompatible with C++ standards before C++17; for compatibility, 
use explicit type name 'V'}}
+void g2() { V v(0); } // expected-warning {{class template argument deduction 
is incompatible with C++ standards before C++17; for compatibility, use 
explicit type name 'V'}}
+
+void h2() {
+auto lam = [](){};
+V v(lam); // expected-warning {{class template argument deduction is 
incompatible with C++ standards before C++17}}
+}
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2164,7 +2164,7 @@
 def warn_cxx14_compat_class_template_argument_deduction : Warning<
   "class template argument deduction is incompatible with C++ standards "
   "before C++17%select{|; for compatibility, use explicit type name %1}0">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 
 // C++14 deduced return types
 def err_auto_fn_deduction_failure : Error<
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -173,6 +173,7 @@
 
 def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios-deployment-target">;
 
+def CXX14CompatCTAD : DiagGroup<"c++14-compat-ctad">;
 def CXX17CompatMangling : DiagGroup<"c++17-compat-mangling">;
 def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>;
 // Name of this warning in GCC.
@@ -183,7 +184,8 @@
 def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic",
[CXXPre14Compat,
 CXXPre14CompatBinaryLiteral]>;
-def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">;
+def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat",
+   [CXX14CompatCTAD]>;
 def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
[CXXPre17Compat]>;
 def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;


Index: test/SemaCXX/cxx14-compat-ctad.cpp
===
--- /dev/null
+++ test/SemaCXX/cxx14-compat-ctad.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++14-compat-ctad -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wc++14-compat-ctad -verify %s
+
+template struct X {};
+X x; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'X'}}
+
+template class> struct Y {};
+Y yx; // ok, not class template argument deduction
+
+template void f

[PATCH] D54589: [clang][UBSan] Sanitization for alignment assumptions.

2018-11-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 174451.
lebedev.ri added a comment.

Adapt to https://reviews.llvm.org/D54588 no longer providing the actual pointer.
The handled itself will have to deal with subtracting the offset.


Repository:
  rC Clang

https://reviews.llvm.org/D54589

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  test/CodeGen/catch-alignment-assumption-blacklist.c
  
test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  test/CodeGen/catch-alignment-assumption-openmp.cpp

Index: test/CodeGen/catch-alignment-assumption-openmp.cpp
===
--- /dev/null
+++ test/CodeGen/catch-alignment-assumption-openmp.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fopenmp-simd -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100_ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 100, i32 30 }, {{.*}}* @[[CHAR]] }
+
+void func(char *data) {
+  // CHECK: define void @{{.*}}(i8* %[[DATA:.*]])
+  // CHECK-NEXT: [[ENTRY:.*]]:
+  // CHECK-NEXT:   %[[DATA_ADDR:.*]] = alloca i8*, align 8
+  // CHECK:   store i8* %[[DATA]], i8** %[[DATA_ADDR]], align 8
+  // CHECK:   %[[DATA_RELOADED:.*]] = load i8*, i8** %[[DATA_ADDR]], align 8
+  // CHECK-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[DATA_RELOADED]] to i64
+  // CHECK-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 1073741823
+  // CHECK-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[DATA_RELOADED]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1073741824, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1073741824, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
+  // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
+  // CHECK-SANITIZE:  [[CONT]]:
+  // CHECK-NEXT:call void @llvm.assume(i1 %[[MASKCOND]])
+
+#line 100
+#pragma omp for simd aligned(data : 0x4000)
+  for (int x = 0; x < 1; x++)
+data[x] = data[x];
+}
Index: test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
===
--- /dev/null
+++ test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANI

[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2018-11-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: jyknight, craig.topper, lebedev.ri.

As discussed on IRC, check sign/power of 2 correctly for the
alignment assumptions.


Repository:
  rC Clang

https://reviews.llvm.org/D54654

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/alloc-align-attr.c

Index: test/CodeGen/alloc-align-attr.c
===
--- test/CodeGen/alloc-align-attr.c
+++ test/CodeGen/alloc-align-attr.c
@@ -8,9 +8,12 @@
   return *m1(a);
 // CHECK: call i32* @m1(i32 [[PARAM1:%[^\)]+]]) 
 // CHECK: [[ALIGNCAST1:%.+]] = sext i32 [[PARAM1]] to i64
-// CHECK: [[ISPOS1:%.+]] = icmp sgt i64 [[ALIGNCAST1]], 0
-// CHECK: [[POSMASK1:%.+]] = sub i64 [[ALIGNCAST1]], 1
-// CHECK: [[MASK1:%.+]] = select i1 [[ISPOS1]], i64 [[POSMASK1]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp sgt i64 [[ALIGNCAST1]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[ALIGNCAST1]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[ALIGNCAST1]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK1:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT1:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], [[MASK1]]
 // CHECK: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
@@ -23,9 +26,12 @@
 // CHECK: [[CONV2:%.+]] = trunc i64 %{{.+}} to i32
 // CHECK: call i32* @m1(i32 [[CONV2]])
 // CHECK: [[ALIGNCAST2:%.+]] = sext i32 [[CONV2]] to i64
-// CHECK: [[ISPOS2:%.+]] = icmp sgt i64 [[ALIGNCAST2]], 0
-// CHECK: [[POSMASK2:%.+]] = sub i64 [[ALIGNCAST2]], 1
-// CHECK: [[MASK2:%.+]] = select i1 [[ISPOS2]], i64 [[POSMASK2]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp sgt i64 [[ALIGNCAST2]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[ALIGNCAST2]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[ALIGNCAST2]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK2:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT2:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR2:%.+]] = and i64 [[PTRINT2]], [[MASK2]]
 // CHECK: [[MASKCOND2:%.+]] = icmp eq i64 [[MASKEDPTR2]], 0
@@ -39,9 +45,12 @@
   return *m2(a);
 // CHECK: [[CONV3:%.+]] = sext i32 %{{.+}} to i64
 // CHECK: call i32* @m2(i64 [[CONV3]])
-// CHECK: [[ISPOS3:%.+]] = icmp sgt i64 [[CONV3]], 0
-// CHECK: [[POSMASK3:%.+]] = sub i64 [[CONV3]], 1
-// CHECK: [[MASK3:%.+]] = select i1 [[ISPOS3]], i64 [[POSMASK3]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp ugt i64 [[CONV3]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[CONV3]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[CONV3]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK3:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT3:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR3:%.+]] = and i64 [[PTRINT3]], [[MASK3]]
 // CHECK: [[MASKCOND3:%.+]] = icmp eq i64 [[MASKEDPTR3]], 0
@@ -53,16 +62,18 @@
 // CHECK: define i32 @test4
   return *m2(a);
 // CHECK: call i32* @m2(i64 [[PARAM4:%[^\)]+]]) 
-// CHECK: [[ISPOS4:%.+]] = icmp sgt i64 [[PARAM4]], 0
-// CHECK: [[POSMASK4:%.+]] = sub i64 [[PARAM4]], 1
-// CHECK: [[MASK4:%.+]] = select i1 [[ISPOS4]], i64 [[POSMASK4]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp ugt i64 [[PARAM4]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[PARAM4]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[PARAM4]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK4:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT4:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR4:%.+]] = and i64 [[PTRINT4]], [[MASK4]]
 // CHECK: [[MASKCOND4:%.+]] = icmp eq i64 [[MASKEDPTR4]], 0
 // CHECK: call void @llvm.assume(i1 [[MASKCOND4]])
 }
 
-
 struct Empty {};
 struct MultiArgs { __INT64_TYPE__ a, b;};
 // Struct parameter doesn't take up an IR parameter, 'i' takes up 2.
@@ -74,9 +85,12 @@
   return *m3(e, a);
 // CHECK: call i32* @m3(i64 %{{.*}}, i64 %{{.*}}) 
 // CHECK: [[ALIGNCAST5:%.+]] = trunc i128 %{{.*}} to i64
-// CHECK: [[ISPOS5:%.+]] = icmp sgt i64 [[ALIGNCAST5]], 0
-// CHECK: [[POSMASK5:%.+]] = sub i64 [[ALIGNCAST5]], 1
-// CHECK: [[MASK5:%.+]] = select i1 [[ISPOS5]], i64 [[POSMASK5]], i64 0
+// CHECK: [[ISPOS:%.+]] = icmp sgt i64 [[ALIGNCAST5]], 0
+// CHECK: [[ALIGNSUB1:%.+]] = sub i64 [[ALIGNCAST5]], 1
+// CHECK: [[ALIGNANDSUB1:%.+]] = and i64 [[ALIGNCAST5]], [[ALIGNSUB1]]
+// CHECK: [[ISPOWER2:%.+]] = icmp eq i64 [[ALIGNANDSUB1]], 0
+// CHECK: [[ALIGNVALID:%.+]] = and i1 [[ISPOS]], [[ISPOWER2]]
+// CHECK: [[MASK5:%.+]] = select i1 [[ALIGNVALID]], i64 [[ALIGNSUB1]], i64 0
 // CHECK: [[PTRINT5:%.+]] = ptrtoint
 // CHECK: [[MASKEDPTR5:%.+]] = and i64 [[PTRINT5]

[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2018-11-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Repository:
  rC Clang

https://reviews.llvm.org/D54654



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


[PATCH] D54655: [CMake] Use lld and llvm-objcopy for first stage compiler in Fuchsia

2018-11-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: juliehockett, mcgrathr, jakehehrlich.
Herald added subscribers: cfe-commits, mgorny.
Herald added a reviewer: alexshap.

When cross-compiling the second stage to a different target, we need to
make sure that the first-stage compiler can produce binaries for that
target. Using lld and llvm-objcopy as the default linker and objcopy
tool eliminates some of the dependencies on the host toolchain.


Repository:
  rC Clang

https://reviews.llvm.org/D54655

Files:
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -22,6 +22,10 @@
   set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 endif()
 
+if(NOT APPLE)
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
+endif()
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -22,6 +22,10 @@
   set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 endif()
 
+if(NOT APPLE)
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
+endif()
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r347108 - [CMake] Use lld and llvm-objcopy for first stage compiler in Fuchsia

2018-11-16 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Nov 16 15:07:03 2018
New Revision: 347108

URL: http://llvm.org/viewvc/llvm-project?rev=347108&view=rev
Log:
[CMake] Use lld and llvm-objcopy for first stage compiler in Fuchsia

When cross-compiling the second stage to a different target, we need to
make sure that the first-stage compiler can produce binaries for that
target. Using lld and llvm-objcopy as the default linker and objcopy
tool eliminates some of the dependencies on the host toolchain.

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

Modified:
cfe/trunk/cmake/caches/Fuchsia.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=347108&r1=347107&r2=347108&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia.cmake Fri Nov 16 15:07:03 2018
@@ -22,6 +22,10 @@ if(NOT APPLE)
   set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 endif()
 
+if(NOT APPLE)
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
+endif()
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 


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


[PATCH] D54655: [CMake] Use lld and llvm-objcopy for first stage compiler in Fuchsia

2018-11-16 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347108: [CMake] Use lld and llvm-objcopy for first stage 
compiler in Fuchsia (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54655?vs=174462&id=174463#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54655

Files:
  cfe/trunk/cmake/caches/Fuchsia.cmake


Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -22,6 +22,10 @@
   set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 endif()
 
+if(NOT APPLE)
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
+endif()
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 


Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -22,6 +22,10 @@
   set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 endif()
 
+if(NOT APPLE)
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
+endif()
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54654: Correct CreateAlignmentAssumption to check sign and power-of-2 (Clang Part)

2018-11-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

LG.
I hope that extra is-power-of-two won't confuse the optimizer.


Repository:
  rC Clang

https://reviews.llvm.org/D54654



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-16 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally added a comment.

Fair enough. Just for conversation's sake, I was envisioning the FE support a 
little differently...

1. Add a command line option, say `-ffpe_safe=[true|false]`, that toggles 
FPEnv-safe code generation for a whole file. A `-ffpe_safe=true` would be 
equivalent to `FENV_ACCESS=ON` at the beginning of a translation unit and we 
would capture it in some FE variable. That command line option can be 
overridden by the FENV_ACCESS pragma.

2. If the FENV_ACCESS pragma is seen, carry a nop/metadata/something construct 
to toggle the FE variable during IR generation.

3. Then when generating IR, choose between constrained/unconstrained IR 
depending on the state of the FE variable.

#1 may seem superfluous, but there are certain benchmarks (e.g. SPEC CPU) that 
do not allow for code modifications. So, in order to run those with FPEnv-safe 
code, we'd need a non-invasive way to toggle FPEnv-safe code generation.

I'll also add that my interpretation of FENV_ACCESS in the C Standard [7.6.1] 
implies that we have to track the FENV_ACCESS pragma. That is, it's not okay to 
ignore FENV_ACCESS=OFF. When we transfer from FENV_ACCESS=OFF code to 
FENV_ACCESS=ON code, the rounding mode needs to be reset to the default 
setting. But, I'm open to hearing other interpretations. My copy of the 
Standard is old, so please correct me if this changed...

  When execution passes from a part of the program translated with FENV_ACCESS 
‘‘off’’ to a part translated with FENV_ACCESS ‘‘on’’, the state of the 
floating-point status flags is unspecified and the floating-point control modes 
have their default settings.


https://reviews.llvm.org/D53157



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


  1   2   >