r342862 - [ARM][AArch64] Add feature +fp16fml

2018-09-24 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Mon Sep 24 00:55:20 2018
New Revision: 342862

URL: http://llvm.org/viewvc/llvm-project?rev=342862&view=rev
Log:
[ARM][AArch64] Add feature +fp16fml

Armv8.4-A adds a few FP16 instructions that can optionally be implemented
in CPUs of Armv8.2-A and above.

This patch adds a feature to clang to permit selection of these
instructions. This interacts with the +fp16 option as follows:

Prior to Armv8.4-A:
*) +fp16fml implies +fp16
*) +nofp16 implies +nofp16fml

From Armv8.4-A:
*) The above conditions apply, additionally: +fp16 implies +fp16fml

Patch by Bernard Ogden.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/Driver/aarch64-cpus.c
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Preprocessor/aarch64-target-features.c
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp?rev=342862&r1=342861&r2=342862&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp Mon Sep 24 00:55:20 2018
@@ -193,6 +193,32 @@ void aarch64::getAArch64TargetFeatures(c
   Features.push_back("-crc");
   }
 
+  // Handle (arch-dependent) fp16fml/fullfp16 relationship.
+  // FIXME: this fp16fml option handling will be reimplemented after the
+  // TargetParser rewrite.
+  const auto ItRNoFullFP16 = std::find(Features.rbegin(), Features.rend(), 
"-fullfp16");
+  const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), 
"+fp16fml");
+  if (std::find(Features.begin(), Features.end(), "+v8.4a") != Features.end()) 
{
+const auto ItRFullFP16  = std::find(Features.rbegin(), Features.rend(), 
"+fullfp16");
+if (ItRFullFP16 < ItRNoFullFP16 && ItRFullFP16 < ItRFP16FML) {
+  // Only entangled feature that can be to the right of this +fullfp16 is 
-fp16fml.
+  // Only append the +fp16fml if there is no -fp16fml after the +fullfp16.
+  if (std::find(Features.rbegin(), ItRFullFP16, "-fp16fml") == ItRFullFP16)
+Features.push_back("+fp16fml");
+}
+else
+  goto fp16_fml_fallthrough;
+  }
+  else {
+fp16_fml_fallthrough:
+// In both of these cases, putting the 'other' feature on the end of the 
vector will
+// result in the same effect as placing it immediately after the current 
feature.
+if (ItRNoFullFP16 < ItRFP16FML)
+  Features.push_back("-fp16fml");
+else if (ItRNoFullFP16 > ItRFP16FML)
+  Features.push_back("+fullfp16");
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access))
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=342862&r1=342861&r2=342862&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Mon Sep 24 00:55:20 2018
@@ -391,6 +391,33 @@ void arm::getARMTargetFeatures(const Too
   } else if (HDivArg)
 getARMHWDivFeatures(D, HDivArg, Args, HDivArg->getValue(), Features);
 
+  // Handle (arch-dependent) fp16fml/fullfp16 relationship.
+  // Must happen before any features are disabled due to soft-float.
+  // FIXME: this fp16fml option handling will be reimplemented after the
+  // TargetParser rewrite.
+  const auto ItRNoFullFP16 = std::find(Features.rbegin(), Features.rend(), 
"-fullfp16");
+  const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), 
"+fp16fml");
+  if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8_4a) {
+const auto ItRFullFP16  = std::find(Features.rbegin(), Features.rend(), 
"+fullfp16");
+if (ItRFullFP16 < ItRNoFullFP16 && ItRFullFP16 < ItRFP16FML) {
+  // Only entangled feature that can be to the right of this +fullfp16 is 
-fp16fml.
+  // Only append the +fp16fml if there is no -fp16fml after the +fullfp16.
+  if (std::find(Features.rbegin(), ItRFullFP16, "-fp16fml") == ItRFullFP16)
+Features.push_back("+fp16fml");
+}
+else
+  goto fp16_fml_fallthrough;
+  }
+  else {
+fp16_fml_fallthrough:
+// In both of these cases, putting the 'other' feature on the end of the 
vector will
+// result in the same effect as placing it immediately after the current 
feature.
+if (ItRNoFullFP16 < ItRFP16FML)
+  Features.push_back("-fp16fml");
+else if (ItRNoFullFP16 > ItRFP16FML)
+  Features.push_back("+fullfp16");
+  }
+
   // Setting -msoft-float/-mfloat-abi=soft effectively disables the FPU (GCC

[clang-tools-extra] r342866 - [clangd] Force Dex to respect symbol collector flags

2018-09-24 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Sep 24 01:45:18 2018
New Revision: 342866

URL: http://llvm.org/viewvc/llvm-project?rev=342866&view=rev
Log:
[clangd] Force Dex to respect symbol collector flags

`Dex` should utilize `FuzzyFindRequest.RestrictForCodeCompletion` flags
and omit symbols not meant for code completion when asked for it.

The measurements below were conducted with setting
`FuzzyFindRequest.RestrictForCodeCompletion` to `true` (so that it's
more realistic). Sadly, the average latency goes down, I suspect that is
mostly because of the empty queries where the number of posting lists is
critical.

| Metrics  | Before | After | Relative difference
| -  | -  | -   | -
| Cumulative query latency (7000 `FuzzyFindRequest`s over LLVM static index)  | 
6182735043 ns| 7202442053 ns | +16%
| Whole Index size | 81.24 MB| 81.79 MB | +0.6%

Out of 292252 symbols collected from LLVM codebase 136926 appear to be
restricted for code completion.

Reviewers: ioeric

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
clang-tools-extra/trunk/unittests/clangd/DexTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Dex.cpp?rev=342866&r1=342865&r2=342866&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp Mon Sep 24 01:45:18 2018
@@ -22,6 +22,10 @@ namespace dex {
 
 namespace {
 
+// Mark symbols which are can be used for code completion.
+static const Token RestrictedForCodeCompletion =
+Token(Token::Kind::Sentinel, "Restricted For Code Completion");
+
 // Returns the tokens which are given symbol's characteristics. Currently, the
 // generated tokens only contain fuzzy matching trigrams and symbol's scope,
 // but in the future this will also return path proximity tokens and other
@@ -39,6 +43,8 @@ std::vector generateSearchTokens(
 for (const auto &ProximityURI :
  generateProximityURIs(Sym.CanonicalDeclaration.FileURI))
   Result.emplace_back(Token::Kind::ProximityURI, ProximityURI);
+  if (Sym.Flags & Symbol::IndexedForCodeCompletion)
+Result.emplace_back(RestrictedForCodeCompletion);
   return Result;
 }
 
@@ -175,6 +181,10 @@ bool Dex::fuzzyFind(const FuzzyFindReque
 TopLevelChildren.push_back(createOr(move(BoostingIterators)));
   }
 
+  if (Req.RestrictForCodeCompletion)
+TopLevelChildren.push_back(
+InvertedIndex.find(RestrictedForCodeCompletion)->second.iterator());
+
   // Use TRUE iterator if both trigrams and scopes from the query are not
   // present in the symbol index.
   auto QueryIterator = TopLevelChildren.empty()

Modified: clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/DexTests.cpp?rev=342866&r1=342865&r2=342866&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/DexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/DexTests.cpp Mon Sep 24 01:45:18 
2018
@@ -583,6 +583,20 @@ TEST(DexTest, Lookup) {
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(DexTest, SymbolIndexOptionsFilter) {
+  auto CodeCompletionSymbol = symbol("Completion");
+  auto NonCodeCompletionSymbol = symbol("NoCompletion");
+  CodeCompletionSymbol.Flags = Symbol::SymbolFlag::IndexedForCodeCompletion;
+  NonCodeCompletionSymbol.Flags = Symbol::SymbolFlag::None;
+  std::vector Symbols{CodeCompletionSymbol, NonCodeCompletionSymbol};
+  Dex I(Symbols, URISchemes);
+  FuzzyFindRequest Req;
+  Req.RestrictForCodeCompletion = false;
+  EXPECT_THAT(match(I, Req), ElementsAre("Completion", "NoCompletion"));
+  Req.RestrictForCodeCompletion = true;
+  EXPECT_THAT(match(I, Req), ElementsAre("Completion"));
+}
+
 TEST(DexTest, ProximityPathsBoosting) {
   auto RootSymbol = symbol("root::abc");
   RootSymbol.CanonicalDeclaration.FileURI = "unittest:///file.h";


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


r342876 - Fix Wundef NDEBUG warning; NFC

2018-09-24 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon Sep 24 05:12:03 2018
New Revision: 342876

URL: http://llvm.org/viewvc/llvm-project?rev=342876&view=rev
Log:
Fix Wundef NDEBUG warning; NFC

Check for definedness of the NDEBUG macro rather than its value,
to be consistent with other uses.

Modified:
cfe/trunk/lib/Sema/ParsedAttr.cpp

Modified: cfe/trunk/lib/Sema/ParsedAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParsedAttr.cpp?rev=342876&r1=342875&r2=342876&view=diff
==
--- cfe/trunk/lib/Sema/ParsedAttr.cpp (original)
+++ cfe/trunk/lib/Sema/ParsedAttr.cpp Mon Sep 24 05:12:03 2018
@@ -82,7 +82,7 @@ void AttributeFactory::deallocate(Parsed
   if (freeListIndex >= FreeLists.size())
 FreeLists.resize(freeListIndex + 1);
 
-#if !NDEBUG
+#ifndef NDEBUG
   // In debug mode, zero out the attribute to help find memory overwriting.
   memset(Attr, 0, size);
 #endif


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


r342883 - [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`.

2018-09-24 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Mon Sep 24 07:06:47 2018
New Revision: 342883

URL: http://llvm.org/viewvc/llvm-project?rev=342883&view=rev
Log:
[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`.

[Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets
that use `-fconstant-cfstrings`. The original changes from differential 
for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not
check for an edge case where the global could be a constant which surfaced
as an issue when building for ELF because of different linkage semantics.

This patch addresses several issues with crashes related to CF builds on ELF
as well as improves data layout by ensuring string literals that back
the actual CFConstStrings end up in .rodata in line with Mach-O.

Change itself tested with CoreFoundation on Linux x86_64 but should be valid
for BSD-like systems as well that use ELF as the native object format.

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


Added:
cfe/trunk/test/CodeGen/cfstring-elf.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=342883&r1=342882&r2=342883&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 24 07:06:47 2018
@@ -4109,37 +4109,48 @@ CodeGenModule::GetAddrOfConstantCFString
 
   llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
   llvm::Constant *Zeros[] = { Zero, Zero };
-
+  
   // If we don't already have it, get __CFConstantStringClassReference.
   if (!CFConstantStringClassRef) {
 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
 Ty = llvm::ArrayType::get(Ty, 0);
-llvm::GlobalValue *GV = cast(
-CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"));
-
-if (getTriple().isOSBinFormatCOFF()) {
-  IdentifierInfo &II = getContext().Idents.get(GV->getName());
-  TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
-  DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
-
-  const VarDecl *VD = nullptr;
-  for (const auto &Result : DC->lookup(&II))
-if ((VD = dyn_cast(Result)))
-  break;
-
-  if (!VD || !VD->hasAttr()) {
-GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-  } else {
-GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+llvm::Constant *C =
+CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
+
+if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) {
+  llvm::GlobalValue *GV = nullptr;
+  
+  if ((GV = dyn_cast(C))) {
+IdentifierInfo &II = getContext().Idents.get(GV->getName());
+TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
+DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
+
+const VarDecl *VD = nullptr;
+for (const auto &Result : DC->lookup(&II))
+  if ((VD = dyn_cast(Result)))
+break;
+  
+if (getTriple().isOSBinFormatELF()) {
+  if (!VD)
+GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+}
+else {
+  if (!VD || !VD->hasAttr()) {
+GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  } else {
+GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  }
+}
+
+setDSOLocal(GV);
   }
 }
-setDSOLocal(GV);
-
+  
 // Decay array -> ptr
 CFConstantStringClassRef =
-llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
+llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros);
   }
 
   QualType CFTy = getContext().getCFConstantStringType();
@@ -4185,7 +4196,11 @@ CodeGenModule::GetAddrOfConstantCFString
   if (getTriple().isOSBinFormatMachO())
 GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
-
+  // Make sure the literal ends up in .rodata to allow for safe ICF and for
+  // the static linker to adjust permissions to read-only later on.
+  else if (getTriple().isOSBinFormatELF())
+GV->setSection(".rodata");
+  
   // String.
   llvm::Constant *Str =
   llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);

Added: cfe/trunk/test/CodeGen/cfstring-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfstring-elf.c?rev=342883&view=auto
=

[PATCH] D50179: [AArch64][ARM] Context sensitive meaning of option "crypto"

2018-09-24 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 166643.
SjoerdMeijer added a comment.

Added FIXMEs, like in https://reviews.llvm.org/D50229, that this needs 
reimplementation too after the TargerParser rewrite.

About v8.5, the ISA description is now available here: 
https://developer.arm.com/products/architecture/cpu-architecture/a-profile/exploration-tools

But we will add support for that when we upstream v8.5 support, so will be 
added later.


https://reviews.llvm.org/D50179

Files:
  lib/Driver/ToolChains/Arch/AArch64.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-features.c
  test/Preprocessor/aarch64-target-features.c

Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -170,6 +170,101 @@
 // CHECK-MARCH-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-fp-armv8" "-target-feature" "-neon" "-target-feature" "-crc" "-target-feature" "-crypto"
 // CHECK-MARCH-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon"
 
+// Check +sm4:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+sm4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SM4 %s
+// CHECK-SM4:  "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sm4"
+//
+// Check +sha3:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+sha3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA3 %s
+// CHECK-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sha3"
+//
+// Check +sha2:
+//
+// RUN: %clang -target aarch64 -march=armv8.3a+sha2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA2 %s
+// CHECK-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+sha2"
+//
+// Check +aes:
+//
+// RUN: %clang -target aarch64 -march=armv8.3a+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-AES %s
+// CHECK-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+aes"
+//
+// Check -sm4:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noSM4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SM4 %s
+// CHECK-NO-SM4:  "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sm4"
+//
+// Check -sha3:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noSHA3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA3 %s
+// CHECK-NO-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha3"
+//
+// Check -sha2:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noSHA2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA2 %s
+// CHECK-NO-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha2"
+//
+// Check -aes:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noAES -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AES %s
+// CHECK-NO-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-aes"
+//
+//
+// Arch <= ARMv8.3:  crypto = sha2 + aes
+// -
+//
+// Check +crypto:
+//
+// RUN: %clang -target aarch64 -march=armv8a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8.1a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8.2a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8.3a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8a+crypto+nocrypto+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// CHECK-CRYPTO83: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+crypto" "-target-feature" "+sha2" "-target-feature" "+aes"
+//
+// Check -crypto:
+//
+// RUN: %clang -target aarch64 -march=armv8a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO8A %s
+// RUN: %clang -target aarch64 -march=armv8.1a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO81 %s
+// RUN: %clang -target aarch64 -march=armv8.2a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s
+// RUN: %clang -target aarch64 -march=armv8.3a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s
+// RUN: %clang -target aarch64 -march=armv8.3a+nocrypto+crypto+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s
+
+// CHECK-NOCRYPTO8A: "-target-feature" "+neon" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs"
+// CHECK-NOCRYPTO81: "-target-feature" "+neon" "-target-feature" "+v8.1a" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs"
+// CHECK-NOCRYPTO82: "-target-feature" "+neon" "-target-feature" "+v8.{{.}}a" "-target-feature" "-crypto

[PATCH] D52334: [clang-tidy] Build it even without static analyzer

2018-09-24 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Actually, I had not run the tests. Thanks for the reminder there. I extended 
the patch to enable the tests even if CSA is not available.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52334



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


[PATCH] D52334: [clang-tidy] Build it even without static analyzer

2018-09-24 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 166644.
steveire marked 2 inline comments as done.
steveire added a comment.

Handle tests


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52334

Files:
  CMakeLists.txt
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidy.cpp
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/plugin/ClangTidyPlugin.cpp
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  test/CMakeLists.txt
  unittests/CMakeLists.txt

Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -18,8 +18,6 @@
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
-if(CLANG_ENABLE_STATIC_ANALYZER)
-  add_subdirectory(clang-tidy)
-endif()
+add_subdirectory(clang-tidy)
 add_subdirectory(clangd)
 add_subdirectory(include-fixer)
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -60,18 +60,14 @@
 
   # Unit tests
   ExtraToolsUnitTests
-  )
 
-if(CLANG_ENABLE_STATIC_ANALYZER)
-  list(APPEND CLANG_TOOLS_TEST_DEPS
-# For the clang-tidy libclang integration test.
-c-index-test
-# clang-tidy tests require it.
-clang-headers
+  # For the clang-tidy libclang integration test.
+  c-index-test
+  # clang-tidy tests require it.
+  clang-headers
 
-clang-tidy
-)
-endif()
+  clang-tidy
+  )
 
 set(llvm_utils
   FileCheck count not
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -534,10 +534,12 @@
 static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
 ModernizeModuleAnchorSource;
 
+#if CLANG_ENABLE_STATIC_ANALYZER
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
 MPIModuleAnchorSource;
+#endif
 
 // This anchor is used to force the linker to link the PerformanceModule.
 extern volatile int PerformanceModuleAnchorSource;
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -29,7 +29,6 @@
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
-  clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
@@ -39,6 +38,12 @@
   clangToolingCore
   )
 
+if(CLANG_ENABLE_STATIC_ANALYZER)
+  target_link_libraries(clang-tidy PRIVATE
+clangTidyMPIModule
+  )
+endif()
+
 install(PROGRAMS clang-tidy-diff.py
   DESTINATION share/clang
   COMPONENT clang-tidy)
Index: clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -133,10 +133,12 @@
 static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
 ModernizeModuleAnchorSource;
 
+#if CLANG_ENABLE_STATIC_ANALYZER
 // This anchor is used to force the linker to link the MPIModule.
 extern volatile int MPIModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
 MPIModuleAnchorSource;
+#endif
 
 // This anchor is used to force the linker to link the ObjCModule.
 extern volatile int ObjCModuleAnchorSource;
Index: clang-tidy/plugin/CMakeLists.txt
===
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -20,11 +20,16 @@
   clangTidyLLVMModule
   clangTidyMiscModule
   clangTidyModernizeModule
-  clangTidyMPIModule
   clangTidyObjCModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
   clangTidyZirconModule
   clangTooling
   )
+
+if(CLANG_ENABLE_STATIC_ANALYZER)
+target_link_libraries(clangTidyPlugin PRIVATE
+  clangTidyMPIModule
+)
+endif()
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -34,8 +34,10 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Rewrite/Frontend/FixItRewriter.h"
 #include "clang/Rewrite/Frontend/FrontendActions.h"
+#if CLANG_ENABLE_STATIC_ANALYZER
 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#endif
 #include "clang/Tooling/DiagnosticsYaml.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
@@ -56,6 +58,7 @@
 namespace tidy {
 
 namespace {
+#if CLANG_ENABLE_STATIC_ANALYZER
 static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
 
 class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
@@ -87,6 +90,7 @@
 private:
   ClangTidyContext

[PATCH] D52344: [Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets that use `-fconstant-cfstrings`.

2018-09-24 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

In https://reviews.llvm.org/D52344#1243149, @rjmccall wrote:

> I can respect wanting to change the rules on ELF, but it sounds like we do 
> need to stick with the current section names.  Absent an ABI break to stop 
> looking for the existing section names, CF will misbehave if they exist even 
> if we change the compiler output, so effectively those identifiers are 
> claimed in a way that cannot be incrementally changed.
>
> Also, it's probably correct for CF on non-Darwin OSes to stick to non-system 
> namespaces anyway.


Yes makes sense, I kept it as `cfstring`, should be in that revision.


Repository:
  rC Clang

https://reviews.llvm.org/D52344



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


[PATCH] D52390: [analyzer] StackSizeChecker

2018-09-24 Thread Máté Tóth via Phabricator via cfe-commits
mate1214 added a comment.

Hi @Szelethus !

Thanks for all your detailed and helpful input, I will make sure to go over all 
the comments and answer them, but it will take some time.

A bit more background information on this checker and how it came to be might 
help you and others to understand some of the choices I made, and also address 
some of your general questions and worries.
I was hesitant about putting too much in the summary but it seems I should have 
added more.

This was a university assignment and I was encouraged to put it up here. This 
code has seen quite a few iterations and criticism.
It was my introduction to the clang tool-chain, and the clang-tidy checker was 
actually the first one to exist. Explaining it briefly will help with the 
"bigger picture".
It focused on single function bodies and could tell you how much the maximal 
stack space that body can occupy is.
It was able to calculate with:

- variable lifetimes (even taking into account lifetimes extended by `const` 
references etc.)
- recycled space (if the lifetime of a variable ends you can place the new ones 
can take up its place)
- execution rules (for example: if there is an `if` statement then you take the 
maximal space from its branches and not add them together etc.).
- variable length arrays (it took note when it saw one and if the resulting 
number was close enough to the limit but not over it you still got a warning)

The final result was the all-time maximum so if you had a ` ... {... char 
c[1000]; ...} ...` somewhere in the middle that was, by lifetime rules, gone by 
the end and nothing surpassed it, you still got the correct numbers.
To produce the result, 2-3 massive recursive functions with tons of `else if`-s 
were used to traverse the AST of the function body with an in-order traverse 
strategy.
Now for ordinary functions it was an easy "traverse it all then get the final 
number" task. But enter the templates. There seemed to be no way to tell right 
away that we entered a function that had dependent types.
The easiest answer to templates was going until you see something that has 
dependent types involved then quit right away and say "it is a template we have 
nothing to do here".
The implementation was crude but it got the job done. It had (and still has) 
tests for most of the cases (statement types, expressions, VLA, templates etc.) 
and those tests felt natural there because they were concerned
with the contents of a particular function body.

Now single functions are fun, but entire call chains are what usually matter. 
You can pack a few `char[1]`-s in one body but having them in each function 
of a call stack may not be so good idea.
So the static analyzer checker basically uses the same logic for single 
functions as mentioned before but as the analyzer follows the execution paths 
it adds up everything.
Now you could say that simply taking the whole bodies into account is enough 
but consider the following example:

  void f(...){
  ... some minor stack space is used
  if(...) {
  start_a_deep_and_costly_calculation();
  } else {
  char x[5000];
  
  }
  }

Here taking the whole body of `f` may yield 5000+"someting" bytes, instead of 
the actual small space, that gets used in the call stack when the condition is 
true and the other function gets called.
So it is reasonable to say that partial summaries should be possible up to 
certain point in the body.
Having said these and the fact that the original code was even harder to read, 
the `StackUsageMeasuringVisitor` came into existence to replace those massive 
recursive functions.
It is based on the `RecursiveASTVisitor` and uses post-order traverse strategy 
to accomplish its goals. This is where the readability over performance aspect 
comes in.
Without going too deep into details my visitor assigns `Usage` values to the 
AST nodes and then their parents can calculate with that, depending on what 
they actually are. The aforementioned requirement to stop on templates is quite 
easy,
because you do not need a real answer at the end so you can stop. The 
requirement to leave out the parts after a certain point is trickier, because 
it has to assign a value to all the nodes up to the top for proper calculations.
With the specifics of the visitor base class (I've seen no in-order traverse 
possibility), the solution was to assign zero to everything we do not care 
about and basically after a certain point it is a dry run on the rest of the 
function body and some calculation in the parent nodes.
I saw a question about that `ContinueTraversing` and `ExitFlag` in the visitor. 
They are both needed, because you can use the same logic for "I don't care 
about anything following this statement" and "I don't care about anything if I 
see a template type"
with some predicates, but in the first case you still need to do stuff with the 
post-order strategy and can not stop the visitor right away.
Also I saw a

[PATCH] D52390: [analyzer] StackSizeChecker

2018-09-24 Thread Máté Tóth via Phabricator via cfe-commits
mate1214 added a comment.

Hi @lebedev.ri!

Thanks for the question. I was not sure as to where exactly put the files. The 
important thing for me is that the `StackUsageMeasuringVisitor` should be 
reachable from the clang-tidy checker. (For the bigger picture please refer to 
my answer to @Szelethus). I was not able to find documentation I could use to 
put the extra logic in the right place (may be my fault). Any suggestions and 
references are welcome!


Repository:
  rC Clang

https://reviews.llvm.org/D52390



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


[PATCH] D52392: [X86] For lzcnt/tzcnt intrinsics use cttz/ctlz intrinsics with zero_undef flag set to false.

2018-09-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

The only other header that uses the existing builtins is arm_acle.h. But
ARM returns false in isCLZForZeroUndef. So they should be creating the
cttz/ctlz intrinsics with false for the second argument from
__builtin_clz/ctz. The sanitizer code
in CodeGenFunction::EmitCheckedArgForBuiltin also checks isCLZForZeroUndef
to determine if it should emit a runtime check to flag 0 as a sanitizer
error.

~Craig


Repository:
  rC Clang

https://reviews.llvm.org/D52392



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


[PATCH] D52334: [clang-tidy] Build it even without static analyzer

2018-09-24 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

> ! In https://reviews.llvm.org/D52334#1242955, @JonasToth wrote:
>  ... to me it makes sense to have clang-tidy without CSA.

Yep, it seems reasonable.




Comment at: test/CMakeLists.txt:69
 
-clang-tidy
-)
-endif()
+  clang-tidy
+  )

There are some clang-tidy tests for the static analyzer integration (at least 
test/clang-tidy/static-analyzer.cpp and 
test/clang-tidy/static-analyzer-config.cpp). I would expect them to start 
failing when clang-tidy is built without static analyzer. Did you try running 
all the tests?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52334



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


[PATCH] D50214: Add inherited attributes before parsed attributes.

2018-09-24 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur closed this revision.
Meinersbur added a comment.

Commited as https://reviews.llvm.org/rL342861.


Repository:
  rC Clang

https://reviews.llvm.org/D50214



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In https://reviews.llvm.org/D52193#1241067, @aganea wrote:

> @thakis > clang-cl isn't supposed to do (explicit) registry accesses when you 
> hold it right (pass in -fms-compatibility-version etc). Have you seen 
> registry access costs, or is that speculation?
>
> Please see this log: F7268226: clang-cl-log.zip 
>  - the child `clang-cl -cc1` takes about 
> ~117ms until it gets into the global initializers. This is on my Haswell PC. 
> On the Skylake, this takes "only" ~60ms.
>  This probably explains why Ninja is slower on the Skylake when using 
> `clang-cl` as a compiler. There should be a shorter codepath maybe when only 
> a single .cpp is being compiled, and avoid running the child process.


Huh, interesting! I had a local hack years ago where I had measured how much 
not spawning a subprocess for cc1 saves (it looked like 
https://reviews.llvm.org/D52411) and over here it didn't do anything. Can you 
check if patching that in helps you a lot? If so, we should reconsider doing 
something like that.


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-09-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: include/clang/AST/OperationKinds.def:325
 // Convert a zero value for OpenCL queue_t initialization.
 CAST_OPERATION(ZeroToOCLQueue)
 

I am wondering if we could potentially unify all of those ZeroToOCL* into one 
cast type... and also do similar for all of the zero init patterns. 



Comment at: include/clang/AST/Type.h:6379
+inline bool Type::isOCLIntelSubgroupAVCType() const {
+#define EXT_OPAQUE_TYPE(Name, Id, Ext)
+#define INTEL_SUBGROUP_AVC_TYPE(ExtType, Id) \

I guess this define is not needed here.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:68
+return llvm::PointerType::get( \
+llvm::StructType::create(Ctx, "opencl." #ExtType), 0);
+#include "clang/Basic/OpenCLExtensionTypes.def"

I think more generic approach would be to pass AddrSpc and then targets can 
override getOpenCLTypeAddrSpace putting address space that is needed.



Comment at: lib/Headers/opencl-c.h:16196
 
+#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : begin
+

I think we should guard this by
  #ifdef cl_intel_device_side_avc_motion_estimation
so that it's not added for the targets that don't support this.

Also it might be worth adding a check for a function from this block into 
`test/Headers/opencl-c-header.cl` to verify that it's unavailable by default.



Comment at: lib/Headers/opencl-c.h:16320
+
+#define CLK_AVC_IME_PAYLOAD_INITIALIZE_INTEL   { 0 }
+#define CLK_AVC_REF_PAYLOAD_INITIALIZE_INTEL   { 0 }

Could this just be regular integer literal like the ones above?



Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 
-cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify 
-DNEGATIVE %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 
-cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify %s

Any reasons to separate into 2 clang calls? Could we tests both in one 
invocation of parsing.



Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:13
+
+#define CLK_AVC_IME_PAYLOAD_INITIALIZE_INTEL   { 0 }
+#define CLK_AVC_REF_PAYLOAD_INITIALIZE_INTEL   { 0 }

Just 0 would work too?



Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:26
+ char4 c4, event_t e, struct st ss) {
+  intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer 
for mce types
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with 
an expression of incompatible type 'int'}}

Would it make sense to add a check for non-zero constant?

Also can you assign variables of intel_sub_group_avc_mce_payload_t type from 
the same type? Any other restrictions on assignment (i.e. w integer literals) 
and operations over these types?



Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:54
+  intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list = {0x0, 
0x1};
+  // expected-warning@-1 {{excess elements in struct initializer}}
+  intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list2 = {};

This error message is probably not the best, but at least it's rejected. Some 
thing like 
`initializing ... with an expression of incompatible type` would have been 
better. Not asking to do this change though...



Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:57
+  // expected-error@-1 {{scalar initializer cannot be empty}}
+  intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list3 = {c};
+  // expected-error@-1 {{initializing 
'intel_sub_group_avc_ime_dual_reference_streamin_t' with an expression of 
incompatible type 'char'}}

Can you add something like:

   = {1}


https://reviews.llvm.org/D51484



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


[PATCH] D49864: [clang-tidy] The script clang-tidy-diff.py doesn't accept 'pass by' options (--)

2018-09-24 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/tool/clang-tidy-diff.py:123-130
   if args.fix:
 command.append('-fix')
   if args.checks != '':
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
 command.append('-quiet')
   if args.build_path is not None:

If we make the script leave out the `--` flag, we should stop forwarding these 
flags and the `extra_arg(_before)?` below. Otherwise it's too confusing (should 
one place -fix before `--` or after? what about `-warnings-as-errors`?).

Please also update the usage example at the top.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49864



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


[PATCH] D52412: OpenCL: Mark printf format string argument

2018-09-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added a reviewer: Anastasia.
Herald added subscribers: yaxunl, wdng.

Fixes not warning on format string errors.


https://reviews.llvm.org/D52412

Files:
  lib/Headers/opencl-c.h
  test/SemaOpenCL/printf-format-string-warnings.cl


Index: test/SemaOpenCL/printf-format-string-warnings.cl
===
--- /dev/null
+++ test/SemaOpenCL/printf-format-string-warnings.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 
-finclude-default-header
+
+// Make sure warnings are produced based on printf format strings.
+
+
+kernel void format_string_warnings(__constant char* arg) {
+
+  printf("%d", arg); // expected-warning {{format specifies type 'int' but the 
argument has type '__constant char *'}}
+
+  printf("not enough arguments %d %d", 4); // expected-warning {{more '%' 
conversions than data arguments}}
+
+  printf("too many arguments", 4); // expected-warning {{data argument not 
used by format string}}
+}
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -14462,7 +14462,7 @@
 #if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 // OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
 
-int printf(__constant const char* st, ...);
+int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 
2)));
 #endif
 
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write 
Functions


Index: test/SemaOpenCL/printf-format-string-warnings.cl
===
--- /dev/null
+++ test/SemaOpenCL/printf-format-string-warnings.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
+
+// Make sure warnings are produced based on printf format strings.
+
+
+kernel void format_string_warnings(__constant char* arg) {
+
+  printf("%d", arg); // expected-warning {{format specifies type 'int' but the argument has type '__constant char *'}}
+
+  printf("not enough arguments %d %d", 4); // expected-warning {{more '%' conversions than data arguments}}
+
+  printf("too many arguments", 4); // expected-warning {{data argument not used by format string}}
+}
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -14462,7 +14462,7 @@
 #if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 // OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
 
-int printf(__constant const char* st, ...);
+int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
 #endif
 
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52320: AMDGPU: add __builtin_amdgcn_update_dpp

2018-09-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:11313-11315
+  case AMDGPU::BI__builtin_amdgcn_update_dpp: {
+llvm::SmallVector Args;
+for (unsigned I = 0; I != 6; ++I)

The only difference between this and mov_dpp is the argument count and the 
intrinsic ID, so you can combine the cases


https://reviews.llvm.org/D52320



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


[PATCH] D52230: [clang-tidy] use CHECK-NOTES in tests for bugprone-macro-repeated-side-effects

2018-09-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

For the other patches and the following doing the same for other modules too?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52230



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


[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-24 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

Ping?

This patch reduced obj size largely, and I expect this makes distributed build 
(like goma) faster by reducing data transferred on network.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5244
+   false))
+CmdArgs.push_back("-fvisibility-inlines-hidden");
+

takuto.ikuta wrote:
> rnk wrote:
> > takuto.ikuta wrote:
> > > hans wrote:
> > > > takuto.ikuta wrote:
> > > > > hans wrote:
> > > > > > Huh, does this actually affect whether functions get dllexported or 
> > > > > > not?
> > > > > Sorry, what you want to ask?
> > > > > 
> > > > > This will used to not add dllexport attr in L5690 of SemaDeclCXX.cpp.
> > > > > 
> > > > Oops, I didn't see that. I'm glad to see this is looking so simple :-)
> > > > 
> > > > Actually, I don't think we should the same flag name for this, since 
> > > > "hidden" is an ELF concept, not a COFF one, just that we should match 
> > > > the behaviour of the flag.
> > > > 
> > > > Hmm, or do people use -fvisibility-inlines-hidden on MinGW or 
> > > > something? Where does the hidden-dllimport.cpp file come from?
> > > > 
> > > > Also, is it the case that -fvisibility-inlines-hidden just ignores the 
> > > > problem of static local variables? If that's the case we can probably 
> > > > do it too, we just have to be sure, and document it eventually.
> > > > 
> > > I confirmed that -fvisibility-inlines-hidden treats local static var 
> > > correctly in linux.
> > > So I'm trying to export inline functions if it has local static variables.
> > This sounds like it would be really hard in general, since you can hide 
> > static locals almost anywhere:
> > ```
> > struct Foo {
> >   static int foo() {
> > return ([]() { static int x; return ++x; })();
> >   }
> > };
> > ```
> > Can we reuse the RecursiveASTVisitor @hans added to check if we can emit 
> > dllimport inline functions as available_externally definitions? I think it 
> > will find exactly the circumstances we are looking for, i.e. export all the 
> > things that cannot be emitted inline in other DLLs.
> Actually, StmtVisitor added dll export attribute to local static variable in 
> lambda function. And static variables seems exported.
> 
> But I found other issue in current implementation, some cxx method decls 
> passed to emitting function before local static variable checker adds dll 
> export attributes. In such case local static variables are not exported and 
> link failure happens.
> 
> So let me try to use DLLImportFunctionVisitor in 
> CodeGenModule::shouldEmitFunction for exported function instead of 
> processing/checking dll attribute around SemaDeclCXX.
I think avoiding dll export is better to be done before we reached around 
CodeGenModule. Also removing dll attribute later made it difficult to pass 
tests.


https://reviews.llvm.org/D51340



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


[PATCH] D52418: [driver][mips] Enable integrated assembler for MIPS64 except N32 ABI selected

2018-09-24 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
atanasyan added reviewers: rsmith, rnk, zturner.
Herald added subscribers: jrtc27, arichardson, sdardis, srhines.

Enable integrated assembler for MIPS64 targets except N32 ABI explicitly 
selected by the `-mabi=n32` command line option or `mips64(el)-linux-gnuabin32` 
target triple.


Repository:
  rC Clang

https://reviews.llvm.org/D52418

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/mips-gnu-integrated-as.c


Index: test/Driver/mips-gnu-integrated-as.c
===
--- /dev/null
+++ test/Driver/mips-gnu-integrated-as.c
@@ -0,0 +1,27 @@
+# Check cases when MIPS cannot use the integrated assembler.
+
+# RUN: %clang -target mips-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mipsel-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64el-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64-unknown-gnu -mabi=64 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64el-unknown-gnu -mabi=64 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+
+# INT-NOT: "-no-integrated-as"
+
+# RUN: %clang -target mips64-linux-gnuabin32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64el-linux-gnuabin32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64-unknown-gnu -mabi=n32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64el-unknown-gnu -mabi=n32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+
+# EXT: "-no-integrated-as"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2408,15 +2408,9 @@
 return true;
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
-// Enabled for Debian, Android, FreeBSD and OpenBSD mips64/mipsel, as they
-// can precisely identify the ABI in use (Debian) or only use N64 for 
MIPS64
-// (Android). Other targets are unable to distinguish N32 from N64.
-if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
-getTriple().isAndroid() ||
-getTriple().isOSFreeBSD() ||
-getTriple().isOSOpenBSD())
-  return true;
-return false;
+// Do not use integrated assembler for N32 ABI only.
+return !tools::mips::hasMipsAbiArg(getArgs(), "n32") &&
+   getTriple().getEnvironment() != llvm::Triple::GNUABIN32;
   default:
 return false;
   }
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -156,6 +156,8 @@
 
   void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
 
+  const llvm::opt::ArgList &getArgs() const { return Args; };
+
   virtual Tool *buildAssembler() const;
   virtual Tool *buildLinker() const;
   virtual Tool *getTool(Action::ActionClass AC) const;


Index: test/Driver/mips-gnu-integrated-as.c
===
--- /dev/null
+++ test/Driver/mips-gnu-integrated-as.c
@@ -0,0 +1,27 @@
+# Check cases when MIPS cannot use the integrated assembler.
+
+# RUN: %clang -target mips-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mipsel-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64el-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64-unknown-gnu -mabi=64 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64el-unknown-gnu -mabi=64 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+
+# INT-NOT: "-no-integrated-as"
+
+# RUN: %clang -target mips64-linux-gnuabin32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64el-linux-gnuabin32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64-unknown-gnu -mabi=n32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64el-unknown-gnu -mabi=n32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+
+# EXT: "-no-integrated-as"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2408,15 +2408,9 @@
 return true;
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
-// Enable

[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.
ioeric updated this revision to Diff 17.
ioeric added a comment.

- update comment


The file stats can be reused when preamble is reused (e.g. code
completion). It's safe to assume that cached status is not outdated as we
assume preamble files to remain unchanged.

On real file system, this made code completion ~20% faster on a measured file
(with big preamble). The preamble build time doesn't change much.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -963,6 +963,89 @@
Field(&CodeCompletion::Name, "baz")));
 }
 
+TEST(ClangdTests, PreambleVFSStatCache) {
+  class ListenStatsFSProvider : public FileSystemProvider {
+  public:
+ListenStatsFSProvider(llvm::StringMap &CountStats)
+: CountStats(CountStats) {}
+
+IntrusiveRefCntPtr getFileSystem() override {
+  class ListenStatVFS : public vfs::FileSystem {
+  public:
+ListenStatVFS(IntrusiveRefCntPtr FS,
+  llvm::StringMap &CountStats)
+: FS(std::move(FS)), CountStats(CountStats) {}
+
+vfs::directory_iterator dir_begin(const Twine &Dir,
+  std::error_code &EC) override {
+  return FS->dir_begin(Dir, EC);
+}
+std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+  return FS->setCurrentWorkingDirectory(Path);
+}
+llvm::ErrorOr getCurrentWorkingDirectory() const override {
+  return FS->getCurrentWorkingDirectory();
+}
+std::error_code
+getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const override {
+  return FS->getRealPath(Path, Output);
+}
+
+llvm::ErrorOr>
+openFileForRead(const Twine &Path) override {
+  return FS->openFileForRead(Path);
+}
+
+llvm::ErrorOr status(const Twine &Path) override {
+  auto I =
+  CountStats.try_emplace(llvm::sys::path::filename(Path.str()), 1);
+  if (!I.second)
+I.first->second += 1;
+  return FS->status(Path);
+}
+
+  private:
+IntrusiveRefCntPtr FS;
+llvm::StringMap &CountStats;
+  };
+
+  return IntrusiveRefCntPtr(
+  new ListenStatVFS(buildTestFS(Files), CountStats));
+}
+
+// If relative paths are used, they are resolved with testPath().
+llvm::StringMap Files;
+llvm::StringMap &CountStats;
+  };
+
+  llvm::StringMap CountStats;
+  ListenStatsFSProvider FS(CountStats);
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto SourcePath = testPath("foo.cpp");
+  auto HeaderPath = testPath("foo.h");
+  FS.Files[HeaderPath] = "struct TestSym {};";
+  Annotations Code(R"cpp(
+#include "foo.h"
+
+int main() {
+  TestSy^
+})cpp");
+
+  runAddDocument(Server, SourcePath, Code.code());
+
+  unsigned Before = CountStats["foo.h"];
+  auto Completions = cantFail(runCodeComplete(Server, SourcePath, Code.point(),
+  clangd::CodeCompleteOptions()))
+ .Completions;
+  EXPECT_EQ(CountStats["foo.h"], Before);
+  EXPECT_THAT(Completions,
+  ElementsAre(Field(&CodeCompletion::Name, "TestSym")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -20,6 +20,7 @@
 #include "Logger.h"
 #include "Path.h"
 #include "Protocol.h"
+#include "TUScheduler.h"
 #include "index/Index.h"
 #include "clang/Frontend/PrecompiledPreamble.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
@@ -212,11 +213,8 @@
 /// the speculative result is used by code completion (e.g. speculation failed),
 /// the speculative result is not consumed, and `SpecFuzzyFind` is only
 /// destroyed when the async request finishes.
-CodeCompleteResult codeComplete(PathRef FileName,
-const tooling::CompileCommand &Command,
-PrecompiledPreamble const *Preamble,
-const IncludeStructure &PreambleInclusions,
-StringRef Contents, Position Pos,
+CodeCompleteResult codeComplete(PathRef FileName, Position Pos,
+cons

[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 17.
ioeric added a comment.

- update comment


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -963,6 +963,89 @@
Field(&CodeCompletion::Name, "baz")));
 }
 
+TEST(ClangdTests, PreambleVFSStatCache) {
+  class ListenStatsFSProvider : public FileSystemProvider {
+  public:
+ListenStatsFSProvider(llvm::StringMap &CountStats)
+: CountStats(CountStats) {}
+
+IntrusiveRefCntPtr getFileSystem() override {
+  class ListenStatVFS : public vfs::FileSystem {
+  public:
+ListenStatVFS(IntrusiveRefCntPtr FS,
+  llvm::StringMap &CountStats)
+: FS(std::move(FS)), CountStats(CountStats) {}
+
+vfs::directory_iterator dir_begin(const Twine &Dir,
+  std::error_code &EC) override {
+  return FS->dir_begin(Dir, EC);
+}
+std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+  return FS->setCurrentWorkingDirectory(Path);
+}
+llvm::ErrorOr getCurrentWorkingDirectory() const override {
+  return FS->getCurrentWorkingDirectory();
+}
+std::error_code
+getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const override {
+  return FS->getRealPath(Path, Output);
+}
+
+llvm::ErrorOr>
+openFileForRead(const Twine &Path) override {
+  return FS->openFileForRead(Path);
+}
+
+llvm::ErrorOr status(const Twine &Path) override {
+  auto I =
+  CountStats.try_emplace(llvm::sys::path::filename(Path.str()), 1);
+  if (!I.second)
+I.first->second += 1;
+  return FS->status(Path);
+}
+
+  private:
+IntrusiveRefCntPtr FS;
+llvm::StringMap &CountStats;
+  };
+
+  return IntrusiveRefCntPtr(
+  new ListenStatVFS(buildTestFS(Files), CountStats));
+}
+
+// If relative paths are used, they are resolved with testPath().
+llvm::StringMap Files;
+llvm::StringMap &CountStats;
+  };
+
+  llvm::StringMap CountStats;
+  ListenStatsFSProvider FS(CountStats);
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto SourcePath = testPath("foo.cpp");
+  auto HeaderPath = testPath("foo.h");
+  FS.Files[HeaderPath] = "struct TestSym {};";
+  Annotations Code(R"cpp(
+#include "foo.h"
+
+int main() {
+  TestSy^
+})cpp");
+
+  runAddDocument(Server, SourcePath, Code.code());
+
+  unsigned Before = CountStats["foo.h"];
+  auto Completions = cantFail(runCodeComplete(Server, SourcePath, Code.point(),
+  clangd::CodeCompleteOptions()))
+ .Completions;
+  EXPECT_EQ(CountStats["foo.h"], Before);
+  EXPECT_THAT(Completions,
+  ElementsAre(Field(&CodeCompletion::Name, "TestSym")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -20,6 +20,7 @@
 #include "Logger.h"
 #include "Path.h"
 #include "Protocol.h"
+#include "TUScheduler.h"
 #include "index/Index.h"
 #include "clang/Frontend/PrecompiledPreamble.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
@@ -212,11 +213,8 @@
 /// the speculative result is used by code completion (e.g. speculation failed),
 /// the speculative result is not consumed, and `SpecFuzzyFind` is only
 /// destroyed when the async request finishes.
-CodeCompleteResult codeComplete(PathRef FileName,
-const tooling::CompileCommand &Command,
-PrecompiledPreamble const *Preamble,
-const IncludeStructure &PreambleInclusions,
-StringRef Contents, Position Pos,
+CodeCompleteResult codeComplete(PathRef FileName, Position Pos,
+const InputsAndPreamble &Input,
 IntrusiveRefCntPtr VFS,
 std::shared_ptr PCHs,
 CodeCompleteOptions Opts,
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1000,7 +1000,8 @@
 struct SemaCompleteInput {
   PathRef FileName;
   const tooling::CompileCommand &Command;
-  PrecompiledPre

[PATCH] D52344: [Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets that use `-fconstant-cfstrings`.

2018-09-24 Thread Kristina Brooks via Phabricator via cfe-commits
kristina closed this revision.
kristina added a comment.

Closed by https://reviews.llvm.org/rL342883 
(https://reviews.llvm.org/rC342883). Manually closing it as Phabricator is 
slightly broken, hopefully it makes the links when it catches up.


Repository:
  rC Clang

https://reviews.llvm.org/D52344



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


[PATCH] D52344: [Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets that use `-fconstant-cfstrings`.

2018-09-24 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Alright, I guess I'll land it if there's no objections to it, `cfstring` is 
staying as is, the PE/COFF codepath is not affected in terms of functionality 
and test is fine I think, hopefully `x86_64-elf` will not yield different 
results on different machines in terms of alignment etc. That should allow 
building CF on x86_64 Linux without any additional runtime and fix a crash, as 
well as make the check explicit instead of relying on a blind `cast<>`.


Repository:
  rC Clang

https://reviews.llvm.org/D52344



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


[PATCH] D50229: [ARM][AArch64] Add feature +fp16fml

2018-09-24 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC342862: [ARM][AArch64] Add feature +fp16fml (authored by 
SjoerdMeijer, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D50229

Files:
  lib/Driver/ToolChains/Arch/AArch64.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/arm-cortex-cpus.c
  test/Preprocessor/aarch64-target-features.c
  test/Preprocessor/arm-target-features.c

Index: lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- lib/Driver/ToolChains/Arch/AArch64.cpp
+++ lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -193,6 +193,32 @@
   Features.push_back("-crc");
   }
 
+  // Handle (arch-dependent) fp16fml/fullfp16 relationship.
+  // FIXME: this fp16fml option handling will be reimplemented after the
+  // TargetParser rewrite.
+  const auto ItRNoFullFP16 = std::find(Features.rbegin(), Features.rend(), "-fullfp16");
+  const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), "+fp16fml");
+  if (std::find(Features.begin(), Features.end(), "+v8.4a") != Features.end()) {
+const auto ItRFullFP16  = std::find(Features.rbegin(), Features.rend(), "+fullfp16");
+if (ItRFullFP16 < ItRNoFullFP16 && ItRFullFP16 < ItRFP16FML) {
+  // Only entangled feature that can be to the right of this +fullfp16 is -fp16fml.
+  // Only append the +fp16fml if there is no -fp16fml after the +fullfp16.
+  if (std::find(Features.rbegin(), ItRFullFP16, "-fp16fml") == ItRFullFP16)
+Features.push_back("+fp16fml");
+}
+else
+  goto fp16_fml_fallthrough;
+  }
+  else {
+fp16_fml_fallthrough:
+// In both of these cases, putting the 'other' feature on the end of the vector will
+// result in the same effect as placing it immediately after the current feature.
+if (ItRNoFullFP16 < ItRFP16FML)
+  Features.push_back("-fp16fml");
+else if (ItRNoFullFP16 > ItRFP16FML)
+  Features.push_back("+fullfp16");
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access))
 if (A->getOption().matches(options::OPT_mno_unaligned_access))
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -391,6 +391,33 @@
   } else if (HDivArg)
 getARMHWDivFeatures(D, HDivArg, Args, HDivArg->getValue(), Features);
 
+  // Handle (arch-dependent) fp16fml/fullfp16 relationship.
+  // Must happen before any features are disabled due to soft-float.
+  // FIXME: this fp16fml option handling will be reimplemented after the
+  // TargetParser rewrite.
+  const auto ItRNoFullFP16 = std::find(Features.rbegin(), Features.rend(), "-fullfp16");
+  const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), "+fp16fml");
+  if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8_4a) {
+const auto ItRFullFP16  = std::find(Features.rbegin(), Features.rend(), "+fullfp16");
+if (ItRFullFP16 < ItRNoFullFP16 && ItRFullFP16 < ItRFP16FML) {
+  // Only entangled feature that can be to the right of this +fullfp16 is -fp16fml.
+  // Only append the +fp16fml if there is no -fp16fml after the +fullfp16.
+  if (std::find(Features.rbegin(), ItRFullFP16, "-fp16fml") == ItRFullFP16)
+Features.push_back("+fp16fml");
+}
+else
+  goto fp16_fml_fallthrough;
+  }
+  else {
+fp16_fml_fallthrough:
+// In both of these cases, putting the 'other' feature on the end of the vector will
+// result in the same effect as placing it immediately after the current feature.
+if (ItRNoFullFP16 < ItRFP16FML)
+  Features.push_back("-fp16fml");
+else if (ItRNoFullFP16 > ItRFP16FML)
+  Features.push_back("+fullfp16");
+  }
+
   // Setting -msoft-float/-mfloat-abi=soft effectively disables the FPU (GCC
   // ignores the -mfpu options in this case).
   // Note that the ABI can also be set implicitly by the target selected.
@@ -404,7 +431,7 @@
 //now just be explicit and disable all known dependent features
 //as well.
 for (std::string Feature : {"vfp2", "vfp3", "vfp4", "fp-armv8", "fullfp16",
-"neon", "crypto", "dotprod"})
+"neon", "crypto", "dotprod", "fp16fml"})
   if (std::find(std::begin(Features), std::end(Features), "+" + Feature) != std::end(Features))
 Features.push_back(Args.MakeArgString("-" + Feature));
   }
Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -93,18 +93,45 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s
 // C

[PATCH] D52396: [libcxx] Document new symbols __u64toa and __u32toa on Darwin

2018-09-24 Thread Louis Dionne via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX342849: [libcxx] Document new symbols __u64toa and 
__u32toa on Darwin (authored by ldionne, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52396?vs=166616&id=166671#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D52396

Files:
  lib/abi/CHANGELOG.TXT
  lib/abi/x86_64-apple-darwin.v1.abilist


Index: lib/abi/x86_64-apple-darwin.v1.abilist
===
--- lib/abi/x86_64-apple-darwin.v1.abilist
+++ lib/abi/x86_64-apple-darwin.v1.abilist
@@ -1282,6 +1282,8 @@
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__15wcerrE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__15wclogE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__15wcoutE', 'size': 0}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__16__itoa8__u32toaEjPc'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__16__itoa8__u64toaEyPc'}
 {'type': 'FUNC', 'is_defined': True, 'name': 
'__ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_'}
 {'type': 'FUNC', 'is_defined': True, 'name': 
'__ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_'}
 {'type': 'FUNC', 'is_defined': True, 'name': 
'__ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_'}
Index: lib/abi/CHANGELOG.TXT
===
--- lib/abi/CHANGELOG.TXT
+++ lib/abi/CHANGELOG.TXT
@@ -27,6 +27,9 @@
 
   x86_64-apple-darwin16.0
   ---
+  Symbol added: __ZNSt3__16__itoa8__u64toaEyPc
+  Symbol added: __ZNSt3__16__itoa8__u32toaEjPc
+
 
 * r333467 - Fix embarrasing typo in uncaught_exceptions.
 


Index: lib/abi/x86_64-apple-darwin.v1.abilist
===
--- lib/abi/x86_64-apple-darwin.v1.abilist
+++ lib/abi/x86_64-apple-darwin.v1.abilist
@@ -1282,6 +1282,8 @@
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__15wcerrE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__15wclogE', 'size': 0}
 {'type': 'OBJECT', 'is_defined': True, 'name': '__ZNSt3__15wcoutE', 'size': 0}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__16__itoa8__u32toaEjPc'}
+{'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__16__itoa8__u64toaEyPc'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_'}
 {'type': 'FUNC', 'is_defined': True, 'name': '__ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_'}
Index: lib/abi/CHANGELOG.TXT
===
--- lib/abi/CHANGELOG.TXT
+++ lib/abi/CHANGELOG.TXT
@@ -27,6 +27,9 @@
 
   x86_64-apple-darwin16.0
   ---
+  Symbol added: __ZNSt3__16__itoa8__u64toaEyPc
+  Symbol added: __ZNSt3__16__itoa8__u32toaEjPc
+
 
 * r333467 - Fix embarrasing typo in uncaught_exceptions.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342885 - Revert "We allow implicit function declarations as an extension in all C dialects. Remove OpenCL special case."

2018-09-24 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Mon Sep 24 07:21:56 2018
New Revision: 342885

URL: http://llvm.org/viewvc/llvm-project?rev=342885&view=rev
Log:
Revert "We allow implicit function declarations as an extension in all C 
dialects. Remove OpenCL special case."

Discussed on cfe-commits (Week-of-Mon-20180820), this change leads to
the generation of invalid IR for OpenCL without giving an error.
Therefore, the conclusion was to revert.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl
cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=342885&r1=342884&r2=342885&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep 24 07:21:56 
2018
@@ -369,7 +369,7 @@ def warn_implicit_function_decl : Warnin
   "implicit declaration of function %0">,
   InGroup, DefaultIgnore;
 def ext_implicit_function_decl : ExtWarn<
-  "implicit declaration of function %0 is invalid in %select{C99|OpenCL}1">,
+  "implicit declaration of function %0 is invalid in C99">,
   InGroup;
 def note_function_suggestion : Note<"did you mean %0?">;
 
@@ -8556,6 +8556,8 @@ def err_opencl_scalar_type_rank_greater_
 "element. (%0 and %1)">;
 def err_bad_kernel_param_type : Error<
   "%0 cannot be used as the type of a kernel parameter">;
+def err_opencl_implicit_function_decl : Error<
+  "implicit declaration of function %0 is invalid in OpenCL">;
 def err_record_with_pointers_kernel_param : Error<
   "%select{struct|union}0 kernel parameters may not contain pointers">;
 def note_within_field_of_type : Note<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=342885&r1=342884&r2=342885&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Sep 24 07:21:56 2018
@@ -13360,15 +13360,17 @@ NamedDecl *Sema::ImplicitlyDefineFunctio
   }
 
   // Extension in C99.  Legal in C90, but warn about it.
-  // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.
   unsigned diag_id;
   if (II.getName().startswith("__builtin_"))
 diag_id = diag::warn_builtin_unknown;
-  else if (getLangOpts().C99 || getLangOpts().OpenCL)
+  // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.
+  else if (getLangOpts().OpenCL)
+diag_id = diag::err_opencl_implicit_function_decl;
+  else if (getLangOpts().C99)
 diag_id = diag::ext_implicit_function_decl;
   else
 diag_id = diag::warn_implicit_function_decl;
-  Diag(Loc, diag_id) << &II << getLangOpts().OpenCL;
+  Diag(Loc, diag_id) << &II;
 
   // If we found a prior declaration of this function, don't bother building
   // another one. We've already pushed that one into scope, so there's nothing

Modified: cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl?rev=342885&r1=342884&r2=342885&view=diff
==
--- cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl (original)
+++ cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl Mon Sep 24 07:21:56 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fblocks -verify -pedantic-errors -fsyntax-only 
-ferror-limit 100
+// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 
100
 
 // Confirm CL2.0 Clang builtins are not available in earlier versions
 

Modified: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl?rev=342885&r1=342884&r2=342885&view=diff
==
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl (original)
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl Mon Sep 24 07:21:56 2018
@@ -10,7 +10,7 @@ void test(void) {
 
   glob = to_global(glob, loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-warning@-2{{implicit declaration of function 'to_global' is 
invalid in OpenCL}}
+  // expected-error@-2{{implicit declaration of function 'to_global' is 
invalid in OpenCL}}
   // expected-warning@-3{{incompatible integer to pointer conversion assigning 
to '__global int *' from 'int'}}
 #else
   // expected-error@-5{{invalid number of arguments to function: 'to_global'}}


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


[PATCH] D52357: [clangd] Force Dex to respect symbol collector flags

2018-09-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342866: [clangd] Force Dex to respect symbol collector flags 
(authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52357?vs=166482&id=166673#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52357

Files:
  clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
  clang-tools-extra/trunk/unittests/clangd/DexTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
@@ -583,6 +583,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(DexTest, SymbolIndexOptionsFilter) {
+  auto CodeCompletionSymbol = symbol("Completion");
+  auto NonCodeCompletionSymbol = symbol("NoCompletion");
+  CodeCompletionSymbol.Flags = Symbol::SymbolFlag::IndexedForCodeCompletion;
+  NonCodeCompletionSymbol.Flags = Symbol::SymbolFlag::None;
+  std::vector Symbols{CodeCompletionSymbol, NonCodeCompletionSymbol};
+  Dex I(Symbols, URISchemes);
+  FuzzyFindRequest Req;
+  Req.RestrictForCodeCompletion = false;
+  EXPECT_THAT(match(I, Req), ElementsAre("Completion", "NoCompletion"));
+  Req.RestrictForCodeCompletion = true;
+  EXPECT_THAT(match(I, Req), ElementsAre("Completion"));
+}
+
 TEST(DexTest, ProximityPathsBoosting) {
   auto RootSymbol = symbol("root::abc");
   RootSymbol.CanonicalDeclaration.FileURI = "unittest:///file.h";
Index: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
@@ -22,6 +22,10 @@
 
 namespace {
 
+// Mark symbols which are can be used for code completion.
+static const Token RestrictedForCodeCompletion =
+Token(Token::Kind::Sentinel, "Restricted For Code Completion");
+
 // Returns the tokens which are given symbol's characteristics. Currently, the
 // generated tokens only contain fuzzy matching trigrams and symbol's scope,
 // but in the future this will also return path proximity tokens and other
@@ -39,6 +43,8 @@
 for (const auto &ProximityURI :
  generateProximityURIs(Sym.CanonicalDeclaration.FileURI))
   Result.emplace_back(Token::Kind::ProximityURI, ProximityURI);
+  if (Sym.Flags & Symbol::IndexedForCodeCompletion)
+Result.emplace_back(RestrictedForCodeCompletion);
   return Result;
 }
 
@@ -175,6 +181,10 @@
 TopLevelChildren.push_back(createOr(move(BoostingIterators)));
   }
 
+  if (Req.RestrictForCodeCompletion)
+TopLevelChildren.push_back(
+InvertedIndex.find(RestrictedForCodeCompletion)->second.iterator());
+
   // Use TRUE iterator if both trigrams and scopes from the query are not
   // present in the symbol index.
   auto QueryIterator = TopLevelChildren.empty()


Index: clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/DexTests.cpp
@@ -583,6 +583,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(DexTest, SymbolIndexOptionsFilter) {
+  auto CodeCompletionSymbol = symbol("Completion");
+  auto NonCodeCompletionSymbol = symbol("NoCompletion");
+  CodeCompletionSymbol.Flags = Symbol::SymbolFlag::IndexedForCodeCompletion;
+  NonCodeCompletionSymbol.Flags = Symbol::SymbolFlag::None;
+  std::vector Symbols{CodeCompletionSymbol, NonCodeCompletionSymbol};
+  Dex I(Symbols, URISchemes);
+  FuzzyFindRequest Req;
+  Req.RestrictForCodeCompletion = false;
+  EXPECT_THAT(match(I, Req), ElementsAre("Completion", "NoCompletion"));
+  Req.RestrictForCodeCompletion = true;
+  EXPECT_THAT(match(I, Req), ElementsAre("Completion"));
+}
+
 TEST(DexTest, ProximityPathsBoosting) {
   auto RootSymbol = symbol("root::abc");
   RootSymbol.CanonicalDeclaration.FileURI = "unittest:///file.h";
Index: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
@@ -22,6 +22,10 @@
 
 namespace {
 
+// Mark symbols which are can be used for code completion.
+static const Token RestrictedForCodeCompletion =
+Token(Token::Kind::Sentinel, "Restricted For Code Completion");
+
 // Returns the tokens which are given symbol's characteristics. Currently, the
 // generated tokens only contain fuzzy matching trigrams and symbol's scope,
 // but in the future this will also return path proximity tokens and other
@@ -39,6 +43,8 @@
 for (const auto &ProximityURI :
  generateProximityURIs(Sym.CanonicalDeclaration.FileURI))
   Result.emplac

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-24 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D51340#1243331, @takuto.ikuta wrote:

> Ping?
>
> This patch reduced obj size largely, and I expect this makes distributed 
> build (like goma) faster by reducing data transferred on network.


I'll try to look at it this week.

Have you confirmed on some Chromium file, e.g. stroke_opacity_custom.cc 
(go/stroke-opactity-custom) that the number of functions that we codegen 
decreases as expected? I'd expect this to save a lot of compile time.


https://reviews.llvm.org/D51340



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


[PATCH] D52390: [analyzer] StackSizeChecker

2018-09-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D52390#1243228, @mate1214 wrote:

> Hi @lebedev.ri!
>
> Thanks for the question. I was not sure as to where exactly put the files. 
> The important thing for me is that the `StackUsageMeasuringVisitor` should be 
> reachable from the clang-tidy checker. (For the bigger picture please refer 
> to my answer to @Szelethus). I was not able to find documentation I could use 
> to put the extra logic in the right place (may be my fault). Any suggestions 
> and references are welcome!


Reachable *how*?
Is clang-tidy check using this very same logic?
For recent examples, see ExprMutationAnalyzer, how it is structured (especially 
the tests, they are **so** nice!).
It started in clang-tidy, but then was promoted to analysis/.
So i'm wondering if the same should happen here, too.


Repository:
  rC Clang

https://reviews.llvm.org/D52390



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support

2018-09-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

...and to reword this a bit: Clang taking a long time to start up in some 
configurations is a bug we should profile and fix :-)


Repository:
  rC Clang

https://reviews.llvm.org/D52193



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


[PATCH] D52420: [clangd] Fix crash if pending computations were active on exit

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, ioeric.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.

Make sure JSONRPCDispatcher outlives the worker threads, they access
its fields to remove the stored cancellations when Context dies.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52420

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h

Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -19,6 +19,7 @@
 #include "ProtocolHandlers.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -170,7 +171,9 @@
   // Server must be the last member of the class to allow its destructor to exit
   // the worker thread that may otherwise run an async callback on partially
   // destructed instance of ClangdLSPServer.
-  ClangdServer Server;
+  // Set in construtor and destroyed when run() finishes. To ensure all worker
+  // threads exit before run() returns.
+  std::unique_ptr Server;
 };
 } // namespace clangd
 } // namespace clang
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "ClangdLSPServer.h"
+#include "ClangdServer.h"
 #include "Diagnostics.h"
 #include "JSONRPCDispatcher.h"
 #include "SourceCode.h"
@@ -77,9 +78,9 @@
 applyConfiguration(*Params.initializationOptions);
 
   if (Params.rootUri && *Params.rootUri)
-Server.setRootPath(Params.rootUri->file());
+Server->setRootPath(Params.rootUri->file());
   else if (Params.rootPath && !Params.rootPath->empty())
-Server.setRootPath(*Params.rootPath);
+Server->setRootPath(*Params.rootPath);
 
   CCOpts.EnableSnippets =
   Params.capabilities.textDocument.completion.completionItem.snippetSupport;
@@ -147,7 +148,7 @@
   std::string &Contents = Params.textDocument.text;
 
   DraftMgr.addDraft(File, Contents);
-  Server.addDocument(File, Contents, WantDiagnostics::Yes);
+  Server->addDocument(File, Contents, WantDiagnostics::Yes);
 }
 
 void ClangdLSPServer::onDocumentDidChange(DidChangeTextDocumentParams &Params) {
@@ -164,17 +165,17 @@
 // the client.  It is better to remove the draft and let further operations
 // fail rather than giving wrong results.
 DraftMgr.removeDraft(File);
-Server.removeDocument(File);
+Server->removeDocument(File);
 CDB.invalidate(File);
 elog("Failed to update {0}: {1}", File, Contents.takeError());
 return;
   }
 
-  Server.addDocument(File, *Contents, WantDiags);
+  Server->addDocument(File, *Contents, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams &Params) {
-  Server.onFileEvent(Params);
+  Server->onFileEvent(Params);
 }
 
 void ClangdLSPServer::onCommand(ExecuteCommandParams &Params) {
@@ -210,7 +211,7 @@
 }
 
 void ClangdLSPServer::onWorkspaceSymbol(WorkspaceSymbolParams &Params) {
-  Server.workspaceSymbols(
+  Server->workspaceSymbols(
   Params.query, CCOpts.Limit,
   [this](llvm::Expected> Items) {
 if (!Items)
@@ -230,7 +231,7 @@
 return replyError(ErrorCode::InvalidParams,
   "onRename called for non-added file");
 
-  Server.rename(
+  Server->rename(
   File, Params.position, Params.newName,
   [File, Code,
Params](llvm::Expected> Replacements) {
@@ -252,7 +253,7 @@
 void ClangdLSPServer::onDocumentDidClose(DidCloseTextDocumentParams &Params) {
   PathRef File = Params.textDocument.uri.file();
   DraftMgr.removeDraft(File);
-  Server.removeDocument(File);
+  Server->removeDocument(File);
   CDB.invalidate(File);
 }
 
@@ -264,7 +265,7 @@
 return replyError(ErrorCode::InvalidParams,
   "onDocumentOnTypeFormatting called for non-added file");
 
-  auto ReplacementsOrError = Server.formatOnType(*Code, File, Params.position);
+  auto ReplacementsOrError = Server->formatOnType(*Code, File, Params.position);
   if (ReplacementsOrError)
 reply(json::Array(replacementsToEdits(*Code, ReplacementsOrError.get(;
   else
@@ -280,7 +281,7 @@
 return replyError(ErrorCode::InvalidParams,
   "onDocumentRangeFormatting called for non-added file");
 
-  auto ReplacementsOrError = Server.formatRange(*Code, File, Params.range);
+  auto ReplacementsOrError = Server->formatRange(*Code, File, Params.range);
   if (ReplacementsOrError)
 reply(json::Array(replacementsToEdits(*Code, ReplacementsOrError.get(;
   else
@@ -295,16 +296,16 @@
 return replyError(ErrorCode::InvalidParams,
   "onDocumentFormatting called for non-added file");
 
-  auto ReplacementsOrError = Server.formatFile(*Code, File);
+  auto ReplacementsOrError = Server->fo

[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdUnit.cpp:119
 
+/// Collect and cache all file status from the underlying file system.
+class CollectStatCacheVFS : public vfs::FileSystem {

Would it make sense to add a `clang::vfs::ProxyFS` that proxies calls to 
underlying FS by default and allows to override some methods?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419



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


[PATCH] D51041: [clang-tidy] Don't run misc-unused-using-decls check in C++17.

2018-09-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: test/clang-tidy/misc-unused-using-decls-cxx17.cpp:1
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- 
-fno-delayed-template-parsing -std=gnu++17
+

why gnu++17 and not standard?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51041



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


[clang-tools-extra] r342888 - [clangd] Do bounds checks while reading data, otherwise var-length records are too painful. NFC

2018-09-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Sep 24 07:51:15 2018
New Revision: 342888

URL: http://llvm.org/viewvc/llvm-project?rev=342888&view=rev
Log:
[clangd] Do bounds checks while reading data, otherwise var-length records are 
too painful. NFC

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

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=342888&r1=342887&r2=342888&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Mon Sep 24 07:51:15 
2018
@@ -23,24 +23,83 @@ Error makeError(const Twine &Msg) {
 
 // IO PRIMITIVES
 // We use little-endian 32 bit ints, sometimes with variable-length encoding.
+//
+// Variable-length int encoding (varint) uses the bottom 7 bits of each byte
+// to encode the number, and the top bit to indicate whether more bytes follow.
+// e.g. 9a 2f means [0x1a and keep reading, 0x2f and stop].
+// This represents 0x1a | 0x2f<<7 = 6042.
+// A 32-bit integer takes 1-5 bytes to encode; small numbers are more compact.
 
-StringRef consume(StringRef &Data, int N) {
-  StringRef Ret = Data.take_front(N);
-  Data = Data.drop_front(N);
-  return Ret;
-}
+// Reads binary data from a StringRef, and keeps track of position.
+class Reader {
+  const char *Begin, *End;
+  bool Err;
 
-uint8_t consume8(StringRef &Data) {
-  uint8_t Ret = Data.front();
-  Data = Data.drop_front();
-  return Ret;
-}
+public:
+  Reader(StringRef Data) : Begin(Data.begin()), End(Data.end()) {}
+  // The "error" bit is set by reading past EOF or reading invalid data.
+  // When in an error state, reads may return zero values: callers should 
check.
+  bool err() const { return Err; }
+  // Did we read all the data, or encounter an error?
+  bool eof() const { return Begin == End || Err; }
+  // All the data we didn't read yet.
+  StringRef rest() const { return StringRef(Begin, End - Begin); }
+
+  uint8_t consume8() {
+if (LLVM_UNLIKELY(Begin == End)) {
+  Err = true;
+  return 0;
+}
+return *Begin++;
+  }
 
-uint32_t consume32(StringRef &Data) {
-  auto Ret = support::endian::read32le(Data.bytes_begin());
-  Data = Data.drop_front(4);
-  return Ret;
-}
+  uint32_t consume32() {
+if (LLVM_UNLIKELY(Begin + 4 > End)) {
+  Err = true;
+  return 0;
+}
+auto Ret = support::endian::read32le(Begin);
+Begin += 4;
+return Ret;
+  }
+
+  StringRef consume(int N) {
+if (LLVM_UNLIKELY(Begin + N > End)) {
+  Err = true;
+  return StringRef();
+}
+StringRef Ret(Begin, N);
+Begin += N;
+return Ret;
+  }
+
+  uint32_t consumeVar() {
+constexpr static uint8_t More = 1 << 7;
+uint8_t B = consume8();
+if (LLVM_LIKELY(!(B & More)))
+  return B;
+uint32_t Val = B & ~More;
+for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
+  B = consume8();
+  Val |= (B & ~More) << Shift;
+}
+return Val;
+  }
+
+  StringRef consumeString(ArrayRef Strings) {
+auto StringIndex = consumeVar();
+if (LLVM_UNLIKELY(StringIndex >= Strings.size())) {
+  Err = true;
+  return StringRef();
+}
+return Strings[StringIndex];
+  }
+
+  SymbolID consumeID() {
+StringRef Raw = consume(SymbolID::RawSize); // short if truncated.
+return LLVM_UNLIKELY(err()) ? SymbolID() : SymbolID::fromRaw(Raw);
+  }
+};
 
 void write32(uint32_t I, raw_ostream &OS) {
   char buf[4];
@@ -48,11 +107,6 @@ void write32(uint32_t I, raw_ostream &OS
   OS.write(buf, sizeof(buf));
 }
 
-// Variable-length int encoding (varint) uses the bottom 7 bits of each byte
-// to encode the number, and the top bit to indicate whether more bytes follow.
-// e.g. 9a 2f means [0x1a and keep reading, 0x2f and stop].
-// This represents 0x1a | 0x2f<<7 = 6042.
-// A 32-bit integer takes 1-5 bytes to encode; small numbers are more compact.
 void writeVar(uint32_t I, raw_ostream &OS) {
   constexpr static uint8_t More = 1 << 7;
   if (LLVM_LIKELY(I < 1 << 7)) {
@@ -69,19 +123,6 @@ void writeVar(uint32_t I, raw_ostream &O
   }
 }
 
-uint32_t consumeVar(StringRef &Data) {
-  constexpr static uint8_t More = 1 << 7;
-  uint8_t B = consume8(Data);
-  if (LLVM_LIKELY(!(B & More)))
-return B;
-  uint32_t Val = B & ~More;
-  for (int Shift = 7; B & More && Shift < 32; Shift += 7) {
-B = consume8(Data);
-Val |= (B & ~More) << Shift;
-  }
-  return Val;
-}
-
 // STRING TABLE ENCODING
 // Index data has many string fields, and many strings are identical.
 // We store each string once, and refer to them by index.
@@ -146,30 +187,34 @@ struct StringTableIn {
 };
 
 Expected readStringTable(StringRef Data) {
-  if (Data.size() < 4)
-return makeError("Bad string table: not enough metadata");
-  size_t UncompressedSize = consume32(Data);
+  Reader R(Data);
+  size_t Uncompres

[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: lebedev.ri, rsmith, dblaikie.

This patch diagnoses parameter names that shadow the names of inherited fields 
under -Wshadow-field. It addresses PR34120. Note, unlike GCC, we take into 
account the accessibility of the field when deciding whether to warn or not.


https://reviews.llvm.org/D52421

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -222,3 +222,23 @@
   };
 }
 }
+
+namespace PR34120 {
+struct A {
+  int B; // expected-note {{declared here}}
+};
+
+class C : public A {
+  void D(int B) {} // expected-warning {{parameter 'B' shadows member inherited from type 'A'}}
+  void E() {
+extern void f(int B); // Ok
+  }
+};
+
+class Private {
+  int B;
+};
+class Derived : Private {
+  void D(int B) {} // Ok
+};
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2852,7 +2852,8 @@
 // Check if there is a field shadowing.
 void Sema::CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD) {
+  const CXXRecordDecl *RD,
+  bool DeclIsField) {
   if (Diags.isIgnored(diag::warn_shadow_field, Loc))
 return;
 
@@ -2892,7 +2893,7 @@
 if (AS_none !=
 CXXRecordDecl::MergeAccess(P.Access, BaseField->getAccess())) {
   Diag(Loc, diag::warn_shadow_field)
-<< FieldName << RD << Base;
+<< FieldName << RD << Base << DeclIsField;
   Diag(BaseField->getLocation(), diag::note_shadow_field);
   Bases.erase(It);
 }
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12379,6 +12379,13 @@
 }
   }
 
+  if (LangOpts.CPlusPlus && II) {
+DeclarationNameInfo DNI = GetNameForDeclarator(D);
+if (auto *RD = dyn_cast(CurContext))
+  CheckShadowInheritedFields(DNI.getLoc(), DNI.getName(), RD,
+ /*DeclIsField*/ false);
+  }
+
   // Temporarily put parameter variables in the translation unit, not
   // the enclosing context.  This prevents them from accidentally
   // looking like class members in C++.
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -10524,7 +10524,8 @@
   /// Check if there is a field shadowing.
   void CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD);
+  const CXXRecordDecl *RD,
+  bool DeclIsField = true);
 
   /// Check if the given expression contains 'break' or 'continue'
   /// statement that produces control flow different from GCC.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -9418,10 +9418,9 @@
   "__final is a GNU extension, consider using C++11 final">,
   InGroup;
 
-def warn_shadow_field :
-  Warning<"non-static data member %0 of %1 shadows member inherited from "
-  "type %2">,
-  InGroup, DefaultIgnore;
+def warn_shadow_field : Warning<
+  "%select{parameter|non-static data member}3 %0 %select{|of %1 }3shadows "
+  "member inherited from type %2">, InGroup, DefaultIgnore;
 def note_shadow_field : Note<"declared here">;
 
 def err_multiversion_required_in_redecl : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342889 - [VFS] Use llvm::StringMap instead of std::map. NFC

2018-09-24 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Sep 24 07:52:11 2018
New Revision: 342889

URL: http://llvm.org/viewvc/llvm-project?rev=342889&view=rev
Log:
[VFS] Use llvm::StringMap instead of std::map. NFC

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=342889&r1=342888&r2=342889&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Sep 24 07:52:11 2018
@@ -566,7 +566,7 @@ public:
 
 class InMemoryDirectory : public InMemoryNode {
   Status Stat;
-  std::map> Entries;
+  llvm::StringMap> Entries;
 
 public:
   InMemoryDirectory(Status Stat)


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


r342890 - [CFString][ELF] Fix a missed test causing buildbot failures from 342883.

2018-09-24 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Mon Sep 24 07:52:48 2018
New Revision: 342890

URL: http://llvm.org/viewvc/llvm-project?rev=342890&view=rev
Log:
[CFString][ELF] Fix a missed test causing buildbot failures from 342883.

Accidetanlly forgot to update it, big sorry.


Modified:
cfe/trunk/test/CodeGen/CFStrings.c

Modified: cfe/trunk/test/CodeGen/CFStrings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=342890&r1=342889&r2=342890&view=diff
==
--- cfe/trunk/test/CodeGen/CFStrings.c (original)
+++ cfe/trunk/test/CodeGen/CFStrings.c Mon Sep 24 07:52:48 2018
@@ -22,7 +22,7 @@ const CFStringRef one = (CFStringRef)__b
 const CFStringRef two = 
(CFStringRef)__builtin___CFStringMakeConstantString("\xef\xbf\xbd\x74\xef\xbf\xbd\x77\xef\xbf\xbd\x6f");
 
 // CHECK-COFF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 
1
-// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1
+// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", 
section ".rodata", align 1
 // CHECK-MACHO: @.str = private unnamed_addr constant [4 x i8] c"one\00", 
section "__TEXT,__cstring,cstring_literals", align 1
 
 // CHECK-COFF: @_unnamed_cfstring_ = private global 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, 
section "cfstring", align {{[48]}}
@@ -32,7 +32,7 @@ const CFStringRef two = (CFStringRef)__b
 // CHECK-MACHO64: @_unnamed_cfstring_ = private global 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3 }, 
section "__DATA,__cfstring", align 8
 
 // CHECK-COFF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], align 2
-// CHECK-ELF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], align 2
+// CHECK-ELF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], section ".rodata", align 2
 // CHECK-MACHO: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 
116, i16 -3, i16 119, i16 -3, i16 111, i16 0], section "__TEXT,__ustring", 
align 2
 
 // CHECK-COFF: @_unnamed_cfstring_.2 = private global 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 2000, i8* bitcast 
([7 x i16]* @.str.1 to i8*), i32 6 }, section "cfstring", align {{[48]}}


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


[PATCH] D52422: [clangd] Handle template args for disabled function arg snippets

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: kadircet, ioeric, sammccall.
Herald added subscribers: arphaman, jkorous, MaskRay.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52422

Files:
  clangd/CodeComplete.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1741,32 +1741,65 @@
   CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;
   Opts.EnableFunctionArgSnippets = false;
-  const std::string Header =
-  R"cpp(
+
+  {
+auto Results = completions(
+R"cpp(
   void xfoo();
   void xfoo(int x, int y);
-  void xbar();
-  void f() {
-)cpp";
-  {
-auto Results = completions(Header + "\nxfo^", {}, Opts);
+  void f() { xfo^ })cpp",
+{}, Opts);
 EXPECT_THAT(
 Results.Completions,
 UnorderedElementsAre(AllOf(Named("xfoo"), SnippetSuffix("()")),
  AllOf(Named("xfoo"), SnippetSuffix("($0)";
   }
   {
-auto Results = completions(Header + "\nxba^", {}, Opts);
+auto Results = completions(
+R"cpp(
+  void xbar();
+  void f() { xba^ })cpp",
+{}, Opts);
 EXPECT_THAT(Results.Completions, UnorderedElementsAre(AllOf(
  Named("xbar"), SnippetSuffix("()";
   }
   {
 Opts.BundleOverloads = true;
-auto Results = completions(Header + "\nxfo^", {}, Opts);
+auto Results = completions(
+R"cpp(
+  void xfoo();
+  void xfoo(int x, int y);
+  void f() { xfo^ })cpp",
+{}, Opts);
 EXPECT_THAT(
 Results.Completions,
 UnorderedElementsAre(AllOf(Named("xfoo"), SnippetSuffix("($0)";
   }
+  {
+auto Results = completions(
+R"cpp(
+  template 
+  void xfoo(int a, U b);
+  void f() { xfo^ })cpp",
+{}, Opts);
+EXPECT_THAT(
+Results.Completions,
+UnorderedElementsAre(AllOf(Named("xfoo"), SnippetSuffix("<$1>($0)";
+  }
+  {
+auto Results = completions(
+R"cpp(
+  template 
+  class foo_class{};
+  template 
+  using foo_alias = T**;
+  void f() { foo_^ })cpp",
+{}, Opts);
+EXPECT_THAT(
+Results.Completions,
+UnorderedElementsAre(AllOf(Named("foo_class"), SnippetSuffix("<$0>")),
+ AllOf(Named("foo_alias"), SnippetSuffix("<$0>";
+  }
 }
 
 TEST(CompletionTest, SuggestOverrides) {
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -46,6 +46,7 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -482,13 +483,43 @@
 auto *Snippet = onlyValue<&BundledEntry::SnippetSuffix>();
 if (!Snippet)
   // All bundles are function calls.
+  // FIXME(ibiryukov): sometimes add template arguments to a snippet, e.g.
+  // we need to complete 'forward<$1>($0)'.
   return "($0)";
-if (!Snippet->empty() && !EnableFunctionArgSnippets &&
-((Completion.Kind == CompletionItemKind::Function) ||
- (Completion.Kind == CompletionItemKind::Method)) &&
-(Snippet->front() == '(') && (Snippet->back() == ')'))
-  // Check whether function has any parameters or not.
-  return Snippet->size() > 2 ? "($0)" : "()";
+if (EnableFunctionArgSnippets)
+  return *Snippet;
+
+// Replace argument snippets with a simplified pattern.
+if (Snippet->empty())
+  return "";
+if (Completion.Kind == CompletionItemKind::Function ||
+Completion.Kind == CompletionItemKind::Method) {
+  // Functions snippets can be of 2 types:
+  // - containing only function arguments, e.g.
+  //   foo(${1:int p1}, ${2:int p2});
+  //   We transform this pattern to '($0)' or '()'.
+  // - template arguments and function arguments, e.g.
+  //   foo<${1:class}>(${2:int p1}).
+  //   We transform this pattern to '<$1>($0)' or '<$0>()'.
+
+  bool EmptyArgs = llvm::StringRef(*Snippet).endswith("()");
+  if (Snippet->front() == '<')
+return EmptyArgs ? "<$0>()" : "<$1>($0)";
+  if (Snippet->front() == '(')
+return EmptyArgs ? "()" : "($0)";
+  return *Snippet; // Not an arg snippet?
+}
+if (Completion.Kind == CompletionItemKind::Reference ||
+Completion.Kind == CompletionItemKind::Class) {
+  if (Snippet->front() != '<')
+return *Snippet; // Not an arg snippet?
+
+  // Classes and template using aliases can only have template arguments,
+  // e.g. Foo<${1:class}>.
+  if (llvm::StringRef(*Snippet).endsw

[PATCH] D52423: Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy created this revision.
donat.nagy added a reviewer: dergachev.a.
Herald added a subscriber: cfe-commits.

ConversionChecker produces false positives when it encounters the
idiomatic usage of certain well-known functions (e.g. getc() and the
character classification functions like isalpha()). To eliminate these
false positives, the analyzer needs some information about semantics of
these functions. This functionality have been implemented already in
StdCLibraryFunctionsChecker, so we simply load that automatically when
ConversionChecker is loaded.


Repository:
  rC Clang

https://reviews.llvm.org/D52423

Files:
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
  test/Analysis/conversion.c


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -138,15 +138,14 @@
 }
 
 
-// false positives..
+// old false positives..
 
 int isascii(int c);
 void falsePositive1() {
   char kb2[5];
   int X = 1000;
   if (isascii(X)) {
-// FIXME: should not warn here:
-kb2[0] = X; // expected-warning {{Loss of precision}}
+kb2[0] = X; // no-warning
   }
 }
 
@@ -175,8 +174,7 @@
   if (c == EOF)
 return(4);
   if (cp < &reply_string[sizeof(reply_string) - 1])
-// FIXME: should not warn here:
-*cp++ = c; // expected-warning {{Loss of precision}}
+*cp++ = c; // no-warning
 }
   }
 }
Index: lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
===
--- lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
+++ lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
@@ -23,5 +23,8 @@
 /// Register the part of MallocChecker connected to InnerPointerChecker.
 void registerInnerPointerCheckerAux(CheckerManager &Mgr);
 
+/// Register evaluation of some basic C standard library functions.
+void registerStdCLibraryFunctionsChecker(CheckerManager &mgr);
+
 }}
 #endif /* INTERCHECKERAPI_H_ */
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -23,6 +23,7 @@
 //
 
//===--===//
 #include "ClangSACheckers.h"
+#include "InterCheckerAPI.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -159,5 +160,6 @@
 }
 
 void ento::registerConversionChecker(CheckerManager &mgr) {
+  registerStdCLibraryFunctionsChecker(mgr);
   mgr.registerChecker();
 }


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -138,15 +138,14 @@
 }
 
 
-// false positives..
+// old false positives..
 
 int isascii(int c);
 void falsePositive1() {
   char kb2[5];
   int X = 1000;
   if (isascii(X)) {
-// FIXME: should not warn here:
-kb2[0] = X; // expected-warning {{Loss of precision}}
+kb2[0] = X; // no-warning
   }
 }
 
@@ -175,8 +174,7 @@
   if (c == EOF)
 return(4);
   if (cp < &reply_string[sizeof(reply_string) - 1])
-// FIXME: should not warn here:
-*cp++ = c; // expected-warning {{Loss of precision}}
+*cp++ = c; // no-warning
 }
   }
 }
Index: lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
===
--- lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
+++ lib/StaticAnalyzer/Checkers/InterCheckerAPI.h
@@ -23,5 +23,8 @@
 /// Register the part of MallocChecker connected to InnerPointerChecker.
 void registerInnerPointerCheckerAux(CheckerManager &Mgr);
 
+/// Register evaluation of some basic C standard library functions.
+void registerStdCLibraryFunctionsChecker(CheckerManager &mgr);
+
 }}
 #endif /* INTERCHECKERAPI_H_ */
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -23,6 +23,7 @@
 //
 //===--===//
 #include "ClangSACheckers.h"
+#include "InterCheckerAPI.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -159,5 +160,6 @@
 }
 
 void ento::registerConversionChecker(CheckerManager &mgr) {
+  registerStdCLibraryFunctionsChecker(mgr);
   mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52420: [clangd] Fix crash if pending computations were active on exit

2018-09-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:483
+  // Destroy ClangdServer to ensure all worker threads finish.
+  Server.reset();
 

This woudn't work if `run()` is called multiple times. Maybe create a `Server` 
in each `run()`? 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52420



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


r342893 - Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`."

2018-09-24 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Mon Sep 24 08:26:08 2018
New Revision: 342893

URL: http://llvm.org/viewvc/llvm-project?rev=342893&view=rev
Log:
Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with 
`-fconstant-cfstrings`."

Seems to be causing buildbot failures, need to look into it.


Removed:
cfe/trunk/test/CodeGen/cfstring-elf.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/CFStrings.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=342893&r1=342892&r2=342893&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 24 08:26:08 2018
@@ -4109,48 +4109,37 @@ CodeGenModule::GetAddrOfConstantCFString
 
   llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
   llvm::Constant *Zeros[] = { Zero, Zero };
-  
+
   // If we don't already have it, get __CFConstantStringClassReference.
   if (!CFConstantStringClassRef) {
 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
 Ty = llvm::ArrayType::get(Ty, 0);
-llvm::Constant *C =
-CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
-
-if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) {
-  llvm::GlobalValue *GV = nullptr;
-  
-  if ((GV = dyn_cast(C))) {
-IdentifierInfo &II = getContext().Idents.get(GV->getName());
-TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
-DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
-
-const VarDecl *VD = nullptr;
-for (const auto &Result : DC->lookup(&II))
-  if ((VD = dyn_cast(Result)))
-break;
-  
-if (getTriple().isOSBinFormatELF()) {
-  if (!VD)
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-}
-else {
-  if (!VD || !VD->hasAttr()) {
-GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-  } else {
-GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-  }
-}
-
-setDSOLocal(GV);
+llvm::GlobalValue *GV = cast(
+CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"));
+
+if (getTriple().isOSBinFormatCOFF()) {
+  IdentifierInfo &II = getContext().Idents.get(GV->getName());
+  TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
+  DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
+
+  const VarDecl *VD = nullptr;
+  for (const auto &Result : DC->lookup(&II))
+if ((VD = dyn_cast(Result)))
+  break;
+
+  if (!VD || !VD->hasAttr()) {
+GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  } else {
+GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
 }
-  
+setDSOLocal(GV);
+
 // Decay array -> ptr
 CFConstantStringClassRef =
-llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros);
+llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
   }
 
   QualType CFTy = getContext().getCFConstantStringType();
@@ -4196,11 +4185,7 @@ CodeGenModule::GetAddrOfConstantCFString
   if (getTriple().isOSBinFormatMachO())
 GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
-  // Make sure the literal ends up in .rodata to allow for safe ICF and for
-  // the static linker to adjust permissions to read-only later on.
-  else if (getTriple().isOSBinFormatELF())
-GV->setSection(".rodata");
-  
+
   // String.
   llvm::Constant *Str =
   llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);

Modified: cfe/trunk/test/CodeGen/CFStrings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=342893&r1=342892&r2=342893&view=diff
==
--- cfe/trunk/test/CodeGen/CFStrings.c (original)
+++ cfe/trunk/test/CodeGen/CFStrings.c Mon Sep 24 08:26:08 2018
@@ -22,7 +22,7 @@ const CFStringRef one = (CFStringRef)__b
 const CFStringRef two = 
(CFStringRef)__builtin___CFStringMakeConstantString("\xef\xbf\xbd\x74\xef\xbf\xbd\x77\xef\xbf\xbd\x6f");
 
 // CHECK-COFF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 
1
-// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", 
section ".rodata", align 1
+// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1
 // CHECK-MACHO: @.str = private unnamed_addr constant

[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus edited reviewers, added: NoQ; removed: dergachev.a.
Szelethus added a comment.

Cool!




Comment at: test/Analysis/conversion.c:141
 
-// false positives..
+// old false positives..
 

I think this comment is no longer relevant ^-^


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D51432: [AArch64] Unwinding support for return address signing

2018-09-24 Thread Luke Cheeseman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342895: [AArch64] Unwinding support for return address 
signing (authored by LukeCheeseman, committed by ).
Herald added subscribers: llvm-commits, christof.

Changed prior to commit:
  https://reviews.llvm.org/D51432?vs=165775&id=166700#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51432

Files:
  libunwind/trunk/include/libunwind.h
  libunwind/trunk/src/DwarfInstructions.hpp
  libunwind/trunk/src/DwarfParser.hpp
  libunwind/trunk/src/Registers.hpp
  libunwind/trunk/src/dwarf2.h

Index: libunwind/trunk/src/DwarfInstructions.hpp
===
--- libunwind/trunk/src/DwarfInstructions.hpp
+++ libunwind/trunk/src/DwarfInstructions.hpp
@@ -198,6 +198,24 @@
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+  // If the target is aarch64 then the return address may have been signed
+  // using the v8.3 pointer authentication extensions. The original
+  // return address needs to be authenticated before the return address is
+  // restored. autia1716 is used instead of autia as autia1716 assembles
+  // to a NOP on pre-v8.3a architectures.
+  if (prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value) {
+#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+return UNW_ECROSSRASIGNING;
+#else
+register unsigned long long x17 __asm("x17") = returnAddress;
+register unsigned long long x16 __asm("x16") = cfa;
+asm("autia1716": "+r"(x17): "r"(x16));
+returnAddress = x17;
+#endif
+  }
+#endif
+
   // Return address is address after call site instruction, so setting IP to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);
Index: libunwind/trunk/src/dwarf2.h
===
--- libunwind/trunk/src/dwarf2.h
+++ libunwind/trunk/src/dwarf2.h
@@ -49,7 +49,10 @@
   // GNU extensions
   DW_CFA_GNU_window_save  = 0x2D,
   DW_CFA_GNU_args_size= 0x2E,
-  DW_CFA_GNU_negative_offset_extended = 0x2F
+  DW_CFA_GNU_negative_offset_extended = 0x2F,
+
+  // AARCH64 extensions
+  DW_CFA_AARCH64_negate_ra_state  = 0x2D
 };
 
 
Index: libunwind/trunk/src/DwarfParser.hpp
===
--- libunwind/trunk/src/DwarfParser.hpp
+++ libunwind/trunk/src/DwarfParser.hpp
@@ -666,6 +666,14 @@
   _LIBUNWIND_TRACE_DWARF(
   "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
   break;
+
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+case DW_CFA_AARCH64_negate_ra_state:
+  results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^= 0x1;
+  _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n");
+  break;
+#endif
+
 default:
   operand = opcode & 0x3F;
   switch (opcode & 0xC0) {
Index: libunwind/trunk/src/Registers.hpp
===
--- libunwind/trunk/src/Registers.hpp
+++ libunwind/trunk/src/Registers.hpp
@@ -1786,7 +1786,7 @@
 uint64_t __lr;// Link register x30
 uint64_t __sp;// Stack pointer x31
 uint64_t __pc;// Program counter
-uint64_t padding; // 16-byte align
+uint64_t __ra_sign_state; // RA sign state register
   };
 
   GPRs_registers;
@@ -1822,6 +1822,8 @@
 return false;
   if (regNum > 95)
 return false;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return true;
   if ((regNum > 31) && (regNum < 64))
 return false;
   return true;
@@ -1832,16 +1834,21 @@
 return _registers.__pc;
   if (regNum == UNW_REG_SP)
 return _registers.__sp;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return _registers.__ra_sign_state;
   if ((regNum >= 0) && (regNum < 32))
 return _registers.__x[regNum];
+
   _LIBUNWIND_ABORT("unsupported arm64 register");
 }
 
 inline void Registers_arm64::setRegister(int regNum, uint64_t value) {
   if (regNum == UNW_REG_IP)
 _registers.__pc = value;
   else if (regNum == UNW_REG_SP)
 _registers.__sp = value;
+  else if (regNum == UNW_ARM64_RA_SIGN_STATE)
+_registers.__ra_sign_state = value;
   else if ((regNum >= 0) && (regNum < 32))
 _registers.__x[regNum] = value;
   else
Index: libunwind/trunk/include/libunwind.h
===
--- libunwind/trunk/include/libunwind.h
+++ libunwind/trunk/include/libunwind.h
@@ -57,6 +57,9 @@
   UNW_EINVAL= -6547, /* unsupported operation or bad value */
   UNW_EBADVERSION   = -6548, /* unwind info has unsupported version */
   UNW_ENOINFO   = -6549  /* no unwind info found */
+#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  , UNW_ECROSSRASIGNING = -6550 /* cross unwind with return address signing */
+#endif
 };
 
 struct unw_context_t {
@@ -547,6 +550,8 @@
   UNW_ARM64_

[libunwind] r342895 - [AArch64] Unwinding support for return address signing

2018-09-24 Thread Luke Cheeseman via cfe-commits
Author: lukecheeseman
Date: Mon Sep 24 08:55:35 2018
New Revision: 342895

URL: http://llvm.org/viewvc/llvm-project?rev=342895&view=rev
Log:
[AArch64] Unwinding support for return address signing

- When return address signing is enabled, the LR may be signed on function entry
- When an exception is thrown the return address is inspected used to unwind 
the call stack
- Before this happens, the return address must be correctly authenticated to 
avoid causing an abort by dereferencing the signed pointer

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


Modified:
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/dwarf2.h

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Mon Sep 24 08:55:35 2018
@@ -57,6 +57,9 @@ enum {
   UNW_EINVAL= -6547, /* unsupported operation or bad value */
   UNW_EBADVERSION   = -6548, /* unwind info has unsupported version */
   UNW_ENOINFO   = -6549  /* no unwind info found */
+#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  , UNW_ECROSSRASIGNING = -6550 /* cross unwind with return address signing */
+#endif
 };
 
 struct unw_context_t {
@@ -547,6 +550,8 @@ enum {
   UNW_ARM64_X31 = 31,
   UNW_ARM64_SP  = 31,
   // reserved block
+  UNW_ARM64_RA_SIGN_STATE = 34,
+  // reserved block
   UNW_ARM64_D0  = 64,
   UNW_ARM64_D1  = 65,
   UNW_ARM64_D2  = 66,

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Mon Sep 24 08:55:35 2018
@@ -198,6 +198,24 @@ int DwarfInstructions::stepWithDwa
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+  // If the target is aarch64 then the return address may have been signed
+  // using the v8.3 pointer authentication extensions. The original
+  // return address needs to be authenticated before the return address is
+  // restored. autia1716 is used instead of autia as autia1716 assembles
+  // to a NOP on pre-v8.3a architectures.
+  if (prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value) {
+#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+return UNW_ECROSSRASIGNING;
+#else
+register unsigned long long x17 __asm("x17") = returnAddress;
+register unsigned long long x16 __asm("x16") = cfa;
+asm("autia1716": "+r"(x17): "r"(x16));
+returnAddress = x17;
+#endif
+  }
+#endif
+
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Mon Sep 24 08:55:35 2018
@@ -666,6 +666,14 @@ bool CFI_Parser::parseInstructions(A
   _LIBUNWIND_TRACE_DWARF(
   "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
   break;
+
+#if defined(_LIBUNWIND_TARGET_AARCH64)
+case DW_CFA_AARCH64_negate_ra_state:
+  results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^= 0x1;
+  _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n");
+  break;
+#endif
+
 default:
   operand = opcode & 0x3F;
   switch (opcode & 0xC0) {

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=342895&r1=342894&r2=342895&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Mon Sep 24 08:55:35 2018
@@ -1786,7 +1786,7 @@ private:
 uint64_t __lr;// Link register x30
 uint64_t __sp;// Stack pointer x31
 uint64_t __pc;// Program counter
-uint64_t padding; // 16-byte align
+uint64_t __ra_sign_state; // RA sign state register
   };
 
   GPRs_registers;
@@ -1822,6 +1822,8 @@ inline bool Registers_arm64::validRegist
 return false;
   if (regNum > 95)
 return false;
+  if (regNum == UNW_ARM64_RA_SIGN_STATE)
+return true;
   if ((regNum > 31) && (regNum < 64))
 return false;
   retur

[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-24 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.

In https://reviews.llvm.org/D50171#1236792, @mgorny wrote:

> @ilya-biryukov, gentle ping. I'd like to patch this for 7.0.0 in Gentoo. Do 
> you think my patch would be good enough, or do you expect to submit something 
> else soonish?


Sorry about the delay.
LGTM to allow committing/cherrypicking. I'll make sure to investigate why the 
change was there and explain/fix this case and update this thread.


https://reviews.llvm.org/D50171



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


r342897 - [python] [tests] Update test_code_completion

2018-09-24 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Sep 24 09:10:25 2018
New Revision: 342897

URL: http://llvm.org/viewvc/llvm-project?rev=342897&view=rev
Log:
[python] [tests] Update test_code_completion

Update expected completions to match output generated by clang-7.0.

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

Modified:
cfe/trunk/bindings/python/tests/cindex/test_code_completion.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_code_completion.py?rev=342897&r1=342896&r2=342897&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py Mon Sep 24 
09:10:25 2018
@@ -61,11 +61,11 @@ void f(P x, Q y) {
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available 
|| Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


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


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-24 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342897: [python] [tests] Update test_code_completion 
(authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50171?vs=164871&id=166703#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50171

Files:
  cfe/trunk/bindings/python/tests/cindex/test_code_completion.py


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available 
|| Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50171: [python] [tests] Update test_code_completion

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

Thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D50171



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


[libunwind] r342901 - Reverting r342895

2018-09-24 Thread Luke Cheeseman via cfe-commits
Author: lukecheeseman
Date: Mon Sep 24 09:36:33 2018
New Revision: 342901

URL: http://llvm.org/viewvc/llvm-project?rev=342901&view=rev
Log:
Reverting r342895

- The used builtins do not compile for pre arm v8.3a targets with gcc


Modified:
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/dwarf2.h

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Mon Sep 24 09:36:33 2018
@@ -57,9 +57,6 @@ enum {
   UNW_EINVAL= -6547, /* unsupported operation or bad value */
   UNW_EBADVERSION   = -6548, /* unwind info has unsupported version */
   UNW_ENOINFO   = -6549  /* no unwind info found */
-#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
-  , UNW_ECROSSRASIGNING = -6550 /* cross unwind with return address signing */
-#endif
 };
 
 struct unw_context_t {
@@ -550,8 +547,6 @@ enum {
   UNW_ARM64_X31 = 31,
   UNW_ARM64_SP  = 31,
   // reserved block
-  UNW_ARM64_RA_SIGN_STATE = 34,
-  // reserved block
   UNW_ARM64_D0  = 64,
   UNW_ARM64_D1  = 65,
   UNW_ARM64_D2  = 66,

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Mon Sep 24 09:36:33 2018
@@ -198,24 +198,6 @@ int DwarfInstructions::stepWithDwa
   // restoring SP means setting it to CFA.
   newRegisters.setSP(cfa);
 
-#if defined(_LIBUNWIND_TARGET_AARCH64)
-  // If the target is aarch64 then the return address may have been signed
-  // using the v8.3 pointer authentication extensions. The original
-  // return address needs to be authenticated before the return address is
-  // restored. autia1716 is used instead of autia as autia1716 assembles
-  // to a NOP on pre-v8.3a architectures.
-  if (prolog.savedRegisters[UNW_ARM64_RA_SIGN_STATE].value) {
-#if !defined(_LIBUNWIND_IS_NATIVE_ONLY)
-return UNW_ECROSSRASIGNING;
-#else
-register unsigned long long x17 __asm("x17") = returnAddress;
-register unsigned long long x16 __asm("x16") = cfa;
-asm("autia1716": "+r"(x17): "r"(x16));
-returnAddress = x17;
-#endif
-  }
-#endif
-
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Mon Sep 24 09:36:33 2018
@@ -666,14 +666,6 @@ bool CFI_Parser::parseInstructions(A
   _LIBUNWIND_TRACE_DWARF(
   "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset);
   break;
-
-#if defined(_LIBUNWIND_TARGET_AARCH64)
-case DW_CFA_AARCH64_negate_ra_state:
-  results->savedRegisters[UNW_ARM64_RA_SIGN_STATE].value ^= 0x1;
-  _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n");
-  break;
-#endif
-
 default:
   operand = opcode & 0x3F;
   switch (opcode & 0xC0) {

Modified: libunwind/trunk/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=342901&r1=342900&r2=342901&view=diff
==
--- libunwind/trunk/src/Registers.hpp (original)
+++ libunwind/trunk/src/Registers.hpp Mon Sep 24 09:36:33 2018
@@ -1786,7 +1786,7 @@ private:
 uint64_t __lr;// Link register x30
 uint64_t __sp;// Stack pointer x31
 uint64_t __pc;// Program counter
-uint64_t __ra_sign_state; // RA sign state register
+uint64_t padding; // 16-byte align
   };
 
   GPRs_registers;
@@ -1822,8 +1822,6 @@ inline bool Registers_arm64::validRegist
 return false;
   if (regNum > 95)
 return false;
-  if (regNum == UNW_ARM64_RA_SIGN_STATE)
-return true;
   if ((regNum > 31) && (regNum < 64))
 return false;
   return true;
@@ -1834,11 +1832,8 @@ inline uint64_t Registers_arm64::getRegi
 return _registers.__pc;
   if (regNum == UNW_REG_SP)
 return _registers.__sp;
-  if (regNum == UNW_ARM64_RA_SIGN_STATE)
-return _registers.__ra_sign_state;
   if ((regNum >= 0) && (regNum < 32))
 return _registers.__x[regNum];
-
   _LIBUNWIND_AB

[PATCH] D52420: [clangd] Fix crash if pending computations were active on exit

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:483
+  // Destroy ClangdServer to ensure all worker threads finish.
+  Server.reset();
 

ioeric wrote:
> This woudn't work if `run()` is called multiple times. Maybe create a 
> `Server` in each `run()`? 
run() asserts it's never called multiple times, so we don't break the contract.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52420



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


[PATCH] D52422: [clangd] Handle template args for disabled function arg snippets

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/CodeComplete.cpp:1699
+  if (Opts.EnableSnippets) {
+log("Suffix: {0}", SnippetSuffix);
 LSP.textEdit->newText += SnippetSuffix;

Sorry, leftover from debug printing. Will remove


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52422



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: test/Sema/gnu89.c:1-2
-// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
+// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-PEDANTIC %s
+// RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck %s
 

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > lebedev.ri wrote:
> > > This ideally needs positive tests. E.g.:
> > > * `-std=c89`
> > > * `-std=c89 -pedantic`
> > > * `-std=gnu99`
> > > * `-std=gnu99 -pedantic`
> > > * `-std=c99`
> > > * `-std=c99 -pedantic`
> > > 
> > Since `typeof` is a gnu extension, its use constitutes an error for all non 
> > gnu C standards, so it's moot to check for duplicate const specifiers from 
> > typeof exprs.
> > 
> > Since we're trying to match GCC's behavior here, GCC does not warn for 
> > `-std=gnu99` or `-std=gnu99 -pedantic` so I will add those test cases.
> https://godbolt.org/z/3trZdl
Ah, I can still put CHECKs for errors.  Will add additional tests.


Repository:
  rC Clang

https://reviews.llvm.org/D52248



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


[PATCH] D43783: [OpenCL] Remove block invoke function from emitted block literal struct

2018-09-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D43783#1235126, @yaxunl wrote:

> In https://reviews.llvm.org/D43783#1235090, @Anastasia wrote:
>
> > Ping! Do you still plan to do this? :)
>
>
> Sorry I caught up in something else. Since there are some subsequent commits, 
> it may take some efforts to revert it.


No problem. Let me know if help is needed. :)

In https://reviews.llvm.org/D43783#1235126, @yaxunl wrote:

> In https://reviews.llvm.org/D43783#1235090, @Anastasia wrote:
>
> > Ping! Do you still plan to do this? :)
>
>
> Sorry I caught up in something else. Since there are some subsequent commits, 
> it may take some efforts to revert it.


Let me know if you need help. I am happy to do this myself.


Repository:
  rC Clang

https://reviews.llvm.org/D43783



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


[clang-tools-extra] r342903 - [clangd] Fix uninit bool in r342888

2018-09-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Sep 24 09:52:48 2018
New Revision: 342903

URL: http://llvm.org/viewvc/llvm-project?rev=342903&view=rev
Log:
[clangd] Fix uninit bool in r342888

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

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=342903&r1=342902&r2=342903&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Mon Sep 24 09:52:48 
2018
@@ -33,7 +33,7 @@ Error makeError(const Twine &Msg) {
 // Reads binary data from a StringRef, and keeps track of position.
 class Reader {
   const char *Begin, *End;
-  bool Err;
+  bool Err = false;
 
 public:
   Reader(StringRef Data) : Begin(Data.begin()), End(Data.end()) {}


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


[PATCH] D52273: [clangd] Initial implementation of expected types

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

> This seems very clever, but extremely complicated - you've implemented much 
> of C++'s conversion logic, it's not clear to me which parts are actually 
> necessary to completion quality.

Clearly the model that supports C++ conversions is something that **will** 
improve code completion quality.
I do agree it's not trivial, but would argue we at least want:

- qualification conversions (i.e. adding const)
- user-defined conversions (e.g. operator bool is commonly useful think)
- derived-to-base conversions (Derived* should convert to Base*)

Without those, we don't support a bunch of useful cases.

> As chatted offline, I think the return type can be split into multiple 
> orthogonal signals. For example, const T & can be split into 3 independent 
> signals {const, type T, reference}. I think this can make the reasoning of 
> boosting/scoring easier for both index and code completion. Agree with Sam 
> that we should start with something simple (e.g. type matching without 
> conversing) and land basic components to make further evaluation possible.

Yeah, I do keep it in mind and I think it's a great idea. E.g., we can put all 
numeric types into one equivalence class and get rid of all numeric conversions.
That adds some complexity to the interface, though, I wanted to measure how the 
trivial solution (enumerate all types) works. To make sure we actually can't 
get away without it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D51568: [modules] Add `-fno-absolute-module-directory` flag for relocatable modules

2018-09-24 Thread Andrew Gallagher via Phabricator via cfe-commits
andrewjcg updated this revision to Diff 166709.
andrewjcg added a comment.

Dropping the module directory entirely and fully resolving paths on 
serialization
broke some things during deserialization, specifically when the deserializer 
wanted
to update paths to use an alternate module directory.

This switches to a different strategy of only relativizing the paths that are
actually under the module home dir, and adding a bit to the serialized paths to
indiciate this.  This bit is read on deserializiation to determine whether the
path is resolved against the module directory or not.


Repository:
  rC Clang

https://reviews.llvm.org/D51568

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderInternals.h
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GlobalModuleIndex.cpp
  test/Modules/relocatable-modules.modulemap

Index: test/Modules/relocatable-modules.modulemap
===
--- /dev/null
+++ test/Modules/relocatable-modules.modulemap
@@ -0,0 +1,29 @@
+// Build two otherwise identical modules in two different directories and
+// verify that using `-fno-absolute-module-directory` makes them identical.
+//
+// RUN: rm -rf %t
+//
+// RUN: mkdir -p %t/p1
+// RUN: cd %t/p1
+// RUN: mkdir -p main other
+// RUN: grep "" %s > main/a.modulemap
+// RUN: grep "" %s > main/a.h
+// RUN: grep "" %s > other/b.h
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fno-absolute-module-directory \
+// RUN:   -fmodule-name="a" -Imain -I. -o - main/a.modulemap > a.pcm
+//
+// RUN: mkdir -p %t/p2
+// RUN: cd %t/p2
+// RUN: mkdir -p main other
+// RUN: grep "" %s > main/a.modulemap
+// RUN: grep "" %s > main/a.h
+// RUN: grep "" %s > other/b.h
+// RUN: %clang_cc1 -x c++ -fmodules -emit-module -fno-absolute-module-directory \
+// RUN:   -fmodule-name="a" -Imain -I. -o - main/a.modulemap > a.pcm
+//
+// RUN: diff %t/p1/a.pcm %t/p2/a.pcm
+
+module "a" {// 
+}   // 
+
+#include "b.h"  // 
Index: lib/Serialization/GlobalModuleIndex.cpp
===
--- lib/Serialization/GlobalModuleIndex.cpp
+++ lib/Serialization/GlobalModuleIndex.cpp
@@ -628,6 +628,7 @@
 SmallString<128> ImportedFile(Record.begin() + Idx,
   Record.begin() + Idx + Length);
 Idx += Length;
+Idx++;  // Relative
 
 // Find the imported module file.
 const FileEntry *DependsOnFile
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -1327,9 +1327,14 @@
 ///
 /// \return \c true if the path was changed.
 static bool cleanPathForOutput(FileManager &FileMgr,
-   SmallVectorImpl &Path) {
-  bool Changed = FileMgr.makeAbsolutePath(Path);
-  return Changed | llvm::sys::path::remove_dots(Path);
+   SmallVectorImpl &Path,
+   bool MakeAbsolute = true) {
+  bool Changed = false;
+  if (MakeAbsolute) {
+Changed |= FileMgr.makeAbsolutePath(Path);
+  }
+  Changed |= llvm::sys::path::remove_dots(Path);
+  return Changed;
 }
 
 /// Adjusts the given filename to only write out the portion of the
@@ -1493,7 +1498,10 @@
 
   if (WritingModule && WritingModule->Directory) {
 SmallString<128> BaseDir(WritingModule->Directory->getName());
-cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
+cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir,
+   !PP.getHeaderSearchInfo()
+.getHeaderSearchOpts()
+.NoAbsoluteModuleDirectory);
 
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
@@ -1708,6 +1716,7 @@
 auto FileAbbrev = std::make_shared();
 FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
+FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relative
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
 unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
 
@@ -1772,6 +1781,7 @@
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Overridden
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Transient
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Module map
+  IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relative
   IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
   unsigned IF

[PATCH] D46443: Add missing cstdalign header

2018-09-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: mclow.lists.
ldionne added a comment.

I believe this header has been deprecated. According to 
http://eel.is/c++draft/diff.cpp17.library, the effect of this header is 
nothing. @mclow.lists can you chime in?


Repository:
  rCXX libc++

https://reviews.llvm.org/D46443



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


[PATCH] D52219: [analyzer] (1/n) Support pointee mutation analysis in ExprMutationAnalyzer.

2018-09-24 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 166710.
shuaiwang added a comment.

Added test case place holder for cases that should be supported in later 
patches.


Repository:
  rC Clang

https://reviews.llvm.org/D52219

Files:
  include/clang/Analysis/Analyses/ExprMutationAnalyzer.h
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -52,11 +52,21 @@
 bool isMutated(const SmallVectorImpl &Results, ASTUnit *AST) {
   const auto *const S = selectFirst("stmt", Results);
   const auto *const E = selectFirst("expr", Results);
+  assert(S && E);
   return ExprMutationAnalyzer(*S, AST->getASTContext()).isMutated(E);
 }
 
+bool isPointeeMutated(const SmallVectorImpl &Results,
+  ASTUnit *AST) {
+  const auto *const S = selectFirst("stmt", Results);
+  const auto *const E = selectFirst("expr", Results);
+  assert(S && E);
+  return ExprMutationAnalyzer(*S, AST->getASTContext()).isPointeeMutated(E);
+}
+
 SmallVector
 mutatedBy(const SmallVectorImpl &Results, ASTUnit *AST) {
+  EXPECT_TRUE(isMutated(Results, AST));
   const auto *const S = selectFirst("stmt", Results);
   SmallVector Chain;
   ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
@@ -71,6 +81,19 @@
   return Chain;
 }
 
+std::string pointeeMutatedBy(const SmallVectorImpl &Results,
+ ASTUnit *AST) {
+  EXPECT_TRUE(isPointeeMutated(Results, AST));
+  const auto *const S = selectFirst("stmt", Results);
+  const auto *const E = selectFirst("expr", Results);
+  ExprMutationAnalyzer Analyzer(*S, AST->getASTContext());
+  const Stmt *By = Analyzer.findPointeeMutation(E);
+  std::string buffer;
+  llvm::raw_string_ostream stream(buffer);
+  By->printPretty(stream, nullptr, AST->getASTContext().getPrintingPolicy());
+  return StringRef(stream.str()).trim().str();
+}
+
 std::string removeSpace(std::string s) {
   s.erase(std::remove_if(s.begin(), s.end(),
  [](char c) { return std::isspace(c); }),
@@ -100,10 +123,14 @@
 } // namespace
 
 TEST(ExprMutationAnalyzerTest, Trivial) {
-  const auto AST = buildASTFromCode("void f() { int x; x; }");
-  const auto Results =
+  auto AST = buildASTFromCode("void f() { int x; x; }");
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_FALSE(isMutated(Results, AST.get()));
+
+  AST = buildASTFromCode("void f() { const int x = 0; x; }");
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
 }
 
 class AssignmentTest : public ::testing::TestWithParam {};
@@ -134,41 +161,111 @@
 Values("++x", "--x", "x++", "x--"), );
 
 TEST(ExprMutationAnalyzerTest, NonConstMemberFunc) {
-  const auto AST = buildASTFromCode(
+  auto AST = buildASTFromCode(
   "void f() { struct Foo { void mf(); }; Foo x; x.mf(); }");
-  const auto Results =
+  auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+  EXPECT_FALSE(isPointeeMutated(Results, AST.get()));
+
+  AST = buildASTFromCode(
+  "void f() { struct Foo { void mf(); }; Foo *p; p->mf(); }");
+  Results = match(withEnclosingCompound(declRefTo("p")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_EQ(pointeeMutatedBy(Results, AST.get()), "p->mf()");
+
+  AST = buildASTFromCode(
+  "void f() { struct Foo { void mf(); }; Foo *x; Foo *&p = x; p->mf(); }");
+  Results = match(withEnclosingCompound(declRefTo("p")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_EQ(pointeeMutatedBy(Results, AST.get()), "p->mf()");
 }
 
 TEST(ExprMutationAnalyzerTest, AssumedNonConstMemberFunc) {
   auto AST = buildASTFromCodeWithArgs(
   "struct X { template  void mf(); };"
-  "template  void f() { X x; x.mf(); }",
+  "template  void f() { X x; x.mf(); }"
+  "template  void g() { X *p; p->mf(); }",
   {"-fno-delayed-template-parsing"});
   auto Results =
   match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x.mf()"));
+  Results = match(withEnclosingCompound(declRefTo("p")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+  EXPECT_EQ(pointeeMutatedBy(Results, AST.get()), "p->mf()");
 
-  AST = buildASTFromCodeWithArgs("template  void f() { T x; x.mf(); }",
- {"-fno-delayed-template-parsing"});
+  AST =
+  buildASTFromCodeWithArgs("template  void f() { T x; x.mf(); }"
+   "template  void g() { T *p; p->mf(); }",
+   {"-fno-delayed-template

[PATCH] D52252: Driver: render arguments for the embedded bitcode correctly

2018-09-24 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Thanks for doing this!

Can you add some test cases just to be complete? Other than that, LGTM!


Repository:
  rC Clang

https://reviews.llvm.org/D52252



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


[PATCH] D52273: [clangd] Initial implementation of expected types

2018-09-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ExpectedTypes.h:68
+
+/// Represents a type of partially applied conversion. Should be treated as an
+/// opaque value and can only be used to check whether the types are converible

sammccall wrote:
> this represents a type (in the c++ sense), not a conversion, right?
It's an "expression" with an extra data with some extra data (whether the user 
conversion was applied to get this expression)



Comment at: clangd/ExpectedTypes.h:82
+  static llvm::SmallVector
+  fromCompletionResult(ASTContext &Ctx, const CodeCompletionResult &R);
+

sammccall wrote:
> coupling to CompletionResult seems premature here, can we stick to passing 
> getExpectedType() until we know that abstraction needs to be broken?
There's some useful logic that is tied to completion results, e.g. to extract 
function return type `CompletionResult`.
Happy to accept a decl, but would keep the name `fromCompletionResult`. Does 
that LG?



Comment at: clangd/ExpectedTypes.h:213
+
+void collectConvertibleFrom(ASTContext &Ctx, MockExpr Source,
+llvm::function_ref OutF);

sammccall wrote:
> sammccall wrote:
> > why is implementing one of these directions not enough?
> > 
> > It should probably be:
> > As far as I can tell, derived-to-base is the tricky one here: it's an 
> > important conversion (albeit one we should leave out of the first patch), 
> > and you can't ask "what's convertible to base" since the answer is an open 
> > set you can't see.
> > 
> > So it seems the minimal set you need for handling pointer to base is `Type 
> > getRepresentative(Type)` and `set 
> > getRepresentativesAfterConversion(Type)` or so...
> names are unclear: is `collectConvertibleFrom(T)` the convertible-from types 
> for T (i.e the types T is convertible from), or the types that are 
> convertible from T?
Derived-to-base and user conversions.

We can't enumerate all derived classes for some type, so instead need to 
enumerate all bases when adding a symbol to the index.
We can't enumerate all types that have user-defined conversions to some type T, 
so we need to enumerate all user-defined conversions when adding a symbol 
instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D52296: [Clang] - Add -gsingle-file-split-dwarf option.

2018-09-24 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D52296#1241928, @probinson wrote:

> Do we generate the .dwo file directly these days?  If not, I can imagine 
> wanting to avoid the overhead of the objcopy hack; as long as the linker is 
> smart enough not to bother with the .debug_*.dwo sections this seems like a 
> build-time win.


We do generate them generically with no objcopy hack.

As far as the standard text here, IMO it was just there in case people didn't 
have an objcopy around or don't want to split it. I'm not sure why we would 
want the ability. That said, if we do I'd rather have it as dwarf5 without 
split-dwarf as an option rather than a -gsingle-file-split-dwarf option.


https://reviews.llvm.org/D52296



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


[PATCH] D52296: [Clang] - Add -gsingle-file-split-dwarf option.

2018-09-24 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D52296#1241928, @probinson wrote:

> Do we generate the .dwo file directly these days?  If not, I can imagine 
> wanting to avoid the overhead of the objcopy hack; as long as the linker is 
> smart enough not to bother with the .debug_*.dwo sections this seems like a 
> build-time win.


We do generate them generically with no objcopy hack.

As far as the standard text here, IMO it was just there in case people didn't 
have an objcopy around or don't want to split it. I'm not sure why we would 
want the ability. That said, if we do I'd rather have it as dwarf5 without 
split-dwarf as an option rather than a -gsingle-file-split-dwarf option.


https://reviews.llvm.org/D52296



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


[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thanks!




Comment at: lib/Sema/SemaDecl.cpp:12380-12382
   }
 
+  if (LangOpts.CPlusPlus && II) {

I think you could move it into the `if()` above?


https://reviews.llvm.org/D52421



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


[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

The concept makes sense. @NoQ any comments? I don't recall seeing that pattern 
before.




Comment at: test/Analysis/conversion.c:144
 int isascii(int c);
 void falsePositive1() {
   char kb2[5];

Also the function name should be changed as well


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 166716.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Updated based on review feedback.


https://reviews.llvm.org/D52421

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -62,7 +62,7 @@
   void test() {
 char *field; // expected-warning {{declaration shadows a field of 'A'}}
 char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
-char *a1; // no warning 
+char *a1; // no warning
 char *a2; // no warning
 char *jj; // no warning
 char *jjj; // no warning
@@ -199,8 +199,8 @@
   using l=char; // no warning or error.
   using l=char; // no warning or error.
   typedef char l; // no warning or error.
- 
-  typedef char n; // no warning or error. 
+
+  typedef char n; // no warning or error.
   typedef char n; // no warning or error.
   using n=char; // no warning or error.
 }
@@ -222,3 +222,31 @@
   };
 }
 }
+
+namespace PR34120 {
+struct A {
+  int B; // expected-note {{declared here}}
+};
+
+class C : public A {
+  void D(int B) {} // expected-warning {{parameter 'B' shadows member inherited from type 'A'}}
+  void E() {
+extern void f(int B); // Ok
+  }
+};
+
+class Private {
+  int B;
+};
+class Derived : Private {
+  void D(int B) {} // Ok
+};
+
+struct Static {
+  static int B;
+};
+
+struct Derived2 : Static {
+  void D(int B) {}
+};
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2852,7 +2852,8 @@
 // Check if there is a field shadowing.
 void Sema::CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD) {
+  const CXXRecordDecl *RD,
+  bool DeclIsField) {
   if (Diags.isIgnored(diag::warn_shadow_field, Loc))
 return;
 
@@ -2892,7 +2893,7 @@
 if (AS_none !=
 CXXRecordDecl::MergeAccess(P.Access, BaseField->getAccess())) {
   Diag(Loc, diag::warn_shadow_field)
-<< FieldName << RD << Base;
+<< FieldName << RD << Base << DeclIsField;
   Diag(BaseField->getLocation(), diag::note_shadow_field);
   Bases.erase(It);
 }
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12377,6 +12377,13 @@
 D.setInvalidType(true);
   }
 }
+
+if (LangOpts.CPlusPlus) {
+  DeclarationNameInfo DNI = GetNameForDeclarator(D);
+  if (auto *RD = dyn_cast(CurContext))
+CheckShadowInheritedFields(DNI.getLoc(), DNI.getName(), RD,
+   /*DeclIsField*/ false);
+}
   }
 
   // Temporarily put parameter variables in the translation unit, not
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -10524,7 +10524,8 @@
   /// Check if there is a field shadowing.
   void CheckShadowInheritedFields(const SourceLocation &Loc,
   DeclarationName FieldName,
-  const CXXRecordDecl *RD);
+  const CXXRecordDecl *RD,
+  bool DeclIsField = true);
 
   /// Check if the given expression contains 'break' or 'continue'
   /// statement that produces control flow different from GCC.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -9418,10 +9418,9 @@
   "__final is a GNU extension, consider using C++11 final">,
   InGroup;
 
-def warn_shadow_field :
-  Warning<"non-static data member %0 of %1 shadows member inherited from "
-  "type %2">,
-  InGroup, DefaultIgnore;
+def warn_shadow_field : Warning<
+  "%select{parameter|non-static data member}3 %0 %select{|of %1 }3shadows "
+  "member inherited from type %2">, InGroup, DefaultIgnore;
 def note_shadow_field : Note<"declared here">;
 
 def err_multiversion_required_in_redecl : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52421: [Sema] Diagnose parameter names that shadow inherited field names

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:12380-12382
   }
 
+  if (LangOpts.CPlusPlus && II) {

lebedev.ri wrote:
> I think you could move it into the `if()` above?
You are correct, I'll hoist it.


https://reviews.llvm.org/D52421



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


[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: test/Analysis/conversion.c:158
 extern int dostuff (void);
 int falsePositive2() {
   int c, n;

And this one


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Maybe just move `StdCLibraryFunctionsChecker` to `core`? (`.apiModeling`?) We 
officially don't support disabling `core`, so i guess it kinda solves the 
issue. Also all of our languages are C-based, these functions are present on 
all platforms (if any of those aren't, we could split them out and keep in 
`unix`).


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


r342909 - Fix the type of 1<<31 integer constants.

2018-09-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Sep 24 10:51:15 2018
New Revision: 342909

URL: http://llvm.org/viewvc/llvm-project?rev=342909&view=rev
Log:
Fix the type of 1<<31 integer constants.

Shifting into the sign bit is technically undefined behavior. No known
compiler exploits it though.

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/CodeGen/CGBlocks.h

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=342909&r1=342908&r2=342909&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Sep 24 10:51:15 2018
@@ -449,7 +449,7 @@ namespace SrcMgr {
 }
 
 static SLocEntry get(unsigned Offset, const FileInfo &FI) {
-  assert(!(Offset & (1 << 31)) && "Offset is too large");
+  assert(!(Offset & (1u << 31)) && "Offset is too large");
   SLocEntry E;
   E.Offset = Offset;
   E.IsExpansion = false;
@@ -458,7 +458,7 @@ namespace SrcMgr {
 }
 
 static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) {
-  assert(!(Offset & (1 << 31)) && "Offset is too large");
+  assert(!(Offset & (1u << 31)) && "Offset is too large");
   SLocEntry E;
   E.Offset = Offset;
   E.IsExpansion = true;

Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=342909&r1=342908&r2=342909&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Mon Sep 24 10:51:15 2018
@@ -60,7 +60,7 @@ enum BlockLiteralFlags {
   BLOCK_IS_GLOBAL = (1 << 28),
   BLOCK_USE_STRET = (1 << 29),
   BLOCK_HAS_SIGNATURE  =(1 << 30),
-  BLOCK_HAS_EXTENDED_LAYOUT = (1 << 31)
+  BLOCK_HAS_EXTENDED_LAYOUT = (1u << 31)
 };
 class BlockFlags {
   uint32_t flags;


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


r342911 - [Power9] [CLANG] Add __float128 exponent GET and SET builtins

2018-09-24 Thread Stefan Pintilie via cfe-commits
Author: stefanp
Date: Mon Sep 24 11:14:50 2018
New Revision: 342911

URL: http://llvm.org/viewvc/llvm-project?rev=342911&view=rev
Log:
[Power9] [CLANG] Add __float128 exponent GET and SET builtins

Added

__builtin_vsx_scalar_extract_expq
__builtin_vsx_scalar_insert_exp_qp

Builtins should behave the same way as in GCC.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsPPC.def
cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=342911&r1=342910&r2=342911&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Mon Sep 24 11:14:50 2018
@@ -431,6 +431,8 @@ BUILTIN(__builtin_mulf128_round_to_odd,
 BUILTIN(__builtin_divf128_round_to_odd, "LLdLLdLLd", "")
 BUILTIN(__builtin_fmaf128_round_to_odd, "LLdLLdLLdLLd", "")
 BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "")
+BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "")
+BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "")
 
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")

Modified: cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c?rev=342911&r1=342910&r2=342911&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-p9-f128.c Mon Sep 24 11:14:50 2018
@@ -48,3 +48,15 @@ double testTruncOdd() {
 // CHECK-NEXT: ret double
 }
 
+__float128 insert_exp_qp(unsigned long long int b) {
+  return __builtin_vsx_scalar_insert_exp_qp(A, b);
+// CHECK: @llvm.ppc.scalar.insert.exp.qp(fp128 %{{.+}}, i64
+// CHECK-NEXT: ret fp128
+}
+
+unsigned long long int extract_exp() {
+  return __builtin_vsx_scalar_extract_expq(A);
+// CHECK: @llvm.ppc.scalar.extract.expq(fp128
+// CHECK-NEXT: ret i64
+}
+


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


[PATCH] D48184: [Power9] [CLANG] Add __float128 exponent GET and SET builtins

2018-09-24 Thread Stefan Pintilie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC342911: [Power9] [CLANG] Add __float128 exponent GET and SET 
builtins (authored by stefanp, committed by ).
Herald added subscribers: cfe-commits, jsji, kristina.

Changed prior to commit:
  https://reviews.llvm.org/D48184?vs=151392&id=166721#toc

Repository:
  rC Clang

https://reviews.llvm.org/D48184

Files:
  include/clang/Basic/BuiltinsPPC.def
  test/CodeGen/builtins-ppc-p9-f128.c


Index: include/clang/Basic/BuiltinsPPC.def
===
--- include/clang/Basic/BuiltinsPPC.def
+++ include/clang/Basic/BuiltinsPPC.def
@@ -431,6 +431,8 @@
 BUILTIN(__builtin_divf128_round_to_odd, "LLdLLdLLd", "")
 BUILTIN(__builtin_fmaf128_round_to_odd, "LLdLLdLLdLLd", "")
 BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "")
+BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "")
+BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "")
 
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")
Index: test/CodeGen/builtins-ppc-p9-f128.c
===
--- test/CodeGen/builtins-ppc-p9-f128.c
+++ test/CodeGen/builtins-ppc-p9-f128.c
@@ -48,3 +48,15 @@
 // CHECK-NEXT: ret double
 }
 
+__float128 insert_exp_qp(unsigned long long int b) {
+  return __builtin_vsx_scalar_insert_exp_qp(A, b);
+// CHECK: @llvm.ppc.scalar.insert.exp.qp(fp128 %{{.+}}, i64
+// CHECK-NEXT: ret fp128
+}
+
+unsigned long long int extract_exp() {
+  return __builtin_vsx_scalar_extract_expq(A);
+// CHECK: @llvm.ppc.scalar.extract.expq(fp128
+// CHECK-NEXT: ret i64
+}
+


Index: include/clang/Basic/BuiltinsPPC.def
===
--- include/clang/Basic/BuiltinsPPC.def
+++ include/clang/Basic/BuiltinsPPC.def
@@ -431,6 +431,8 @@
 BUILTIN(__builtin_divf128_round_to_odd, "LLdLLdLLd", "")
 BUILTIN(__builtin_fmaf128_round_to_odd, "LLdLLdLLdLLd", "")
 BUILTIN(__builtin_truncf128_round_to_odd, "dLLd", "")
+BUILTIN(__builtin_vsx_scalar_extract_expq, "ULLiLLd", "")
+BUILTIN(__builtin_vsx_scalar_insert_exp_qp, "LLdLLdULLi", "")
 
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")
Index: test/CodeGen/builtins-ppc-p9-f128.c
===
--- test/CodeGen/builtins-ppc-p9-f128.c
+++ test/CodeGen/builtins-ppc-p9-f128.c
@@ -48,3 +48,15 @@
 // CHECK-NEXT: ret double
 }
 
+__float128 insert_exp_qp(unsigned long long int b) {
+  return __builtin_vsx_scalar_insert_exp_qp(A, b);
+// CHECK: @llvm.ppc.scalar.insert.exp.qp(fp128 %{{.+}}, i64
+// CHECK-NEXT: ret fp128
+}
+
+unsigned long long int extract_exp() {
+  return __builtin_vsx_scalar_extract_expq(A);
+// CHECK: @llvm.ppc.scalar.extract.expq(fp128
+// CHECK-NEXT: ret i64
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.

2018-09-24 Thread Tri Vo via Phabricator via cfe-commits
trong updated this revision to Diff 166722.
trong added a comment.

- Added test case for using -fcall-saved-x18 and -ffixed-x18 together.


Repository:
  rC Clang

https://reviews.llvm.org/D52399

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Arch/AArch64.cpp
  test/Driver/aarch64-call-saved-x-register.c
  test/Driver/aarch64-fixed-call-saved-x-register.c

Index: test/Driver/aarch64-fixed-call-saved-x-register.c
===
--- /dev/null
+++ test/Driver/aarch64-fixed-call-saved-x-register.c
@@ -0,0 +1,8 @@
+// Check that -ffixed and -fcall-saved flags work correctly together.
+// RUN: %clang -target aarch64-none-gnu \
+// RUN: -ffixed-x18 \
+// RUN: -fcall-saved-x18 \
+// RUN: -### %s  2>&1 | FileCheck %s
+
+// CHECK: "-target-feature" "+reserve-x18"
+// CHECK: "-target-feature" "+call-saved-x18"
Index: test/Driver/aarch64-call-saved-x-register.c
===
--- /dev/null
+++ test/Driver/aarch64-call-saved-x-register.c
@@ -0,0 +1,58 @@
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x8 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X8 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x9 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X9 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x10 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X10 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x11 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X11 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x12 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X12 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x13 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X13 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x14 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X14 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x15 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X15 %s
+
+// RUN: %clang -target aarch64-none-gnu -fcall-saved-x18 -### %s  2>&1  \
+// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X18 %s
+
+// Test all call-saved-x# options together.
+// RUN: %clang -target aarch64-none-gnu \
+// RUN: -fcall-saved-x8 \
+// RUN: -fcall-saved-x9 \
+// RUN: -fcall-saved-x10 \
+// RUN: -fcall-saved-x11 \
+// RUN: -fcall-saved-x12 \
+// RUN: -fcall-saved-x13 \
+// RUN: -fcall-saved-x14 \
+// RUN: -fcall-saved-x15 \
+// RUN: -fcall-saved-x18 \
+// RUN: -### %s  2>&1 | FileCheck %s \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X8 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X9 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X10 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X11 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X12 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X13 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X14 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X15 \
+// RUN: --check-prefix=CHECK-CALL-SAVED-X18
+
+// CHECK-CALL-SAVED-X8: "-target-feature" "+call-saved-x8"
+// CHECK-CALL-SAVED-X9: "-target-feature" "+call-saved-x9"
+// CHECK-CALL-SAVED-X10: "-target-feature" "+call-saved-x10"
+// CHECK-CALL-SAVED-X11: "-target-feature" "+call-saved-x11"
+// CHECK-CALL-SAVED-X12: "-target-feature" "+call-saved-x12"
+// CHECK-CALL-SAVED-X13: "-target-feature" "+call-saved-x13"
+// CHECK-CALL-SAVED-X14: "-target-feature" "+call-saved-x14"
+// CHECK-CALL-SAVED-X15: "-target-feature" "+call-saved-x15"
+// CHECK-CALL-SAVED-X18: "-target-feature" "+call-saved-x18"
Index: lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- lib/Driver/ToolChains/Arch/AArch64.cpp
+++ lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -225,6 +225,33 @@
   if (Args.hasArg(options::OPT_ffixed_x20))
 Features.push_back("+reserve-x20");
 
+  if (Args.hasArg(options::OPT_fcall_saved_x8))
+Features.push_back("+call-saved-x8");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x9))
+Features.push_back("+call-saved-x9");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x10))
+Features.push_back("+call-saved-x10");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x11))
+Features.push_back("+call-saved-x11");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x12))
+Features.push_back("+call-saved-x12");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x13))
+Features.push_back("+call-saved-x13");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x14))
+Features.push_back("+call-saved-x14");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x15))
+Features.push_back("+call-saved-x15");
+
+  if (Args.hasArg(options::OPT_fcall_saved_x18))
+Features.push_back("+call-saved-x18");
+
   if (Args.hasArg(options::OPT_mno_neg_immediates))
 Features.push_back("+no-neg-immediates");
 }
Index: include/clang/Drive

r342912 - [CodeGen] Revert commit https://reviews.llvm.org/rL342717

2018-09-24 Thread Calixte Denizet via cfe-commits
Author: calixte
Date: Mon Sep 24 11:24:18 2018
New Revision: 342912

URL: http://llvm.org/viewvc/llvm-project?rev=342912&view=rev
Log:
[CodeGen] Revert commit https://reviews.llvm.org/rL342717

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/debug-info-scope-file.c
cfe/trunk/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
cfe/trunk/test/CodeGenObjC/arc-linetable.m
cfe/trunk/test/CodeGenObjC/debug-info-blocks.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=342912&r1=342911&r2=342912&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 24 11:24:18 2018
@@ -76,22 +76,20 @@ CGDebugInfo::~CGDebugInfo() {
 }
 
 ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
-   SourceLocation TemporaryLocation,
-   bool ImplicitCode)
+   SourceLocation TemporaryLocation)
 : CGF(&CGF) {
-  init(TemporaryLocation, false /* DefaultToEmpty */, ImplicitCode);
+  init(TemporaryLocation);
 }
 
 ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
bool DefaultToEmpty,
-   SourceLocation TemporaryLocation,
-   bool ImplicitCode)
+   SourceLocation TemporaryLocation)
 : CGF(&CGF) {
-  init(TemporaryLocation, DefaultToEmpty, ImplicitCode);
+  init(TemporaryLocation, DefaultToEmpty);
 }
 
 void ApplyDebugLocation::init(SourceLocation TemporaryLocation,
-  bool DefaultToEmpty, bool ImplicitCode) {
+  bool DefaultToEmpty) {
   auto *DI = CGF->getDebugInfo();
   if (!DI) {
 CGF = nullptr;
@@ -104,7 +102,7 @@ void ApplyDebugLocation::init(SourceLoca
 return;
 
   if (TemporaryLocation.isValid()) {
-DI->EmitLocation(CGF->Builder, TemporaryLocation, ImplicitCode);
+DI->EmitLocation(CGF->Builder, TemporaryLocation);
 return;
   }
 
@@ -3486,8 +3484,7 @@ void CGDebugInfo::EmitInlineFunctionEnd(
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
-void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
-   bool ImplicitCode) {
+void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) {
   // Update our current location
   setLocation(Loc);
 
@@ -3495,9 +3492,8 @@ void CGDebugInfo::EmitLocation(CGBuilder
 return;
 
   llvm::MDNode *Scope = LexicalBlockStack.back();
-  Builder.SetCurrentDebugLocation(
-  llvm::DebugLoc::get(getLineNumber(CurLoc), getColumnNumber(CurLoc), 
Scope,
-  CurInlinedAt, ImplicitCode));
+  Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(
+  getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope, CurInlinedAt));
 }
 
 void CGDebugInfo::CreateLexicalBlock(SourceLocation Loc) {
@@ -3544,7 +3540,7 @@ void CGDebugInfo::EmitLexicalBlockEnd(CG
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
 
   // Provide an entry in the line table for the end of the block.
-  EmitLocation(Builder, Loc, true /* ImplicitCode */);
+  EmitLocation(Builder, Loc);
 
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
@@ -3560,7 +3556,7 @@ void CGDebugInfo::EmitFunctionEnd(CGBuil
   // Pop all regions for this function.
   while (LexicalBlockStack.size() != RCount) {
 // Provide an entry in the line table for the end of the block.
-EmitLocation(Builder, CurLoc, true /* ImplicitCode */);
+EmitLocation(Builder, CurLoc);
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=342912&r1=342911&r2=342912&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Sep 24 11:24:18 2018
@@ -377,9 +377,7 @@ public:
   /// Emit metadata to indicate a change in line/column information in
   /// the source file. If the location is invalid, the previous
   /// location will be reused.
-  /// \param ImplicitCode  True if the Loc must have coverage information
-  void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
-bool ImplicitCode = false);
+  void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc);
 
   /// Emit a call to llvm.dbg.function.sta

[PATCH] D52344: [Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets that use `-fconstant-cfstrings`.

2018-09-24 Thread Kristina Brooks via Phabricator via cfe-commits
kristina reopened this revision.
kristina added a comment.
This revision is now accepted and ready to land.

Cascade of build failures stemming from `GV->setSection(".rodata");`, reverted 
the commit, it seems that `CFString.c` is causing all those issues despite 
passing when ran locally.


Repository:
  rC Clang

https://reviews.llvm.org/D52344



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


[PATCH] D52273: [clangd] Initial implementation of expected types

2018-09-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Happy to speculate about what might work here, but I strongly believe the path 
forward here is to build the simplest version of this feature, without 
conversions, and try to avoid complicated conversion logic if we can get most 
of the benefit in simpler ways.

In https://reviews.llvm.org/D52273#1243652, @ilya-biryukov wrote:

> > This seems very clever, but extremely complicated - you've implemented much 
> > of C++'s conversion logic, it's not clear to me which parts are actually 
> > necessary to completion quality.
>
> Clearly the model that supports C++ conversions is something that **will** 
> improve code completion quality.


It's not clear that will be significant. This isn't hard to measure, so I'm not 
sure why we should guess. And I'm not sure why it all has to go in the first 
patch.

> I do agree it's not trivial, but would argue we at least want:
> 
> - qualification conversions (i.e. adding const)

Another approach here is just always dropping const. (And refs, and so on). 
This will create some false positives, but maybe they don't hurt much. This 
handles some true cases too, like invoking copy constructors.

> - user-defined conversions (e.g. operator bool is commonly useful think)

My **guess** is you're not going to measure a difference here, bool has lots of 
false positives and others are rare.

> - derived-to-base conversions (Derived* should convert to Base*)

Yes, probably. If this ends up being the only "chain" we have to follow, we're 
probably in good shape complexity-wise.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52273



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


[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for this patch, Tri!


Repository:
  rC Clang

https://reviews.llvm.org/D52399



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


[PATCH] D52390: [analyzer] StackSizeChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

> Thanks for all your detailed and helpful input, I will make sure to go over 
> all the comments and answer them, but it will take some time.

Cheers! I can't emphasize enough however that I might be wrong on what I've 
said, or say in this comment.

> It was my introduction to the clang tool-chain

I always struggled getting enough literature about the static analyzer, if you 
didn't come across these works already, it might be worth taking a look :)

1. http://lcs.ios.ac.cn/~xuzb/canalyze/memmodel.pdf
2. 
https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/README.txt
3. https://clang-analyzer.llvm.org/checker_dev_manual.html
4. 
https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/RegionStore.txt
5. 
https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf
 <--- by far the best guide for the static analyzer at the moment.
6. https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/IPA.txt

> A bit more background information on this checker and how it came to be might 
> help you and others to understand some of the choices I made, and also 
> address some of your general questions and worries.
>  I was hesitant about putting too much in the summary but it seems I should 
> have added more.

Summaries are one thing, that most likely won't be (and shouldn't have to be) 
read by a future maintainer, the code should speak for itself.

> This was a university assignment and I was encouraged to put it up here. This 
> code has seen quite a few iterations and criticism.

It's great that you put it up here! New checkers (which from what I've seen are 
mostly written by beginners) tend to go through in some cases a many month long 
review process, so I guess be prepared for some back and forth, but I 
personally really enjoyed the process, I hope you will too.

I have read the rest of your comment, thanks for the details! I can't say that 
I understand every aspect of your algorithm, but I have a couple question for 
the grand picture (but feel free to correct me if I misunderstood anything):

I can see that you use `check::PreCall, check::PostCall, check::EndFunction`, 
and you also modifiy the program state to have a fairly good idea about what 
execution path did the analyzer take, but a function's stack usage it 
calculated very roughly. Let's imagine that in the next example, `f` is only 
called after heavy stack usage:

  // Let's just pretend that this function actually
  // has a meaningful implementation that the analyzer
  // knows will return false in this case.
  bool hasStackEnoughSpace() { return false; }
  
  void f() {
if (hasStackEnoughSpace())
  // use the stack like an absolute madman
else
  chill();
  }

This is silly, but what it wants to demonstrate, that you could report a false 
positive here, despite the analyzer potentially knowing that that path will  
never be taken. To me it seems like you don't utilize the actual 
`ProgramState`, but I think you should.

To me it also seems like that you pretty much reinvent the compiler in this 
patch, by modeling almost everything the compiler does by itself. I'm sadly 
nowhere near an expert on this topic, but it begs the question whether there's 
an already existing solution to this. Let's wait for others to weigh in on 
this, maybe I'm wrong and this is what has to be done.

A couple tips for easier development and review process:

- I think before deep diving into the fixes, you really should split up this 
patch at least into an empty callback (essentially an announcement), and add 
each feature as a separate patch. Ideally, each time you implement a new 
feature, such as handling branches, you should make a neat patch with a small 
implementation and related test cases. As a beginner (and I suffered from this 
myself) this is exceptionally hard to do, because you can often find yourself 
deleting everything and starting all over, but I've grown to appreciate this 
principle as I often saved myself a whole lot of effort due to some feedback. 
However, making a rough proof of concept is in this case IMO a good idea, 
because it's hard to see at the start where the code will end up, but later it 
should be split up.
- Comment everything. I mean, `bool isSuccessful() const { return IsSuccessful; 
}` and similar functions speak for themselves, but ideally every non-trivial 
function and structure should be documented, as well as any non-trivial hackery 
inside a function.


Repository:
  rC Clang

https://reviews.llvm.org/D52390



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166737.
nickdesaulniers added a comment.

- remove debug statments


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c

Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,87 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK-C89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 66:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C99: 66:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C11: 66:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 66:19: error: expected function body aft

[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166736.
nickdesaulniers added a comment.

- add ISO C tests, handle typedef case new tests found


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c

Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,87 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK-C89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17: 21:7: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU89-PEDANTIC: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-NOT: 43:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 43:1: warning: duplicate 'const' declaration specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 66:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C99: 66:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 66:19: error: expected function body after function declarator
+CHECK-C11: 66:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 66:19: err

[PATCH] D51657: [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-09-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good, sorry for the delay.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D51657



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166740.
nickdesaulniers added a comment.

- condense CHECK-prefixes into CHECK for const const


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c


Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,71 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 50:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 50:19: error: expected function body after function 
declarator
+CHECK-C99: 50:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 50:19: error: expected function body after function 
declarator
+CHECK-C11: 50:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 50:19: error: expected function body after function 
declarator
+CHECK-C17: 50:19: error: expected function body after function declarator
+CHECK-C17-PEDANTIC: 50:19: error: expected function body after function 
declarator
+
+CHECK-GNU89-NOT: 50:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU89-PEDANTIC: 50:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 50:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 50:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 50:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 50:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 50:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 50:1: warning: duplicate 'const' declaration 
specifier
+*/
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1679,8 +1679,16 @@

[PATCH] D52390: [analyzer] StackSizeChecker

2018-09-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

One important thing I forgot, that you cant rely on `ProgramState` due to 
tidy's constraints. Btw, how do you plan to make this into a tidy checker? To 
me it seems like it would amplify the already existing false positive issues 
(if I understand your currect way of thinking correctly).


Repository:
  rC Clang

https://reviews.llvm.org/D52390



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: test/Sema/gnu89-const.c:41-46
+CHECK-CNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-CNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-CNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier

gah, `CNU` typo!


Repository:
  rC Clang

https://reviews.llvm.org/D52248



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


[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, caomhin.
Herald added subscribers: cfe-commits, guansong, jholewinski.

For the OpenMP NVPTX toolchain choose default schedules which ensure coalescing 
on the GPU when in SPMD mode. This significantly increases the performance of 
offloaded target code.


Repository:
  rC Clang

https://reviews.llvm.org/D52434

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -34,7 +34,7 @@
 l = i;
   }
 
-  #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
+ #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
   for(int i = 0; i < n; i++) {
 aa[i] += 1;
   }
@@ -81,44 +81,44 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_distribute_default_init_4({{.+}}, {{.+}}, {{.+}} 1,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_distribute_default_init_4({{.+}}, {{.+}}, {{.+}} 1,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
 // CHECK: define {{.*}}void {{@__omp_offloading_.+}}({{.+}}, i{{32|64}} [[F_IN:%.+]])
 // CHECK: store {{.+}} [[F_IN]], {{.+}}* {{.+}},
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
 // CHECK: store {{.+}} 99, {{.+}}* [[COMB_UB:%.+]], align
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
+// CHECK: call void @__kmpc_distribute_default_init_4({{.+}}, {{.+}}, {{.+}} 1, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
@@ -24,7 +24,7 @@
 // CHECK: define weak void @__omp_offloading_{{.*}}_main_l16(i{{64|32}} %{{[^,].*}}, i32* dereferenceable{{[^,]*}}, i{{64|32}} %{{[^,)]*}})
 // CHECK: [[TID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @
 // CHECK: call void @__kmpc_spmd_kernel_init(
-// CHECK: call void @__kmpc_for_static_init_4(
+// CHECK: call void @__kmpc_distribute_default_init_4(
 
 // CHECK: call void [[PARALLEL:@.+]](i32* %{{.*}}, i32* %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} %{{.*}}, i{{64|32}} %{{.*}}, i32* %{{.*}})
 // CHECK: br label %
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

[PATCH] D51657: [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.

2018-09-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/CMakeLists.txt:60
+  append_if(libraries LIBUNWIND_HAS_GCC_S_LIB gcc_s)
+  list(APPEND libraries gcc)
+endif()

I'm a little suspicious of this line, of forcibly linking against libgcc here, 
even if we might not have checked that it even exists.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D51657



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


[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166742.
nickdesaulniers added a comment.

- fix typo s/CNU/GNU/g and update NOTEs


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c


Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,71 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 51:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C99: 51:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C11: 51:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C17: 51:19: error: expected function body after function declarator
+CHECK-C17-PEDANTIC: 51:19: error: expected function body after function 
declarator
+
+CHECK-GNU89-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 51:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+*/
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1679,8 +1679,16 @@
 // C90 6

[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 166743.
nickdesaulniers added a comment.

- adjust wording in comment


Repository:
  rC Clang

https://reviews.llvm.org/D52248

Files:
  lib/Sema/SemaType.cpp
  test/Sema/gnu89-const.c


Index: test/Sema/gnu89-const.c
===
--- /dev/null
+++ test/Sema/gnu89-const.c
@@ -0,0 +1,71 @@
+/*
+RUN: not %clang_cc1 %s -std=c89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89 %s
+RUN: not %clang_cc1 %s -std=c89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C89-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99 %s
+RUN: not %clang_cc1 %s -std=c99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C99-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11 %s
+RUN: not %clang_cc1 %s -std=c11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C11-PEDANTIC %s
+RUN: not %clang_cc1 %s -std=c17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17 %s
+RUN: not %clang_cc1 %s -std=c17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-C17-PEDANTIC %s
+
+RUN: %clang_cc1 %s -std=gnu89 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89 %s
+RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU89-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu99 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99 %s
+RUN: %clang_cc1 %s -std=gnu99 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU99-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu11 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11 %s
+RUN: %clang_cc1 %s -std=gnu11 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU11-PEDANTIC %s
+RUN: %clang_cc1 %s -std=gnu17 -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17 %s
+RUN: %clang_cc1 %s -std=gnu17 -pedantic -fsyntax-only 2>&1 | FileCheck 
-check-prefix=CHECK-GNU17-PEDANTIC %s
+*/
+
+const const int c_i;
+/*
+CHECK: 21:7: warning: duplicate 'const' declaration specifier
+*/
+
+typedef const int t;
+const t c_i2;
+/*
+CHECK-C89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+  ^ NOTE: special case
+CHECK-C99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-C17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration specifier
+
+CHECK-GNU89-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 27:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 27:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 27:1: warning: duplicate 'const' declaration 
specifier
+*/
+
+const int c_i3;
+const typeof(c_i) c_i4;
+/*
+CHECK-C89: 51:19: error: expected function body after function declarator
+CHECK-C89-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C99: 51:19: error: expected function body after function declarator
+CHECK-C99-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C11: 51:19: error: expected function body after function declarator
+CHECK-C11-PEDANTIC: 51:19: error: expected function body after function 
declarator
+CHECK-C17: 51:19: error: expected function body after function declarator
+CHECK-C17-PEDANTIC: 51:19: error: expected function body after function 
declarator
+
+CHECK-GNU89-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU89-PEDANTIC: 51:1: warning: duplicate 'const' declaration specifier
+^ NOTE: special case
+CHECK-GNU99-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU99-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU11-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU11-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+CHECK-GNU17-NOT: 51:1: warning: duplicate 'const' declaration specifier
+CHECK-GNU17-PEDANTIC-NOT: 51:1: warning: duplicate 'const' declaration 
specifier
+*/
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1679,8 +1679,16 @@
 // C90 6.5.3 constra

[PATCH] D52136: [clang-tidy] Add modernize-concat-nested-namespaces check

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

Aside from the local `const` qualification stuff and some minor wordsmithing of 
the documentation, this LGTM.




Comment at: clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:52
+const NamespaceContextVec &Namespaces) {
+  std::ostringstream Result;
+  bool First = true;

wgml wrote:
> aaron.ballman wrote:
> > wgml wrote:
> > > aaron.ballman wrote:
> > > > Can this be rewritten with `llvm::for_each()` and a `Twine` so that we 
> > > > don't have to use `ostringstream` (which is a big hammer for this).
> > > The main advantage of `stringstream` was that it is concise.
> > > 
> > > I don't think I can effectively use `Twine` to build a result in a loop. 
> > > If I'm wrong, correct me, please.
> > > 
> > > I reworked `concatNamespaces` to use `SmallString` with another educated 
> > > guess of `40` for capacity.
> > The `Twine` idea I was thinking of is not too far off from what you have 
> > with `SmallString`, but perhaps is too clever:
> > ```
> > return std::accumulate(Namespaces.begin(), Namespaces.end(), llvm::Twine(), 
> > [](llvm::Twine Ret, const NamespaceDecl *ND) {
> >   return Ret + "::" + ND->getName();
> > }).str();
> > ```
> Yeah, I tried that, but Twine has it's `operator=` deleted.
Ugh, good catch! The current formulation is fine then, thank you!



Comment at: clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:31
+static bool singleNamedNamespaceChild(const NamespaceDecl &ND) {
+  const NamespaceDecl::decl_range Decls = ND.decls();
+  if (std::distance(Decls.begin(), Decls.end()) != 1)

wgml wrote:
> aaron.ballman wrote:
> > We usually only const-qualify local declarations when they're 
> > pointers/references, so you can drop the `const` here (and in several other 
> > places). It's not a hard and fast rule, but the clutter is not useful in 
> > such small functions.
> From my perspective, `const` is a easy way of declaring that my intention is 
> only to name given declaration only for reading and to improve code 
> readability. 
I wasn't making a value judgement about the coding style so much as pointing 
out that this is novel to the code base and we tend to avoid novel constructs 
unless there's a good reason to deviate. I don't see a strong justification 
here, so I'd prefer them to be removed for consistency.



Comment at: docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst:6
+
+Checks for use of nested namespaces in a form of ``namespace a { namespace b { 
... } }``
+and offers change to syntax introduced in C++17: ``namespace a::b { ... }``.

in a form of -> such as



Comment at: docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst:7
+Checks for use of nested namespaces in a form of ``namespace a { namespace b { 
... } }``
+and offers change to syntax introduced in C++17: ``namespace a::b { ... }``.
+Inlined namespaces are not modified.

offers change to syntax -> suggests changing to the more concise syntax



Comment at: docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst:8
+and offers change to syntax introduced in C++17: ``namespace a::b { ... }``.
+Inlined namespaces are not modified.
+

Inlined -> Inline


https://reviews.llvm.org/D52136



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


[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic

2018-09-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 166746.
leonardchan added a comment.
Herald added a subscriber: cfe-commits.

- Removed passes since ssaturate can be expanded in the DAG


Repository:
  rC Clang

https://reviews.llvm.org/D52286

Files:
  include/llvm/CodeGen/ISDOpcodes.h
  include/llvm/IR/Intrinsics.td
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/LegalizeTypes.h
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  test/CodeGen/Generic/ssaturate.ll

Index: test/CodeGen/Generic/ssaturate.ll
===
--- /dev/null
+++ test/CodeGen/Generic/ssaturate.ll
@@ -0,0 +1,26 @@
+; RUN: llc < %s
+
+declare i4 @llvm.ssaturate.i4  (i4, i32)
+declare i32 @llvm.ssaturate.i32  (i32, i32)
+
+define i32 @func() {
+entry:
+  %x = alloca i32, align 4
+
+  store i32 16, i32* %x, align 4
+  %val = load i32, i32* %x
+
+  %tmp = call i32 @llvm.ssaturate.i32( i32 %val, i32 4 )
+  ret i32 %tmp
+}
+
+define i4 @func2() {
+entry:
+  %x = alloca i4, align 1
+
+  store i4 1, i4* %x, align 1
+  %val = load i4, i4* %x
+
+  %tmp = call i4 @llvm.ssaturate.i4( i4 %val, i32 8 )
+  ret i4 %tmp
+}
Index: lib/CodeGen/TargetLoweringBase.cpp
===
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -608,6 +608,7 @@
 setOperationAction(ISD::UMIN, VT, Expand);
 setOperationAction(ISD::UMAX, VT, Expand);
 setOperationAction(ISD::ABS, VT, Expand);
+setOperationAction(ISD::SSAT, VT, Expand);
 
 // Overflow operations default to expand
 setOperationAction(ISD::SADDO, VT, Expand);
Index: lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -282,6 +282,8 @@
   case ISD::SRA_PARTS:  return "sra_parts";
   case ISD::SRL_PARTS:  return "srl_parts";
 
+  case ISD::SSAT:   return "ssaturate";
+
   // Conversion operators.
   case ISD::SIGN_EXTEND:return "sign_extend";
   case ISD::ZERO_EXTEND:return "zero_extend";
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5763,6 +5763,12 @@
 setValue(&I, DAG.getSelect(sdl, VT, IsZeroShift, IsFSHL ? X : Y, Or));
 return nullptr;
   }
+  case Intrinsic::ssaturate: {
+SDValue Op1 = getValue(I.getArgOperand(0));
+SDValue Op2 = getValue(I.getArgOperand(1));
+setValue(&I, DAG.getNode(ISD::SSAT, sdl, Op1.getValueType(), Op1, Op2));
+return nullptr;
+  }
   case Intrinsic::stacksave: {
 SDValue Op = getRoot();
 Res = DAG.getNode(
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.h
===
--- lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -330,6 +330,7 @@
   SDValue PromoteIntRes_UNDEF(SDNode *N);
   SDValue PromoteIntRes_VAARG(SDNode *N);
   SDValue PromoteIntRes_XMULO(SDNode *N, unsigned ResNo);
+  SDValue PromoteIntRes_SSAT(SDNode *N);
 
   // Integer Operand Promotion.
   bool PromoteIntegerOperand(SDNode *N, unsigned OpNo);
Index: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
===
--- lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -141,6 +141,10 @@
   case ISD::ADDCARRY:
   case ISD::SUBCARRY:Res = PromoteIntRes_ADDSUBCARRY(N, ResNo); break;
 
+  case ISD::SSAT:
+Res = PromoteIntRes_SSAT(N);
+break;
+
   case ISD::ATOMIC_LOAD:
 Res = PromoteIntRes_Atomic0(cast(N)); break;
 
@@ -534,6 +538,12 @@
   return SDValue(Res.getNode(), 1);
 }
 
+SDValue DAGTypeLegalizer::PromoteIntRes_SSAT(SDNode *N) {
+  SDValue LHS = GetPromotedInteger(N->getOperand(0));
+  SDValue RHS = N->getOperand(1);
+  return DAG.getNode(N->getOpcode(), SDLoc(N), LHS.getValueType(), LHS, RHS);
+}
+
 SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(SDNode *N, unsigned ResNo) {
   if (ResNo == 1)
 return PromoteIntRes_Overflow(N);
Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===
--- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3461,6 +3461,36 @@
 }
 break;
   }
+  case ISD::SSAT: {
+SDValue SatBits = Node->getOperand(1);
+auto *SatBitsNode = dyn_cast(SatBits);
+if (!SatBitsNode)
+  report_fatal_error(
+  "Second argument of ssaturate intrinsic must be a constant integer");
+
+

[PATCH] D52248: [SEMA] ignore duplicate declaration specifiers from typeof exprs

2018-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

This now matches GCC AFAICT.  My only question is:

Should GCC instead warn for the typedef case for -std=c89 (non pedantic), 
according to C90 6.5.3?


Repository:
  rC Clang

https://reviews.llvm.org/D52248



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


[PATCH] D52281: [clang-tidy] Add modernize check to use std::invoke in generic code

2018-09-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/ReplaceGenericFunctorCallCheck.cpp:70
+  if (MFunctor && MFunctor->isTypeDependent()) {
+const auto *Paren = static_cast(MFunctor->getCallee());
+const auto *BinOp =

JonasToth wrote:
> Eugene.Zelenko wrote:
> > I think you should use LLVM's cast instead, but I'm not sure which one. 
> > Same for other places.
> in this case i think `const auto *BinOp = 
> dyn_cast(Paren->getSubExpr());` would match.
> 
> As a safety measure adding a `assert(BinOp && "No Binary Operator as 
> subexpression");` helps spotting bugs.
I agree; you'd want `dyn_cast` here. There's no need to add that assertion -- 
`dyn_cast` already asserts that the given value is non-null. If the value could 
be null and still be valid, you could use `dyn_cast_or_null` instead.


https://reviews.llvm.org/D52281



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


[PATCH] D52398: Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExpr

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

LGTM, but you should give @delesley a chance to weigh in before you commit.


Repository:
  rC Clang

https://reviews.llvm.org/D52398



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


[PATCH] D52264: Deduplicate replacements from diagnostics.

2018-09-24 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52264



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


[PATCH] D52437: [CUDA] Add preliminary support for CUDA 10.0

2018-09-24 Thread Andrea Bocci via Phabricator via cfe-commits
fwyzard created this revision.
fwyzard added reviewers: tra, Hahnfeld.
Herald added a subscriber: cfe-commits.

Add the definitions for CUDA 10.0 and CUDA architecture 7.5 (Turing),
and define CUDA 10.0 as the highest supported version.

Starting with CUDA 10.0, the include files

  include/crt/*
  include/common_functions.h
  include/device_double_functions.h
  include/device_functions.h
  include/host_config.h
  include/host_defines.h
  include/math_functions.h

are marked as internal, and issue a warning if they are directly included.
To suppress the warning, __clang_cuda_runtime_wrapper.h defines the macro
__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__ before including any of them.


Repository:
  rC Clang

https://reviews.llvm.org/D52437

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,7 +62,7 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
 #error "Unsupported CUDA version!"
 #endif
 
@@ -94,6 +94,9 @@
 #else
 #define __CUDA_LIBDEVICE__
 #endif
+#if CUDA_VERSION >= 1
+#define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#endif
 // Disables definitions of device-side runtime support stubs in
 // cuda_device_runtime_api.h
 #include "driver_types.h"
@@ -420,5 +423,9 @@
 #pragma pop_macro("uint3")
 #pragma pop_macro("__USE_FAST_MATH__")
 
+#ifdef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#endif
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -59,6 +59,8 @@
 return CudaVersion::CUDA_91;
   if (Major == 9 && Minor == 2)
 return CudaVersion::CUDA_92;
+  if (Major == 10 && Minor == 0)
+return CudaVersion::CUDA_100;
   return CudaVersion::UNKNOWN;
 }
 
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -22,6 +22,8 @@
 return "9.1";
   case CudaVersion::CUDA_92:
 return "9.2";
+  case CudaVersion::CUDA_100:
+return "10.0";
   }
   llvm_unreachable("invalid enum");
 }
@@ -60,6 +62,8 @@
 return "sm_70";
   case CudaArch::SM_72:
 return "sm_72";
+  case CudaArch::SM_75:
+return "sm_75";
   case CudaArch::GFX600: // tahiti
 return "gfx600";
   case CudaArch::GFX601: // pitcairn, verde, oland,hainan
@@ -106,6 +110,7 @@
   .Case("sm_62", CudaArch::SM_62)
   .Case("sm_70", CudaArch::SM_70)
   .Case("sm_72", CudaArch::SM_72)
+  .Case("sm_75", CudaArch::SM_75)
   .Case("gfx600", CudaArch::GFX600)
   .Case("gfx601", CudaArch::GFX601)
   .Case("gfx700", CudaArch::GFX700)
@@ -152,6 +157,8 @@
 return "compute_70";
   case CudaVirtualArch::COMPUTE_72:
 return "compute_72";
+  case CudaVirtualArch::COMPUTE_75:
+return "compute_75";
   case CudaVirtualArch::COMPUTE_AMDGCN:
 return "compute_amdgcn";
   }
@@ -173,6 +180,7 @@
   .Case("compute_62", CudaVirtualArch::COMPUTE_62)
   .Case("compute_70", CudaVirtualArch::COMPUTE_70)
   .Case("compute_72", CudaVirtualArch::COMPUTE_72)
+  .Case("compute_75", CudaVirtualArch::COMPUTE_75)
   .Case("compute_amdgcn", CudaVirtualArch::COMPUTE_AMDGCN)
   .Default(CudaVirtualArch::UNKNOWN);
 }
@@ -210,6 +218,8 @@
 return CudaVirtualArch::COMPUTE_70;
   case CudaArch::SM_72:
 return CudaVirtualArch::COMPUTE_72;
+  case CudaArch::SM_75:
+return CudaVirtualArch::COMPUTE_75;
   case CudaArch::GFX600:
   case CudaArch::GFX601:
   case CudaArch::GFX700:
@@ -252,6 +262,8 @@
 return CudaVersion::CUDA_90;
   case CudaArch::SM_72:
 return CudaVersion::CUDA_91;
+  case CudaArch::SM_75:
+return CudaVersion::CUDA_100;
   case CudaArch::GFX600:
   case CudaArch::GFX601:
   case CudaArch::GFX700:
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -24,7 +24,8 @@
   CUDA_90,
   CUDA_91,
   CUDA_92,
-  LATEST = CUDA_92,
+  CUDA_100,
+  LATEST = CUDA_100,
 };
 const char *CudaVersionToString(CudaVersion V);
 
@@ -47,6 +48,7 @@
   SM_62,
   SM_70,
   SM_72,
+  SM_75,
   GFX600,
   GFX601,
   GFX700,
@@ -82,6 +84,7 @@
   COMPUTE_62,
   COMPUTE_70,
   COMPUTE_72,
+  COMPUTE_75,
   COMPUTE_AMDGCN,
 };
 const char *CudaVirtualArchToString(CudaVirtualArch A);

r342920 - [analyzer] Prevent crashes in FindLastStoreBRVisitor

2018-09-24 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Sep 24 14:20:30 2018
New Revision: 342920

URL: http://llvm.org/viewvc/llvm-project?rev=342920&view=rev
Log:
[analyzer] Prevent crashes in FindLastStoreBRVisitor

This patch is a band-aid. A proper solution would be too change
trackNullOrUndefValue to only try to dereference the pointer when it is
relevant to the problem.

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

Added:
cfe/trunk/test/Analysis/diagnostics/find_last_store.c
Modified:

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

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h?rev=342920&r1=342919&r2=342920&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
Mon Sep 24 14:20:30 2018
@@ -83,6 +83,8 @@ public:
 BugReport &BR);
 };
 
+/// Finds last store into the given region,
+/// which is different from a given symbolic value.
 class FindLastStoreBRVisitor final : public BugReporterVisitor {
   const MemRegion *R;
   SVal V;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=342920&r1=342919&r2=342920&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Sep 24 
14:20:30 2018
@@ -1294,8 +1294,7 @@ FindLastStoreBRVisitor::VisitNode(const
 if (const auto *BDR =
   dyn_cast_or_null(V.getAsRegion())) {
   if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {
-if (Optional KV =
-State->getSVal(OriginalR).getAs())
+if (auto KV = State->getSVal(OriginalR).getAs())
   BR.addVisitor(llvm::make_unique(
   *KV, OriginalR, EnableNullFPSuppression));
   }
@@ -1752,8 +1751,18 @@ bool bugreporter::trackNullOrUndefValue(
 else
   RVal = state->getSVal(L->getRegion());
 
-if (auto KV = RVal.getAs())
-  report.addVisitor(llvm::make_unique(
+// FIXME: this is a hack for fixing a later crash when attempting to
+// dereference a void* pointer.
+// We should not try to dereference pointers at all when we don't care
+// what is written inside the pointer.
+bool ShouldFindLastStore = true;
+if (const auto *SR = dyn_cast(L->getRegion()))
+  if (SR->getSymbol()->getType()->getPointeeType()->isVoidType())
+ShouldFindLastStore = false;
+
+if (ShouldFindLastStore)
+  if (auto KV = RVal.getAs())
+report.addVisitor(llvm::make_unique(
 *KV, L->getRegion(), EnableNullFPSuppression));
 
 const MemRegion *RegionRVal = RVal.getAsRegion();

Added: cfe/trunk/test/Analysis/diagnostics/find_last_store.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/find_last_store.c?rev=342920&view=auto
==
--- cfe/trunk/test/Analysis/diagnostics/find_last_store.c (added)
+++ cfe/trunk/test/Analysis/diagnostics/find_last_store.c Mon Sep 24 14:20:30 
2018
@@ -0,0 +1,17 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+typedef struct { float b; } c;
+void *a();
+void *d() {
+  return a(); // expected-note{{Returning pointer}}
+}
+
+void no_find_last_store() {
+  c *e = d(); // expected-note{{Calling 'd'}}
+  // expected-note@-1{{Returning from 'd'}}
+  // expected-note@-2{{'e' initialized here}}
+
+  (void)(e || e->b); // expected-note{{Assuming 'e' is null}}
+  // expected-note@-1{{Left side of '||' is false}}
+  // expected-note@-2{{Access to field 'b' results in a dereference of a 
null pointer (loaded from variable 'e')}}
+  // expected-warning@-3{{Access to field 'b' results in a dereference of 
a null pointer (loaded from variable 'e')}}
+}


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


[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic

2018-09-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 166756.
leonardchan added a reviewer: rjmccall.
leonardchan changed the repository for this revision from rC Clang to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D52286

Files:
  include/llvm/CodeGen/ISDOpcodes.h
  include/llvm/IR/Intrinsics.td
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/LegalizeTypes.h
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  test/CodeGen/Generic/ssaturate.ll
  test/CodeGen/X86/ssaturate.ll

Index: test/CodeGen/X86/ssaturate.ll
===
--- /dev/null
+++ test/CodeGen/X86/ssaturate.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s
+
+declare i4 @llvm.ssaturate.i4  (i4, i32)
+declare i32 @llvm.ssaturate.i32  (i32, i32)
+
+define  i32 @func(i32 %x) {
+entry:
+; CHECK: func:
+; CHECK: 	cmpl	$127, %edi
+; CHECK-NEXT: 	movl	$127, %ecx
+; CHECK-NEXT: 	cmovlel	%edi, %ecx
+; CHECK-NEXT: 	cmpl	$-128, %edi
+; CHECK-NEXT: 	movl	$-128, %eax
+; CHECK-NEXT: 	cmovgel	%ecx, %eax
+; CHECK-NEXT: 	retq
+
+  %tmp = call i32 @llvm.ssaturate.i32( i32 %x, i32 8 )
+  ret i32 %tmp
+}
+
+define  i4 @func2(i4 %x) {
+entry:
+; CHECK: func2:
+; CHECK: # %bb.0:# %entry
+; CHECK-NEXT:movl%edi, %eax
+; CHECK-NEXT:# kill: def $al killed $al killed $eax
+; CHECK-NEXT:retq
+
+  %tmp = call i4 @llvm.ssaturate.i4( i4 %x, i32 8 )
+  ret i4 %tmp
+}
Index: test/CodeGen/Generic/ssaturate.ll
===
--- /dev/null
+++ test/CodeGen/Generic/ssaturate.ll
@@ -0,0 +1,26 @@
+; RUN: llc < %s
+
+declare i4 @llvm.ssaturate.i4  (i4, i32)
+declare i32 @llvm.ssaturate.i32  (i32, i32)
+
+define i32 @func() {
+entry:
+  %x = alloca i32, align 4
+
+  store i32 16, i32* %x, align 4
+  %val = load i32, i32* %x
+
+  %tmp = call i32 @llvm.ssaturate.i32( i32 %val, i32 4 )
+  ret i32 %tmp
+}
+
+define i4 @func2() {
+entry:
+  %x = alloca i4, align 1
+
+  store i4 1, i4* %x, align 1
+  %val = load i4, i4* %x
+
+  %tmp = call i4 @llvm.ssaturate.i4( i4 %val, i32 8 )
+  ret i4 %tmp
+}
Index: lib/CodeGen/TargetLoweringBase.cpp
===
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -608,6 +608,7 @@
 setOperationAction(ISD::UMIN, VT, Expand);
 setOperationAction(ISD::UMAX, VT, Expand);
 setOperationAction(ISD::ABS, VT, Expand);
+setOperationAction(ISD::SSAT, VT, Expand);
 
 // Overflow operations default to expand
 setOperationAction(ISD::SADDO, VT, Expand);
Index: lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -282,6 +282,8 @@
   case ISD::SRA_PARTS:  return "sra_parts";
   case ISD::SRL_PARTS:  return "srl_parts";
 
+  case ISD::SSAT:   return "ssaturate";
+
   // Conversion operators.
   case ISD::SIGN_EXTEND:return "sign_extend";
   case ISD::ZERO_EXTEND:return "zero_extend";
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5763,6 +5763,12 @@
 setValue(&I, DAG.getSelect(sdl, VT, IsZeroShift, IsFSHL ? X : Y, Or));
 return nullptr;
   }
+  case Intrinsic::ssaturate: {
+SDValue Op1 = getValue(I.getArgOperand(0));
+SDValue Op2 = getValue(I.getArgOperand(1));
+setValue(&I, DAG.getNode(ISD::SSAT, sdl, Op1.getValueType(), Op1, Op2));
+return nullptr;
+  }
   case Intrinsic::stacksave: {
 SDValue Op = getRoot();
 Res = DAG.getNode(
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.h
===
--- lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -330,6 +330,7 @@
   SDValue PromoteIntRes_UNDEF(SDNode *N);
   SDValue PromoteIntRes_VAARG(SDNode *N);
   SDValue PromoteIntRes_XMULO(SDNode *N, unsigned ResNo);
+  SDValue PromoteIntRes_SSAT(SDNode *N);
 
   // Integer Operand Promotion.
   bool PromoteIntegerOperand(SDNode *N, unsigned OpNo);
Index: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
===
--- lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -141,6 +141,10 @@
   case ISD::ADDCARRY:
   case ISD::SUBCARRY:Res = PromoteIntRes_ADDSUBCARRY(N, ResNo); break;
 
+  case ISD::SSAT:
+Res = PromoteIntRes_

[PATCH] D52286: [Intrinsic] Signed Saturation Intirnsic

2018-09-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Of the intrinsics we plan to implement, it seems that the ordering of 
legalization affects specifically the fixed point mul/div intrinsics since if 
they get expanded into other nodes, we will need to check again for legal types 
since performing scaled mul/div requires larger integers for a buffer. The 
remaining ones though I don't think require any extra legalization. Both 
saturation and saturated add/sub can be done without different sized operands.

For ssat specifically, I think this patch has most of the necessary code to 
have this ready for a formal review. I removed the passes for this one since it 
seems all expansion can be done safely in the DAG without any extra type or 
operation legalization.




Comment at: include/llvm/CodeGen/ISDOpcodes.h:264
+/// signed value is returned instead.
+SSAT,
+

ebevhan wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > With the way the rest is written, it doesn't seem like this DAG opcode is 
> > > ever used.
> > > 
> > > The way you would normally do this in DAG would be to:
> > > * Lower the intrinsic to this node in SelectionDAGBuilder, regardless of 
> > > type or operation legality
> > > * Deal with illegally typed nodes in LegalizeTypes
> > > * Deal with illegal opcodes in LegalizeDAG
> > > 
> > > I think that doing the legalization in DAG for some of the fixed-point 
> > > operations could be hard. Opcode legalization occurs after type 
> > > legalization, so the legalization for opcodes that have legal types but 
> > > where the target doesn't actually support the operation must be able to 
> > > legalize to valid types. I think this could get unnecessarily tricky. For 
> > > example, an N-bit, M-scale fixsmul must actually be done as N+M-bits or 
> > > greater, and if that type (or anything greater than it) isn't legal it 
> > > gets hairy.
> > > 
> > > There's also the issue of how a target specifies legality of these 
> > > operations. A target might support ISD::FIXSMUL on MVT::i16, but only 
> > > with a scale of 15. However, there's currently no way of expressing 
> > > legality of an operation based on anything than the type (in general). 
> > > Something would probably have to be added to 
> > > TargetLowering/TargetLoweringBase that lets targets specify the legality 
> > > of these operations. (The same issue applies to ssaturate; it might be 
> > > legal to do 'i32 ssaturate (X, 15)', but not 'i32 ssaturate (X, 19)')
> > > 
> > > 
> > > I think that doing the legalization in DAG for some of the fixed-point 
> > > operations could be hard. Opcode legalization occurs after type 
> > > legalization, so the legalization for opcodes that have legal types but 
> > > where the target doesn't actually support the operation must be able to 
> > > legalize to valid types. I think this could get unnecessarily tricky. For 
> > > example, an N-bit, M-scale fixsmul must actually be done as N+M-bits or 
> > > greater, and if that type (or anything greater than it) isn't legal it 
> > > gets hairy.
> > 
> > I'm not sure if I follow still. (Still learning how the instruction 
> > selection process works). So for the fixsmul example, is the problem that 
> > during the operation legalization step, the target may not be able to 
> > support an int that has N+M bits? Wouldn't this legalization occur during 
> > the first type legalization step before operation legalization, like we 
> > check if the target can support a N+M bit int before operation 
> > legalization? Then during the following optimization stage, have a DAG pass 
> > that will expand an illegal intrinsic operation into other DAG nodes.
> > 
> > > There's also the issue of how a target specifies legality of these 
> > > operations. A target might support ISD::FIXSMUL on MVT::i16, but only 
> > > with a scale of 15. However, there's currently no way of expressing 
> > > legality of an operation based on anything than the type (in general). 
> > > Something would probably have to be added to 
> > > TargetLowering/TargetLoweringBase that lets targets specify the legality 
> > > of these operations. (The same issue applies to ssaturate; it might be 
> > > legal to do 'i32 ssaturate (X, 15)', but not 'i32 ssaturate (X, 19)')
> > 
> > Also having trouble understanding this one. Is the problem that you don't 
> > have access to operand types during the instruction legalization step?
> > I'm not sure if I follow still. (Still learning how the instruction 
> > selection process works). So for the fixsmul example, is the problem that 
> > during the operation legalization step, the target may not be able to 
> > support an int that has N+M bits?
> 
> Correct. Operation legalization (as I understand it; I could be wrong!) can 
> not introduce illegal types into the DAG since type legalization occurs 
> first. Say that you have a 'i16 fixsmul(X, Y, 15)' on a target where i16 is 
> legal and i32 is not, and the fixsmul is not legal. Th

[PATCH] D52438: [CUDA] Add basic support for CUDA-10.0

2018-09-24 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added subscribers: bixia, hiraditya, sanjoy, jholewinski.

https://reviews.llvm.org/D52438

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  llvm/lib/Target/NVPTX/NVPTX.td

Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -54,6 +54,8 @@
  "Target SM 7.0">;
 def SM72 : SubtargetFeature<"sm_72", "SmVersion", "72",
  "Target SM 7.2">;
+def SM75 : SubtargetFeature<"sm_75", "SmVersion", "75",
+ "Target SM 7.5">;
 
 // PTX Versions
 def PTX32 : SubtargetFeature<"ptx32", "PTXVersion", "32",
@@ -72,6 +74,8 @@
  "Use PTX version 6.0">;
 def PTX61 : SubtargetFeature<"ptx61", "PTXVersion", "61",
  "Use PTX version 6.1">;
+def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
+ "Use PTX version 6.3">;
 
 //===--===//
 // NVPTX supported processors.
@@ -94,6 +98,7 @@
 def : Proc<"sm_62", [SM62, PTX50]>;
 def : Proc<"sm_70", [SM70, PTX60]>;
 def : Proc<"sm_72", [SM72, PTX61]>;
+def : Proc<"sm_75", [SM75, PTX63]>;
 
 def NVPTXInstrInfo : InstrInfo {
 }
Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -62,10 +62,15 @@
 #include "cuda.h"
 #if !defined(CUDA_VERSION)
 #error "cuda.h did not define CUDA_VERSION"
-#elif CUDA_VERSION < 7000 || CUDA_VERSION > 9020
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 1
 #error "Unsupported CUDA version!"
 #endif
 
+#pragma push_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__")
+#if CUDA_VERSION >= 1
+#define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
+#endif
+
 // Make largest subset of device functions available during host
 // compilation -- SM_35 for the time being.
 #ifndef __CUDA_ARCH__
@@ -419,6 +424,7 @@
 #pragma pop_macro("dim3")
 #pragma pop_macro("uint3")
 #pragma pop_macro("__USE_FAST_MATH__")
+#pragma pop_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__")
 
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -59,6 +59,8 @@
 return CudaVersion::CUDA_91;
   if (Major == 9 && Minor == 2)
 return CudaVersion::CUDA_92;
+  if (Major == 10 && Minor == 0)
+return CudaVersion::CUDA_100;
   return CudaVersion::UNKNOWN;
 }
 
@@ -165,7 +167,7 @@
   if (FS.exists(FilePath)) {
 for (const char *GpuArchName :
  {"sm_30", "sm_32", "sm_35", "sm_37", "sm_50", "sm_52", "sm_53",
-  "sm_60", "sm_61", "sm_62", "sm_70", "sm_72"}) {
+  "sm_60", "sm_61", "sm_62", "sm_70", "sm_72", "sm_75"}) {
   const CudaArch GpuArch = StringToCudaArch(GpuArchName);
   if (Version >= MinVersionForCudaArch(GpuArch) &&
   Version <= MaxVersionForCudaArch(GpuArch))
@@ -628,6 +630,9 @@
   // defaults to. Use PTX4.2 by default, which is the PTX version that came with
   // CUDA-7.0.
   const char *PtxFeature = "+ptx42";
+  // TODO(tra): CUDA-10+ needs PTX 6.3 to support new features. However that
+  // requires fair amount of work on LLVM side. We'll keep using PTX 6.1 until
+  // all prerequisites are in place.
   if (CudaInstallation.version() >= CudaVersion::CUDA_91) {
 // CUDA-9.1 uses new instructions that are only available in PTX6.1+
 PtxFeature = "+ptx61";
Index: clang/lib/Basic/Targets/NVPTX.cpp
===
--- clang/lib/Basic/Targets/NVPTX.cpp
+++ clang/lib/Basic/Targets/NVPTX.cpp
@@ -221,6 +221,8 @@
 return "700";
   case CudaArch::SM_72:
 return "720";
+  case CudaArch::SM_75:
+return "750";
   }
   llvm_unreachable("unhandled CudaArch");
 }();
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -22,6 +22,8 @@
 return "9.1";
   case CudaVersion::CUDA_92:
 return "9.2";
+  case CudaVersion::CUDA_100:
+return "10.0";
   }
   llvm_unreachable("invalid enum");
 }
@@ -60,6 +62,8 @@
 return "sm_70";
   case CudaArch::SM_72:
 return "sm_72";
+  case CudaArch::SM_75:
+return "sm_75";
   case CudaArch::GFX600: // tahiti
 return "gfx600";
   case CudaArch::GFX601: // pitcairn, verde, oland,hainan
@@ -106,6 +110,7 @@
   .C

  1   2   >