[PATCH] D6260: Add -mlong-double-64 flag

2018-06-21 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc edited subscribers, added: brooksmoses, chandlerc; removed: rnk.
chandlerc edited reviewers, added: echristo, timshen, dlj; removed: kcc.
chandlerc added a comment.

Ok folks, I know this is a blast from the past, but can we actually review 
this? I'm willing to commandeer it, rebase it, and get it landed if you all can 
review this and confirm that it is the right direction.


https://reviews.llvm.org/D6260



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


[PATCH] D48375: [clangd] Remove FilterText from the index.

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48375



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


[clang-tools-extra] r335209 - Fix double-float constant truncation warnings. NFCI.

2018-06-21 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun 21 00:54:47 2018
New Revision: 335209

URL: http://llvm.org/viewvc/llvm-project?rev=335209&view=rev
Log:
Fix double-float constant truncation warnings. NFCI.

Modified:
clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp?rev=335209&r1=335208&r2=335209&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp Thu Jun 21 
00:54:47 2018
@@ -97,13 +97,13 @@ TEST(QualityTests, SymbolRelevanceSignal
 
   Relevance = {};
   Relevance.merge(CodeCompletionResult(&findDecl(AST, "main"), 42));
-  EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0) << "Decl in current file";
+  EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) << "Decl in current 
file";
   Relevance = {};
   Relevance.merge(CodeCompletionResult(&findDecl(AST, "header"), 42));
-  EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 0.6) << "Decl from header";
+  EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 0.6f) << "Decl from header";
   Relevance = {};
   Relevance.merge(CodeCompletionResult(&findDecl(AST, "header_main"), 42));
-  EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0)
+  EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f)
   << "Current file and header";
 
   Relevance = {};
@@ -186,7 +186,7 @@ std::string joinPaths(llvm::ArrayRefhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48341: [clang-doc] Adding a second reduce pass

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-tools-extra/clang-doc/Representation.h:173
   bool mergeable(const Info &Other);
+  llvm::Expected getEnclosingScope();
 };

Comment? What is an enclong scope?



Comment at: clang-tools-extra/clang-doc/Representation.h:264
 
+// A standalone function to wrap a reference in an Info of the appropriate
+// enclosing scope.

"A standalone function" is redundant.

It's unclear to me what "wrap a reference in an Info of the appropriate 
enclosing scope" mean. How does this change the input, and what are the output?



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:121
 llvm::Expected>
 getPath(StringRef Root, StringRef Ext, StringRef Name,
 llvm::SmallVectorImpl &Namespaces) {

This deserves a comment. It's hard to tell what this does without looking at 
the implementation. 



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:147
 
+void addToOutput(
+StringRef Key, std::unique_ptr &&I,

`Output` is a bit vague here. It's usually used for output stream. Maybe 
`addToInfos`?



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:238
+
+// Prepare for second reduce pass.
+

Could you add a comment explaining what the second reduction is?



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:238
+
+// Prepare for second reduce pass.
+

ioeric wrote:
> Could you add a comment explaining what the second reduction is?
I think a lot of code here is too specific to be in main function. Can they 
live in a library? 



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:249
+if (EnclosingScope.get().RefType == doc::InfoType::IT_function)
+  continue;
+

Are symbols declared in functions indexed by the tool? If not, this should 
probably assert or at least emit a warning message.



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:252
+std::string EnclosingScopeKey;
+if (EnclosingScope.get().USR == doc::SymbolID())
+  EnclosingScopeKey = "";

What scopes would have empty USR? Could you add a comment?



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:277
+  // Wrap a reference in the type of the enclosing scope.
+  std::unique_ptr Ref = llvm::make_unique(
+  Reduced.get()->USR, Reduced.get()->Name);

This does exactly the same thing as the case above except for the doc info 
type... could the code be shared?



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:304
+default:
+  llvm::errs() << "Error sorting for second reduce pass.\n";
+}

How severe is this? Should the tool bail out?



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:309
+  // Second reducing phase (by scope) and docs generation phase
+  llvm::outs() << "Further reducing " << ReduceOutput.size() << " infos...\n";
+  for (auto &Group : ReduceOutput) {

It would be helpful to print more messages. What kind of reduction is this?



Comment at: clang-tools-extra/test/clang-doc/yaml-comments.cpp:30
+// CHECK: ---  
+// CHECK-NEXT: USR: ''
+// CHECK-NEXT: ChildFunctions:  

I wouldn't check the exact value of USR in the tests. It would be very painful 
to fix tests when USR semantics are updated. Maybe just check that this has the 
expected number of characters?

Same below.


https://reviews.llvm.org/D48341



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


r335211 - [Sema] Fix overloaded static functions for templates

2018-06-21 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Thu Jun 21 01:34:50 2018
New Revision: 335211

URL: http://llvm.org/viewvc/llvm-project?rev=335211&view=rev
Log:
[Sema] Fix overloaded static functions for templates

Apply almost the same fix as https://reviews.llvm.org/D36390 but for templates.

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

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Index/complete-call.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=335211&r1=335210&r2=335211&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun 21 01:34:50 2018
@@ -6363,63 +6363,61 @@ bool Sema::diagnoseArgIndependentDiagnos
 /// the overload candidate set.
 void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns,
  ArrayRef Args,
- OverloadCandidateSet& CandidateSet,
+ OverloadCandidateSet &CandidateSet,
  TemplateArgumentListInfo 
*ExplicitTemplateArgs,
  bool SuppressUserConversions,
  bool PartialOverloading,
  bool FirstArgumentIsBase) {
   for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) {
 NamedDecl *D = F.getDecl()->getUnderlyingDecl();
-if (FunctionDecl *FD = dyn_cast(D)) {
-  ArrayRef FunctionArgs = Args;
-  if (isa(FD) && !cast(FD)->isStatic()) {
-QualType ObjectType;
-Expr::Classification ObjectClassification;
-if (Args.size() > 0) {
-  if (Expr *E = Args[0]) {
-// Use the explicit base to restrict the lookup:
-ObjectType = E->getType();
-ObjectClassification = E->Classify(Context);
-  } // .. else there is an implit base.
-  FunctionArgs = Args.slice(1);
-}
-AddMethodCandidate(cast(FD), F.getPair(),
-   cast(FD)->getParent(), ObjectType,
-   ObjectClassification, FunctionArgs, CandidateSet,
-   SuppressUserConversions, PartialOverloading);
-  } else {
-// Slice the first argument (which is the base) when we access
-// static method as non-static
-if (Args.size() > 0 && (!Args[0] || (FirstArgumentIsBase && 
isa(FD) &&
- !isa(FD {
-  assert(cast(FD)->isStatic());
-  FunctionArgs = Args.slice(1);
-}
-AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
- SuppressUserConversions, PartialOverloading);
-  }
-} else {
-  FunctionTemplateDecl *FunTmpl = cast(D);
-  if (isa(FunTmpl->getTemplatedDecl()) &&
-  !cast(FunTmpl->getTemplatedDecl())->isStatic()) {
-QualType ObjectType;
-Expr::Classification ObjectClassification;
+ArrayRef FunctionArgs = Args;
+
+FunctionTemplateDecl *FunTmpl = dyn_cast(D);
+FunctionDecl *FD =
+FunTmpl ? FunTmpl->getTemplatedDecl() : cast(D);
+
+if (isa(FD) && !cast(FD)->isStatic()) {
+  QualType ObjectType;
+  Expr::Classification ObjectClassification;
+  if (Args.size() > 0) {
 if (Expr *E = Args[0]) {
   // Use the explicit base to restrict the lookup:
   ObjectType = E->getType();
   ObjectClassification = E->Classify(Context);
-} // .. else there is an implit base.
+} // .. else there is an implicit base.
+FunctionArgs = Args.slice(1);
+  }
+  if (FunTmpl) {
 AddMethodTemplateCandidate(
 FunTmpl, F.getPair(),
 cast(FunTmpl->getDeclContext()),
 ExplicitTemplateArgs, ObjectType, ObjectClassification,
-Args.slice(1), CandidateSet, SuppressUserConversions,
+FunctionArgs, CandidateSet, SuppressUserConversions,
 PartialOverloading);
   } else {
-AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
- ExplicitTemplateArgs, Args,
- CandidateSet, SuppressUserConversions,
- PartialOverloading);
+AddMethodCandidate(cast(FD), F.getPair(),
+   cast(FD)->getParent(), ObjectType,
+   ObjectClassification, FunctionArgs, CandidateSet,
+   SuppressUserConversions, PartialOverloading);
+  }
+} else {
+  // This branch handles both standalone functions and static methods.
+
+  // Slice the first argument (which is the base) when we access
+  // static method as non-static.
+  if (Args.size() > 0 &&
+  (!Args[0] || (FirstArgumentIsBase && isa(FD) &&
+ 

[PATCH] D43453: Fix overloaded static functions for templates

2018-06-21 Thread Ivan Donchevskii via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335211: [Sema] Fix overloaded static functions for templates 
(authored by yvvan, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D43453

Files:
  lib/Sema/SemaOverload.cpp
  test/Index/complete-call.cpp

Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -6363,63 +6363,61 @@
 /// the overload candidate set.
 void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns,
  ArrayRef Args,
- OverloadCandidateSet& CandidateSet,
+ OverloadCandidateSet &CandidateSet,
  TemplateArgumentListInfo *ExplicitTemplateArgs,
  bool SuppressUserConversions,
  bool PartialOverloading,
  bool FirstArgumentIsBase) {
   for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) {
 NamedDecl *D = F.getDecl()->getUnderlyingDecl();
-if (FunctionDecl *FD = dyn_cast(D)) {
-  ArrayRef FunctionArgs = Args;
-  if (isa(FD) && !cast(FD)->isStatic()) {
-QualType ObjectType;
-Expr::Classification ObjectClassification;
-if (Args.size() > 0) {
-  if (Expr *E = Args[0]) {
-// Use the explicit base to restrict the lookup:
-ObjectType = E->getType();
-ObjectClassification = E->Classify(Context);
-  } // .. else there is an implit base.
-  FunctionArgs = Args.slice(1);
-}
-AddMethodCandidate(cast(FD), F.getPair(),
-   cast(FD)->getParent(), ObjectType,
-   ObjectClassification, FunctionArgs, CandidateSet,
-   SuppressUserConversions, PartialOverloading);
-  } else {
-// Slice the first argument (which is the base) when we access
-// static method as non-static
-if (Args.size() > 0 && (!Args[0] || (FirstArgumentIsBase && isa(FD) &&
- !isa(FD {
-  assert(cast(FD)->isStatic());
-  FunctionArgs = Args.slice(1);
-}
-AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
- SuppressUserConversions, PartialOverloading);
-  }
-} else {
-  FunctionTemplateDecl *FunTmpl = cast(D);
-  if (isa(FunTmpl->getTemplatedDecl()) &&
-  !cast(FunTmpl->getTemplatedDecl())->isStatic()) {
-QualType ObjectType;
-Expr::Classification ObjectClassification;
+ArrayRef FunctionArgs = Args;
+
+FunctionTemplateDecl *FunTmpl = dyn_cast(D);
+FunctionDecl *FD =
+FunTmpl ? FunTmpl->getTemplatedDecl() : cast(D);
+
+if (isa(FD) && !cast(FD)->isStatic()) {
+  QualType ObjectType;
+  Expr::Classification ObjectClassification;
+  if (Args.size() > 0) {
 if (Expr *E = Args[0]) {
   // Use the explicit base to restrict the lookup:
   ObjectType = E->getType();
   ObjectClassification = E->Classify(Context);
-} // .. else there is an implit base.
+} // .. else there is an implicit base.
+FunctionArgs = Args.slice(1);
+  }
+  if (FunTmpl) {
 AddMethodTemplateCandidate(
 FunTmpl, F.getPair(),
 cast(FunTmpl->getDeclContext()),
 ExplicitTemplateArgs, ObjectType, ObjectClassification,
-Args.slice(1), CandidateSet, SuppressUserConversions,
+FunctionArgs, CandidateSet, SuppressUserConversions,
 PartialOverloading);
   } else {
-AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
- ExplicitTemplateArgs, Args,
- CandidateSet, SuppressUserConversions,
- PartialOverloading);
+AddMethodCandidate(cast(FD), F.getPair(),
+   cast(FD)->getParent(), ObjectType,
+   ObjectClassification, FunctionArgs, CandidateSet,
+   SuppressUserConversions, PartialOverloading);
+  }
+} else {
+  // This branch handles both standalone functions and static methods.
+
+  // Slice the first argument (which is the base) when we access
+  // static method as non-static.
+  if (Args.size() > 0 &&
+  (!Args[0] || (FirstArgumentIsBase && isa(FD) &&
+!isa(FD {
+assert(cast(FD)->isStatic());
+FunctionArgs = Args.slice(1);
+  }
+  if (FunTmpl) {
+AddTemplateOverloadCandidate(
+FunTmpl, F.getPair(), ExplicitTemplateArgs, FunctionArgs,
+CandidateSet, SuppressUserConversions, PartialOverl

[PATCH] D48367: [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts

2018-06-21 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 152240.
yamaguchi added a comment.

Add a test case


https://reviews.llvm.org/D48367

Files:
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/Inputs/autoload-subdirectory/a.h
  clang/test/Modules/Inputs/autoload-subdirectory/b.h
  clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
  clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
  clang/test/Modules/autoload-subdirectory.cpp


Index: clang/test/Modules/autoload-subdirectory.cpp
===
--- /dev/null
+++ clang/test/Modules/autoload-subdirectory.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang -fmodules -fmodule-name=Foo -I %S/Inputs/autoload-subdirectory/ 
%s
+
+#include "a.h"
+
+int main() {
+  foo neko;
+  return 0;
+}
Index: clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
@@ -0,0 +1,2 @@
+module a { header "a.h" }
+module b { header "b.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
@@ -0,0 +1,2 @@
+module a { header "a.h" }
+module b { header "b.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/b.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/b.h
@@ -0,0 +1 @@
+class bar {};
Index: clang/test/Modules/Inputs/autoload-subdirectory/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/a.h
@@ -0,0 +1,8 @@
+#include "b.h"
+
+class foo {
+  int x,y;
+  public:
+foo() {};
+~foo() {};
+};
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -282,7 +282,8 @@
 
 // Load all module maps in the immediate subdirectories of this search
 // directory.
-loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+if (ModMap.getLangOpts().ObjC1 || ModMap.getLangOpts().ObjC2)
+  loadSubdirectoryModuleMaps(SearchDirs[Idx]);
 
 // Look again for the module.
 Module = ModMap.findModule(ModuleName);
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -110,6 +110,11 @@
   llvm::StringMap> PendingLinkAsModule;
 
 public:
+  /// Get LangOpts of ModuleMap
+  const LangOptions& getLangOpts() {
+return LangOpts;
+  }
+
   /// Use PendingLinkAsModule information to mark top level link names that
   /// are going to be replaced by export_as aliases.
   void resolveLinkAsDependencies(Module *Mod);


Index: clang/test/Modules/autoload-subdirectory.cpp
===
--- /dev/null
+++ clang/test/Modules/autoload-subdirectory.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang -fmodules -fmodule-name=Foo -I %S/Inputs/autoload-subdirectory/ %s
+
+#include "a.h"
+
+int main() {
+  foo neko;
+  return 0;
+}
Index: clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
@@ -0,0 +1,2 @@
+module a { header "a.h" }
+module b { header "b.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
@@ -0,0 +1,2 @@
+module a { header "a.h" }
+module b { header "b.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/b.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/b.h
@@ -0,0 +1 @@
+class bar {};
Index: clang/test/Modules/Inputs/autoload-subdirectory/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/a.h
@@ -0,0 +1,8 @@
+#include "b.h"
+
+class foo {
+  int x,y;
+  public:
+foo() {};
+~foo() {};
+};
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -282,7 +282,8 @@
 
 // Load all module maps in the immediate subdirectories of this search
 // directory.
-loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+if (ModMap.getLangOpts().ObjC1 || ModMap.getLangOpts().ObjC2)
+  loadSubdirectoryModuleMaps(SearchDirs[

[PATCH] D48116: [libclang] Allow skipping warnings from all included files

2018-06-21 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

@ilya-biryukov what do you think?


Repository:
  rC Clang

https://reviews.llvm.org/D48116



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


[PATCH] D48367: [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts

2018-06-21 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:285
 // directory.
-loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+if (ModMap.getLangOpts().ObjC1 || ModMap.getLangOpts().ObjC2)
+  loadSubdirectoryModuleMaps(SearchDirs[Idx]);

bruno wrote:
> aprantl wrote:
> > Are these flags also enabled in Objective-C++ mode?
> Looks like all this logic was introduced in r177621 to allow the names of 
> modules to differ from the name of their subdirectory in the include path.
> 
> Instead of having this to be based on the language, it's probably better if 
> we have it based on @import name lookup, which is the scenario where we 
> actually currently look more aggressively, did you try that path?
> 
> This is also lacking a testcase, can you create one?
> Are these flags also enabled in Objective-C++ mode?
I think so from FrontendOptions.h:190
`bool isObjectiveC() const { return Lang == ObjC || Lang == ObjCXX; }`

> it's probably better if we have it based on @import name lookup
I don't think I understood what you're saying, could you explain a bit more?

> This is also lacking a testcase, can you create one?
Sure!


https://reviews.llvm.org/D48367



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


[PATCH] D48412: [RISCV] Support for __attribute__((interrupt))

2018-06-21 Thread Simon Cook via Phabricator via cfe-commits
simoncook added a comment.

I think this should also cover mismatched arguments if the attribute appears 
several times, and reject/warn about the attribute combination in these cases.

For example, `__attribute__((interrupt("machine"))) 
__attribute__((interrupt("user"))) void foo() {}` is accepted, and adds the 
attribute `"interrupt"="user"`. It seems whichever is first used appears on the 
function.

I don't have an up to date GCC to compare to see what it does in this case, nor 
am sure whether repeating the same interrupt type should be accepted.


https://reviews.llvm.org/D48412



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


[PATCH] D48418: [clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48418

Files:
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h

Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -29,7 +29,7 @@
 /// - Library-specific private declarations (e.g. private declaration generated
 /// by protobuf compiler)
 ///
-/// See also shouldFilterDecl().
+/// See also shouldCollectSymbol(...).
 ///
 /// Clients (e.g. clangd) can use SymbolCollector together with
 /// index::indexTopLevelDecls to retrieve all symbols when the source file is
@@ -56,6 +56,10 @@
 
   SymbolCollector(Options Opts);
 
+  /// Returns true is \p ND should be collected.
+  /// AST matchers require non-const ASTContext.
+  static bool shouldCollectSymbol(const NamedDecl &ND, ASTContext &ASTCtx);
+
   void initialize(ASTContext &Ctx) override;
 
   void setPreprocessor(std::shared_ptr PP) override {
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -130,51 +130,6 @@
  std::any_of(Name.begin(), Name.end(), islower);
 }
 
-bool shouldFilterDecl(const NamedDecl *ND, ASTContext *ASTCtx,
-  const SymbolCollector::Options &Opts) {
-  using namespace clang::ast_matchers;
-  if (ND->isImplicit())
-return true;
-  // Skip anonymous declarations, e.g (anonymous enum/class/struct).
-  if (ND->getDeclName().isEmpty())
-return true;
-
-  // FIXME: figure out a way to handle internal linkage symbols (e.g. static
-  // variables, function) defined in the .cc files. Also we skip the symbols
-  // in anonymous namespace as the qualifier names of these symbols are like
-  // `foobar`, which need a special handling.
-  // In real world projects, we have a relatively large set of header files
-  // that define static variables (like "static const int A = 1;"), we still
-  // want to collect these symbols, although they cause potential ODR
-  // violations.
-  if (ND->isInAnonymousNamespace())
-return true;
-
-  // We want most things but not "local" symbols such as symbols inside
-  // FunctionDecl, BlockDecl, ObjCMethodDecl and OMPDeclareReductionDecl.
-  // FIXME: Need a matcher for ExportDecl in order to include symbols declared
-  // within an export.
-  auto InNonLocalContext = hasDeclContext(anyOf(
-  translationUnitDecl(), namespaceDecl(), linkageSpecDecl(), recordDecl(),
-  enumDecl(), objcProtocolDecl(), objcInterfaceDecl(), objcCategoryDecl(),
-  objcCategoryImplDecl(), objcImplementationDecl()));
-  // Don't index template specializations and expansions in main files.
-  auto IsSpecialization =
-  anyOf(functionDecl(isExplicitTemplateSpecialization()),
-cxxRecordDecl(isExplicitTemplateSpecialization()),
-varDecl(isExplicitTemplateSpecialization()));
-  if (match(decl(allOf(unless(isExpansionInMainFile()), InNonLocalContext,
-   unless(IsSpecialization))),
-*ND, *ASTCtx)
-  .empty())
-return true;
-
-  // Avoid indexing internal symbols in protobuf generated headers.
-  if (isPrivateProtoDecl(*ND))
-return true;
-  return false;
-}
-
 // We only collect #include paths for symbols that are suitable for global code
 // completion, except for namespaces since #include path for a namespace is hard
 // to define.
@@ -283,6 +238,51 @@
   llvm::make_unique(CompletionAllocator);
 }
 
+bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
+  ASTContext &ASTCtx) {
+  using namespace clang::ast_matchers;
+  if (ND.isImplicit())
+return false;
+  // Skip anonymous declarations, e.g (anonymous enum/class/struct).
+  if (ND.getDeclName().isEmpty())
+return false;
+
+  // FIXME: figure out a way to handle internal linkage symbols (e.g. static
+  // variables, function) defined in the .cc files. Also we skip the symbols
+  // in anonymous namespace as the qualifier names of these symbols are like
+  // `foobar`, which need a special handling.
+  // In real world projects, we have a relatively large set of header files
+  // that define static variables (like "static const int A = 1;"), we still
+  // want to collect these symbols, although they cause potential ODR
+  // violations.
+  if (ND.isInAnonymousNamespace())
+return false;
+
+  // We want most things but not "local" symbols such as symbols inside
+  // FunctionDecl, BlockDecl, ObjCMethodDecl and OMPDeclareReductionDecl.
+  // FIXME: Need a matcher for ExportDecl in order to include symbols declared
+  // within an export.
+  auto InNonLocalContext = hasDeclContext(anyOf(
+  translationUnitDecl(), names

[clang-tools-extra] r335212 - [clangd] Fix proximity signal output format. NFC

2018-06-21 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Jun 21 02:51:28 2018
New Revision: 335212

URL: http://llvm.org/viewvc/llvm-project?rev=335212&view=rev
Log:
[clangd] Fix proximity signal output format. NFC

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

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=335212&r1=335211&r2=335212&view=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Thu Jun 21 02:51:28 2018
@@ -235,7 +235,7 @@ float FileProximityMatcher::uriProximity
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
   const FileProximityMatcher &M) {
   OS << formatv("File proximity matcher: ");
-  OS << formatv("ProximityPaths{{0}}", llvm::join(M.ProximityPaths.begin(),
+  OS << formatv("ProximityPaths[{0}]", llvm::join(M.ProximityPaths.begin(),
   M.ProximityPaths.end(), 
","));
   return OS;
 }
@@ -326,9 +326,9 @@ raw_ostream &operator<<(raw_ostream &OS,
   OS << formatv("\tForbidden: {0}\n", S.Forbidden);
   OS << formatv("\tSymbol URI: {0}\n", S.SymbolURI);
   if (S.FileProximityMatch) {
-OS << formatv("\tIndex proximity: {0}\n",
-  S.FileProximityMatch->uriProximity(S.SymbolURI))
-   << " (" << *S.FileProximityMatch << ")\n";
+OS << "\tIndex proximity: "
+   << S.FileProximityMatch->uriProximity(S.SymbolURI) << " ("
+   << *S.FileProximityMatch << ")\n";
   }
   OS << formatv("\tSema proximity: {0}\n", S.SemaProximityScore);
   OS << formatv("\tQuery type: {0}\n", static_cast(S.Query));


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


[PATCH] D48418: [clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.

2018-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Can you motivate this change a bit, and add tests?




Comment at: clangd/index/SymbolCollector.h:61
+  /// AST matchers require non-const ASTContext.
+  static bool shouldCollectSymbol(const NamedDecl &ND, ASTContext &ASTCtx);
+

in principle, this should take const Options&?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48418



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


[PATCH] D48419: [OpenCL] Fixed parsing of address spaces for C++

2018-06-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: yaxunl.

Due to missing handling of address space tokens in parsing code of C++ we were 
unable to parse declarations that start from an address space keyword. For 
example we would get an error:

  test.cl:2:1: error: expected expression
  __global int  * arg_glob;

No idea if there are some more cases missing but this patch at least fixes 
basic variable and function argument declaration parsing.

I enable address space test but part of it still can't run correctly in C++ 
mode.


https://reviews.llvm.org/D48419

Files:
  lib/Parse/ParseTentative.cpp
  test/SemaOpenCL/address-spaces.cl


Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=c++ -verify -pedantic -fsyntax-only
 
 __constant int ci = 1;
 
@@ -8,6 +9,8 @@
   __local int lj = 2; // expected-error {{'__local' variable cannot have an 
initializer}}
 
   int *ip;
+// FIXME: Temporarily disable part of the test that doesn't work for C++ yet.
+#if !__OPENCL_CPP_VERSION__
 #if __OPENCL_C_VERSION__ < 200
   ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes 
address space of pointer}}
   ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes 
address space of pointer}}
@@ -62,4 +65,5 @@
   __local __private int *var2;  // expected-error {{multiple address spaces 
specified for type}}
   __local private_int_t var3;   // expected-error {{multiple address spaces 
specified for type}}
   __local private_int_t *var4;  // expected-error {{multiple address spaces 
specified for type}}
+#endif // !__OPENCL_CXX_VERSION__
 
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1357,6 +1357,11 @@
 // cv-qualifier
   case tok::kw_const:
   case tok::kw_volatile:
+  case tok::kw___private:
+  case tok::kw___local:
+  case tok::kw___global:
+  case tok::kw___constant:
+  case tok::kw___generic:
 
 // GNU
   case tok::kw_restrict:


Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=c++ -verify -pedantic -fsyntax-only
 
 __constant int ci = 1;
 
@@ -8,6 +9,8 @@
   __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}}
 
   int *ip;
+// FIXME: Temporarily disable part of the test that doesn't work for C++ yet.
+#if !__OPENCL_CPP_VERSION__
 #if __OPENCL_C_VERSION__ < 200
   ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}}
   ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}}
@@ -62,4 +65,5 @@
   __local __private int *var2;  // expected-error {{multiple address spaces specified for type}}
   __local private_int_t var3;   // expected-error {{multiple address spaces specified for type}}
   __local private_int_t *var4;  // expected-error {{multiple address spaces specified for type}}
+#endif // !__OPENCL_CXX_VERSION__
 
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1357,6 +1357,11 @@
 // cv-qualifier
   case tok::kw_const:
   case tok::kw_volatile:
+  case tok::kw___private:
+  case tok::kw___local:
+  case tok::kw___global:
+  case tok::kw___constant:
+  case tok::kw___generic:
 
 // GNU
   case tok::kw_restrict:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48418: [clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 152249.
ioeric marked an inline comment as done.
ioeric added a comment.

- added tests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48418

Files:
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -9,6 +9,7 @@
 
 #include "Annotations.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "index/SymbolCollector.h"
 #include "index/SymbolYAML.h"
 #include "clang/Basic/FileManager.h"
@@ -75,6 +76,87 @@
 namespace clangd {
 
 namespace {
+
+class ShouldCollectSymbolTest : public ::testing::Test {
+public:
+  void build(StringRef HeaderCode, StringRef Code = "") {
+File.HeaderFilename = HeaderName;
+File.Filename = FileName;
+File.HeaderCode = HeaderCode;
+File.Code = Code;
+AST = File.build();
+  }
+
+  // build() must have been called.
+  bool shouldCollect(StringRef Name, bool Qualified = true) {
+assert(AST.hasValue());
+llvm::errs() << " " << Name << "\n";
+return SymbolCollector::shouldCollectSymbol(
+Qualified ? findDecl(*AST, Name) : findAnyDecl(*AST, Name),
+AST->getASTContext(), SymbolCollector::Options());
+  }
+
+protected:
+  std::string HeaderName = "f.h";
+  std::string FileName = "f.cpp";
+  TestTU File;
+  Optional AST;  // Initialized after build.
+};
+
+TEST_F(ShouldCollectSymbolTest, ShouldCollectSymbol) {
+  build(R"(
+namespace nx {
+class X{}
+void f() { int Local; }
+struct { int x } var;
+namespace { class InAnonymous {}; }
+}
+  )",
+"class InMain {};");
+  auto AST = File.build();
+  EXPECT_TRUE(shouldCollect("nx"));
+  EXPECT_TRUE(shouldCollect("nx::X"));
+  EXPECT_TRUE(shouldCollect("nx::f"));
+
+  EXPECT_FALSE(shouldCollect("InMain"));
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("InAnonymous", /*Qualified=*/false));
+}
+
+TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
+  HeaderName = "f.proto.h";
+  build(
+  R"(// Generated by the protocol buffer compiler.  DO NOT EDIT!
+ namespace nx {
+   class Top_Level {};
+   class TopLevel {};
+   enum Kind {
+ KIND_OK,
+ Kind_Not_Ok,
+   };
+ })");
+  EXPECT_TRUE(shouldCollect("nx::TopLevel"));
+  EXPECT_TRUE(shouldCollect("nx::Kind::KIND_OK"));
+  EXPECT_TRUE(shouldCollect("nx::Kind"));
+
+  EXPECT_FALSE(shouldCollect("nx::Top_Level"));
+  EXPECT_FALSE(shouldCollect("nx::Kind::Kind_Not_Ok"));
+}
+
+TEST_F(ShouldCollectSymbolTest, DoubleCheckProtoHeaderComment) {
+  HeaderName = "f.proto.h";
+  build(R"(
+namespace nx {
+  class Top_Level {};
+  enum Kind {
+Kind_Fine
+  };
+}
+  )");
+  EXPECT_TRUE(shouldCollect("nx::Top_Level"));
+  EXPECT_TRUE(shouldCollect("nx::Kind_Fine"));
+}
+
 class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
 public:
   SymbolIndexActionFactory(SymbolCollector::Options COpts,
@@ -865,42 +947,6 @@
AllOf(QName("pörk"), DeclRange(Header.range();
 }
 
-TEST_F(SymbolCollectorTest, FilterPrivateProtoSymbols) {
-  TestHeaderName = testPath("x.proto.h");
-  const std::string Header =
-  R"(// Generated by the protocol buffer compiler.  DO NOT EDIT!
- namespace nx {
-   class Top_Level {};
-   class TopLevel {};
-   enum Kind {
- KIND_OK,
- Kind_Not_Ok,
-   };
-   bool operator<(const TopLevel &, const TopLevel &);
- })";
-  runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
-   QName("nx::Kind"), QName("nx::KIND_OK"),
-   QName("nx::operator<")));
-}
-
-TEST_F(SymbolCollectorTest, DoubleCheckProtoHeaderComment) {
-  TestHeaderName = testPath("x.proto.h");
-  const std::string Header = R"(
-  namespace nx {
-class Top_Level {};
-enum Kind {
-  Kind_Fine
-};
-  }
-  )";
-  runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("nx"), QName("nx::Top_Level"),
-   QName("nx::Kind"), QName("nx::Kind_Fine")));
-}
-
 TEST_F(SymbolCollectorTest, DoNotIndexSymbolsInFriendDecl) {
   Annotations Header(R"(
 namespace nx {
Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -29,7 +29,7 @@
 /// - Library-specific private declarations (e.g. private declaration generated
 /// by protobuf compiler)
 ///
-/// See also shouldFilterDecl().
+/// See also shouldColl

[PATCH] D48418: [clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D48418#1138984, @sammccall wrote:

> Can you motivate this change a bit, and add tests?


Done.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48418



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


[PATCH] D48346: [X86] Rewrite the add/mul/or/and reduction intrinsics to make better use of other intrinsics and remove undef shuffle indices.

2018-06-21 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM (with suitable IR fast-isel tests in llvm)


https://reviews.llvm.org/D48346



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


[clang-tools-extra] r335218 - [clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.

2018-06-21 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Jun 21 05:12:26 2018
New Revision: 335218

URL: http://llvm.org/viewvc/llvm-project?rev=335218&view=rev
Log:
[clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.

Summary: This allows tools to examine symbols that would be collected in a 
symbol index. For example, a tool that measures index-based completion quality 
would be interested in references to symbols that are collected in the index.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.h
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=335218&r1=335217&r2=335218&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Thu Jun 21 
05:12:26 2018
@@ -130,51 +130,6 @@ bool isPrivateProtoDecl(const NamedDecl
  std::any_of(Name.begin(), Name.end(), islower);
 }
 
-bool shouldFilterDecl(const NamedDecl *ND, ASTContext *ASTCtx,
-  const SymbolCollector::Options &Opts) {
-  using namespace clang::ast_matchers;
-  if (ND->isImplicit())
-return true;
-  // Skip anonymous declarations, e.g (anonymous enum/class/struct).
-  if (ND->getDeclName().isEmpty())
-return true;
-
-  // FIXME: figure out a way to handle internal linkage symbols (e.g. static
-  // variables, function) defined in the .cc files. Also we skip the symbols
-  // in anonymous namespace as the qualifier names of these symbols are like
-  // `foobar`, which need a special handling.
-  // In real world projects, we have a relatively large set of header files
-  // that define static variables (like "static const int A = 1;"), we still
-  // want to collect these symbols, although they cause potential ODR
-  // violations.
-  if (ND->isInAnonymousNamespace())
-return true;
-
-  // We want most things but not "local" symbols such as symbols inside
-  // FunctionDecl, BlockDecl, ObjCMethodDecl and OMPDeclareReductionDecl.
-  // FIXME: Need a matcher for ExportDecl in order to include symbols declared
-  // within an export.
-  auto InNonLocalContext = hasDeclContext(anyOf(
-  translationUnitDecl(), namespaceDecl(), linkageSpecDecl(), recordDecl(),
-  enumDecl(), objcProtocolDecl(), objcInterfaceDecl(), objcCategoryDecl(),
-  objcCategoryImplDecl(), objcImplementationDecl()));
-  // Don't index template specializations and expansions in main files.
-  auto IsSpecialization =
-  anyOf(functionDecl(isExplicitTemplateSpecialization()),
-cxxRecordDecl(isExplicitTemplateSpecialization()),
-varDecl(isExplicitTemplateSpecialization()));
-  if (match(decl(allOf(unless(isExpansionInMainFile()), InNonLocalContext,
-   unless(IsSpecialization))),
-*ND, *ASTCtx)
-  .empty())
-return true;
-
-  // Avoid indexing internal symbols in protobuf generated headers.
-  if (isPrivateProtoDecl(*ND))
-return true;
-  return false;
-}
-
 // We only collect #include paths for symbols that are suitable for global code
 // completion, except for namespaces since #include path for a namespace is 
hard
 // to define.
@@ -283,6 +238,52 @@ void SymbolCollector::initialize(ASTCont
   llvm::make_unique(CompletionAllocator);
 }
 
+bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
+  ASTContext &ASTCtx,
+  const Options &Opts) {
+  using namespace clang::ast_matchers;
+  if (ND.isImplicit())
+return false;
+  // Skip anonymous declarations, e.g (anonymous enum/class/struct).
+  if (ND.getDeclName().isEmpty())
+return false;
+
+  // FIXME: figure out a way to handle internal linkage symbols (e.g. static
+  // variables, function) defined in the .cc files. Also we skip the symbols
+  // in anonymous namespace as the qualifier names of these symbols are like
+  // `foobar`, which need a special handling.
+  // In real world projects, we have a relatively large set of header files
+  // that define static variables (like "static const int A = 1;"), we still
+  // want to collect these symbols, although they cause potential ODR
+  // violations.
+  if (ND.isInAnonymousNamespace())
+return false;
+
+  // We want most things but not "local" symbols such as symbols inside
+  // FunctionDecl, BlockDecl, ObjCMethodDecl and OMPDeclareReductionDecl.
+  // FIXME: Need a matcher for ExportDecl in order to include symbols declared
+  // within an export.
+  auto InNonLocalContext = hasD

[PATCH] D48418: [clangd] Expose 'shouldCollectSymbol' helper from SymbolCollector.

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335218: [clangd] Expose 'shouldCollectSymbol' 
helper from SymbolCollector. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48418?vs=152249&id=152259#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48418

Files:
  clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
  clang-tools-extra/trunk/clangd/index/SymbolCollector.h
  clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
@@ -9,6 +9,7 @@
 
 #include "Annotations.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "index/SymbolCollector.h"
 #include "index/SymbolYAML.h"
 #include "clang/Basic/FileManager.h"
@@ -75,6 +76,86 @@
 namespace clangd {
 
 namespace {
+
+class ShouldCollectSymbolTest : public ::testing::Test {
+public:
+  void build(StringRef HeaderCode, StringRef Code = "") {
+File.HeaderFilename = HeaderName;
+File.Filename = FileName;
+File.HeaderCode = HeaderCode;
+File.Code = Code;
+AST = File.build();
+  }
+
+  // build() must have been called.
+  bool shouldCollect(StringRef Name, bool Qualified = true) {
+assert(AST.hasValue());
+return SymbolCollector::shouldCollectSymbol(
+Qualified ? findDecl(*AST, Name) : findAnyDecl(*AST, Name),
+AST->getASTContext(), SymbolCollector::Options());
+  }
+
+protected:
+  std::string HeaderName = "f.h";
+  std::string FileName = "f.cpp";
+  TestTU File;
+  Optional AST;  // Initialized after build.
+};
+
+TEST_F(ShouldCollectSymbolTest, ShouldCollectSymbol) {
+  build(R"(
+namespace nx {
+class X{}
+void f() { int Local; }
+struct { int x } var;
+namespace { class InAnonymous {}; }
+}
+  )",
+"class InMain {};");
+  auto AST = File.build();
+  EXPECT_TRUE(shouldCollect("nx"));
+  EXPECT_TRUE(shouldCollect("nx::X"));
+  EXPECT_TRUE(shouldCollect("nx::f"));
+
+  EXPECT_FALSE(shouldCollect("InMain"));
+  EXPECT_FALSE(shouldCollect("Local", /*Qualified=*/false));
+  EXPECT_FALSE(shouldCollect("InAnonymous", /*Qualified=*/false));
+}
+
+TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {
+  HeaderName = "f.proto.h";
+  build(
+  R"(// Generated by the protocol buffer compiler.  DO NOT EDIT!
+ namespace nx {
+   class Top_Level {};
+   class TopLevel {};
+   enum Kind {
+ KIND_OK,
+ Kind_Not_Ok,
+   };
+ })");
+  EXPECT_TRUE(shouldCollect("nx::TopLevel"));
+  EXPECT_TRUE(shouldCollect("nx::Kind::KIND_OK"));
+  EXPECT_TRUE(shouldCollect("nx::Kind"));
+
+  EXPECT_FALSE(shouldCollect("nx::Top_Level"));
+  EXPECT_FALSE(shouldCollect("nx::Kind::Kind_Not_Ok"));
+}
+
+TEST_F(ShouldCollectSymbolTest, DoubleCheckProtoHeaderComment) {
+  HeaderName = "f.proto.h";
+  build(R"(
+namespace nx {
+  class Top_Level {};
+  enum Kind {
+Kind_Fine
+  };
+}
+  )");
+  EXPECT_TRUE(shouldCollect("nx::Top_Level"));
+  EXPECT_TRUE(shouldCollect("nx::Kind_Fine"));
+}
+
 class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
 public:
   SymbolIndexActionFactory(SymbolCollector::Options COpts,
@@ -865,42 +946,6 @@
AllOf(QName("pörk"), DeclRange(Header.range();
 }
 
-TEST_F(SymbolCollectorTest, FilterPrivateProtoSymbols) {
-  TestHeaderName = testPath("x.proto.h");
-  const std::string Header =
-  R"(// Generated by the protocol buffer compiler.  DO NOT EDIT!
- namespace nx {
-   class Top_Level {};
-   class TopLevel {};
-   enum Kind {
- KIND_OK,
- Kind_Not_Ok,
-   };
-   bool operator<(const TopLevel &, const TopLevel &);
- })";
-  runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
-   QName("nx::Kind"), QName("nx::KIND_OK"),
-   QName("nx::operator<")));
-}
-
-TEST_F(SymbolCollectorTest, DoubleCheckProtoHeaderComment) {
-  TestHeaderName = testPath("x.proto.h");
-  const std::string Header = R"(
-  namespace nx {
-class Top_Level {};
-enum Kind {
-  Kind_Fine
-};
-  }
-  )";
-  runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("nx"), QName("nx::Top_Level"),
-   QName("nx::Kind"), QName("nx::Kind_Fine")));
-}
-
 TEST_F(SymbolCollectorTest, DoNotIndexSymbolsInFriendDecl) {
   Annotations Header(R"(
 namespace nx {
Index: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
==

[PATCH] D48423: [liblang] Remove DOS line endings in libclang.exports

2018-06-21 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added a reviewer: rsmith.
Herald added a subscriber: fedor.sergeev.

libclang.so fails to link on Solaris:

Undefined   first referenced
 symbol in file
clang_getCompletionFixIt   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenLocation 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getToken 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTemplateCursorKind
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTUResourceUsageName   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkKind   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkText   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getSpellingLocation  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionParent  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkCompletionString 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionPriority
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionNumFixIts   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenExtent   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionNumAnnotations  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenKind 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[2]: *** 
[tools/clang/tools/libclang/CMakeFiles/libclang.dir/build.make:651: 
lib/libclang.so.7] Error 1

It turns out that this is caused by https://reviews.llvm.org/D46862: it added a
couple of CRs (^M) to some lines.  Solaris ld takes them to be part of the 
symbol
names, which of course are missing from the input objects.  GNU ld handles this
just fine.  Fixed by removing the CRs.

Bootstrapped on i386-pc-solaris2.11.  I guess this is obvious.


Repository:
  rC Clang

https://reviews.llvm.org/D48423

Files:
  tools/libclang/libclang.exports


Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -168,14 +168,14 @@
 clang_getCompletionAnnotation
 clang_getCompletionAvailability
 clang_getCompletionBriefComment
-clang_getCompletionChunkCompletionString
-clang_getCompletionChunkKind
-clang_getCompletionChunkText
-clang_getCompletionNumFixIts
-clang_getCompletionFixIt
-clang_getCompletionNumAnnotations
-clang_getCompletionParent
-clang_getCompletionPriority
+clang_getCompletionChunkCompletionString
+clang_getCompletionChunkKind
+clang_getCompletionChunkText
+clang_getCompletionNumFixIts
+clang_getCompletionFixIt
+clang_getCompletionNumAnnotations
+clang_getCompletionParent
+clang_getCompletionPriority
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
@@ -259,13 +259,13 @@
 clang_getResultType
 clang_getSkippedRanges
 clang_getSpecializedCursorTemplate
-clang_getSpellingLocation
-clang_getTUResourceUsageName
-clang_getTemplateCursorKind
-clang_getToken
-clang_getTokenExtent
-clang_getTokenKind
-clang_getTokenLocation
+clang_getSpellingLocation
+clang_getTUResourceUsageName
+clang_getTemplateCursorKind
+clang_getToken
+clang_getTokenExtent
+clang_getTokenKind
+clang_getTokenLocation
 clang_getTokenSpelling
 clang_getTranslationUnitCursor
 clang_getTranslationUnitSpelling


Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -168,14 +168,14 @@
 clang_getCompletionAnnotation
 clang_getCompletionAvailability
 clang_getCompletionBriefComment
-clang_getCompletionChunkCompletionString
-clang_getCompletionChunkKind
-clang_getCompletionChunkText
-clang_getCompletionNumFixIts
-clang_getCompletionFixIt
-clang_getCompletionNumAnnotations
-clang_getCompletionParent
-clang_getCompletionPriority
+clang_getCompletionChunkCompletionString
+clang_getCompletionChunkKind
+clang_getCompletionChunkText
+clang_getCompletionNumFixIts
+clang_getCompletionFixIt
+clang_getCompletionNumAnnotations
+clang_getCompletionParent
+clang_getCompletionPriority
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
@@ -259,13 +259,13 @@
 clang_getResultType
 clang_getSkippedRanges
 clang_getSpecializedCursorTemplate
-clang_getSpellingLocation
-clang_getTUResourceUsageName
-clang_getTemplateCursorKind
-clang_getToken
-clang_getTokenExtent
-clang_getTokenKind
-clang_getTokenLocation
+clang_getSp

[PATCH] D47532: [ASTImporter] Import the whole redecl chain of functions

2018-06-21 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 152262.
martong marked 15 inline comments as done.
martong added a comment.

- Addressing Alexei's comments.


Repository:
  rC Clang

https://reviews.llvm.org/D47532

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclBase.cpp
  test/ASTMerge/class/test.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -20,7 +20,7 @@
 
 #include "DeclMatcher.h"
 #include "Language.h"
-#include "gtest/gtest.h"
+#include "gmock/gmock.h"
 #include "llvm/ADT/StringMap.h"
 
 namespace clang {
@@ -433,6 +433,48 @@
   }
 }
 
+struct CanonicalRedeclChain : ASTImporterTestBase {};
+
+TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers) {
+  Decl *FromTU = getTuDecl("void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto *D0 = FirstDeclMatcher().match(FromTU, Pattern);
+
+  auto Redecls = getCanonicalForwardRedeclChain(D0);
+  ASSERT_EQ(Redecls.size(), 1u);
+  EXPECT_EQ(D0, Redecls[0]);
+}
+
+TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers2) {
+  Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto *D0 = FirstDeclMatcher().match(FromTU, Pattern);
+  auto *D2 = LastDeclMatcher().match(FromTU, Pattern);
+  FunctionDecl *D1 = D2->getPreviousDecl();
+
+  auto Redecls = getCanonicalForwardRedeclChain(D0);
+  ASSERT_EQ(Redecls.size(), 3u);
+  EXPECT_EQ(D0, Redecls[0]);
+  EXPECT_EQ(D1, Redecls[1]);
+  EXPECT_EQ(D2, Redecls[2]);
+}
+
+TEST_P(CanonicalRedeclChain, ShouldBeSameForAllDeclInTheChain) {
+  Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto *D0 = FirstDeclMatcher().match(FromTU, Pattern);
+  auto *D2 = LastDeclMatcher().match(FromTU, Pattern);
+  FunctionDecl *D1 = D2->getPreviousDecl();
+
+  auto RedeclsD0 = getCanonicalForwardRedeclChain(D0);
+  auto RedeclsD1 = getCanonicalForwardRedeclChain(D1);
+  auto RedeclsD2 = getCanonicalForwardRedeclChain(D2);
+
+  EXPECT_THAT(RedeclsD0, ::testing::ContainerEq(RedeclsD1));
+  EXPECT_THAT(RedeclsD1, ::testing::ContainerEq(RedeclsD2));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
   testImport("void declToImport() { \"foo\"; }",
@@ -1615,41 +1657,9 @@
 .match(ToTU, classTemplateSpecializationDecl()));
 }
 
-INSTANTIATE_TEST_CASE_P(
-ParameterizedTests, ASTImporterTestBase,
-::testing::Values(ArgVector(), ArgVector{"-fdelayed-template-parsing"}),);
-
 struct ImportFunctions : ASTImporterTestBase {};
 
 TEST_P(ImportFunctions,
-   PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition) {
-  Decl *FromTU = getTuDecl("void f();", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD =
-  FirstDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(!cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions,
-   PrototypeShouldBeImportedAsDefintionWhenThereIsADefinition) {
-  Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD = // Prototype
-  FirstDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions,
DefinitionShouldBeImportedAsDefintionWhenThereIsAPrototype) {
   Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
   auto Pattern = functionDecl(hasName("f"));
@@ -1659,7 +1669,7 @@
   Decl *ImportedD = Import(FromD, Lang_CXX);
   Decl *ToTU = ImportedD->getTranslationUnitDecl();
 
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
   EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
 }
 
@@ -1676,80 +1686,116 @@
   EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
 }
 
-TEST_P(ImportFunctions, DISABLED_ImportPrototypeOfRecursiveFunction) {
+TEST_P(ImportFunctions, ImportPrototypeOfRecursiveFunction) {
   Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX);
   auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *PrototypeFD =
-  FirstDeclMatcher().match(FromTU, Pattern);
+  auto From =
+  FirstDeclMatcher().match(FromTU, Pattern); // Proto
 
-  Decl *ImportedD = Import(PrototypeFD, Lang_CXX);
+  Decl *ImportedD = Import(From, Lang_CXX);
   Decl *ToTU = ImportedD->getTranslationUnitDecl();
 
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(c

[PATCH] D47532: [ASTImporter] Import the whole redecl chain of functions

2018-06-21 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:79
+for (auto R : D->getFirstDecl()->redecls()) {
+  if (R != D->getFirstDecl())
+Redecls.push_back(R);

a.sidorin wrote:
> Does this code mean that we can get R == getFirstDecl() in the middle of the 
> import chain?
No.
`D->redecls()` gives a list of decls which always starts with D  and the next 
item is actually the previous item in the order of source locations. But this 
is a circular list, so once we reached the first item then the next item will 
be the last in the order of the source locations.
So, `D->getFirstDecl()->redecls()` gives a reversed list which has D as the 
first element. We must make D as the last, so we can easily reverse.




Comment at: lib/AST/ASTImporter.cpp:2340
+ FunctionDecl::TK_FunctionTemplateSpecialization);
+  auto *FTSInfo = FromFD->getTemplateSpecializationInfo();
+  auto *Template = cast_or_null(

a.sidorin wrote:
> This code should be unified with `ImportTemplateInformation()` to avoid 
> duplication.
OK, I've refactored the common code into a new import function.



Comment at: lib/AST/ASTImporter.cpp:2363
+  // declarations starting from the canonical decl.
+  for (;RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt)
+Importer.Import(*RedeclIt);

a.sidorin wrote:
> Can we just import `getPreviousDecl()`?
In short, we can't. 

The `Redeclarable` class provides the `getPreviousDecl()` function and the 
`redecls()`range.
The list of the declarations is singly linked circular list and the directions 
goes backwards.
E.g.:
```
  ///  #1 int f(int x, int y = 1); // previousDecl: 
  ///  #2 int f(int x = 0, int y); // previousDecl: 
  ///  #3 int f(int x, int y) { return x + y; } // previousDecl: 
```
I think, it is very important to preserve the order of the Decls as it was in 
the from context. Keeping the order makes the imported AST to be structurally 
similar to the original AST. Also, the canonical Decl in the "From" context 
will be the canonical in the "To" context too (when we import to an empty 
context).

During the import of #2 if we used `getPreviousDecl` then we would import first 
#1 and then #2. The order would be fine. But, during the import of #2 there is 
no way to import #3, because we can't go forward in the linked list. We could 
however import #3 during the import of #1, but that would result a #3, #1, #2 
order (i.e. a redecl chain where #3 is the canonical decl).

Alternatively we could start the import from the most recent decl (i.e the 
last) and then recursively import the previous decl up to the first decl, but 
then we should pass an extra parameter through the function calls of 
ASTImporter to avoid jumping back to the last decl if we are in the middle of a 
chain. We could perhaps follow this state in a member variable too, but I 
consider this way too complex and error prone.

This is the exact reason why we need the `getCanonicalForwardRedeclChain()` 
function which provides a list of declarations starting from the first 
(canonical) decl and ends with the latest redecl, this provides the same list 
for each element in the redecl chain.



Comment at: lib/AST/ASTImporter.cpp:2364
+  for (;RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt)
+Importer.Import(*RedeclIt);
+  assert(*RedeclIt == D);

a.sidorin wrote:
> Unchecked import result, is it intentional?
Good catch, thanks! Changed it to check the result.



Comment at: lib/AST/ASTImporter.cpp:2409
 FoundFunction->getType())) {
-// FIXME: Actually try to merge the body and other attributes.
-const FunctionDecl *FromBodyDecl = nullptr;
-D->hasBody(FromBodyDecl);
-if (D == FromBodyDecl && !FoundFunction->hasBody()) {
-  // This function is needed to merge completely.
-  FoundWithoutBody = FoundFunction;
+  if (D->doesThisDeclarationHaveABody() &&
+  FoundFunction->hasBody())

a.sidorin wrote:
> Has removed comment become irrelevant? (Same below)
`// FIXME: Actually try to merge the body and other attributes.`
This FIXME comment (and some other comments) is in strong contrast to all the 
ODR diagnostics implemented in ASTImporter. Actually, (generally in the 
ASTImporter) rather than merging two definitions we diagnose an ODR violation.
Perhaps the ASTImporter is used or had been used previously to merge two 
compatible function or class definitions. But having two structurally 
equivalent definitions is against the ODR. 
I think we should follow the ODR violation approach here and we should not 
merge two function body ever.



Comment at: lib/AST/ASTImporter.cpp:2619
+
+  // Import the rest of the chain. I.e. import all subsequent declarations.
+  for (++Redec

[PATCH] D48423: [liblang] Remove DOS line endings in libclang.exports

2018-06-21 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan accepted this revision.
yvvan added a comment.
This revision is now accepted and ready to land.

Thanks! I probably forgot to check line endings for this file before committing 
which I do for source files and headers...


Repository:
  rC Clang

https://reviews.llvm.org/D48423



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


r335220 - Fix line endings in recently updated test file

2018-06-21 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Thu Jun 21 05:39:24 2018
New Revision: 335220

URL: http://llvm.org/viewvc/llvm-project?rev=335220&view=rev
Log:
Fix line endings in recently updated test file

Modified:
cfe/trunk/test/Index/complete-call.cpp

Modified: cfe/trunk/test/Index/complete-call.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-call.cpp?rev=335220&r1=335219&r2=335220&view=diff
==
--- cfe/trunk/test/Index/complete-call.cpp (original)
+++ cfe/trunk/test/Index/complete-call.cpp Thu Jun 21 05:39:24 2018
@@ -109,39 +109,39 @@ void test() {
 struct Bar2 : public Bar {
   Bar2() {
 Bar::foo_1();
-  }
-};
-
-struct BarTemplates {
-  static void foo_1() {}
-  void foo_1(float) {}
-  static void foo_1(int) {}
-
-  template
-  static void foo_1(T1 a, T2 b) { a + b; }
-
-  template
-  void foo_1(T1 a, T2 b, float c) { a + b + c; }
-
-  template
-  static void foo_1(T2 a, int b, T1 c)  { a + b + c; }
-};
-
-void testTemplates() {
-  BarTemplates::foo_1();
-  BarTemplates b;
-  b.foo_1();
-}
-
-struct Bar2Template : public BarTemplates {
-  Bar2Template() {
-BarTemplates::foo_1();
-  }
-};
-
-// RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck 
-check-prefix=CHECK-CC1 %s
-// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{RightParen )} (1)
-// CHECK-CC1: Completion contexts:
+  }
+};
+
+struct BarTemplates {
+  static void foo_1() {}
+  void foo_1(float) {}
+  static void foo_1(int) {}
+
+  template
+  static void foo_1(T1 a, T2 b) { a + b; }
+
+  template
+  void foo_1(T1 a, T2 b, float c) { a + b + c; }
+
+  template
+  static void foo_1(T2 a, int b, T1 c)  { a + b + c; }
+};
+
+void testTemplates() {
+  BarTemplates::foo_1();
+  BarTemplates b;
+  b.foo_1();
+}
+
+struct Bar2Template : public BarTemplates {
+  Bar2Template() {
+BarTemplates::foo_1();
+  }
+};
+
+// RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck 
-check-prefix=CHECK-CC1 %s
+// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{RightParen )} (1)
+// CHECK-CC1: Completion contexts:
 // CHECK-CC1-NEXT: Any type
 // CHECK-CC1-NEXT: Any value
 // CHECK-CC1-NEXT: Enum tag
@@ -887,30 +887,30 @@ struct Bar2Template : public BarTemplate
 // CHECK-CC62-NEXT: Enum tag
 // CHECK-CC62-NEXT: Union tag
 // CHECK-CC62-NEXT: Struct tag
-// CHECK-CC62-NEXT: Class name
-// CHECK-CC62-NEXT: Nested name specifier
-// CHECK-CC62-NEXT: Objective-C interface
-
-// RUN: c-index-test -code-completion-at=%s:131:23 %s | FileCheck 
-check-prefix=CHECK-CC63 %s
-// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{RightParen )} (1)
-// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter float}{RightParen )} (1)
-// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter int}{RightParen )} (1)
-// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{RightParen )} (1)
-// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{Comma , }{Placeholder 
float c}{RightParen )} (1)
-// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter T2 a}{Comma , }{Placeholder int b}{Comma , }{Placeholder T1 
c}{RightParen )} (1)
-
-// RUN: c-index-test -code-completion-at=%s:133:11 %s | FileCheck 
-check-prefix=CHECK-CC64 %s
-// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{RightParen )} (1)
-// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter float}{RightParen )} (1)
-// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter int}{RightParen )} (1)
-// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{RightParen )} (1)
-// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter T2 a}{Comma , }{Placeholder int b}{Comma , }{Placeholder T1 
c}{RightParen )} (1)
-
-// RUN: c-index-test -code-completion-at=%s:138:25 %s | FileCheck 
-check-prefix=CHECK-CC65 %s
-// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{RightParen )} (1)
-// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter float}{RightParen )} (1)
-// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter int}{RightParen )} (1)
-// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{RightParen )} (1)
-// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen 
(}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{Comma , }{Placeholder 
float c}{RightParen )} (1)
-// CHECK-CC65: OverloadCandidat

[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ilya-biryukov.

The qualified name can be used to match a completion item to its corresponding
symbol. This can be useful for tools that measure code completion quality.
Qualified names are not precise for identifying symbols; we need to figure out a
better way to identify completion items.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48425

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


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -44,6 +44,7 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.insertText == Name; }
+MATCHER_P(QName, Name, "") { return arg.QualifiedName == Name; }
 MATCHER_P(Labeled, Label, "") {
   std::string Indented;
   if (!StringRef(Label).startswith(
@@ -1251,6 +1252,18 @@
   Failed());
 }
 
+TEST(CompletionTest, QualifiedNames) {
+  auto Results = completions(
+  R"cpp(
+  namespace ns { int local; void both(); }
+  void f() { ::ns::^ }
+  )cpp",
+  {func("ns::both"), cls("ns::Index")});
+  // We get results from both index and sema, with no duplicates.
+  EXPECT_THAT(Results.items,
+  UnorderedElementsAre(QName("ns::local"), QName("ns::Index"),
+   QName("ns::both")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -734,6 +734,13 @@
   //
   // data?: any - A data entry field that is preserved on a completion item
   //  between a completion and a completion resolve request.
+
+  // C++ extension that is only expected to be used by users of ClangdServer's
+  // C++ API. Not serialized from/to json.
+  /// Qualified name of the symbol this item corresponds to. Empty if the item
+  /// has no corresponding symbol (e.g. keyword).
+  /// FIXME: find a more precise way to identify a completion item.
+  std::string QualifiedSymbolName;
 };
 json::Expr toJSON(const CompletionItem &);
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const CompletionItem &);
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -243,6 +243,8 @@
const IncludeInserter &Includes,
llvm::StringRef SemaDocComment) const {
 assert(bool(SemaResult) == bool(SemaCCS));
+assert(bool(SemaResult) || bool(IndexResult));
+
 CompletionItem I;
 bool InsertingInclude = false; // Whether a new #include will be added.
 if (SemaResult) {
@@ -252,8 +254,14 @@
   I.filterText = getFilterText(*SemaCCS);
   I.documentation = formatDocumentation(*SemaCCS, SemaDocComment);
   I.detail = getDetail(*SemaCCS);
+  if (SemaResult->Kind == CodeCompletionResult::RK_Declaration)
+if (const auto *D = SemaResult->getDeclaration())
+  if (const auto *ND = llvm::dyn_cast(D))
+I.QualifiedName = ND->getQualifiedNameAsString();
 }
 if (IndexResult) {
+  if (I.QualifiedName.empty())
+I.QualifiedName = (IndexResult->Scope + IndexResult->Name).str();
   if (I.kind == CompletionItemKind::Missing)
 I.kind = toCompletionItemKind(IndexResult->SymInfo.Kind);
   // FIXME: reintroduce a way to show the index source for debugging.


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -44,6 +44,7 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.insertText == Name; }
+MATCHER_P(QName, Name, "") { return arg.QualifiedName == Name; }
 MATCHER_P(Labeled, Label, "") {
   std::string Indented;
   if (!StringRef(Label).startswith(
@@ -1251,6 +1252,18 @@
   Failed());
 }
 
+TEST(CompletionTest, QualifiedNames) {
+  auto Results = completions(
+  R"cpp(
+  namespace ns { int local; void both(); }
+  void f() { ::ns::^ }
+  )cpp",
+  {func("ns::both"), cls("ns::Index")});
+  // We get results from both index and sema, with no duplicates.
+  EXPECT_THAT(Results.items,
+  UnorderedElementsAre(QName("ns::local"), QName("ns::Index"),
+   QName("ns::both")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -734,6 +734,13 @@
   //
   // data?: any - A data entry field that is preserved on a completion item
   // 

[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 152265.
ioeric added a comment.

- Fix build


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48425

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


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -44,6 +44,7 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.insertText == Name; }
+MATCHER_P(QName, Name, "") { return arg.QualifiedSymbolName == Name; }
 MATCHER_P(Labeled, Label, "") {
   std::string Indented;
   if (!StringRef(Label).startswith(
@@ -1251,6 +1252,18 @@
   Failed());
 }
 
+TEST(CompletionTest, QualifiedNames) {
+  auto Results = completions(
+  R"cpp(
+  namespace ns { int local; void both(); }
+  void f() { ::ns::^ }
+  )cpp",
+  {func("ns::both"), cls("ns::Index")});
+  // We get results from both index and sema, with no duplicates.
+  EXPECT_THAT(Results.items,
+  UnorderedElementsAre(QName("ns::local"), QName("ns::Index"),
+   QName("ns::both")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -734,6 +734,13 @@
   //
   // data?: any - A data entry field that is preserved on a completion item
   //  between a completion and a completion resolve request.
+
+  // C++ extension that is only expected to be used by users of ClangdServer's
+  // C++ API. Not serialized from/to json.
+  /// Qualified name of the symbol this item corresponds to. Empty if the item
+  /// has no corresponding symbol (e.g. keyword).
+  /// FIXME: find a more precise way to identify a completion item.
+  std::string QualifiedSymbolName;
 };
 json::Expr toJSON(const CompletionItem &);
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const CompletionItem &);
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -243,6 +243,8 @@
const IncludeInserter &Includes,
llvm::StringRef SemaDocComment) const {
 assert(bool(SemaResult) == bool(SemaCCS));
+assert(bool(SemaResult) || bool(IndexResult));
+
 CompletionItem I;
 bool InsertingInclude = false; // Whether a new #include will be added.
 if (SemaResult) {
@@ -252,8 +254,14 @@
   I.filterText = getFilterText(*SemaCCS);
   I.documentation = formatDocumentation(*SemaCCS, SemaDocComment);
   I.detail = getDetail(*SemaCCS);
+  if (SemaResult->Kind == CodeCompletionResult::RK_Declaration)
+if (const auto *D = SemaResult->getDeclaration())
+  if (const auto *ND = llvm::dyn_cast(D))
+I.QualifiedSymbolName = ND->getQualifiedNameAsString();
 }
 if (IndexResult) {
+  if (I.QualifiedSymbolName.empty())
+I.QualifiedSymbolName = (IndexResult->Scope + IndexResult->Name).str();
   if (I.kind == CompletionItemKind::Missing)
 I.kind = toCompletionItemKind(IndexResult->SymInfo.Kind);
   // FIXME: reintroduce a way to show the index source for debugging.


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -44,6 +44,7 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.insertText == Name; }
+MATCHER_P(QName, Name, "") { return arg.QualifiedSymbolName == Name; }
 MATCHER_P(Labeled, Label, "") {
   std::string Indented;
   if (!StringRef(Label).startswith(
@@ -1251,6 +1252,18 @@
   Failed());
 }
 
+TEST(CompletionTest, QualifiedNames) {
+  auto Results = completions(
+  R"cpp(
+  namespace ns { int local; void both(); }
+  void f() { ::ns::^ }
+  )cpp",
+  {func("ns::both"), cls("ns::Index")});
+  // We get results from both index and sema, with no duplicates.
+  EXPECT_THAT(Results.items,
+  UnorderedElementsAre(QName("ns::local"), QName("ns::Index"),
+   QName("ns::both")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -734,6 +734,13 @@
   //
   // data?: any - A data entry field that is preserved on a completion item
   //  between a completion and a completion resolve request.
+
+  // C++ extension that is only expected to be used by users of ClangdServer's
+  // C++ API. Not serialized from/to json.
+  /// Qualified name of the symbol this item corresponds to. Empty if the item
+  /// has no corresponding symbo

[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

2018-06-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, rnk, rsmith.

With MSVC, PCH files are created along with an object file that needs to be 
linked into the final library or executable. That object file contains the code 
generated when building the headers. In particular, it will include definitions 
of inline dllexport functions, and because they are emitted in this object 
file, other files using the PCH do not need to emit them. See the bug for an 
example.

This patch makes clang-cl match MSVC's behaviour in this regard, causing 
significant compile-time savings when building dlls using precompiled headers.

For example, in a 64-bit optimized shared library build of Chromium with PCH, 
it reduces the binary size and compile time of stroke_opacity_custom.obj from 
9315564 bytes to 3659629 bytes and 14.6 to 6.63 s. The wall-clock time of 
building blink_core.dll goes from 38m41s to 22m33s. ("user" time goes from 
1979m to 1142m).


https://reviews.llvm.org/D48426

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/ExternalASTSource.h
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/FrontendOptions.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  lib/AST/ASTContext.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  test/CodeGen/pch-dllexport.cpp
  test/Driver/cl-pch.cpp

Index: test/Driver/cl-pch.cpp
===
--- test/Driver/cl-pch.cpp
+++ test/Driver/cl-pch.cpp
@@ -7,13 +7,15 @@
 // 1. Build .pch file.
 // CHECK-YC: cc1
 // CHECK-YC: -emit-pch
+// CHECK-YC: -building-pch-with-obj
 // CHECK-YC: -o
 // CHECK-YC: pchfile.pch
 // CHECK-YC: -x
 // CHECK-YC: "c++-header"
 // 2. Use .pch file.
 // CHECK-YC: cc1
 // CHECK-YC: -emit-obj
+// CHECK-YC: -building-pch-with-obj
 // CHECK-YC: -include-pch
 // CHECK-YC: pchfile.pch
 
@@ -24,11 +26,13 @@
 // 1. Build .pch file.
 // CHECK-YCO: cc1
 // CHECK-YCO: -emit-pch
+// CHECK-YCO: -building-pch-with-obj
 // CHECK-YCO: -o
 // CHECK-YCO: pchfile.pch
 // 2. Use .pch file.
 // CHECK-YCO: cc1
 // CHECK-YCO: -emit-obj
+// CHECK-YCO: -building-pch-with-obj
 // CHECK-YCO: -include-pch
 // CHECK-YCO: pchfile.pch
 // CHECK-YCO: -o
@@ -46,6 +50,7 @@
 // RUN:   | FileCheck -check-prefix=CHECK-YU %s
 // Use .pch file, but don't build it.
 // CHECK-YU-NOT: -emit-pch
+// CHECK-YU-NOT: -building-pch-with-obj
 // CHECK-YU: cc1
 // CHECK-YU: -emit-obj
 // CHECK-YU: -include-pch
@@ -63,6 +68,7 @@
 // 1. Build .pch file.
 // CHECK-YC-YU: cc1
 // CHECK-YC-YU: -emit-pch
+// CHECK-YC-YU: -building-pch-with-obj
 // CHECK-YC-YU: -o
 // CHECK-YC-YU: pchfile.pch
 // 2. Use .pch file.
Index: test/CodeGen/pch-dllexport.cpp
===
--- /dev/null
+++ test/CodeGen/pch-dllexport.cpp
@@ -0,0 +1,25 @@
+// Build PCH without object file, then use it.
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCH %s
+
+// Build PCH with object file, then use it.
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-pch -building-pch-with-obj -o %t %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -building-pch-with-obj -o - %s | FileCheck -check-prefix=OBJ %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm -include-pch %t -o - %s | FileCheck -check-prefix=PCHWITHOBJ %s
+
+#ifndef IN_HEADER
+#define IN_HEADER
+
+inline void __declspec(dllexport) foo() {}
+// OBJ: define weak_odr dso_local dllexport void @"?foo@@YAXXZ"
+// PCH: define weak_odr dso_local dllexport void @"?foo@@YAXXZ"
+// PCHWITHOBJ-NOT: define weak_odr dso_local dllexport void @"?foo@@YAXXZ"
+
+struct __declspec(dllexport) S {
+  void bar() {}
+// OBJ: define weak_odr dso_local dllexport x86_thiscallcc void @"?bar@S@@QAEXXZ"
+// PCH: define weak_odr dso_local dllexport x86_thiscallcc void @"?bar@S@@QAEXXZ"
+// PCHWITHOBJ-NOT: define weak_odr dso_local dllexport x86_thiscallcc void @"?bar@S@@QAEXXZ"
+};
+
+#endif
Index: lib/Serialization/GeneratePCH.cpp
===
--- lib/Serialization/GeneratePCH.cpp
+++ lib/Serialization/GeneratePCH.cpp
@@ -25,11 +25,11 @@
 const Preprocessor &PP, StringRef OutputFile, StringRef isysroot,
 std::shared_ptr Buffer,
 ArrayRef> Extensions,
-bool AllowASTWithErrors, bool IncludeTimestamps)
+bool AllowASTWithErrors, bool In

[PATCH] D48427: [Analyzer] Fix for D47417 to make the tests pass

2018-06-21 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, rnkovacs.
Herald added subscribers: mikhail.ramalho, a.sidorin, dkrupp, szepet, 
xazax.hun, whisperity.
Herald added a reviewer: george.karpenkov.

https://reviews.llvm.org/D47417 is a fix for an accidentally missing 
transition. However, if we apply that fix, the checker will remove data from 
the GDM which is still needed. In this fix we mark regions of containers with 
active iterators alive.


https://reviews.llvm.org/D48427

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp


Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -168,7 +168,7 @@
 class IteratorChecker
 : public Checker,
- check::DeadSymbols,
+ check::LiveSymbols, check::DeadSymbols,
  eval::Assume> {
 
   std::unique_ptr OutOfRangeBugType;
@@ -198,6 +198,7 @@
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostStmt(const MaterializeTemporaryExpr *MTE,
  CheckerContext &C) const;
+  void checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const;
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
   ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
  bool Assumption) const;
@@ -363,6 +364,22 @@
   C.addTransition(State);
 }
 
+void IteratorChecker::checkLiveSymbols(ProgramStateRef State,
+   SymbolReaper &SR) const {
+  // Keep containers alive while iterators are alive
+  auto RegionMap = State->get();
+  for (const auto Reg : RegionMap) {
+const auto Pos = Reg.second;
+SR.markLive(Pos.getContainer());
+  }
+
+  auto SymbolMap = State->get();
+  for (const auto Sym : SymbolMap) {
+const auto Pos = Sym.second;
+SR.markLive(Pos.getContainer());
+  }
+}
+
 void IteratorChecker::checkDeadSymbols(SymbolReaper &SR,
CheckerContext &C) const {
   // Cleanup
@@ -395,6 +412,8 @@
   State = State->remove(Comp.first);
 }
   }
+
+  C.addTransition(State);
 }
 
 ProgramStateRef IteratorChecker::evalAssume(ProgramStateRef State, SVal Cond,


Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -168,7 +168,7 @@
 class IteratorChecker
 : public Checker,
- check::DeadSymbols,
+ check::LiveSymbols, check::DeadSymbols,
  eval::Assume> {
 
   std::unique_ptr OutOfRangeBugType;
@@ -198,6 +198,7 @@
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostStmt(const MaterializeTemporaryExpr *MTE,
  CheckerContext &C) const;
+  void checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const;
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
   ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
  bool Assumption) const;
@@ -363,6 +364,22 @@
   C.addTransition(State);
 }
 
+void IteratorChecker::checkLiveSymbols(ProgramStateRef State,
+   SymbolReaper &SR) const {
+  // Keep containers alive while iterators are alive
+  auto RegionMap = State->get();
+  for (const auto Reg : RegionMap) {
+const auto Pos = Reg.second;
+SR.markLive(Pos.getContainer());
+  }
+
+  auto SymbolMap = State->get();
+  for (const auto Sym : SymbolMap) {
+const auto Pos = Sym.second;
+SR.markLive(Pos.getContainer());
+  }
+}
+
 void IteratorChecker::checkDeadSymbols(SymbolReaper &SR,
CheckerContext &C) const {
   // Cleanup
@@ -395,6 +412,8 @@
   State = State->remove(Comp.first);
 }
   }
+
+  C.addTransition(State);
 }
 
 ProgramStateRef IteratorChecker::evalAssume(ProgramStateRef State, SVal Cond,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47956: [MS] Consder constexpr globals to be inline, as in C++17

2018-06-21 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks for explaining, makes sense to me.


https://reviews.llvm.org/D47956



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


[PATCH] D48423: [liblang] Remove DOS line endings in libclang.exports

2018-06-21 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335234: [liblang] Remove DOS line endings in 
libclang.exports (authored by ro, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D48423

Files:
  tools/libclang/libclang.exports


Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -168,14 +168,14 @@
 clang_getCompletionAnnotation
 clang_getCompletionAvailability
 clang_getCompletionBriefComment
-clang_getCompletionChunkCompletionString
-clang_getCompletionChunkKind
-clang_getCompletionChunkText
-clang_getCompletionNumFixIts
-clang_getCompletionFixIt
-clang_getCompletionNumAnnotations
-clang_getCompletionParent
-clang_getCompletionPriority
+clang_getCompletionChunkCompletionString
+clang_getCompletionChunkKind
+clang_getCompletionChunkText
+clang_getCompletionNumFixIts
+clang_getCompletionFixIt
+clang_getCompletionNumAnnotations
+clang_getCompletionParent
+clang_getCompletionPriority
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
@@ -259,13 +259,13 @@
 clang_getResultType
 clang_getSkippedRanges
 clang_getSpecializedCursorTemplate
-clang_getSpellingLocation
-clang_getTUResourceUsageName
-clang_getTemplateCursorKind
-clang_getToken
-clang_getTokenExtent
-clang_getTokenKind
-clang_getTokenLocation
+clang_getSpellingLocation
+clang_getTUResourceUsageName
+clang_getTemplateCursorKind
+clang_getToken
+clang_getTokenExtent
+clang_getTokenKind
+clang_getTokenLocation
 clang_getTokenSpelling
 clang_getTranslationUnitCursor
 clang_getTranslationUnitSpelling


Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -168,14 +168,14 @@
 clang_getCompletionAnnotation
 clang_getCompletionAvailability
 clang_getCompletionBriefComment
-clang_getCompletionChunkCompletionString
-clang_getCompletionChunkKind
-clang_getCompletionChunkText
-clang_getCompletionNumFixIts
-clang_getCompletionFixIt
-clang_getCompletionNumAnnotations
-clang_getCompletionParent
-clang_getCompletionPriority
+clang_getCompletionChunkCompletionString
+clang_getCompletionChunkKind
+clang_getCompletionChunkText
+clang_getCompletionNumFixIts
+clang_getCompletionFixIt
+clang_getCompletionNumAnnotations
+clang_getCompletionParent
+clang_getCompletionPriority
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
@@ -259,13 +259,13 @@
 clang_getResultType
 clang_getSkippedRanges
 clang_getSpecializedCursorTemplate
-clang_getSpellingLocation
-clang_getTUResourceUsageName
-clang_getTemplateCursorKind
-clang_getToken
-clang_getTokenExtent
-clang_getTokenKind
-clang_getTokenLocation
+clang_getSpellingLocation
+clang_getTUResourceUsageName
+clang_getTemplateCursorKind
+clang_getToken
+clang_getTokenExtent
+clang_getTokenKind
+clang_getTokenLocation
 clang_getTokenSpelling
 clang_getTranslationUnitCursor
 clang_getTranslationUnitSpelling
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

2018-06-21 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Looks like pretty straightforward plumbing. I can't think of a better place 
than ASTContext either. I think this is fine with your two XXXs just removed.

Exciting build time wins!




Comment at: lib/AST/ASTContext.cpp:9557
+  if (D->isFromASTFile() && !BuildingPCHWithObjectFile) {
+assert(getExternalSource() && "It's from an AST file; must be a source.");
+// On Windows, PCH files are built together with an object file. If this

nit: s/be/have/


https://reviews.llvm.org/D48426



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


[PATCH] D6260: Add -mlong-double-64 flag

2018-06-21 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: lib/Basic/TargetInfo.cpp:277
+LongDoubleWidth = 64;
+LongDoubleAlign = 32;
+LongDoubleFormat = &llvm::APFloat::IEEEdouble;

This seems wrong for targets in general. Maybe this should be, instead of 32 
always, 64 on 64-bit targets?


https://reviews.llvm.org/D6260



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


[PATCH] D48259: [clang-format] Fix bug with UT_Always when there is less than one full tab

2018-06-21 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/WhitespaceManager.cpp:678
 // Indent with tabs only when there's at least one full tab.
-if (FirstTabWidth + Style.TabWidth <= Spaces) {
+if (Style.TabWidth <= Spaces) {
   Spaces -= FirstTabWidth;

guigu wrote:
> klimek wrote:
> > Why is this not just if (FirstTabWidth <= Spaces) then?
> Actually, that was my first way of fixing it. 
> 
> ```
> if (FirstTabWidth <= Spaces && Spaces > 1) // to avoid converting a single 
> space to a tab
> ```
> 
> Doing so will produce a correct output but introduce what I thought could be 
> an unwanted change : whitespace less than **TabWidth** might get converted to 
> a tab.
> The comment above the test seems to indicate that this behavior was not 
> originally wanted, that's why I changed my mind. 
> 
> But after thinking it over, I think my fix attempt also introduce an unwanted 
> change. I misinterpreted the original goal of this option.
> I went back to the official documentation and it says
> 
> > Use tabs whenever we need to fill whitespace that spans at least from one 
> > tab stop to the next one
> 
> This is clearly not what this code is doing. I can land another patch for a 
> more appropriate fix but I wonder if this option should stay like this. 
> Aren't people expecting the formatting to use as much tab as possible with 
> UT_Always ?
> 
> Unless I'm mistaken, the following example (**TabWidth** of 4)
> 
> 
> ```
> int a = 42;
> int aa = 42;
> int aaa = 42;
> int  = 42;
> ```
> would become (following what's written in the documentation)
> 
> ```
> int a= 42;
> int aa   = 42;
> int aaa  = 42;
> int  = 42; 
> // only spaces since there's never enough whitespace to span a full tab stop
> ```
> And this is what I would expect:
> 
> ```
> int a  = 42; // int a\t = 42;
> int aa = 42; // int aa\t = 42;
> int aaa= 42; // int aaa\t = 42;
> int  = 42; // int  = 42;
> ```
The intent of the Always setting was to mirror what the Linux kernel wants, so 
whatever that is, we should probably follow it :)


Repository:
  rC Clang

https://reviews.llvm.org/D48259



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


[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

2018-06-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I think you revved the PCH version last. Did you have to do anything special, 
e.g. will it break vendors who ship PCH files as part of SDKs and such? Or are 
things generally set up to handle this?


https://reviews.llvm.org/D48426



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


[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments

2018-06-21 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

Ping?


https://reviews.llvm.org/D46013



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


[PATCH] D48432: [clang-format] Add AlwaysBreakBeforeMultilineString tests

2018-06-21 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D48432

Files:
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1227,6 +1227,15 @@
" @\"\");");
   verifyFormat("(qqq, @\"\"\n"
"  @\"\");");
+  verifyFormat("[ :@\"\"\n"
+   "   @\"\"];");
+  verifyFormat(" = [ :@\"\"\n"
+   "  @\"\"];");
+  verifyFormat("[ :@\"\"\n"
+   "   @\"\"\n"
+   "rr:42\n"
+   "ss:@\"ee\"\n"
+   "   @\"f\"];");
 }
 
 } // end namespace


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1227,6 +1227,15 @@
" @\"\");");
   verifyFormat("(qqq, @\"\"\n"
"  @\"\");");
+  verifyFormat("[ :@\"\"\n"
+   "   @\"\"];");
+  verifyFormat(" = [ :@\"\"\n"
+   "  @\"\"];");
+  verifyFormat("[ :@\"\"\n"
+   "   @\"\"\n"
+   "rr:42\n"
+   "ss:@\"ee\"\n"
+   "   @\"f\"];");
 }
 
 } // end namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

2018-06-21 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

PCHs aren't compatible with themselves if only the compiler revision changes, 
so I'm not sure changing that field should be worse than a regular compiler 
revision update (which happens at every commit). But I don't know what this 
field is for. I don't remember any trouble from me changing it though, and if 
it was bad to change it I'd hope there'd be a comment right above the field 
telling us why. (If I had run into problems, I would've expected me to add a 
comment like this.)


https://reviews.llvm.org/D48426



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


r335234 - [liblang] Remove DOS line endings in libclang.exports

2018-06-21 Thread Rainer Orth via cfe-commits
Author: ro
Date: Thu Jun 21 06:40:50 2018
New Revision: 335234

URL: http://llvm.org/viewvc/llvm-project?rev=335234&view=rev
Log:
[liblang] Remove DOS line endings in libclang.exports

Undefined   first referenced
 symbol in file
clang_getCompletionFixIt   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenLocation 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getToken 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTemplateCursorKind
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTUResourceUsageName   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkKind   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkText   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getSpellingLocation  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionParent  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionChunkCompletionString 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionPriority
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionNumFixIts   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenExtent   
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getCompletionNumAnnotations  
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
clang_getTokenKind 
/var/gcc/llvm/obj/local/tools/clang/tools/libclang/libclang.exports
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[2]: *** 
[tools/clang/tools/libclang/CMakeFiles/libclang.dir/build.make:651: 
lib/libclang.so.7] Error 1

It turns out that this is caused by https://reviews.llvm.org/D46862: it added a
couple of CRs (^M) to some lines.  Solaris ld takes them to be part of the 
symbol
names, which of course are missing from the input objects.  GNU ld handles this
just fine.  Fixed by removing the CRs.

Bootstrapped on i386-pc-solaris2.11.  I guess this is obvious.

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

Modified:
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/tools/libclang/libclang.exports
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=335234&r1=335233&r2=335234&view=diff
==
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Thu Jun 21 06:40:50 2018
@@ -168,14 +168,14 @@ clang_getClangVersion
 clang_getCompletionAnnotation
 clang_getCompletionAvailability
 clang_getCompletionBriefComment
-clang_getCompletionChunkCompletionString
-clang_getCompletionChunkKind
-clang_getCompletionChunkText
-clang_getCompletionNumFixIts
-clang_getCompletionFixIt
-clang_getCompletionNumAnnotations
-clang_getCompletionParent
-clang_getCompletionPriority
+clang_getCompletionChunkCompletionString
+clang_getCompletionChunkKind
+clang_getCompletionChunkText
+clang_getCompletionNumFixIts
+clang_getCompletionFixIt
+clang_getCompletionNumAnnotations
+clang_getCompletionParent
+clang_getCompletionPriority
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
@@ -259,13 +259,13 @@ clang_getRemappingsFromFileList
 clang_getResultType
 clang_getSkippedRanges
 clang_getSpecializedCursorTemplate
-clang_getSpellingLocation
-clang_getTUResourceUsageName
-clang_getTemplateCursorKind
-clang_getToken
-clang_getTokenExtent
-clang_getTokenKind
-clang_getTokenLocation
+clang_getSpellingLocation
+clang_getTUResourceUsageName
+clang_getTemplateCursorKind
+clang_getToken
+clang_getTokenExtent
+clang_getTokenKind
+clang_getTokenLocation
 clang_getTokenSpelling
 clang_getTranslationUnitCursor
 clang_getTranslationUnitSpelling


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


[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).

2018-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CodeComplete.cpp:246
 assert(bool(SemaResult) == bool(SemaCCS));
+assert(bool(SemaResult) || bool(IndexResult));
+

can skip the bool() here if you like



Comment at: clangd/Protocol.h:743
+  /// FIXME: find a more precise way to identify a completion item.
+  std::string QualifiedSymbolName;
 };

So this is always set to scope + filterText (except for non-decl completions, 
where you're not setting it in this patch).

WDYT about just making that "scope", and for now relying on the fact that scope 
+ filtertext gives you a nice readable name?

Advantages:
 - it's a bit smaller
 - as we add more structure to the C++ completion API, I think we'll want to 
expose scope+name split, so this would be closer to the desired state.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48425



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


[PATCH] D48436: [analyzer][UninitializedObjectChecker] Fixed a false negative by no longer filtering out certain constructor calls

2018-06-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: george.karpenkov, NoQ, xazax.hun, rnkovacs.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, 
whisperity.

As of now, all constructor calls are ignored that are being called by a 
constructor. The point of this was not to analyze the fields of an object, so 
an uninitialized field wouldn't be reported multiple times.

This however introduced false negatives when the two constructors were in no 
relation to one another -- see the test file for a neat example for this with 
singletons.

This patch aims so fix this issue.


Repository:
  rC Clang

https://reviews.llvm.org/D48436

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object.cpp


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1035,13 +1035,12 @@
 // While a singleton would make more sense as a static variable, that would 
zero
 // initialize all of its fields, hence the not too practical implementation.
 struct Singleton {
-  // TODO: we'd expect the note: {{uninitialized field 'this->i'}}
-  int i; // no-note
+  int i; // expected-note{{uninitialized field 'this->i'}}
+  int dontGetFilteredByNonPedanticMode = 0;
 
   Singleton() {
 assert(!isInstantiated);
-// TODO: we'd expect the warning: {{1 uninitialized field}}
-isInstantiated = true; // no-warning
+isInstantiated = true; // expected-warning{{1 uninitialized field}}
   }
 
   ~Singleton() {
Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
@@ -212,9 +212,11 @@
 Optional
 getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context);
 
-/// Checks whether the constructor under checking is called by another
-/// constructor.
-bool isCalledByConstructor(const CheckerContext &Context);
+/// Checks whether the object constructed by \p Ctor will be analyzed later
+/// (e.g. if the object is a field of another object, in which case we'd check
+/// it multiple times).
+bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
+   CheckerContext &Context);
 
 /// Returns whether FD can be (transitively) dereferenced to a void pointer 
type
 /// (void*, void**, ...). The type of the region behind a void pointer isn't
@@ -255,7 +257,7 @@
 return;
 
   // This avoids essentially the same error being reported multiple times.
-  if (isCalledByConstructor(Context))
+  if (willObjectBeAnalyzedLater(CtorDecl, Context))
 return;
 
   Optional Object = getObjectVal(CtorDecl, Context);
@@ -419,8 +421,8 @@
   }
 
   // Checking bases.
-  // FIXME: As of now, because of `isCalledByConstructor`, objects whose type
-  // is a descendant of another type will emit warnings for uninitalized
+  // FIXME: As of now, because of `willObjectBeAnalyzedLater`, objects whose
+  // type is a descendant of another type will emit warnings for uninitalized
   // inherited members.
   // This is not the only way to analyze bases of an object -- if we didn't
   // filter them out, and didn't analyze the bases, this checker would run for
@@ -661,15 +663,29 @@
   return Object.getAs();
 }
 
-// TODO: We should also check that if the constructor was called by another
-// constructor, whether those two are in any relation to one another. In it's
-// current state, this introduces some false negatives.
-bool isCalledByConstructor(const CheckerContext &Context) {
+bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
+   CheckerContext &Context) {
   const LocationContext *LC = Context.getLocationContext()->getParent();
 
+  Optional CurrentObject =
+  getObjectVal(Ctor, Context);
+  if (!CurrentObject)
+return false;
+
   while (LC) {
-if (isa(LC->getDecl()))
-  return true;
+// If this constructor was called by another constructor.
+if (const auto *OtherCtor = dyn_cast(LC->getDecl())) {
+
+  Optional OtherObject =
+  getObjectVal(OtherCtor, Context);
+  if (!OtherObject)
+continue;
+
+  // If the CurrentObject is a field of OtherObject, it will be analyzed
+  // during the analysis of OtherObject.
+  if (CurrentObject->getRegion()->isSubRegionOf(OtherObject->getRegion()))
+return true;
+}
 
 LC = LC->getParent();
   }


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1035,13 +1035,12 @@
 // While a singleton would make more sense as a static variable, that would zero
 // initialize all

[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

2018-06-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D48426#1139318, @thakis wrote:

> PCHs aren't compatible with themselves if only the compiler revision changes, 
> so I'm not sure changing that field should be worse than a regular compiler 
> revision update (which happens at every commit). But I don't know what this 
> field is for. I don't remember any trouble from me changing it though, and if 
> it was bad to change it I'd hope there'd be a comment right above the field 
> telling us why. (If I had run into problems, I would've expected me to add a 
> comment like this.)


Sounds good, thanks.


https://reviews.llvm.org/D48426



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


[PATCH] D48438: [Sema] Updated note for address spaces to print the type.

2018-06-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: yaxunl.

This allows to reuse the same diagnostic for OpenCL or CUDA.

For OpenCL this will be tested in 
`test/SemaOpenCL/address-spaces-conversions-cl2.0.cl` that I plan to enable 
with `-cl-std=c++` after fixing other issues.


https://reviews.llvm.org/D48438

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOverload.cpp
  test/SemaCXX/address-space-references.cpp


Index: test/SemaCXX/address-space-references.cpp
===
--- test/SemaCXX/address-space-references.cpp
+++ test/SemaCXX/address-space-references.cpp
@@ -3,10 +3,10 @@
 typedef int __attribute__((address_space(1))) int_1;
 typedef int __attribute__((address_space(2))) int_2;
 
-void f0(int_1 &); // expected-note{{candidate function not viable: 1st 
argument ('int') is in address space 0, but parameter must be in address space 
1}} \
-// expected-note{{candidate function not viable: 1st argument ('int_2' (aka 
'__attribute__((address_space(2))) int')) is in address space 2, but parameter 
must be in address space 1}}
-void f0(const int_1 &); // expected-note{{candidate function not viable: 1st 
argument ('int') is in address space 0, but parameter must be in address space 
1}} \
-// expected-note{{candidate function not viable: 1st argument ('int_2' (aka 
'__attribute__((address_space(2))) int')) is in address space 2, but parameter 
must be in address space 1}}
+void f0(int_1 &); // expected-note{{candidate function not viable: address 
space mismatch in 1st argument ('int'), parameter type must be 'int_1 &' (aka 
'__attribute__((address_space(1))) int &')}} \
+// expected-note{{candidate function not viable: address space mismatch in 1st 
argument ('int_2' (aka '__attribute__((address_space(2))) int')), parameter 
type must be 'int_1 &' (aka '__attribute__((address_space(1))) int &')}}
+void f0(const int_1 &); // expected-note{{candidate function not viable: 
address space mismatch in 1st argument ('int'), parameter type must be 'const 
int_1 &' (aka 'const __attribute__((address_space(1))) int &')}} \
+// expected-note{{candidate function not viable: address space mismatch in 1st 
argument ('int_2' (aka '__attribute__((address_space(2))) int')), parameter 
type must be 'const int_1 &' (aka 'const __attribute__((address_space(1))) int 
&')}}
 
 void test_f0() {
   int i;
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -9614,9 +9614,7 @@
   S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
   << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << 
FnDesc
   << (FromExpr ? FromExpr->getSourceRange() : SourceRange()) << FromTy
-  << FromQs.getAddressSpaceAttributePrintValue()
-  << ToQs.getAddressSpaceAttributePrintValue()
-  << (unsigned)isObjectArgument << I + 1;
+  << ToTy << (unsigned)isObjectArgument << I + 1;
   MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
   return;
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3680,8 +3680,8 @@
 "%select{%ordinal4 argument|object argument}3">;
 def note_ovl_candidate_bad_addrspace : Note<
 "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: "
-"%select{%ordinal7|'this'}6 argument (%3) is in "
-"address space %4, but parameter must be in address space %5">;
+"address space mismatch in %select{%ordinal6|'this'}5 argument (%3), "
+"parameter type must be %4">;
 def note_ovl_candidate_bad_gc : Note<
 "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: "
 "%select{%ordinal7|'this'}6 argument (%3) has %select{no|__weak|__strong}4 
"


Index: test/SemaCXX/address-space-references.cpp
===
--- test/SemaCXX/address-space-references.cpp
+++ test/SemaCXX/address-space-references.cpp
@@ -3,10 +3,10 @@
 typedef int __attribute__((address_space(1))) int_1;
 typedef int __attribute__((address_space(2))) int_2;
 
-void f0(int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
-// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
-void f0(const int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
-// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
+vo

[PATCH] D45718: [analyzer] Allow registering custom statically-linked analyzer checkers

2018-06-21 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 152317.
alexfh added a comment.
Herald added subscribers: mikhail.ramalho, mgorny.

- Added a test.


Repository:
  rC Clang

https://reviews.llvm.org/D45718

Files:
  include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
  include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
  unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
  unittests/StaticAnalyzer/CMakeLists.txt
  unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- /dev/null
+++ unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -0,0 +1,80 @@
+//===- unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerRegistry.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
+#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+class CustomChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+BugReporter &BR) const {
+BR.EmitBasicReport(D, this, "Custom diagnostic", categories::LogicError,
+   "Custom diagnostic description",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+class TestAction : public ASTFrontendAction {
+  class DiagConsumer : public PathDiagnosticConsumer {
+llvm::raw_ostream &Output;
+
+  public:
+DiagConsumer(llvm::raw_ostream &Output) : Output(Output) {}
+void FlushDiagnosticsImpl(std::vector &Diags,
+  FilesMade *filesMade) override {
+  for (const auto *PD : Diags)
+Output << PD->getCheckName() << ":" << PD->getShortDescription();
+}
+
+StringRef getName() const override { return "Test"; }
+  };
+
+  llvm::raw_ostream &DiagsOutput;
+
+public:
+  TestAction(llvm::raw_ostream &DiagsOutput) : DiagsOutput(DiagsOutput) {}
+
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef File) override {
+std::unique_ptr AnalysisConsumer =
+CreateAnalysisConsumer(Compiler);
+AnalysisConsumer->AddDiagnosticConsumer(new DiagConsumer(DiagsOutput));
+Compiler.getAnalyzerOpts()->CheckersControlList = {
+{"custom.CustomChecker", true}};
+AnalysisConsumer->AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+  Registry.addChecker("custom.CustomChecker", "Description");
+});
+return AnalysisConsumer;
+  }
+};
+
+
+TEST(RegisterCustomCheckers, RegisterChecker) {
+  std::string Diags;
+  {
+llvm::raw_string_ostream OS(Diags);
+EXPECT_TRUE(tooling::runToolOnCode(new TestAction(OS), "void f() {;}"));
+  }
+  EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description");
+}
+
+}
+}
+}
Index: unittests/StaticAnalyzer/CMakeLists.txt
===
--- unittests/StaticAnalyzer/CMakeLists.txt
+++ unittests/StaticAnalyzer/CMakeLists.txt
@@ -4,11 +4,14 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  RegisterCustomCheckersTest.cpp
   )
 
 target_link_libraries(StaticAnalysisTests
   PRIVATE
   clangBasic
   clangAnalysis
-  clangStaticAnalyzerCore 
+  clangStaticAnalyzerCore
+  clangStaticAnalyzerFrontend
+  clangTooling
   )
Index: unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
===
--- unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
+++ unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
@@ -1,4 +1,4 @@
-//===- unittest/Analysis/AnalyzerOptionsTest.cpp - SA Options test ===//
+//===- unittest/StaticAnalyzer/AnalyzerOptionsTest.cpp - SA Options test --===//
 //
 // The LLVM Compiler Infrastructure
 //
Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -111,16 +111,21 @@
   return checkerOpts;
 }
 
-std::unique_ptr
-ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts,
-

[PATCH] D45718: [analyzer] Allow registering custom statically-linked analyzer checkers

2018-06-21 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Please take another look.


Repository:
  rC Clang

https://reviews.llvm.org/D45718



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


[clang-tools-extra] r335252 - [clang-tidy] Remove the google-readability-redundant-smartptr-get alias

2018-06-21 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Jun 21 09:14:27 2018
New Revision: 335252

URL: http://llvm.org/viewvc/llvm-project?rev=335252&view=rev
Log:
[clang-tidy] Remove the google-readability-redundant-smartptr-get alias

I don't remember why I added it, but it's definitely not needed, since the check
doesn't have any options and the check doesn't have any special relation to the
Google C++ style.

Removed:

clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst
Modified:
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst

Modified: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp?rev=335252&r1=335251&r2=335252&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp Thu Jun 21 
09:14:27 2018
@@ -13,7 +13,6 @@
 #include "../readability/BracesAroundStatementsCheck.h"
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/NamespaceCommentCheck.h"
-#include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
 #include "AvoidThrowingObjCExceptionCheck.h"
 #include "DefaultArgumentsCheck.h"
@@ -71,9 +70,6 @@ class GoogleModule : public ClangTidyMod
 CheckFactories
 .registerCheck(
 "google-readability-namespace-comments");
-CheckFactories
-.registerCheck(
-"google-readability-redundant-smartptr-get");
   }
 
   ClangTidyOptions getModuleOptions() override {

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=335252&r1=335251&r2=335252&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Jun 21 09:14:27 2018
@@ -193,6 +193,10 @@ Improvements to clang-tidy
   `
   added.
 
+- Removed the `google-readability-redundant-smartptr-get` alias of the
+  :doc:`readability-redundant-smartptr-get
+  ` check.
+
 - The 'misc-forwarding-reference-overload' check was renamed to 
:doc:`bugprone-forwarding-reference-overload
   `
 

Removed: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst?rev=335251&view=auto
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-redundant-smartptr-get.rst
 (removed)
@@ -1,10 +0,0 @@
-.. title:: clang-tidy - google-readability-redundant-smartptr-get
-.. meta::
-   :http-equiv=refresh: 5;URL=readability-redundant-smartptr-get.html
-
-google-readability-redundant-smartptr-get
-=
-
-The google-readability-redundant-smartptr-get check is an alias, please see
-`readability-redundant-smartptr-get `_
-for more information.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=335252&r1=335251&r2=335252&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Thu Jun 21 09:14:27 
2018
@@ -93,8 +93,8 @@ Clang-Tidy Checks
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
-   fuchsia-header-anon-namespaces (redirects to google-build-namespaces) 

fuchsia-default-arguments
+   fuchsia-header-anon-namespaces (redirects to google-build-namespaces) 

fuchsia-multiple-inheritance
fuchsia-overloaded-operator
fuchsia-restrict-system-includes
@@ -113,7 +113,6 @@ Clang-Tidy Checks
google-readability-casting
google-readability-function-size (redirects to readability-function-size) 

google-readability-namespace-comments (redirects to llvm-namespace-comment) 

-   google-readability-redundant-smartptr-get (redirects to 
readability-redundant-smartptr-get) 
google-readability-todo
google-runtime-int
google-runtime-operator

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst
URL: 
http://llvm.org/viewvc/llvm-projec

[PATCH] D48072: Sema: Fix PR12350 destructor name lookup, addressing (some of) DR244

2018-06-21 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

Ping


Repository:
  rC Clang

https://reviews.llvm.org/D48072



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


[PATCH] D48187: [Intrinsics] Add/move some builtin declarations in intrin.h to get ms-intrinsics.c to not issue warnings

2018-06-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ping


https://reviews.llvm.org/D48187



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


[PATCH] D48441: [clangd] Incorporate transitive #includes into code complete proximity scoring.

2018-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ioeric.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ilya-biryukov, mgorny.

We now compute a distance from the main file to the symbol header, which
is a weighted count of:

- some number of #include traversals from source file --> included file
- some number of FS traversals from file --> parent directory
- some number of FS traversals from parent directory --> child file/dir

This calculation is performed in the appropriate URI scheme.

This means we'll get some proximity boost from header files in main-file
contexts, even when these are in different directory trees.

This extended file proximity model is not yet incorporated in the index
interface/implementation.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48441

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/FileDistance.cpp
  clangd/FileDistance.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/XRefs.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FileDistanceTests.cpp
  unittests/clangd/HeadersTests.cpp
  unittests/clangd/QualityTests.cpp

Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -18,6 +18,7 @@
 //===--===//
 
 #include "Quality.h"
+#include "FileDistance.h"
 #include "TestFS.h"
 #include "TestTU.h"
 #include "gmock/gmock.h"
@@ -157,9 +158,21 @@
   PoorNameMatch.NameMatch = 0.2f;
   EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate());
 
-  SymbolRelevanceSignals WithProximity;
-  WithProximity.SemaProximityScore = 0.2f;
-  EXPECT_GT(WithProximity.evaluate(), Default.evaluate());
+  SymbolRelevanceSignals WithSemaProximity;
+  WithSemaProximity.SemaProximityScore = 0.2f;
+  EXPECT_GT(WithSemaProximity.evaluate(), Default.evaluate());
+
+  SymbolRelevanceSignals IndexProximate;
+  IndexProximate.SymbolURI = "unittest:/foo/bar.h";
+  llvm::StringMap ProxRoots;
+  ProxRoots[testPath("foo/baz.h")] = 0;
+  URIDistance Distance(ProxRoots);
+  IndexProximate.FileProximityMatch = &Distance;
+  EXPECT_GT(IndexProximate.evaluate(), Default.evaluate());
+  SymbolRelevanceSignals IndexDistant = IndexProximate;
+  IndexDistant.SymbolURI = "unittest:/elsewhere/path.h";
+  EXPECT_GT(IndexProximate.evaluate(), IndexDistant.evaluate()) << IndexProximate << IndexDistant;
+  EXPECT_GT(IndexDistant.evaluate(), Default.evaluate());
 
   SymbolRelevanceSignals Scoped;
   Scoped.Scope = SymbolRelevanceSignals::FileScope;
@@ -180,59 +193,6 @@
   EXPECT_LT(sortText(0, "a"), sortText(0, "z"));
 }
 
-// {a,b,c} becomes /clangd-test/a/b/c
-std::string joinPaths(llvm::ArrayRef Parts) {
-  return testPath(
-  llvm::join(Parts.begin(), Parts.end(), llvm::sys::path::get_separator()));
-}
-
-static constexpr float ProximityBase = 0.7;
-
-// Calculates a proximity score for an index symbol with declaration file
-// SymPath with the given URI scheme.
-float URIProximity(const FileProximityMatcher &Matcher, StringRef SymPath,
- StringRef Scheme = "file") {
-  auto U = URI::create(SymPath, Scheme);
-  EXPECT_TRUE(static_cast(U)) << llvm::toString(U.takeError());
-  return Matcher.uriProximity(U->toString());
-}
-
-TEST(QualityTests, URIProximityScores) {
-  FileProximityMatcher Matcher(
-  /*ProximityPaths=*/{joinPaths({"a", "b", "c", "d", "x"})});
-
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "x"})),
-  1);
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "y"})),
-  ProximityBase);
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "y", "z"})),
-  std::pow(ProximityBase, 5));
-  EXPECT_FLOAT_EQ(
-  URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "e", "y"})),
-  std::pow(ProximityBase, 2));
-  EXPECT_FLOAT_EQ(
-  URIProximity(Matcher, joinPaths({"a", "b", "m", "n", "o", "y"})),
-  std::pow(ProximityBase, 5));
-  EXPECT_FLOAT_EQ(
-  URIProximity(Matcher, joinPaths({"a", "t", "m", "n", "o", "y"})),
-  std::pow(ProximityBase, 6));
-  // Note the common directory is /clang-test/
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"m", "n", "o", "p", "y"})),
-  std::pow(ProximityBase, 7));
-}
-
-TEST(QualityTests, URIProximityScoresWithTestURI) {
-  FileProximityMatcher Matcher(
-  /*ProximityPaths=*/{joinPaths({"b", "c", "x"})});
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"b", "c", "x"}), "unittest"),
-  1);
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"b", "y"}), "unittest"),
-  std::pow(ProximityBase, 2));
-  // unittest:///b/c/x vs unittest:///m/n/y. No common directory.
-  EXPECT_FLOAT_EQ(UR

[PATCH] D48441: [clangd] Incorporate transitive #includes into code complete proximity scoring.

2018-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 152326.
sammccall added a comment.

Document some more stuff, and clang-format


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48441

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/FileDistance.cpp
  clangd/FileDistance.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/XRefs.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FileDistanceTests.cpp
  unittests/clangd/HeadersTests.cpp
  unittests/clangd/QualityTests.cpp

Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -17,6 +17,7 @@
 //
 //===--===//
 
+#include "FileDistance.h"
 #include "Quality.h"
 #include "TestFS.h"
 #include "TestTU.h"
@@ -157,9 +158,22 @@
   PoorNameMatch.NameMatch = 0.2f;
   EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate());
 
-  SymbolRelevanceSignals WithProximity;
-  WithProximity.SemaProximityScore = 0.2f;
-  EXPECT_GT(WithProximity.evaluate(), Default.evaluate());
+  SymbolRelevanceSignals WithSemaProximity;
+  WithSemaProximity.SemaProximityScore = 0.2f;
+  EXPECT_GT(WithSemaProximity.evaluate(), Default.evaluate());
+
+  SymbolRelevanceSignals IndexProximate;
+  IndexProximate.SymbolURI = "unittest:/foo/bar.h";
+  llvm::StringMap ProxRoots;
+  ProxRoots[testPath("foo/baz.h")] = 0;
+  URIDistance Distance(ProxRoots);
+  IndexProximate.FileProximityMatch = &Distance;
+  EXPECT_GT(IndexProximate.evaluate(), Default.evaluate());
+  SymbolRelevanceSignals IndexDistant = IndexProximate;
+  IndexDistant.SymbolURI = "unittest:/elsewhere/path.h";
+  EXPECT_GT(IndexProximate.evaluate(), IndexDistant.evaluate())
+  << IndexProximate << IndexDistant;
+  EXPECT_GT(IndexDistant.evaluate(), Default.evaluate());
 
   SymbolRelevanceSignals Scoped;
   Scoped.Scope = SymbolRelevanceSignals::FileScope;
@@ -180,59 +194,6 @@
   EXPECT_LT(sortText(0, "a"), sortText(0, "z"));
 }
 
-// {a,b,c} becomes /clangd-test/a/b/c
-std::string joinPaths(llvm::ArrayRef Parts) {
-  return testPath(
-  llvm::join(Parts.begin(), Parts.end(), llvm::sys::path::get_separator()));
-}
-
-static constexpr float ProximityBase = 0.7;
-
-// Calculates a proximity score for an index symbol with declaration file
-// SymPath with the given URI scheme.
-float URIProximity(const FileProximityMatcher &Matcher, StringRef SymPath,
- StringRef Scheme = "file") {
-  auto U = URI::create(SymPath, Scheme);
-  EXPECT_TRUE(static_cast(U)) << llvm::toString(U.takeError());
-  return Matcher.uriProximity(U->toString());
-}
-
-TEST(QualityTests, URIProximityScores) {
-  FileProximityMatcher Matcher(
-  /*ProximityPaths=*/{joinPaths({"a", "b", "c", "d", "x"})});
-
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "x"})),
-  1);
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "y"})),
-  ProximityBase);
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"a", "y", "z"})),
-  std::pow(ProximityBase, 5));
-  EXPECT_FLOAT_EQ(
-  URIProximity(Matcher, joinPaths({"a", "b", "c", "d", "e", "y"})),
-  std::pow(ProximityBase, 2));
-  EXPECT_FLOAT_EQ(
-  URIProximity(Matcher, joinPaths({"a", "b", "m", "n", "o", "y"})),
-  std::pow(ProximityBase, 5));
-  EXPECT_FLOAT_EQ(
-  URIProximity(Matcher, joinPaths({"a", "t", "m", "n", "o", "y"})),
-  std::pow(ProximityBase, 6));
-  // Note the common directory is /clang-test/
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"m", "n", "o", "p", "y"})),
-  std::pow(ProximityBase, 7));
-}
-
-TEST(QualityTests, URIProximityScoresWithTestURI) {
-  FileProximityMatcher Matcher(
-  /*ProximityPaths=*/{joinPaths({"b", "c", "x"})});
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"b", "c", "x"}), "unittest"),
-  1);
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"b", "y"}), "unittest"),
-  std::pow(ProximityBase, 2));
-  // unittest:///b/c/x vs unittest:///m/n/y. No common directory.
-  EXPECT_FLOAT_EQ(URIProximity(Matcher, joinPaths({"m", "n", "y"}), "unittest"),
-  std::pow(ProximityBase, 4));
-}
-
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -64,18 +64,17 @@
   }
 
 protected:
-  std::vector collectIncludes() {
+  IncludeStructure collectIncludes() {
 auto Clang = setupClang();
 PreprocessOnlyAction Action;
 EXPECT_TRUE(
 Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
-std:

[PATCH] D48367: [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts

2018-06-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:285
 // directory.
-loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+if (ModMap.getLangOpts().ObjC1 || ModMap.getLangOpts().ObjC2)
+  loadSubdirectoryModuleMaps(SearchDirs[Idx]);

yamaguchi wrote:
> bruno wrote:
> > aprantl wrote:
> > > Are these flags also enabled in Objective-C++ mode?
> > Looks like all this logic was introduced in r177621 to allow the names of 
> > modules to differ from the name of their subdirectory in the include path.
> > 
> > Instead of having this to be based on the language, it's probably better if 
> > we have it based on @import name lookup, which is the scenario where we 
> > actually currently look more aggressively, did you try that path?
> > 
> > This is also lacking a testcase, can you create one?
> > Are these flags also enabled in Objective-C++ mode?
> I think so from FrontendOptions.h:190
> `bool isObjectiveC() const { return Lang == ObjC || Lang == ObjCXX; }`
> 
> > it's probably better if we have it based on @import name lookup
> I don't think I understood what you're saying, could you explain a bit more?
> 
> > This is also lacking a testcase, can you create one?
> Sure!
> I don't think I understood what you're saying, could you explain a bit more?

This extra call to `loadSubdirectoryModuleMaps` was introduced in r177621 to 
allow `@import SomeName` to work even if `SomeName` doesn't match a 
subdirectory name. See the original commit for more details.

This means that it was never supposed to be called when the module is built via 
`#include` or `#import`, which is what you are getting. That said, I believe 
it's better if the condition for calling `loadSubdirectoryModuleMaps` checks 
somehow if the lookup is coming from of an `@import` instead of checking the 
language (we too don't want it to be called for ObjC when `#include` or 
`#import` are used).



Comment at: clang/test/Modules/autoload-subdirectory.cpp:1
+// RUN: %clang -fmodules -fmodule-name=Foo -I %S/Inputs/autoload-subdirectory/ 
%s
+

Instead of `%clang`, please use `%clang_cc1` and `-verify` here.


https://reviews.llvm.org/D48367



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


r335253 - [X86] Rewrite the add/mul/or/and reduction intrinsics to make better use of other intrinsics and remove undef shuffle indices.

2018-06-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun 21 09:41:28 2018
New Revision: 335253

URL: http://llvm.org/viewvc/llvm-project?rev=335253&view=rev
Log:
[X86] Rewrite the add/mul/or/and reduction intrinsics to make better use of 
other intrinsics and remove undef shuffle indices.

Similar to what was done to max/min recently.

These already reduced the vector width to 256 and 128 bit as we go unlike the 
original max/min code.

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512-reduceIntrin.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=335253&r1=335252&r2=335253&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Jun 21 09:41:28 2018
@@ -9281,251 +9281,185 @@ _mm512_mask_abs_pd(__m512d __W, __mmask8
  * Used bisection method. At each step, we partition the vector with previous
  * step in half, and the operation is performed on its two halves.
  * This takes log2(n) steps where n is the number of elements in the vector.
-
- * Vec512 - Vector with size 512.
- * Operator - Can be one of following: +,*,&,|
- * T2  - Can get 'i' for int and 'f' for float.
- * T1 - Can get 'i' for int and 'd' for double.
  */
 
-#define _mm512_reduce_operator_64bit(Vec512, Operator, T2, T1) \
-  __extension__({  \
-__m256##T1 Vec256 = __builtin_shufflevector(   \
-(__v8d##T2)Vec512, \
-(__v8d##T2)Vec512, \
-0, 1, 2, 3)\
-Operator   \
-__builtin_shufflevector(   \
-(__v8d##T2)Vec512, \
-(__v8d##T2)Vec512, \
-4, 5, 6, 7);   \
-__m128##T1 Vec128 = __builtin_shufflevector(   \
-(__v4d##T2)Vec256, \
-(__v4d##T2)Vec256, \
-0, 1)  \
-Operator   \
-__builtin_shufflevector(   \
-(__v4d##T2)Vec256, \
-(__v4d##T2)Vec256, \
-2, 3); \
-Vec128 = __builtin_shufflevector((__v2d##T2)Vec128,\
- (__v2d##T2)Vec128, 0, -1) \
- Operator  \
- __builtin_shufflevector((__v2d##T2)Vec128,\
- (__v2d##T2)Vec128, 1, -1);\
-return Vec128[0];  \
-  })
+#define _mm512_mask_reduce_operator(op) \
+  __v4du __t1 = (__v4du)_mm512_extracti64x4_epi64(__W, 0); \
+  __v4du __t2 = (__v4du)_mm512_extracti64x4_epi64(__W, 1); \
+  __m256i __t3 = (__m256i)(__t1 op __t2); \
+  __v2du __t4 = (__v2du)_mm256_extracti128_si256(__t3, 0); \
+  __v2du __t5 = (__v2du)_mm256_extracti128_si256(__t3, 1); \
+  __v2du __t6 = __t4 op __t5; \
+  __v2du __t7 = __builtin_shufflevector(__t6, __t6, 1, 0); \
+  __v2du __t8 = __t6 op __t7; \
+  return __t8[0];
 
 static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_add_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, +, i, i);
+  _mm512_mask_reduce_operator(+);
 }
 
 static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_mul_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, *, i, i);
+  _mm512_mask_reduce_operator(*);
 }
 
 static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_and_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, &, i, i);
+  _mm512_mask_reduce_operator(&);
 }
 
 static __inline__ long long __DEFAULT_FN_ATTRS _mm512_reduce_or_epi64(__m512i 
__W) {
-  _mm512_reduce_operator_64bit(__W, |, i, i);
-}
-
-static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_add_pd(__m512d __W) {
-  _mm512_reduce_operator_64bit(__W, +, f, d);
+  _mm512_mask_reduce_operator(|);
 }
 
-static __inline__ double __DEFAULT_FN_ATTRS _mm512_reduce_mul_pd(__m512d __W) {
-  _mm512_reduce_operator_64bit(__W, *, f, d);
-}
-
-/* Vec512 - Vector with size 512.
- * Vec512Neutral - All vector elements set to the identity element.
- * Identity element: {+,0},{*,1},{&,0x},{|,0}
- * Operator - Can be one of f

[PATCH] D48346: [X86] Rewrite the add/mul/or/and reduction intrinsics to make better use of other intrinsics and remove undef shuffle indices.

2018-06-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335253: [X86] Rewrite the add/mul/or/and reduction 
intrinsics to make better use of… (authored by ctopper, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D48346

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512-reduceIntrin.c

Index: test/CodeGen/avx512-reduceIntrin.c
===
--- test/CodeGen/avx512-reduceIntrin.c
+++ test/CodeGen/avx512-reduceIntrin.c
@@ -1,410 +1,404 @@
-// RUN: %clang_cc1 -ffreestanding %s -O2 -triple=x86_64-apple-darwin -target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin -target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror | FileCheck %s
 
 #include 
 
 long long test_mm512_reduce_add_epi64(__m512i __W){
-  // CHECK: %shuffle.i = shufflevector <8 x i64> %__W, <8 x i64> undef, <4 x i32> 
-  // CHECK: %shuffle1.i = shufflevector <8 x i64> %__W, <8 x i64> undef, <4 x i32> 
-  // CHECK: %add.i = add <4 x i64> %shuffle.i, %shuffle1.i
-  // CHECK: %shuffle2.i = shufflevector <4 x i64> %add.i, <4 x i64> undef, <2 x i32> 
-  // CHECK: %shuffle3.i = shufflevector <4 x i64> %add.i, <4 x i64> undef, <2 x i32> 
-  // CHECK: %add4.i = add <2 x i64> %shuffle2.i, %shuffle3.i
-  // CHECK: %shuffle6.i = shufflevector <2 x i64> %add4.i, <2 x i64> undef, <2 x i32> 
-  // CHECK: %add7.i = add <2 x i64> %shuffle6.i, %add4.i
-  // CHECK: %vecext.i = extractelement <2 x i64> %add7.i, i32 0
-  // CHECK: ret i64 %vecext.i
+// CHECK-LABEL: @test_mm512_reduce_add_epi64(
+// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> undef, <4 x i32> 
+// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> undef, <4 x i32> 
+// CHECK:add <4 x i64> %{{.*}}, %{{.*}}
+// CHECK:shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> 
+// CHECK:shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> 
+// CHECK:add <2 x i64> %{{.*}}, %{{.*}}
+// CHECK:shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> 
+// CHECK:add <2 x i64> %{{.*}}, %{{.*}}
+// CHECK:extractelement <2 x i64> %{{.*}}, i32 0
   return _mm512_reduce_add_epi64(__W);
 }
 
 long long test_mm512_reduce_mul_epi64(__m512i __W){
-  // CHECK: %shuffle.i = shufflevector <8 x i64> %__W, <8 x i64> undef, <4 x i32> 
-  // CHECK: %shuffle1.i = shufflevector <8 x i64> %__W, <8 x i64> undef, <4 x i32> 
-  // CHECK: %mul.i = mul <4 x i64> %shuffle.i, %shuffle1.i
-  // CHECK: %shuffle2.i = shufflevector <4 x i64> %mul.i, <4 x i64> undef, <2 x i32> 
-  // CHECK: %shuffle3.i = shufflevector <4 x i64> %mul.i, <4 x i64> undef, <2 x i32> 
-  // CHECK: %mul4.i = mul <2 x i64> %shuffle2.i, %shuffle3.i
-  // CHECK: %shuffle6.i = shufflevector <2 x i64> %mul4.i, <2 x i64> undef, <2 x i32> 
-  // CHECK: %mul7.i = mul <2 x i64> %shuffle6.i, %mul4.i
-  // CHECK: %vecext.i = extractelement <2 x i64> %mul7.i, i32 0
-  // CHECK: ret i64 %vecext.i
+// CHECK-LABEL: @test_mm512_reduce_mul_epi64(
+// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> undef, <4 x i32> 
+// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> undef, <4 x i32> 
+// CHECK:mul <4 x i64> %{{.*}}, %{{.*}}
+// CHECK:shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> 
+// CHECK:shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> 
+// CHECK:mul <2 x i64> %{{.*}}, %{{.*}}
+// CHECK:shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> 
+// CHECK:mul <2 x i64> %{{.*}}, %{{.*}}
+// CHECK:extractelement <2 x i64> %{{.*}}, i32 0
   return _mm512_reduce_mul_epi64(__W); 
 }
 
 long long test_mm512_reduce_or_epi64(__m512i __W){
-  // CHECK: %shuffle.i = shufflevector <8 x i64> %__W, <8 x i64> undef, <4 x i32> 
-  // CHECK: %shuffle1.i = shufflevector <8 x i64> %__W, <8 x i64> undef, <4 x i32> 
-  // CHECK: %or.i = or <4 x i64> %shuffle.i, %shuffle1.i
-  // CHECK: %shuffle2.i = shufflevector <4 x i64> %or.i, <4 x i64> undef, <2 x i32> 
-  // CHECK: %shuffle3.i = shufflevector <4 x i64> %or.i, <4 x i64> undef, <2 x i32> 
-  // CHECK: %or4.i = or <2 x i64> %shuffle2.i, %shuffle3.i 
-  // CHECK: %shuffle6.i = shufflevector <2 x i64> %or4.i, <2 x i64> undef, <2 x i32> 
-  // CHECK: %or7.i = or <2 x i64> %shuffle6.i, %or4.i
-  // CHECK: %vecext.i = extractelement <2 x i64> %or7.i, i32 0
-  // CHECK: ret i64 %vecext.i
+// CHECK-LABEL: @test_mm512_reduce_or_epi64(
+// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> undef, <4 x i32> 
+// CHECK:shufflevector <8 x i64> %{{.*}}, <8 x i64> undef, <4 x i32> 
+// CHECK:or <4 x i64> %{{.*}}, %{{.*}}
+// CHECK:shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> 
+// CHECK:shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> 
+// CHECK:or <2 x i64> %{{.*}}, %{{.*}}
+// CHECK:shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> 
+// CHECK:or <2 x i64> %{{.*}}, %{{.*}}
+

[PATCH] D45718: [analyzer] Allow registering custom statically-linked analyzer checkers

2018-06-21 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D45718



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


[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/Protocol.h:743
+  /// FIXME: find a more precise way to identify a completion item.
+  std::string QualifiedSymbolName;
 };

sammccall wrote:
> So this is always set to scope + filterText (except for non-decl completions, 
> where you're not setting it in this patch).
> 
> WDYT about just making that "scope", and for now relying on the fact that 
> scope + filtertext gives you a nice readable name?
> 
> Advantages:
>  - it's a bit smaller
>  - as we add more structure to the C++ completion API, I think we'll want to 
> expose scope+name split, so this would be closer to the desired state.
Sounds good. Done.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48425



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


[PATCH] D48187: [Intrinsics] Add/move some builtin declarations in intrin.h to get ms-intrinsics.c to not issue warnings

2018-06-21 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.

lgtm


https://reviews.llvm.org/D48187



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


[PATCH] D48425: [clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).

2018-06-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 152331.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- store scope in completion item. Add splitQualifiedName for NamedDecl.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48425

Files:
  clangd/CodeComplete.cpp
  clangd/Protocol.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/index/SymbolCollector.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/SourceCodeTests.cpp

Index: unittests/clangd/SourceCodeTests.cpp
===
--- unittests/clangd/SourceCodeTests.cpp
+++ unittests/clangd/SourceCodeTests.cpp
@@ -7,11 +7,13 @@
 //
 //===--===//
 #include "SourceCode.h"
+#include "TestTU.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_os_ostream.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang{
 namespace clangd {
@@ -119,6 +121,24 @@
   EXPECT_THAT(offsetToPosition(File, 30), Pos(2, 9)) << "out of bounds";
 }
 
+std::pair makePair(StringRef x, StringRef y) {
+  return std::make_pair(x, y);
+}
+
+TEST(SplitQualifiedName, SplitQName) {
+  auto TU = TestTU::withCode("namespace nx { class X; }");
+  auto AST = TU.build();
+  EXPECT_EQ(makePair("", "nx"), splitQualifiedName(findDecl(AST, "nx")));
+  EXPECT_EQ(makePair("nx::", "X"), splitQualifiedName(findDecl(AST, "nx::X")));
+}
+
+TEST(SplitQualifiedName, NoInlineNamespace) {
+  auto TU =
+  TestTU::withCode("namespace nx { inline namespace ny { class X; } }");
+  auto AST = TU.build();
+  EXPECT_EQ(makePair("nx::", "X"), splitQualifiedName(findAnyDecl(AST, "X")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -44,6 +44,9 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.insertText == Name; }
+MATCHER_P(QName, Name, "") {
+  return (arg.SymbolScope + arg.filterText) == Name;
+}
 MATCHER_P(Labeled, Label, "") {
   std::string Indented;
   if (!StringRef(Label).startswith(
@@ -1251,6 +1254,18 @@
   Failed());
 }
 
+TEST(CompletionTest, QualifiedNames) {
+  auto Results = completions(
+  R"cpp(
+  namespace ns { int local; void both(); }
+  void f() { ::ns::^ }
+  )cpp",
+  {func("ns::both"), cls("ns::Index")});
+  // We get results from both index and sema, with no duplicates.
+  EXPECT_THAT(Results.items,
+  UnorderedElementsAre(QName("ns::local"), QName("ns::Index"),
+   QName("ns::both")));
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -363,21 +363,10 @@
   auto &Ctx = ND.getASTContext();
   auto &SM = Ctx.getSourceManager();
 
-  std::string QName;
-  llvm::raw_string_ostream OS(QName);
-  PrintingPolicy Policy(ASTCtx->getLangOpts());
-  // Note that inline namespaces are treated as transparent scopes. This
-  // reflects the way they're most commonly used for lookup. Ideally we'd
-  // include them, but at query time it's hard to find all the inline
-  // namespaces to query: the preamble doesn't have a dedicated list.
-  Policy.SuppressUnwrittenScope = true;
-  ND.printQualifiedName(OS, Policy);
-  OS.flush();
-  assert(!StringRef(QName).startswith("::"));
-
   Symbol S;
   S.ID = std::move(ID);
-  std::tie(S.Scope, S.Name) = splitQualifiedName(QName);
+  auto ScopeAndName = splitQualifiedName(ND);
+  std::tie(S.Scope, S.Name) = ScopeAndName;
 
   S.IsIndexedForCodeCompletion = isIndexedForCodeCompletion(ND, Ctx);
   S.SymInfo = index::getSymbolInfo(&ND);
@@ -413,8 +402,9 @@
   if (Opts.CollectIncludePath && shouldCollectIncludePath(S.SymInfo.Kind)) {
 // Use the expansion location to get the #include header since this is
 // where the symbol is exposed.
-if (auto Header = getIncludeHeader(
-QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
+if (auto Header =
+getIncludeHeader(ScopeAndName.first + ScopeAndName.second, SM,
+ SM.getExpansionLoc(ND.getLocation()), Opts))
   Include = std::move(*Header);
   }
   S.CompletionFilterText = FilterText;
Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #include "Protocol.h"
+#include "clang/AST/Decl.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Core/Replacement.h"
 
@@ -56,6 +57

r335255 - [DebugInfo] Inline for without DebugLocation

2018-06-21 Thread Anastasis Grammenos via cfe-commits
Author: gramanas
Date: Thu Jun 21 09:53:48 2018
New Revision: 335255

URL: http://llvm.org/viewvc/llvm-project?rev=335255&view=rev
Log:
[DebugInfo] Inline for without DebugLocation

Summary:
This test is a strip down version of a function inside the
amalgamated sqlite source. When converted to IR clang produces
a phi instruction without debug location.

This patch fixes the above issue.

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

Added:
cfe/trunk/test/CodeGen/debug-info-inline-for.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=335255&r1=335254&r2=335255&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jun 21 09:53:48 2018
@@ -3431,6 +3431,12 @@ Value *ScalarExprEmitter::VisitBinLAnd(c
   // Insert an entry into the phi node for the edge with the value of RHSCond.
   PN->addIncoming(RHSCond, RHSBlock);
 
+  // Artificial location to preserve the scope information
+  {
+auto NL = ApplyDebugLocation::CreateArtificial(CGF);
+PN->setDebugLoc(Builder.getCurrentDebugLocation());
+  }
+
   // ZExt result to int.
   return Builder.CreateZExtOrBitCast(PN, ResTy, "land.ext");
 }

Added: cfe/trunk/test/CodeGen/debug-info-inline-for.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-inline-for.c?rev=335255&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-inline-for.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-inline-for.c Thu Jun 21 09:53:48 2018
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// Check that clang emits Debug location in the phi instruction
+
+int func(int n) {
+  int a;
+  for(a = 10; a>0 && n++; a--);
+  return n;
+}
+
+// CHECK: land.end:
+// CHECK-NEXT: {{.*}} = phi i1 {{.*}} !dbg ![[DbgLoc:[0-9]+]]
+
+// CHECK: ![[DbgLoc]] = !DILocation(line: 0


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


[PATCH] D47720: [DebugInfo] Inline for without DebugLocation

2018-06-21 Thread Anastasis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335255: [DebugInfo] Inline for without DebugLocation 
(authored by gramanas, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47720

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/debug-info-inline-for.c


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3431,6 +3431,12 @@
   // Insert an entry into the phi node for the edge with the value of RHSCond.
   PN->addIncoming(RHSCond, RHSBlock);
 
+  // Artificial location to preserve the scope information
+  {
+auto NL = ApplyDebugLocation::CreateArtificial(CGF);
+PN->setDebugLoc(Builder.getCurrentDebugLocation());
+  }
+
   // ZExt result to int.
   return Builder.CreateZExtOrBitCast(PN, ResTy, "land.ext");
 }
Index: cfe/trunk/test/CodeGen/debug-info-inline-for.c
===
--- cfe/trunk/test/CodeGen/debug-info-inline-for.c
+++ cfe/trunk/test/CodeGen/debug-info-inline-for.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// Check that clang emits Debug location in the phi instruction
+
+int func(int n) {
+  int a;
+  for(a = 10; a>0 && n++; a--);
+  return n;
+}
+
+// CHECK: land.end:
+// CHECK-NEXT: {{.*}} = phi i1 {{.*}} !dbg ![[DbgLoc:[0-9]+]]
+
+// CHECK: ![[DbgLoc]] = !DILocation(line: 0


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3431,6 +3431,12 @@
   // Insert an entry into the phi node for the edge with the value of RHSCond.
   PN->addIncoming(RHSCond, RHSBlock);
 
+  // Artificial location to preserve the scope information
+  {
+auto NL = ApplyDebugLocation::CreateArtificial(CGF);
+PN->setDebugLoc(Builder.getCurrentDebugLocation());
+  }
+
   // ZExt result to int.
   return Builder.CreateZExtOrBitCast(PN, ResTy, "land.ext");
 }
Index: cfe/trunk/test/CodeGen/debug-info-inline-for.c
===
--- cfe/trunk/test/CodeGen/debug-info-inline-for.c
+++ cfe/trunk/test/CodeGen/debug-info-inline-for.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// Check that clang emits Debug location in the phi instruction
+
+int func(int n) {
+  int a;
+  for(a = 10; a>0 && n++; a--);
+  return n;
+}
+
+// CHECK: land.end:
+// CHECK-NEXT: {{.*}} = phi i1 {{.*}} !dbg ![[DbgLoc:[0-9]+]]
+
+// CHECK: ![[DbgLoc]] = !DILocation(line: 0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48443: Add no-prototype attribute to prototype-less C functions

2018-06-21 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, dschuff.

The WebAssembly backend in particular benefits from being
able to distinguish between varargs functions (...) and prototype-less
C functions.


Repository:
  rC Clang

https://reviews.llvm.org/D48443

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/no-prototype.ll


Index: test/CodeGen/no-prototype.ll
===
--- /dev/null
+++ test/CodeGen/no-prototype.ll
@@ -0,0 +1,22 @@
+; ModuleID = 
'/usr/local/google/home/sbc/dev/wasm/llvm/tools/clang/test/CodeGen/prototypeless.c'
+source_filename = 
"/usr/local/google/home/sbc/dev/wasm/llvm/tools/clang/test/CodeGen/prototypeless.c"
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-darwin"
+
+; Function Attrs: noinline nounwind optnone
+define void @bar() #0 {
+entry:
+  call void (...) @foo()
+  ret void
+}
+
+declare void @foo(...) #1
+
+attributes #0 = { noinline nounwind optnone 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
"stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" 
"disable-tail-calls"="false" "less-precise-fpmad"="false" 
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false" 
"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" 
"no-trapping-math"="false" "stack-protector-buffer-size"="8" 
"target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" 
"use-soft-float"="false" }
+
+!llvm.module.flags = !{!0}
+!llvm.ident = !{!1}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{!"clang version 7.0.0 (trunk 335193) (llvm/trunk 335137)"}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1845,6 +1845,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::Convergent);
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
+  if (!AttrOnCallSite && !Fn->hasPrototype())
+FuncAttrs.addAttribute("no-prototype");
   AddAttributesFromFunctionProtoType(
   getContext(), FuncAttrs, Fn->getType()->getAs());
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.


Index: test/CodeGen/no-prototype.ll
===
--- /dev/null
+++ test/CodeGen/no-prototype.ll
@@ -0,0 +1,22 @@
+; ModuleID = '/usr/local/google/home/sbc/dev/wasm/llvm/tools/clang/test/CodeGen/prototypeless.c'
+source_filename = "/usr/local/google/home/sbc/dev/wasm/llvm/tools/clang/test/CodeGen/prototypeless.c"
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-darwin"
+
+; Function Attrs: noinline nounwind optnone
+define void @bar() #0 {
+entry:
+  call void (...) @foo()
+  ret void
+}
+
+declare void @foo(...) #1
+
+attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.module.flags = !{!0}
+!llvm.ident = !{!1}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{!"clang version 7.0.0 (trunk 335193) (llvm/trunk 335137)"}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1845,6 +1845,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::Convergent);
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
+  if (!AttrOnCallSite && !Fn->hasPrototype())
+FuncAttrs.addAttribute("no-prototype");
   AddAttributesFromFunctionProtoType(
   getContext(), FuncAttrs, Fn->getType()->getAs());
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48443: [WIP] Add no-prototype attribute to prototype-less C functions

2018-06-21 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 152335.
sbc100 added a comment.

wrong test


Repository:
  rC Clang

https://reviews.llvm.org/D48443

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/no-prototype.c


Index: test/CodeGen/no-prototype.c
===
--- /dev/null
+++ test/CodeGen/no-prototype.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck 
%s
+
+extern void foo();
+
+void bar(int a) {
+  foo(1);
+}
+
+// CHECK: declare void @foo(...) [[NOPROTO:#[0-9]+]]
+// CHECK: attributes [[NOPROTO]] = {  {{.*}}"no-prototype"{{.*}} }
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1845,6 +1845,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::Convergent);
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
+  if (!AttrOnCallSite && !Fn->hasPrototype())
+FuncAttrs.addAttribute("no-prototype");
   AddAttributesFromFunctionProtoType(
   getContext(), FuncAttrs, Fn->getType()->getAs());
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.


Index: test/CodeGen/no-prototype.c
===
--- /dev/null
+++ test/CodeGen/no-prototype.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+extern void foo();
+
+void bar(int a) {
+  foo(1);
+}
+
+// CHECK: declare void @foo(...) [[NOPROTO:#[0-9]+]]
+// CHECK: attributes [[NOPROTO]] = {  {{.*}}"no-prototype"{{.*}} }
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1845,6 +1845,8 @@
   FuncAttrs.addAttribute(llvm::Attribute::Convergent);
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
+  if (!AttrOnCallSite && !Fn->hasPrototype())
+FuncAttrs.addAttribute("no-prototype");
   AddAttributesFromFunctionProtoType(
   getContext(), FuncAttrs, Fn->getType()->getAs());
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335259 - [Intrinsics] Add/move some builtin declarations in intrin.h to get ms-intrinsics.c to not issue warnings

2018-06-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun 21 10:07:04 2018
New Revision: 335259

URL: http://llvm.org/viewvc/llvm-project?rev=335259&view=rev
Log:
[Intrinsics] Add/move some builtin declarations in intrin.h to get 
ms-intrinsics.c to not issue warnings

ud2 and int2c were missing declarations entirely. And the bitscans were only 
under x86_64, but they seem to be in BuiltinsARM.def as well and are tested by 
ms_intrinsics.c

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

Modified:
cfe/trunk/lib/Headers/intrin.h

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=335259&r1=335258&r2=335259&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Thu Jun 21 10:07:04 2018
@@ -83,6 +83,7 @@ void __incfsdword(unsigned long);
 void __incfsword(unsigned long);
 unsigned long __indword(unsigned short);
 void __indwordstring(unsigned short, unsigned long *, unsigned long);
+void __int2c(void);
 void __invlpg(void *);
 unsigned short __inword(unsigned short);
 void __inwordstring(unsigned short, unsigned short *, unsigned long);
@@ -140,6 +141,7 @@ void __svm_stgi(void);
 void __svm_vmload(size_t);
 void __svm_vmrun(size_t);
 void __svm_vmsave(size_t);
+void __ud2(void);
 unsigned __int64 __ull_rshift(unsigned __int64, int);
 void __vmx_off(void);
 void __vmx_vmptrst(unsigned __int64 *);
@@ -246,10 +248,6 @@ void __writegsbyte(unsigned long, unsign
 void __writegsdword(unsigned long, unsigned long);
 void __writegsqword(unsigned long, unsigned __int64);
 void __writegsword(unsigned long, unsigned short);
-static __inline__
-unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
-static __inline__
-unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
 unsigned char _bittest64(__int64 const *, __int64);
 unsigned char _bittestandcomplement64(__int64 *, __int64);
 unsigned char _bittestandreset64(__int64 *, __int64);
@@ -304,6 +302,11 @@ unsigned __int64 _umul128(unsigned __int
 #if defined(__x86_64__) || defined(__arm__)
 
 static __inline__
+unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
+static __inline__
+unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
+
+static __inline__
 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
 static __inline__
 __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);


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


[PATCH] D48187: [Intrinsics] Add/move some builtin declarations in intrin.h to get ms-intrinsics.c to not issue warnings

2018-06-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335259: [Intrinsics] Add/move some builtin declarations in 
intrin.h to get ms… (authored by ctopper, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48187?vs=151401&id=152337#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48187

Files:
  cfe/trunk/lib/Headers/intrin.h


Index: cfe/trunk/lib/Headers/intrin.h
===
--- cfe/trunk/lib/Headers/intrin.h
+++ cfe/trunk/lib/Headers/intrin.h
@@ -83,6 +83,7 @@
 void __incfsword(unsigned long);
 unsigned long __indword(unsigned short);
 void __indwordstring(unsigned short, unsigned long *, unsigned long);
+void __int2c(void);
 void __invlpg(void *);
 unsigned short __inword(unsigned short);
 void __inwordstring(unsigned short, unsigned short *, unsigned long);
@@ -140,6 +141,7 @@
 void __svm_vmload(size_t);
 void __svm_vmrun(size_t);
 void __svm_vmsave(size_t);
+void __ud2(void);
 unsigned __int64 __ull_rshift(unsigned __int64, int);
 void __vmx_off(void);
 void __vmx_vmptrst(unsigned __int64 *);
@@ -246,10 +248,6 @@
 void __writegsdword(unsigned long, unsigned long);
 void __writegsqword(unsigned long, unsigned __int64);
 void __writegsword(unsigned long, unsigned short);
-static __inline__
-unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
-static __inline__
-unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
 unsigned char _bittest64(__int64 const *, __int64);
 unsigned char _bittestandcomplement64(__int64 *, __int64);
 unsigned char _bittestandreset64(__int64 *, __int64);
@@ -304,6 +302,11 @@
 #if defined(__x86_64__) || defined(__arm__)
 
 static __inline__
+unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
+static __inline__
+unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
+
+static __inline__
 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
 static __inline__
 __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);


Index: cfe/trunk/lib/Headers/intrin.h
===
--- cfe/trunk/lib/Headers/intrin.h
+++ cfe/trunk/lib/Headers/intrin.h
@@ -83,6 +83,7 @@
 void __incfsword(unsigned long);
 unsigned long __indword(unsigned short);
 void __indwordstring(unsigned short, unsigned long *, unsigned long);
+void __int2c(void);
 void __invlpg(void *);
 unsigned short __inword(unsigned short);
 void __inwordstring(unsigned short, unsigned short *, unsigned long);
@@ -140,6 +141,7 @@
 void __svm_vmload(size_t);
 void __svm_vmrun(size_t);
 void __svm_vmsave(size_t);
+void __ud2(void);
 unsigned __int64 __ull_rshift(unsigned __int64, int);
 void __vmx_off(void);
 void __vmx_vmptrst(unsigned __int64 *);
@@ -246,10 +248,6 @@
 void __writegsdword(unsigned long, unsigned long);
 void __writegsqword(unsigned long, unsigned __int64);
 void __writegsword(unsigned long, unsigned short);
-static __inline__
-unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
-static __inline__
-unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
 unsigned char _bittest64(__int64 const *, __int64);
 unsigned char _bittestandcomplement64(__int64 *, __int64);
 unsigned char _bittestandreset64(__int64 *, __int64);
@@ -304,6 +302,11 @@
 #if defined(__x86_64__) || defined(__arm__)
 
 static __inline__
+unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
+static __inline__
+unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
+
+static __inline__
 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
 static __inline__
 __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

2018-06-21 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: lib/AST/ASTContext.cpp:9563
+if (getExternalSource()->DeclIsFromPCHWithObjectFile(D))
+  return false;
+  }

It'd be good to add a comment (and a test) explaining why / how _referenced_ 
inline functions still get emitted for inlining.


https://reviews.llvm.org/D48426



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


[PATCH] D48436: [analyzer][UninitializedObjectChecker] Fixed a false negative by no longer filtering out certain constructor calls

2018-06-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 152343.
Szelethus added a comment.

Moved `LC = LC ->getParent()` to the `while` statement's argument to avoid a 
potential infinite loop. Whoops :)


https://reviews.llvm.org/D48436

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object.cpp

Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1035,13 +1035,12 @@
 // While a singleton would make more sense as a static variable, that would zero
 // initialize all of its fields, hence the not too practical implementation.
 struct Singleton {
-  // TODO: we'd expect the note: {{uninitialized field 'this->i'}}
-  int i; // no-note
+  int i; // expected-note{{uninitialized field 'this->i'}}
+  int dontGetFilteredByNonPedanticMode = 0;
 
   Singleton() {
 assert(!isInstantiated);
-// TODO: we'd expect the warning: {{1 uninitialized field}}
-isInstantiated = true; // no-warning
+isInstantiated = true; // expected-warning{{1 uninitialized field}}
   }
 
   ~Singleton() {
Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
@@ -212,9 +212,11 @@
 Optional
 getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context);
 
-/// Checks whether the constructor under checking is called by another
-/// constructor.
-bool isCalledByConstructor(const CheckerContext &Context);
+/// Checks whether the object constructed by \p Ctor will be analyzed later
+/// (e.g. if the object is a field of another object, in which case we'd check
+/// it multiple times).
+bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
+   CheckerContext &Context);
 
 /// Returns whether FD can be (transitively) dereferenced to a void pointer type
 /// (void*, void**, ...). The type of the region behind a void pointer isn't
@@ -255,7 +257,7 @@
 return;
 
   // This avoids essentially the same error being reported multiple times.
-  if (isCalledByConstructor(Context))
+  if (willObjectBeAnalyzedLater(CtorDecl, Context))
 return;
 
   Optional Object = getObjectVal(CtorDecl, Context);
@@ -419,8 +421,8 @@
   }
 
   // Checking bases.
-  // FIXME: As of now, because of `isCalledByConstructor`, objects whose type
-  // is a descendant of another type will emit warnings for uninitalized
+  // FIXME: As of now, because of `willObjectBeAnalyzedLater`, objects whose
+  // type is a descendant of another type will emit warnings for uninitalized
   // inherited members.
   // This is not the only way to analyze bases of an object -- if we didn't
   // filter them out, and didn't analyze the bases, this checker would run for
@@ -661,18 +663,32 @@
   return Object.getAs();
 }
 
-// TODO: We should also check that if the constructor was called by another
-// constructor, whether those two are in any relation to one another. In it's
-// current state, this introduces some false negatives.
-bool isCalledByConstructor(const CheckerContext &Context) {
-  const LocationContext *LC = Context.getLocationContext()->getParent();
+bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
+   CheckerContext &Context) {
 
-  while (LC) {
-if (isa(LC->getDecl()))
-  return true;
+  Optional CurrentObject = getObjectVal(Ctor, Context);
+  if (!CurrentObject)
+return false;
+
+  const LocationContext *LC = Context.getLocationContext();
+  while ((LC = LC->getParent())) {
+
+// If \p Ctor was called by another constructor.
+const auto *OtherCtor = dyn_cast(LC->getDecl());
+if (!OtherCtor)
+  continue;
 
-LC = LC->getParent();
+Optional OtherObject =
+getObjectVal(OtherCtor, Context);
+if (!OtherObject)
+  continue;
+
+// If the CurrentObject is a field of OtherObject, it will be analyzed
+// during the analysis of OtherObject.
+if (CurrentObject->getRegion()->isSubRegionOf(OtherObject->getRegion()))
+  return true;
   }
+
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48443: [WIP] Add no-prototype attribute to prototype-less C functions

2018-06-21 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google added a comment.

Looks very reasonable and straightforward. LGTM in spirit, but I'll wait for 
someone who knows Clang better.


Repository:
  rC Clang

https://reviews.llvm.org/D48443



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


[PATCH] D48438: [Sema] Updated note for address spaces to print the type.

2018-06-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


https://reviews.llvm.org/D48438



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


[PATCH] D48419: [OpenCL] Fixed parsing of address spaces for C++

2018-06-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Did you notice the bug that C++ silently allows implicit casting of a pointer 
to a pointer type with different address space?

Do you have a fix for that?


https://reviews.llvm.org/D48419



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


[PATCH] D48448: [X86] Correct the inline assembly implementations of __movsb/w/d/q and __stosw/d/q to mark registers/memory as modified

2018-06-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: rnk, echristo.

The inline assembly for these didn't mark that edi, esi, ecx are modified by 
movs/stos instruction. It also didn't mark that memory is modified.

This issue was reported to llvm-dev last year 
http://lists.llvm.org/pipermail/cfe-dev/2017-November/055863.html but no bug 
was ever filed.


https://reviews.llvm.org/D48448

Files:
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c

Index: test/CodeGen/ms-intrinsics.c
===
--- test/CodeGen/ms-intrinsics.c
+++ test/CodeGen/ms-intrinsics.c
@@ -29,6 +29,89 @@
 // CHECK-X64:   ret void
 // CHECK-X64: }
 
+void test__movsb(unsigned char *Dest, unsigned char *Src, size_t Count) {
+  return __movsb(Dest, Src, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__movsb
+// CHECK-I386:   call { i8*, i8*, i32 } asm sideeffect "rep movsb", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__movsb
+// CHECK-X64:   call { i8*, i8*, i64 } asm sideeffect "rep movsb", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__stosw(unsigned short *Dest, unsigned short Data, size_t Count) {
+  return __stosw(Dest, Data, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__stosw
+// CHECK-I386:   call { i16*, i32 } asm sideeffect "rep stosw", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* %Dest, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__stosw
+// CHECK-X64:   call { i16*, i64 } asm sideeffect "rep stosw", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* %Dest, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__movsw(unsigned short *Dest, unsigned short *Src, size_t Count) {
+  return __movsw(Dest, Src, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__movsw
+// CHECK-I386:   call { i16*, i16*, i32 } asm sideeffect "rep movsw", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i16* %Dest, i16* %Src, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__movsw
+// CHECK-X64:   call { i16*, i16*, i64 } asm sideeffect "rep movsw", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i16* %Dest, i16* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__stosd(unsigned long *Dest, unsigned long Data, size_t Count) {
+  return __stosd(Dest, Data, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__stosd
+// CHECK-I386:   call { i32*, i32 } asm sideeffect "rep stosl", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i32 %Data, i32* %Dest, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__stosd
+// CHECK-X64:   call { i32*, i64 } asm sideeffect "rep stosl", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i32 %Data, i32* %Dest, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__movsd(unsigned long *Dest, unsigned long *Src, size_t Count) {
+  return __movsd(Dest, Src, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__movsd
+// CHECK-I386:   call { i32*, i32*, i32 } asm sideeffect "rep movsl", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Dest, i32* %Src, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__movsd
+// CHECK-X64:   call { i32*, i32*, i64 } asm sideeffect "rep movsl", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Dest, i32* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+#ifdef __x86_64__
+void test__stosq(unsigned __int64 *Dest, unsigned __int64 Data, size_t Count) {
+  return __stosq(Dest, Data, Count);
+}
+// CHECK-X64-LABEL: define{{.*}} void @test__stosq
+// CHECK-X64:   call { i64*, i64 } asm sideeffect "rep stosq", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i64 %Data, i64* %Dest, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__movsq(unsigned __int64 *Dest, unsigned __int64 *Src, size_t Count) {
+  return __movsq(Dest, Src, Count);
+}
+// CHECK-X64-LABEL: define{{.*}} void @test__movsq
+// CHECK-X64:   call { i64*, i64*, i64 } asm sideeffect "rep movsq", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %Dest, i64* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+#endif
+
 void test__ud2(void) {
   __ud2();
 }
Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -797,33 +797,40 @@
 #if defined(__i386__) || defined(__x86_64__)
 static __inline__ void __DEFAULT_F

r335270 - [X86] Correct the inline assembly implementations of __movsb/w/d/q and __stosw/d/q to mark registers/memory as modified

2018-06-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun 21 11:56:30 2018
New Revision: 335270

URL: http://llvm.org/viewvc/llvm-project?rev=335270&view=rev
Log:
[X86] Correct the inline assembly implementations of __movsb/w/d/q and 
__stosw/d/q to mark registers/memory as modified

The inline assembly for these didn't mark that edi, esi, ecx are modified by 
movs/stos instruction. It also didn't mark that memory is modified.

This issue was reported to llvm-dev last year 
http://lists.llvm.org/pipermail/cfe-dev/2017-November/055863.html but no bug 
was ever filed.

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

Modified:
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/ms-intrinsics.c

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=335270&r1=335269&r2=335270&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Thu Jun 21 11:56:30 2018
@@ -797,33 +797,40 @@ _InterlockedCompareExchange64_rel(__int6
 #if defined(__i386__) || defined(__x86_64__)
 static __inline__ void __DEFAULT_FN_ATTRS
 __movsb(unsigned char *__dst, unsigned char const *__src, size_t __n) {
-  __asm__("rep movsb" : : "D"(__dst), "S"(__src), "c"(__n));
+  __asm__ __volatile__("rep movsb" : "+D"(__dst), "+S"(__src), "+c"(__n)
+   : : "memory");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
 __movsd(unsigned long *__dst, unsigned long const *__src, size_t __n) {
-  __asm__("rep movsl" : : "D"(__dst), "S"(__src), "c"(__n));
+  __asm__ __volatile__("rep movsl" : "+D"(__dst), "+S"(__src), "+c"(__n)
+   : : "memory");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
 __movsw(unsigned short *__dst, unsigned short const *__src, size_t __n) {
-  __asm__("rep movsw" : : "D"(__dst), "S"(__src), "c"(__n));
+  __asm__ __volatile__("rep movsw" : "+D"(__dst), "+S"(__src), "+c"(__n)
+   : : "memory");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
 __stosd(unsigned long *__dst, unsigned long __x, size_t __n) {
-  __asm__("rep stosl" : : "D"(__dst), "a"(__x), "c"(__n));
+  __asm__ __volatile__("rep stosl" : "+D"(__dst), "+c"(__n) : "a"(__x)
+   : "memory");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
 __stosw(unsigned short *__dst, unsigned short __x, size_t __n) {
-  __asm__("rep stosw" : : "D"(__dst), "a"(__x), "c"(__n));
+  __asm__ __volatile__("rep stosw" : "+D"(__dst), "+c"(__n) : "a"(__x)
+   : "memory");
 }
 #endif
 #ifdef __x86_64__
 static __inline__ void __DEFAULT_FN_ATTRS
 __movsq(unsigned long long *__dst, unsigned long long const *__src, size_t 
__n) {
-  __asm__("rep movsq" : : "D"(__dst), "S"(__src), "c"(__n));
+  __asm__ __volatile__("rep movsq" : "+D"(__dst), "+S"(__src), "+c"(__n)
+   : : "memory");
 }
 static __inline__ void __DEFAULT_FN_ATTRS
 __stosq(unsigned __int64 *__dst, unsigned __int64 __x, size_t __n) {
-  __asm__("rep stosq" : : "D"(__dst), "a"(__x), "c"(__n));
+  __asm__ __volatile__("rep stosq" : "+D"(__dst), "+c"(__n) : "a"(__x)
+   : "memory");
 }
 #endif
 

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=335270&r1=335269&r2=335270&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Thu Jun 21 11:56:30 2018
@@ -29,6 +29,89 @@ void test__stosb(unsigned char *Dest, un
 // CHECK-X64:   ret void
 // CHECK-X64: }
 
+void test__movsb(unsigned char *Dest, unsigned char *Src, size_t Count) {
+  return __movsb(Dest, Src, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__movsb
+// CHECK-I386:   call { i8*, i8*, i32 } asm sideeffect "rep movsb", 
"={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* 
%Src, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__movsb
+// CHECK-X64:   call { i8*, i8*, i64 } asm sideeffect "rep movsb", 
"={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* 
%Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__stosw(unsigned short *Dest, unsigned short Data, size_t Count) {
+  return __stosw(Dest, Data, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__stosw
+// CHECK-I386:   call { i16*, i32 } asm sideeffect "rep stosw", 
"={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* 
%Dest, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__stosw
+// CHECK-X64:   call { i16*, i64 } asm sideeffect "rep stosw", 
"={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* 
%Dest, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__movsw(unsig

[PATCH] D48448: [X86] Correct the inline assembly implementations of __movsb/w/d/q and __stosw/d/q to mark registers/memory as modified

2018-06-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335270: [X86] Correct the inline assembly implementations of 
__movsb/w/d/q and… (authored by ctopper, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48448?vs=152346&id=152358#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48448

Files:
  cfe/trunk/lib/Headers/intrin.h
  cfe/trunk/test/CodeGen/ms-intrinsics.c

Index: cfe/trunk/test/CodeGen/ms-intrinsics.c
===
--- cfe/trunk/test/CodeGen/ms-intrinsics.c
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c
@@ -29,6 +29,89 @@
 // CHECK-X64:   ret void
 // CHECK-X64: }
 
+void test__movsb(unsigned char *Dest, unsigned char *Src, size_t Count) {
+  return __movsb(Dest, Src, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__movsb
+// CHECK-I386:   call { i8*, i8*, i32 } asm sideeffect "rep movsb", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__movsb
+// CHECK-X64:   call { i8*, i8*, i64 } asm sideeffect "rep movsb", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %Dest, i8* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__stosw(unsigned short *Dest, unsigned short Data, size_t Count) {
+  return __stosw(Dest, Data, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__stosw
+// CHECK-I386:   call { i16*, i32 } asm sideeffect "rep stosw", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* %Dest, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__stosw
+// CHECK-X64:   call { i16*, i64 } asm sideeffect "rep stosw", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i16 %Data, i16* %Dest, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__movsw(unsigned short *Dest, unsigned short *Src, size_t Count) {
+  return __movsw(Dest, Src, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__movsw
+// CHECK-I386:   call { i16*, i16*, i32 } asm sideeffect "rep movsw", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i16* %Dest, i16* %Src, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__movsw
+// CHECK-X64:   call { i16*, i16*, i64 } asm sideeffect "rep movsw", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i16* %Dest, i16* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__stosd(unsigned long *Dest, unsigned long Data, size_t Count) {
+  return __stosd(Dest, Data, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__stosd
+// CHECK-I386:   call { i32*, i32 } asm sideeffect "rep stosl", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i32 %Data, i32* %Dest, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__stosd
+// CHECK-X64:   call { i32*, i64 } asm sideeffect "rep stosl", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i32 %Data, i32* %Dest, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__movsd(unsigned long *Dest, unsigned long *Src, size_t Count) {
+  return __movsd(Dest, Src, Count);
+}
+// CHECK-I386-LABEL: define{{.*}} void @test__movsd
+// CHECK-I386:   call { i32*, i32*, i32 } asm sideeffect "rep movsl", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Dest, i32* %Src, i32 %Count)
+// CHECK-I386:   ret void
+// CHECK-I386: }
+
+// CHECK-X64-LABEL: define{{.*}} void @test__movsd
+// CHECK-X64:   call { i32*, i32*, i64 } asm sideeffect "rep movsl", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Dest, i32* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+#ifdef __x86_64__
+void test__stosq(unsigned __int64 *Dest, unsigned __int64 Data, size_t Count) {
+  return __stosq(Dest, Data, Count);
+}
+// CHECK-X64-LABEL: define{{.*}} void @test__stosq
+// CHECK-X64:   call { i64*, i64 } asm sideeffect "rep stosq", "={di},={cx},{ax},0,1,~{memory},~{dirflag},~{fpsr},~{flags}"(i64 %Data, i64* %Dest, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+
+void test__movsq(unsigned __int64 *Dest, unsigned __int64 *Src, size_t Count) {
+  return __movsq(Dest, Src, Count);
+}
+// CHECK-X64-LABEL: define{{.*}} void @test__movsq
+// CHECK-X64:   call { i64*, i64*, i64 } asm sideeffect "rep movsq", "={di},={si},={cx},0,1,2,~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %Dest, i64* %Src, i64 %Count)
+// CHECK-X64:   ret void
+// CHECK-X64: }
+#endif
+
 void test__ud2(void) {
   __ud2();
 }
Index: cfe/trunk/lib/Headers/intrin.h
===
--- cfe/trunk/lib/Headers/intrin.h
+++ cfe/trunk/lib/Headers/intrin.h
@@ -797,33 +797,40 @@
 #if defined

[PATCH] D48419: [OpenCL] Fixed parsing of address spaces for C++

2018-06-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D48419#1139601, @yaxunl wrote:

> Did you notice the bug that C++ silently allows implicit casting of a pointer 
> to a pointer type with different address space?
>
> Do you have a fix for that?


I didn't think it did because if I run  
`test/SemaOpenCL/address-spaces-conversions-cl2.0.cl` in `-cl-std=c++` it gives 
me errors when I initialize a pointer with different AS pointer:

  error: cannot initialize a variable of type '__global int *' with an lvalue 
of type '__local int *'
  error: assigning to '__global int *' from incompatible type '__local int *'
  error: comparison of distinct pointer types ('__global int *' and '__local 
int *')

Do you have an example code somewhere?


https://reviews.llvm.org/D48419



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


[PATCH] D47864: [python] Fix most Python binding unittests on Windows

2018-06-21 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

Would you like me to commit this for you?


Repository:
  rC Clang

https://reviews.llvm.org/D47864



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


[PATCH] D47864: [python] Fix most Python binding unittests on Windows

2018-06-21 Thread Ethan via Phabricator via cfe-commits
ethanhs added a comment.

In https://reviews.llvm.org/D47864#1139750, @jbcoe wrote:

> Would you like me to commit this for you?


Sure, that would be great! I don't have commit rights so I was waiting for 
someone to do it. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47864



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


[libclc] r335277 - atom: Consolidate cl_khr_int64_{base, extended}_atomics declarations

2018-06-21 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 21 12:27:23 2018
New Revision: 335277

URL: http://llvm.org/viewvc/llvm-project?rev=335277&view=rev
Log:
atom: Consolidate cl_khr_int64_{base,extended}_atomics declarations

Reviewed-By: Aaron Watry 
Tested-By: Aaron Watry 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/atom_decl_int64.inc
Modified:
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h

Added: libclc/trunk/generic/include/clc/atom_decl_int64.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atom_decl_int64.inc?rev=335277&view=auto
==
--- libclc/trunk/generic/include/clc/atom_decl_int64.inc (added)
+++ libclc/trunk/generic/include/clc/atom_decl_int64.inc Thu Jun 21 12:27:23 
2018
@@ -0,0 +1,11 @@
+#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
+   _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, 
TYPE);
+
+__CLC_DECLARE_ATOM(local, long)
+__CLC_DECLARE_ATOM(local, ulong)
+__CLC_DECLARE_ATOM(global, long)
+__CLC_DECLARE_ATOM(global, ulong)
+
+#undef __CLC_DECLARE_ATOM
+
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h?rev=335277&r1=335276&r2=335277&view=diff
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h 
(original)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h Thu 
Jun 21 12:27:23 2018
@@ -1,4 +1,2 @@
-_CLC_OVERLOAD _CLC_DECL long atom_add(volatile global long *p, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile global unsigned long 
*p, unsigned long val);
-_CLC_OVERLOAD _CLC_DECL long atom_add(volatile local long *p, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile local unsigned long 
*p, unsigned long val);
+#define __CLC_FUNCTION atom_add
+#include 

Modified: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h?rev=335277&r1=335276&r2=335277&view=diff
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h 
(original)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h Thu 
Jun 21 12:27:23 2018
@@ -1,4 +1,2 @@
-_CLC_OVERLOAD _CLC_DECL long atom_sub(volatile global long *p, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_sub(volatile global unsigned long 
*p, unsigned long val);
-_CLC_OVERLOAD _CLC_DECL long atom_sub(volatile local long *p, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_sub(volatile local unsigned long 
*p, unsigned long val);
+#define __CLC_FUNCTION atom_sub
+#include 

Modified: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h?rev=335277&r1=335276&r2=335277&view=diff
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h 
(original)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h Thu 
Jun 21 12:27:23 2018
@@ -1,4 +1,2 @@
-_CLC_OVERLOAD _CLC_DECL long atom_xchg(volatile global long *p, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_xchg(volatile global unsigned long 
*p, unsigned long val);
-_CLC_OVERLOAD _CLC_DECL long atom_xchg(volatile local long *p, long val);
-_CLC_OVERLOAD _CLC_DECL unsigned long atom_xchg(volatile local unsigned long 
*p, unsigned long val);
+#define __CLC_FUNCTION atom_xchg
+#include 

Modified: 
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h?rev=335277&r1=335276&r2=335277&view=diff
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h 
(original)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h 
Thu Jun 21 12:27:23 2018
@@ -1,4 +1,2 @@
-_C

[libclc] r335275 - atomic: Cleanup atomic_cmpxchg header

2018-06-21 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 21 12:27:12 2018
New Revision: 335275

URL: http://llvm.org/viewvc/llvm-project?rev=335275&view=rev
Log:
atomic: Cleanup atomic_cmpxchg header

It's easier to just list the four function declarations

Reviewed-By: Aaron Watry 
Tested-By: Aaron Watry 
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h

Modified: libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h?rev=335275&r1=335274&r2=335275&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h Thu Jun 21 
12:27:12 2018
@@ -1,15 +1,4 @@
-#define __CLC_FUNCTION atomic_cmpxchg
-
-#define __CLC_DECLARE_ATOMIC_3_ARG(ADDRSPACE, TYPE) \
-   _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, 
TYPE, TYPE);
-
-#define __CLC_DECLARE_ATOMIC_ADDRSPACE_3_ARG(TYPE) \
-   __CLC_DECLARE_ATOMIC_3_ARG(global, TYPE) \
-   __CLC_DECLARE_ATOMIC_3_ARG(local, TYPE)
-
-__CLC_DECLARE_ATOMIC_ADDRSPACE_3_ARG(int)
-__CLC_DECLARE_ATOMIC_ADDRSPACE_3_ARG(uint)
-
-#undef __CLC_FUNCTION
-#undef __CLC_DECLARE_ATOMIC_3_ARG
-#undef __CLC_DECLARE_ATOMIC_ADDRESS_SPACE_3_ARG
+_CLC_OVERLOAD _CLC_DECL int atomic_cmpxchg (volatile local int *, int, int);
+_CLC_OVERLOAD _CLC_DECL int atomic_cmpxchg (volatile global int *, int, int);
+_CLC_OVERLOAD _CLC_DECL uint atomic_cmpxchg (volatile local uint *, uint, 
uint);
+_CLC_OVERLOAD _CLC_DECL uint atomic_cmpxchg (volatile global uint *, uint, 
uint);


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


[libclc] r335276 - atom: Consolidate cl_khr_{local, global}_int32_{base, extended}_atomics declarations

2018-06-21 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 21 12:27:18 2018
New Revision: 335276

URL: http://llvm.org/viewvc/llvm-project?rev=335276&view=rev
Log:
atom: Consolidate cl_khr_{local,global}_int32_{base,extended}_atomics 
declarations

Reviewed-By: Aaron Watry 
Tested-By: Aaron Watry 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/atom_decl_int32.inc
Modified:
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h

libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h

libclc/trunk/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_and.h

libclc/trunk/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_max.h

libclc/trunk/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_min.h

libclc/trunk/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_or.h

libclc/trunk/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_xor.h
libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_add.h
libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_sub.h
libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_xchg.h

libclc/trunk/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_and.h

libclc/trunk/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_max.h

libclc/trunk/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_min.h

libclc/trunk/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_or.h

libclc/trunk/generic/include/clc/cl_khr_local_int32_extended_atomics/atom_xor.h

Added: libclc/trunk/generic/include/clc/atom_decl_int32.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atom_decl_int32.inc?rev=335276&view=auto
==
--- libclc/trunk/generic/include/clc/atom_decl_int32.inc (added)
+++ libclc/trunk/generic/include/clc/atom_decl_int32.inc Thu Jun 21 12:27:18 
2018
@@ -0,0 +1,10 @@
+#define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
+   _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (ADDRSPACE TYPE *, TYPE);
+
+__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, int)
+__CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, uint)
+
+#undef __CLC_DECLARE_ATOM
+
+#undef __CLC_FUNCTION
+#undef __CLC_ADDRESS_SPACE

Modified: 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h?rev=335276&r1=335275&r2=335276&view=diff
==
--- 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h 
(original)
+++ 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_add.h 
Thu Jun 21 12:27:18 2018
@@ -1,2 +1,3 @@
-_CLC_OVERLOAD _CLC_DECL int atom_add(global int *p, int val);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_add(global unsigned int *p, unsigned 
int val);
+#define __CLC_FUNCTION atom_add
+#define __CLC_ADDRESS_SPACE global
+#include 

Modified: 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h?rev=335276&r1=335275&r2=335276&view=diff
==
--- 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h 
(original)
+++ 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_sub.h 
Thu Jun 21 12:27:18 2018
@@ -1,2 +1,3 @@
-_CLC_OVERLOAD _CLC_DECL int atom_sub(global int *p, int val);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_sub(global unsigned int *p, unsigned 
int val);
+#define __CLC_FUNCTION atom_sub
+#define __CLC_ADDRESS_SPACE global
+#include 

Modified: 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h?rev=335276&r1=335275&r2=335276&view=diff
==
--- 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h 
(original)
+++ 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_xchg.h 
Thu Jun 21 12:27:18 2018
@@ -1,2 +1,3 @@
-_CLC_OVERLOAD _CLC_DECL int atom_xchg(global int *p, int val);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_xchg(global unsigned int *p, 
unsigned int val);
+#define __CLC_FUNCTION atom_xchg
+#define __CLC_ADDRESS_SPACE global
+#include 

Modified: 
libclc/trunk/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_and.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_extended_atomics/atom_and.h?re

[libclc] r335278 - atomic: Provide function implementation of atomic_{dec, inc}

2018-06-21 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 21 12:27:26 2018
New Revision: 335278

URL: http://llvm.org/viewvc/llvm-project?rev=335278&view=rev
Log:
atomic: Provide function implementation of atomic_{dec,inc}

Reviewed-By: Aaron Watry 
Tested-By: Aaron Watry 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/atomic/atomic_dec.cl
libclc/trunk/generic/lib/atomic/atomic_inc.cl
Modified:
libclc/trunk/generic/include/clc/atomic/atomic_dec.h
libclc/trunk/generic/include/clc/atomic/atomic_inc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/atomic/atomic_dec.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_dec.h?rev=335278&r1=335277&r2=335278&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_dec.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_dec.h Thu Jun 21 12:27:26 
2018
@@ -1 +1,4 @@
-#define atomic_dec(p) atomic_sub(p, 1)
+_CLC_OVERLOAD _CLC_DECL int atomic_dec (volatile local int *);
+_CLC_OVERLOAD _CLC_DECL int atomic_dec (volatile global int *);
+_CLC_OVERLOAD _CLC_DECL uint atomic_dec (volatile local uint *);
+_CLC_OVERLOAD _CLC_DECL uint atomic_dec (volatile global uint *);

Modified: libclc/trunk/generic/include/clc/atomic/atomic_inc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_inc.h?rev=335278&r1=335277&r2=335278&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_inc.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_inc.h Thu Jun 21 12:27:26 
2018
@@ -1 +1,4 @@
-#define atomic_inc(p) atomic_add(p, 1)
+_CLC_OVERLOAD _CLC_DECL int atomic_inc (volatile local int *);
+_CLC_OVERLOAD _CLC_DECL int atomic_inc (volatile global int *);
+_CLC_OVERLOAD _CLC_DECL uint atomic_inc (volatile local uint *);
+_CLC_OVERLOAD _CLC_DECL uint atomic_inc (volatile global uint *);

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=335278&r1=335277&r2=335278&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jun 21 12:27:26 2018
@@ -7,6 +7,8 @@ async/wait_group_events.cl
 atomic/atomic_add.cl
 atomic/atomic_and.cl
 atomic/atomic_cmpxchg.cl
+atomic/atomic_dec.cl
+atomic/atomic_inc.cl
 atomic/atomic_max.cl
 atomic/atomic_min.cl
 atomic/atomic_or.cl

Added: libclc/trunk/generic/lib/atomic/atomic_dec.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/atomic/atomic_dec.cl?rev=335278&view=auto
==
--- libclc/trunk/generic/lib/atomic/atomic_dec.cl (added)
+++ libclc/trunk/generic/lib/atomic/atomic_dec.cl Thu Jun 21 12:27:26 2018
@@ -0,0 +1,12 @@
+#include 
+
+#define IMPL(TYPE, AS) \
+_CLC_OVERLOAD _CLC_DEF TYPE atomic_dec(volatile AS TYPE *p) { \
+  return __sync_fetch_and_sub(p, (TYPE)1); \
+}
+
+IMPL(int, global)
+IMPL(unsigned int, global)
+IMPL(int, local)
+IMPL(unsigned int, local)
+#undef IMPL

Added: libclc/trunk/generic/lib/atomic/atomic_inc.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/atomic/atomic_inc.cl?rev=335278&view=auto
==
--- libclc/trunk/generic/lib/atomic/atomic_inc.cl (added)
+++ libclc/trunk/generic/lib/atomic/atomic_inc.cl Thu Jun 21 12:27:26 2018
@@ -0,0 +1,12 @@
+#include 
+
+#define IMPL(TYPE, AS) \
+_CLC_OVERLOAD _CLC_DEF TYPE atomic_inc(volatile AS TYPE *p) { \
+  return __sync_fetch_and_add(p, (TYPE)1); \
+}
+
+IMPL(int, global)
+IMPL(unsigned int, global)
+IMPL(int, local)
+IMPL(unsigned int, local)
+#undef IMPL


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


[libclc] r335274 - atomic: Move define cleanup to shared include

2018-06-21 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 21 12:27:07 2018
New Revision: 335274

URL: http://llvm.org/viewvc/llvm-project?rev=335274&view=rev
Log:
atomic: Move define cleanup to shared include

Reviewed-By: Aaron Watry 
Tested-By: Aaron Watry 
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/generic/include/clc/atomic/atomic_add.h
libclc/trunk/generic/include/clc/atomic/atomic_and.h
libclc/trunk/generic/include/clc/atomic/atomic_decl.inc
libclc/trunk/generic/include/clc/atomic/atomic_max.h
libclc/trunk/generic/include/clc/atomic/atomic_min.h
libclc/trunk/generic/include/clc/atomic/atomic_or.h
libclc/trunk/generic/include/clc/atomic/atomic_sub.h
libclc/trunk/generic/include/clc/atomic/atomic_xchg.h
libclc/trunk/generic/include/clc/atomic/atomic_xor.h

Modified: libclc/trunk/generic/include/clc/atomic/atomic_add.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_add.h?rev=335274&r1=335273&r2=335274&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_add.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_add.h Thu Jun 21 12:27:07 
2018
@@ -1,5 +1,2 @@
 #define __CLC_FUNCTION atomic_add
 #include 
-#undef __CLC_FUNCTION
-#undef __CLC_DECLARE_ATOMIC
-#undef __CLC_DECLARE_ATOMIC_ADDRSPACE

Modified: libclc/trunk/generic/include/clc/atomic/atomic_and.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_and.h?rev=335274&r1=335273&r2=335274&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_and.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_and.h Thu Jun 21 12:27:07 
2018
@@ -1,5 +1,2 @@
 #define __CLC_FUNCTION atomic_and
 #include 
-#undef __CLC_FUNCTION
-#undef __CLC_DECLARE_ATOMIC
-#undef __CLC_DECLARE_ATOMIC_ADDRSPACE

Modified: libclc/trunk/generic/include/clc/atomic/atomic_decl.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_decl.inc?rev=335274&r1=335273&r2=335274&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_decl.inc (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_decl.inc Thu Jun 21 12:27:07 
2018
@@ -1,4 +1,3 @@
-
 #define __CLC_DECLARE_ATOMIC(ADDRSPACE, TYPE) \
_CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, 
TYPE);
 
@@ -8,3 +7,8 @@
 
 __CLC_DECLARE_ATOMIC_ADDRSPACE(int)
 __CLC_DECLARE_ATOMIC_ADDRSPACE(uint)
+
+#undef __CLC_DECLARE_ATOMIC_ADDRSPACE
+#undef __CLC_DECLARE_ATOMIC
+
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/include/clc/atomic/atomic_max.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_max.h?rev=335274&r1=335273&r2=335274&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_max.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_max.h Thu Jun 21 12:27:07 
2018
@@ -1,5 +1,2 @@
 #define __CLC_FUNCTION atomic_max
 #include 
-#undef __CLC_FUNCTION
-#undef __CLC_DECLARE_ATOMIC
-#undef __CLC_DECLARE_ATOMIC_ADDRSPACE

Modified: libclc/trunk/generic/include/clc/atomic/atomic_min.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_min.h?rev=335274&r1=335273&r2=335274&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_min.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_min.h Thu Jun 21 12:27:07 
2018
@@ -1,5 +1,2 @@
 #define __CLC_FUNCTION atomic_min
 #include 
-#undef __CLC_FUNCTION
-#undef __CLC_DECLARE_ATOMIC
-#undef __CLC_DECLARE_ATOMIC_ADDRSPACE

Modified: libclc/trunk/generic/include/clc/atomic/atomic_or.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_or.h?rev=335274&r1=335273&r2=335274&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_or.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_or.h Thu Jun 21 12:27:07 2018
@@ -1,5 +1,2 @@
 #define __CLC_FUNCTION atomic_or
 #include 
-#undef __CLC_FUNCTION
-#undef __CLC_DECLARE_ATOMIC
-#undef __CLC_DECLARE_ATOMIC_ADDRSPACE

Modified: libclc/trunk/generic/include/clc/atomic/atomic_sub.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_sub.h?rev=335274&r1=335273&r2=335274&view=diff
==
--- libclc/trunk/generic/include/clc/atomic/atomic_sub.h (original)
+++ libclc/trunk/generic/include/clc/atomic/atomic_sub.h Thu Jun 21 12:27:07 
2018
@@ -1,5 +1,2 @@
 #define __CLC_FUNCTION atomic_sub
 #include 
-#undef __CLC_FUNCTION
-#

[libclc] r335279 - atom: Consolidate cl_khr_{local, global}_int32_{base, extended}_atomics implementation

2018-06-21 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 21 12:27:33 2018
New Revision: 335279

URL: http://llvm.org/viewvc/llvm-project?rev=335279&view=rev
Log:
atom: Consolidate cl_khr_{local,global}_int32_{base,extended}_atomics 
implementation

These are just atomic_* wrappers.
Switch inc, dec to use atomic_* wrappers as well.

Reviewed-By: Aaron Watry 
Tested-By: Aaron Watry 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/atom_int32_binary.inc
Modified:
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_xchg.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_and.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_max.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_min.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_or.cl
libclc/trunk/generic/lib/cl_khr_global_int32_extended_atomics/atom_xor.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_add.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_sub.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_xchg.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_and.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_max.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_min.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_or.cl
libclc/trunk/generic/lib/cl_khr_local_int32_extended_atomics/atom_xor.cl

Added: libclc/trunk/generic/lib/atom_int32_binary.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/atom_int32_binary.inc?rev=335279&view=auto
==
--- libclc/trunk/generic/lib/atom_int32_binary.inc (added)
+++ libclc/trunk/generic/lib/atom_int32_binary.inc Thu Jun 21 12:27:33 2018
@@ -0,0 +1,14 @@
+#include 
+#include "utils.h"
+
+#define __CLC_ATOM_IMPL(AS, TYPE) \
+_CLC_OVERLOAD _CLC_DEF TYPE __CLC_XCONCAT(atom_, __CLC_ATOMIC_OP) (AS TYPE *p, 
TYPE val) { \
+  return __CLC_XCONCAT(atomic_, __CLC_ATOMIC_OP) (p, val); \
+}
+
+__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, int)
+__CLC_ATOM_IMPL(__CLC_ATOMIC_ADDRESS_SPACE, uint)
+
+#undef __CLC_ATOM_IMPL
+#undef __CLC_ATOMIC_OP
+#undef __CLC_ATOMIC_ADDRESS_SPACE

Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl?rev=335279&r1=335278&r2=335279&view=diff
==
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl 
(original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_add.cl Thu 
Jun 21 12:27:33 2018
@@ -1,9 +1,3 @@
-#include 
-
-#define IMPL(TYPE) \
-_CLC_OVERLOAD _CLC_DEF TYPE atom_add(global TYPE *p, TYPE val) { \
-  return atomic_add(p, val); \
-}
-
-IMPL(int)
-IMPL(unsigned int)
+#define __CLC_ATOMIC_OP add
+#define __CLC_ATOMIC_ADDRESS_SPACE global
+#include "../atom_int32_binary.inc"

Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl?rev=335279&r1=335278&r2=335279&view=diff
==
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl 
(original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl Thu 
Jun 21 12:27:33 2018
@@ -2,7 +2,7 @@
 
 #define IMPL(TYPE) \
 _CLC_OVERLOAD _CLC_DEF TYPE atom_dec(global TYPE *p) { \
-  return atom_sub(p, (TYPE)1); \
+  return atomic_dec(p); \
 }
 
 IMPL(int)

Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl?rev=335279&r1=335278&r2=335279&view=diff
==
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl 
(original)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl Thu 
Jun 21 12:27:33 2018
@@ -2,7 +2,7 @@
 
 #define IMPL(TYPE) \
 _CLC_OVERLOAD _CLC_DEF TYPE atom_inc(global TYPE *p) { \
-  return atom_add(p, (TYPE)1); \
+  return atomic_inc(p); \
 }
 
 IMPL(int)

Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_sub.c

[libclc] r335280 - atom: Use volatile pointers for cl_khr_{global, local}_int32_{base, extended}_atomics

2018-06-21 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun 21 12:27:39 2018
New Revision: 335280

URL: http://llvm.org/viewvc/llvm-project?rev=335280&view=rev
Log:
atom: Use volatile pointers for 
cl_khr_{global,local}_int32_{base,extended}_atomics

int64 versions were switched to volatile pointers in cl1.1
cl1.1 also renamed atom_ functions to atomic_ that use volatile pointers.
CTS and applications use volatile pointers.

Passes CTS on carrizo
no return piglit tests still pass on turks.

Reviewed-By: Aaron Watry 
Tested-By: Aaron Watry 
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/generic/include/clc/atom_decl_int32.inc

libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h

libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h
libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_dec.h
libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_inc.h
libclc/trunk/generic/lib/atom_int32_binary.inc
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl

Modified: libclc/trunk/generic/include/clc/atom_decl_int32.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atom_decl_int32.inc?rev=335280&r1=335279&r2=335280&view=diff
==
--- libclc/trunk/generic/include/clc/atom_decl_int32.inc (original)
+++ libclc/trunk/generic/include/clc/atom_decl_int32.inc Thu Jun 21 12:27:39 
2018
@@ -1,5 +1,5 @@
 #define __CLC_DECLARE_ATOM(ADDRSPACE, TYPE) \
-   _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (ADDRSPACE TYPE *, TYPE);
+   _CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, 
TYPE);
 
 __CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, int)
 __CLC_DECLARE_ATOM(__CLC_ADDRESS_SPACE, uint)

Modified: 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h?rev=335280&r1=335279&r2=335280&view=diff
==
--- 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
 (original)
+++ 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
 Thu Jun 21 12:27:39 2018
@@ -1,2 +1,2 @@
-_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(global int *p, int cmp, int val);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_cmpxchg(global unsigned int *p, 
unsigned int cmp, unsigned int val);
+_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(volatile global int *p, int cmp, int 
val);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_cmpxchg(volatile global unsigned int 
*p, unsigned int cmp, unsigned int val);

Modified: 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h?rev=335280&r1=335279&r2=335280&view=diff
==
--- 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h 
(original)
+++ 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_dec.h 
Thu Jun 21 12:27:39 2018
@@ -1,2 +1,2 @@
-_CLC_OVERLOAD _CLC_DECL int atom_dec(global int *p);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(global unsigned int *p);
+_CLC_OVERLOAD _CLC_DECL int atom_dec(volatile global int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_dec(volatile global unsigned int *p);

Modified: 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h?rev=335280&r1=335279&r2=335280&view=diff
==
--- 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h 
(original)
+++ 
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_inc.h 
Thu Jun 21 12:27:39 2018
@@ -1,2 +1,2 @@
-_CLC_OVERLOAD _CLC_DECL int atom_inc(global int *p);
-_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(global unsigned int *p);
+_CLC_OVERLOAD _CLC_DECL int atom_inc(volatile global int *p);
+_CLC_OVERLOAD _CLC_DECL unsigned int atom_inc(volatile global unsigned int *p);

Modified: 
libclc/trunk/generic/include/clc/cl_kh

[PATCH] D48448: [X86] Correct the inline assembly implementations of __movsb/w/d/q and __stosw/d/q to mark registers/memory as modified

2018-06-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Yikes.


Repository:
  rL LLVM

https://reviews.llvm.org/D48448



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


[PATCH] D47953: [builtin] Add bitfield support for __builtin_dump_struct

2018-06-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Yeah, I know nothing about this dump feature or what's being fixed here - test 
cases would be great to help motivate/explain.


Repository:
  rC Clang

https://reviews.llvm.org/D47953



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-06-21 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

@rsmith Should I only check for an identifier, like only "int" and nothing 
else? Because parsing a full type specifier might be a bit expensive, no?


https://reviews.llvm.org/D36357



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


r335282 - [bindings] Fix most Python binding unittests on Windows

2018-06-21 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Thu Jun 21 13:07:03 2018
New Revision: 335282

URL: http://llvm.org/viewvc/llvm-project?rev=335282&view=rev
Log:
[bindings] Fix most Python binding unittests on Windows

Summary:
This fixes all but one of the test cases for Windows. TestCDB will
take more work to debug, as CompilationDatabase seems not to work correctly.

Reviewers: bkramer, wanders, jbcoe

Reviewed By: bkramer, jbcoe

Subscribers: cfe-commits

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

Patch written by ethanhs (Ethan)

Modified:
cfe/trunk/bindings/python/tests/cindex/test_cdb.py
cfe/trunk/bindings/python/tests/cindex/test_cursor.py
cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cdb.py?rev=335282&r1=335281&r2=335282&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py Thu Jun 21 13:07:03 2018
@@ -5,11 +5,13 @@ from clang.cindex import CompileCommand
 import os
 import gc
 import unittest
+import sys
 
 
 kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
 
 
+@unittest.skipIf(sys.platform == 'win32', "TODO: Fix these tests on Windows")
 class TestCDB(unittest.TestCase):
 def test_create_fail(self):
 """Check we fail loading a database with an assertion"""

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=335282&r1=335281&r2=335282&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Thu Jun 21 13:07:03 
2018
@@ -335,7 +335,7 @@ class TestCursor(unittest.TestCase):
 
 self.assertEqual(enum.kind, CursorKind.ENUM_DECL)
 enum_type = enum.enum_type
-self.assertEqual(enum_type.kind, TypeKind.UINT)
+self.assertIn(enum_type.kind, (TypeKind.UINT, TypeKind.INT))
 
 def test_enum_type_cpp(self):
 tu = get_tu('enum TEST : long long { FOO=1, BAR=2 };', lang="cpp")
@@ -561,4 +561,4 @@ class TestCursor(unittest.TestCase):
 # all valid manglings.
 # [c-index-test handles this by running the source through clang, 
emitting
 #  an AST file and running libclang on that AST file]
-self.assertIn(foo.mangled_name, ('_Z3fooii', '__Z3fooii', 
'?foo@@YAHHH'))
+self.assertIn(foo.mangled_name, ('_Z3fooii', '__Z3fooii', 
'?foo@@YAHHH', '?foo@@YAHHH@Z'))

Modified: cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py?rev=335282&r1=335281&r2=335282&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py Thu Jun 21 
13:07:03 2018
@@ -1,3 +1,4 @@
+from contextlib import contextmanager
 import gc
 import os
 import tempfile
@@ -19,15 +20,15 @@ from .util import get_tu
 kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
 
 
+@contextmanager
 def save_tu(tu):
 """Convenience API to save a TranslationUnit to a file.
 
 Returns the filename it was saved to.
 """
-_, path = tempfile.mkstemp()
-tu.save(path)
-
-return path
+with tempfile.NamedTemporaryFile() as t:
+tu.save(t.name)
+yield t.name
 
 
 class TestTranslationUnit(unittest.TestCase):
@@ -125,10 +126,9 @@ int SOME_DEFINE;
 
 tu = get_tu('int foo();')
 
-path = save_tu(tu)
-self.assertTrue(os.path.exists(path))
-self.assertGreater(os.path.getsize(path), 0)
-os.unlink(path)
+with save_tu(tu) as path:
+self.assertTrue(os.path.exists(path))
+self.assertGreater(os.path.getsize(path), 0)
 
 def test_save_translation_errors(self):
 """Ensure that saving to an invalid directory raises."""
@@ -149,21 +149,18 @@ int SOME_DEFINE;
 
 tu = get_tu('int foo();')
 self.assertEqual(len(tu.diagnostics), 0)
-path = save_tu(tu)
-
-self.assertTrue(os.path.exists(path))
-self.assertGreater(os.path.getsize(path), 0)
-
-tu2 = TranslationUnit.from_ast_file(filename=path)
-self.assertEqual(len(tu2.diagnostics), 0)
+with save_tu(tu) as path:
+self.assertTrue(os.path.exists(path))
+self.assertGreater(os.path.getsize(path), 0)
 
-foo = get_cursor(tu2, 'foo')
-self.assertIsNotNone(foo)
+tu2 = TranslationUnit.from_ast_file(filename=path)
+self.assertEqual(

[PATCH] D47864: [python] Fix most Python binding unittests on Windows

2018-06-21 Thread Jonathan B Coe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335282: [bindings] Fix most Python binding unittests on 
Windows (authored by jbcoe, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47864

Files:
  cfe/trunk/bindings/python/tests/cindex/test_cdb.py
  cfe/trunk/bindings/python/tests/cindex/test_cursor.py
  cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py

Index: cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
+++ cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
@@ -1,3 +1,4 @@
+from contextlib import contextmanager
 import gc
 import os
 import tempfile
@@ -19,15 +20,15 @@
 kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
 
 
+@contextmanager
 def save_tu(tu):
 """Convenience API to save a TranslationUnit to a file.
 
 Returns the filename it was saved to.
 """
-_, path = tempfile.mkstemp()
-tu.save(path)
-
-return path
+with tempfile.NamedTemporaryFile() as t:
+tu.save(t.name)
+yield t.name
 
 
 class TestTranslationUnit(unittest.TestCase):
@@ -125,10 +126,9 @@
 
 tu = get_tu('int foo();')
 
-path = save_tu(tu)
-self.assertTrue(os.path.exists(path))
-self.assertGreater(os.path.getsize(path), 0)
-os.unlink(path)
+with save_tu(tu) as path:
+self.assertTrue(os.path.exists(path))
+self.assertGreater(os.path.getsize(path), 0)
 
 def test_save_translation_errors(self):
 """Ensure that saving to an invalid directory raises."""
@@ -149,21 +149,18 @@
 
 tu = get_tu('int foo();')
 self.assertEqual(len(tu.diagnostics), 0)
-path = save_tu(tu)
-
-self.assertTrue(os.path.exists(path))
-self.assertGreater(os.path.getsize(path), 0)
-
-tu2 = TranslationUnit.from_ast_file(filename=path)
-self.assertEqual(len(tu2.diagnostics), 0)
+with save_tu(tu) as path:
+self.assertTrue(os.path.exists(path))
+self.assertGreater(os.path.getsize(path), 0)
 
-foo = get_cursor(tu2, 'foo')
-self.assertIsNotNone(foo)
+tu2 = TranslationUnit.from_ast_file(filename=path)
+self.assertEqual(len(tu2.diagnostics), 0)
 
-# Just in case there is an open file descriptor somewhere.
-del tu2
+foo = get_cursor(tu2, 'foo')
+self.assertIsNotNone(foo)
 
-os.unlink(path)
+# Just in case there is an open file descriptor somewhere.
+del tu2
 
 def test_index_parse(self):
 path = os.path.join(kInputsDir, 'hello.cpp')
Index: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py
@@ -5,11 +5,13 @@
 import os
 import gc
 import unittest
+import sys
 
 
 kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
 
 
+@unittest.skipIf(sys.platform == 'win32', "TODO: Fix these tests on Windows")
 class TestCDB(unittest.TestCase):
 def test_create_fail(self):
 """Check we fail loading a database with an assertion"""
Index: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py
@@ -335,7 +335,7 @@
 
 self.assertEqual(enum.kind, CursorKind.ENUM_DECL)
 enum_type = enum.enum_type
-self.assertEqual(enum_type.kind, TypeKind.UINT)
+self.assertIn(enum_type.kind, (TypeKind.UINT, TypeKind.INT))
 
 def test_enum_type_cpp(self):
 tu = get_tu('enum TEST : long long { FOO=1, BAR=2 };', lang="cpp")
@@ -561,4 +561,4 @@
 # all valid manglings.
 # [c-index-test handles this by running the source through clang, emitting
 #  an AST file and running libclang on that AST file]
-self.assertIn(foo.mangled_name, ('_Z3fooii', '__Z3fooii', '?foo@@YAHHH'))
+self.assertIn(foo.mangled_name, ('_Z3fooii', '__Z3fooii', '?foo@@YAHHH', '?foo@@YAHHH@Z'))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48419: [OpenCL] Fixed parsing of address spaces for C++

2018-06-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D48419#1139749, @Anastasia wrote:

> In https://reviews.llvm.org/D48419#1139601, @yaxunl wrote:
>
> > Did you notice the bug that C++ silently allows implicit casting of a 
> > pointer to a pointer type with different address space?
> >
> > Do you have a fix for that?
>
>
> I didn't think it did because if I run  
> `test/SemaOpenCL/address-spaces-conversions-cl2.0.cl` in `-cl-std=c++` it 
> gives me errors when I initialize a pointer with different AS pointer:
>
>   error: cannot initialize a variable of type '__global int *' with an lvalue 
> of type '__local int *'
>   error: assigning to '__global int *' from incompatible type '__local int *'
>   error: comparison of distinct pointer types ('__global int *' and '__local 
> int *')
>   
>
> Do you have an example code somewhere?


Actually this only happens when there is an explicit cast:

  $ cat address-space-cast.cpp
  // RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
  
  #define __private__ __attribute__((address_space(5)))
  
  void f(char* q) {
// CHECK: addrspacecast
__private__ char* p = (__private__ char*)q;
//__private__ char* p = q;
  }
  $clang -cc1 -triple=amdgcn-amd-amdhsa address-space-cast.cpp -ast-dump
  TranslationUnitDecl 0x699f418 <> 
  |-TypedefDecl 0x699fab0 <>  implicit __int128_t 
'__int128'
  | `-BuiltinType 0x699f770 '__int128'
  |-TypedefDecl 0x699fb18 <>  implicit __uint128_t 
'unsigned __int128'
  | `-BuiltinType 0x699f790 'unsigned __int128'
  |-TypedefDecl 0x699fe58 <>  implicit 
__NSConstantString '__NSConstantString_tag'
  | `-RecordType 0x699fc00 '__NSConstantString_tag'
  |   `-CXXRecord 0x699fb68 '__NSConstantString_tag'
  |-TypedefDecl 0x699fef0 <>  implicit 
__builtin_va_list 'char *'
  | `-PointerType 0x699feb0 'char *'
  |   `-BuiltinType 0x699f4b0 'char'
  `-FunctionDecl 0x69a0020  line:5:6 f 
'void (char *)'
|-ParmVarDecl 0x699ff58  col:14 used q 'char *'
`-CompoundStmt 0x69e4130 
  `-DeclStmt 0x69e4118 
`-VarDecl 0x69e4000  col:21 p 
'__attribute__((address_space(5))) char *' cinit
  `-CStyleCastExpr 0x69e40f0  
'__attribute__((address_space(5))) char *' 
`-ImplicitCastExpr 0x69e40d8  
'__attribute__((address_space(5))) char *' 
  `-ImplicitCastExpr 0x69e40c0  'char *' 
`-DeclRefExpr 0x69e4080  'char *' lvalue ParmVar 
0x699ff58 'q' 'char *'

In the AST there is a CStyleCast and an ImplicitCast, both are NoOp, which will 
becomes bitcast in codegen and causes invalid bitcast instruction.


https://reviews.llvm.org/D48419



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


r335284 - [LTO] Enable module summary emission by default for regular LTO

2018-06-21 Thread Tobias Edler von Koch via cfe-commits
Author: tobiasvk
Date: Thu Jun 21 13:20:41 2018
New Revision: 335284

URL: http://llvm.org/viewvc/llvm-project?rev=335284&view=rev
Log:
[LTO] Enable module summary emission by default for regular LTO

Summary:
With D33921, we gained the ability to have module summaries in regular
LTO modules without triggering ThinLTO compilation. Module summaries in
regular LTO allow garbage collection (dead stripping) before LTO
compilation and thus open up additional optimization opportunities.

This patch enables summary emission in regular LTO for all targets
except ld64-based ones (which use the legacy LTO API).

Reviewers: pcc, tejohnson, mehdi_amini

Subscribers: inglorion, eraman, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/emit-summary-index.c
Removed:
cfe/trunk/test/Misc/thinlto.c
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=335284&r1=335283&r2=335284&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Jun 21 13:20:41 2018
@@ -110,7 +110,7 @@ CODEGENOPT(LessPreciseFPMAD  , 1, 0) ///
  ///< be generated.
 CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
  ///< compile step.
-CODEGENOPT(EmitSummaryIndex, 1, 0)   ///< Set when -flto=thin is enabled on the
+CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the
  ///< compile step.
 CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole
   ///< program vtable opt).

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=335284&r1=335283&r2=335284&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 21 13:20:41 2018
@@ -524,7 +524,7 @@ void EmitAssemblyHelper::CreatePasses(le
 PMBuilder.Inliner = createFunctionInliningPass(
 CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize,
 (!CodeGenOpts.SampleProfileFile.empty() &&
- CodeGenOpts.EmitSummaryIndex));
+ CodeGenOpts.PrepareForThinLTO));
   }
 
   PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel;
@@ -534,7 +534,7 @@ void EmitAssemblyHelper::CreatePasses(le
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
-  PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex;
+  PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
@@ -776,7 +776,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex) {
+if (CodeGenOpts.PrepareForThinLTO) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
 if (!ThinLinkOS)
@@ -784,10 +784,20 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   }
   PerModulePasses.add(createWriteThinLTOBitcodePass(
   *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr));
-}
-else
+} else {
+  // Emit a module summary by default for Regular LTO except for ld64
+  // targets
+  bool EmitLTOSummary =
+  (CodeGenOpts.PrepareForLTO &&
+   llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
+   llvm::Triple::Apple);
+  if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO"))
+TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
+
   PerModulePasses.add(
-  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+  EmitLTOSummary));
+}
 break;
 
   case Backend_EmitLL:
@@ -935,7 +945,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   ModulePassManager MPM(CodeGenOpts.DebugPassManager);
 
   if (!CodeGenOpts.DisableLLVMPasses) {
-bool IsThinLTO = CodeGenOpts.EmitSummaryIndex;
+bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
 bool IsLTO = CodeGenOpts.PrepareForLTO;
 
 if (CodeGenOpts.OptimizationLevel == 0) {
@@ -996,7 +1006,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex) {
+if (CodeGenOp

[PATCH] D34156: [LTO] Enable module summary emission by default for regular LTO

2018-06-21 Thread Tobias Edler von Koch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335284: [LTO] Enable module summary emission by default for 
regular LTO (authored by tobiasvk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D34156?vs=150965&id=152367#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34156

Files:
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/emit-summary-index.c
  cfe/trunk/test/Misc/thinlto.c

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -749,11 +749,11 @@
   Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
-  Opts.EmitSummaryIndex = false;
+  Opts.PrepareForThinLTO = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
 StringRef S = A->getValue();
 if (S == "thin")
-  Opts.EmitSummaryIndex = true;
+  Opts.PrepareForThinLTO = true;
 else if (S != "full")
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
   }
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -578,7 +578,7 @@
   CSInfo,
   getSource(SM, SM.getMainFileID())),
   CGOpts.EmitVersionIdentMetadata ? Producer : "",
-  LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
+  LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
   CGOpts.DwarfDebugFlags, RuntimeVers,
   CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind,
   0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -524,7 +524,7 @@
 PMBuilder.Inliner = createFunctionInliningPass(
 CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize,
 (!CodeGenOpts.SampleProfileFile.empty() &&
- CodeGenOpts.EmitSummaryIndex));
+ CodeGenOpts.PrepareForThinLTO));
   }
 
   PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel;
@@ -534,7 +534,7 @@
 
   PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
   PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
-  PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex;
+  PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
   PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
   PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
 
@@ -776,18 +776,28 @@
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex) {
+if (CodeGenOpts.PrepareForThinLTO) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
 if (!ThinLinkOS)
   return;
   }
   PerModulePasses.add(createWriteThinLTOBitcodePass(
   *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr));
-}
-else
+} else {
+  // Emit a module summary by default for Regular LTO except for ld64
+  // targets
+  bool EmitLTOSummary =
+  (CodeGenOpts.PrepareForLTO &&
+   llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
+   llvm::Triple::Apple);
+  if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO"))
+TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
+
   PerModulePasses.add(
-  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+  EmitLTOSummary));
+}
 break;
 
   case Backend_EmitLL:
@@ -935,7 +945,7 @@
   ModulePassManager MPM(CodeGenOpts.DebugPassManager);
 
   if (!CodeGenOpts.DisableLLVMPasses) {
-bool IsThinLTO = CodeGenOpts.EmitSummaryIndex;
+bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
 bool IsLTO = CodeGenOpts.PrepareForLTO;
 
 if (CodeGenOpts.OptimizationLevel == 0) {
@@ -996,18 +1006,26 @@
 break;
 
   case Backend_EmitBC:
-if (CodeGenOpts.EmitSummaryIndex) {
+if (CodeGenOpts.PrepareForThinLTO) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
 if (!ThinLinkOS)
   return;
   }
   MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
: nullptr));
 } else {
+  // Emit a m

[PATCH] D48426: [clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)

2018-06-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: dblaikie.
rnk added a comment.

`LangOpts.ModulesCodegen` is very related in spirit to this, but I think we 
need a distinct option because that was designed to handle all inline functions 
(too much), not just dllexport inline functions. + @dblaikie




Comment at: include/clang/AST/ASTContext.h:2886-2887
+
+  // XXX: I don't like adding this to ASTContext, but I ran out of ideas for 
how ASTContext::DeclMustBeEmitted() would know about it otherwise.
+  bool BuildingPCHWithObjectFile = false;
 };

Does `LangOpts.CompilingPCH` do the right thing, or is that also true when we 
make a PCH with no object file? In any case, I'd probably make this a langopt. 
Even if it's functionally different from ModulesCodegen and ModulesDebugInfo, 
it's the same basic idea.


https://reviews.llvm.org/D48426



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


r335285 - [OPENMP, NVPTX] Fix globalization of the variables passed to orphaned

2018-06-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jun 21 13:26:33 2018
New Revision: 335285

URL: http://llvm.org/viewvc/llvm-project?rev=335285&view=rev
Log:
[OPENMP, NVPTX] Fix globalization of the variables passed to orphaned
parallel region.

If the current construct requires sharing of the local variable in the
inner parallel region, this variable must be globalized to avoid
runtime crash.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=335285&r1=335284&r2=335285&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Jun 21 13:26:33 2018
@@ -184,9 +184,10 @@ class CheckVarsEscapingDeclContext final
   llvm::SetVector EscapedDecls;
   llvm::SetVector EscapedVariableLengthDecls;
   llvm::SmallPtrSet EscapedParameters;
-  bool AllEscaped = false;
   RecordDecl *GlobalizedRD = nullptr;
   llvm::SmallDenseMap MappedDeclsFields;
+  bool AllEscaped = false;
+  bool IsForParallelRegion = false;
 
   static llvm::Optional
   isDeclareTargetDeclaration(const ValueDecl *VD) {
@@ -207,23 +208,32 @@ class CheckVarsEscapingDeclContext final
 // Variables captured by value must be globalized.
 if (auto *CSI = CGF.CapturedStmtInfo) {
   if (const FieldDecl *FD = CSI->lookup(cast(VD))) {
-if (!FD->hasAttrs())
-  return;
-const auto *Attr = FD->getAttr();
-if (!Attr)
-  return;
-if (!isOpenMPPrivate(
-static_cast(Attr->getCaptureKind())) ||
-Attr->getCaptureKind() == OMPC_map)
-  return;
-if (FD->getType()->isReferenceType())
+// Check if need to capture the variable that was already captured by
+// value in the outer region.
+if (!IsForParallelRegion) {
+  if (!FD->hasAttrs())
+return;
+  const auto *Attr = FD->getAttr();
+  if (!Attr)
+return;
+  if (!isOpenMPPrivate(
+  static_cast(Attr->getCaptureKind())) ||
+  Attr->getCaptureKind() == OMPC_map)
+return;
+}
+if (!FD->getType()->isReferenceType()) {
+  assert(!VD->getType()->isVariablyModifiedType() &&
+ "Parameter captured by value with variably modified type");
+  EscapedParameters.insert(VD);
+} else if (!IsForParallelRegion) {
   return;
-assert(!VD->getType()->isVariablyModifiedType() &&
-   "Parameter captured by value with variably modified type");
-EscapedParameters.insert(VD);
+}
   }
-} else if (VD->getType()->isReferenceType())
-  // Do not globalize variables with reference or pointer type.
+}
+if ((!CGF.CapturedStmtInfo ||
+ (IsForParallelRegion && CGF.CapturedStmtInfo)) &&
+VD->getType()->isReferenceType())
+  // Do not globalize variables with reference type.
   return;
 if (VD->getType()->isVariablyModifiedType())
   EscapedVariableLengthDecls.insert(VD);
@@ -243,15 +253,18 @@ class CheckVarsEscapingDeclContext final
   }
 }
   }
-  void VisitOpenMPCapturedStmt(const CapturedStmt *S) {
+  void VisitOpenMPCapturedStmt(const CapturedStmt *S, bool IsParallelRegion) {
 if (!S)
   return;
 for (const CapturedStmt::Capture &C : S->captures()) {
   if (C.capturesVariable() && !C.capturesVariableByCopy()) {
 const ValueDecl *VD = C.getCapturedVar();
+bool SavedIsParallelRegion = IsForParallelRegion;
+IsForParallelRegion = IsParallelRegion;
 markAsEscaped(VD);
 if (isa(VD))
   VisitValueDecl(VD);
+IsForParallelRegion = SavedIsParallelRegion;
   }
 }
   }
@@ -316,20 +329,19 @@ public:
   void VisitOMPExecutableDirective(const OMPExecutableDirective *D) {
 if (!D)
   return;
-if (D->hasAssociatedStmt()) {
-  if (const auto *S =
-  dyn_cast_or_null(D->getAssociatedStmt())) {
-// Do not analyze directives that do not actually require capturing,
-// like `omp for` or `omp simd` directives.
-llvm::SmallVector CaptureRegions;
-getOpenMPCaptureRegions(CaptureRegions, D->getDirectiveKind());
-if (CaptureRegions.size() == 1 &&
-CaptureRegions.back() == OMPD_unknown) {
-  VisitStmt(S->getCapturedStmt());
-  return;
-}
-VisitOpenMPCapturedStmt(S);
+if (!D->hasAssociatedStmt())
+  return;
+if (const auto *S =
+dyn_cast_or_null(D->getAssociatedStmt())) {
+  // Do not analyze directives that do not actually require capturing,
+  // like `omp for` or `omp simd` directives.
+  llvm::Small

r335287 - AMDGPU: Remove amdgpu-debugger-reserve-regs feature

2018-06-21 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Thu Jun 21 13:27:47 2018
New Revision: 335287

URL: http://llvm.org/viewvc/llvm-project?rev=335287&view=rev
Log:
AMDGPU: Remove amdgpu-debugger-reserve-regs feature


Modified:
cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
cfe/trunk/test/Driver/amdgpu-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp?rev=335287&r1=335286&r2=335287&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp Thu Jun 21 13:27:47 2018
@@ -43,7 +43,6 @@ void amdgpu::getAMDGPUTargetFeatures(con
 StringRef value = dAbi->getValue();
 if (value == "1.0") {
   Features.push_back("+amdgpu-debugger-insert-nops");
-  Features.push_back("+amdgpu-debugger-reserve-regs");
   Features.push_back("+amdgpu-debugger-emit-prologue");
 } else {
   D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);

Modified: cfe/trunk/test/Driver/amdgpu-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-features.c?rev=335287&r1=335286&r2=335287&view=diff
==
--- cfe/trunk/test/Driver/amdgpu-features.c (original)
+++ cfe/trunk/test/Driver/amdgpu-features.c Thu Jun 21 13:27:47 2018
@@ -4,7 +4,7 @@
 
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o - 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
-// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-reserve-regs" "-target-feature" 
"+amdgpu-debugger-emit-prologue"
+// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-emit-prologue"
 
 // RUN: %clang -### -target amdgcn -mcpu=gfx700 -mxnack %s 2>&1 | FileCheck 
--check-prefix=XNACK %s
 // XNACK: "-target-feature" "+xnack"


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


[PATCH] D39679: [C++11] Fix warning when dropping cv-qualifiers when assigning to a reference with a braced initializer list

2018-06-21 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 152370.
Rakete added a comment.

Rebased + friendly ping :)


https://reviews.llvm.org/D39679

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/references.cpp

Index: test/SemaCXX/references.cpp
===
--- test/SemaCXX/references.cpp
+++ test/SemaCXX/references.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 
 int g(int);
 
 void f() {
@@ -55,6 +56,24 @@
   //  const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0
   const volatile int cvi = 1;
   const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+
+#if __cplusplus >= 201103L
+  const int& r2{cvi}; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+
+  const int a = 2;
+  int& r3{a}; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const'}}
+
+  const int&& r4{a}; // expected-error{{rvalue reference to type 'const int' cannot bind to lvalue of type 'const int'}}
+
+  void func();
+  void func(int);
+  int &ptr1 = {func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}}
+  int &&ptr2{func}; // expected-error{{address of overloaded function 'func' does not match required type 'int'}}
+  // expected-note@-4{{candidate function}}
+  // expected-note@-4{{candidate function}}
+  // expected-note@-6{{candidate function}}
+  // expected-note@-6{{candidate function}}
+#endif
 }
 
 // C++ [dcl.init.ref]p3
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7565,6 +7565,18 @@
   if (!Failed())
 return false;
 
+  // When we want to diagnose only one element of a braced-init-list, we need to factor it out.
+  Expr *OnlyArg;
+  if (Args.size() == 1) {
+auto *List = dyn_cast(Args[0]);
+if (List && List->getNumInits() == 1)
+  OnlyArg = List->getInit(0);
+else
+  OnlyArg = Args[0];
+  }
+  else
+OnlyArg = nullptr;
+
   QualType DestType = Entity.getType();
   switch (Failure) {
   case FK_TooManyInitsForReference:
@@ -7625,7 +7637,7 @@
   ? diag::err_array_init_different_type
   : diag::err_array_init_non_constant_array))
   << DestType.getNonReferenceType()
-  << Args[0]->getType()
+  << OnlyArg->getType()
   << Args[0]->getSourceRange();
 break;
 
@@ -7636,7 +7648,7 @@
 
   case FK_AddressOfOverloadFailed: {
 DeclAccessPair Found;
-S.ResolveAddressOfOverloadedFunction(Args[0],
+S.ResolveAddressOfOverloadedFunction(OnlyArg,
  DestType.getNonReferenceType(),
  true,
  Found);
@@ -7656,11 +7668,11 @@
 case OR_Ambiguous:
   if (Failure == FK_UserConversionOverloadFailed)
 S.Diag(Kind.getLocation(), diag::err_typecheck_ambiguous_condition)
-  << Args[0]->getType() << DestType
+  << OnlyArg->getType() << DestType
   << Args[0]->getSourceRange();
   else
 S.Diag(Kind.getLocation(), diag::err_ref_init_ambiguous)
-  << DestType << Args[0]->getType()
+  << DestType << OnlyArg->getType()
   << Args[0]->getSourceRange();
 
   FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args);
@@ -7670,10 +7682,10 @@
   if (!S.RequireCompleteType(Kind.getLocation(),
  DestType.getNonReferenceType(),
   diag::err_typecheck_nonviable_condition_incomplete,
-   Args[0]->getType(), Args[0]->getSourceRange()))
+   OnlyArg->getType(), Args[0]->getSourceRange()))
 S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
   << (Entity.getKind() == InitializedEntity::EK_Result)
-  << Args[0]->getType() << Args[0]->getSourceRange()
+  << OnlyArg->getType() << Args[0]->getSourceRange()
   << DestType.getNonReferenceType();
 
   FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args);
@@ -7681,7 +7693,7 @@
 
 case OR_Deleted: {
   S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function)
-<< Args[0]->getType() << DestType.getNonReferenceType()
+<< OnlyArg->getType() << DestType.getNonReferenceType()
 << Args[0]->getSourceRange();
   OverloadCandidateSet::iterator Best;
   OverloadingResult Ovl
@@ -7717,7 +7729,7 @@
  : diag::err_lvalue_reference_bind_to_unrelated)
   << DestType.getNonReferenceType().isVolatileQualified()
   << DestType.getNonReferenceType()
-  << Args[0]->getType()
+  << OnlyArg->getType()
   << Args[0]->getSourceRange

[PATCH] D39679: [C++11] Fix warning when dropping cv-qualifiers when assigning to a reference with a braced initializer list

2018-06-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D39679#1037591, @Rakete wrote:

> Note: I didn't change `Args[0]` to `OnlyArg` in 
> `FK_AddressOfUnaddressableFunction`, because I'm pretty sure that C++ doesn't 
> have unaddressable functions and thus there is no need to decompose an 
> initializer list. Is this correct?


C++ with Clang extensions has unaddressable functions. This example asserts at 
the moment:

  void f() __attribute__((enable_if(false, "")));
  int f();
  void (&&p)() = {f};

... due, I think, to failing to unwrap the initializer list when diagnosing the 
initialization.


https://reviews.llvm.org/D39679



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


[PATCH] D39679: [C++11] Fix warning when dropping cv-qualifiers when assigning to a reference with a braced initializer list

2018-06-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

In any case, this looks good to me. It'll look even better with the 
`FK_AddressOfUnaddressableFunction` case fixed :)


https://reviews.llvm.org/D39679



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


[PATCH] D37442: [C++17] Disallow lambdas in template parameters (PR33696).

2018-06-21 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 152374.
Rakete added a comment.

Rebased + friendly ping :)


https://reviews.llvm.org/D37442

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/TreeTransform.h
  test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp

Index: test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++17 %s -verify
+
+template struct Nothing {};
+
+void pr33696() {
+Nothing<[]() { return 0; }()> nothing; // expected-error{{a lambda expression cannot appear in this context}}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5494,7 +5494,7 @@
   // decltype expressions are not potentially evaluated contexts
   EnterExpressionEvaluationContext Unevaluated(
   SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, nullptr,
-  /*IsDecltype=*/true);
+  Sema::ExpressionEvaluationContextRecord::EK_Decltype);
 
   ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
   if (E.isInvalid())
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6413,7 +6413,8 @@
   if (RD->isInvalidDecl() || RD->isDependentContext())
 return E;
 
-  bool IsDecltype = ExprEvalContexts.back().IsDecltype;
+  bool IsDecltype = ExprEvalContexts.back().ExprContext ==
+ExpressionEvaluationContextRecord::EK_Decltype;
   CXXDestructorDecl *Destructor = IsDecltype ? nullptr : LookupDestructor(RD);
 
   if (Destructor) {
@@ -6495,7 +6496,9 @@
 /// are omitted for the 'topmost' call in the decltype expression. If the
 /// topmost call bound a temporary, strip that temporary off the expression.
 ExprResult Sema::ActOnDecltypeExpression(Expr *E) {
-  assert(ExprEvalContexts.back().IsDecltype && "not in a decltype expression");
+  assert(ExprEvalContexts.back().ExprContext ==
+ ExpressionEvaluationContextRecord::EK_Decltype &&
+ "not in a decltype expression");
 
   // C++11 [expr.call]p11:
   //   If a function call is a prvalue of object type,
@@ -6537,7 +6540,8 @@
 TopBind = nullptr;
 
   // Disable the special decltype handling now.
-  ExprEvalContexts.back().IsDecltype = false;
+  ExprEvalContexts.back().ExprContext =
+  ExpressionEvaluationContextRecord::EK_Other;
 
   // In MS mode, don't perform any extra checking of call return types within a
   // decltype expression.
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14083,11 +14083,11 @@
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  Decl *LambdaContextDecl,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
-LambdaContextDecl, IsDecltype);
+LambdaContextDecl, ExprContext);
   Cleanup.reset();
   if (!MaybeODRUseExprs.empty())
 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
@@ -14094,11 +14094,11 @@
 }
 
 void
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext,
-  ReuseLambdaContextDecl_t,
-  bool IsDecltype) {
+Sema::PushExpressionEvaluationContext(
+ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
+ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
-  PushExpressionEvaluationContext(NewContext, ClosureContextDecl, IsDecltype);
+  PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
 }
 
 void Sema::PopExpressionEvaluationContext() {
@@ -14106,7 +14106,9 @@
   unsigned NumTypos = Rec.NumTypos;
 
   if (!Rec.Lambdas.empty()) {
-if (Rec.isUnevaluated() || Rec.isConstantEvaluated()) {
+using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
+if (Rec.ExprContext == ExpressionKind::EK_TemplateParameter || Rec.isUnevaluated() ||
+(Rec.isConstantEvaluated() && !getLangOp

[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.

2018-06-21 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Another option is to add a special case to blacklist logic to make it not apply 
to __cfi_check_fail.

Yet another option is to make blacklist not apply to functions without a source 
location, but that seems to be done intentionally here:
http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CodeGenModule.cpp#1827


https://reviews.llvm.org/D48454



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


[PATCH] D48443: [WIP] Add no-prototype attribute to prototype-less C functions

2018-06-21 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:1850
+FuncAttrs.addAttribute("no-prototype");
   AddAttributesFromFunctionProtoType(
   getContext(), FuncAttrs, Fn->getType()->getAs());

Would it make sense to put this in `AddAttributesFormFunctionProtoType` Does 
this have the same effect as that would? For that matter, what's the practical 
difference between this call and the one on line 1826?


Repository:
  rC Clang

https://reviews.llvm.org/D48443



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


[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.

2018-06-21 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis created this revision.
eugenis added reviewers: pcc, vlad.tsyrklevich.

Fixes PR37898.


https://reviews.llvm.org/D48454

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/cfi-check-fail2.c


Index: clang/test/CodeGen/cfi-check-fail2.c
===
--- clang/test/CodeGen/cfi-check-fail2.c
+++ clang/test/CodeGen/cfi-check-fail2.c
@@ -3,6 +3,12 @@
 // RUN: -fsanitize=cfi-vcall \
 // RUN: -emit-llvm -o - %s | FileCheck %s
 
+// Check that blacklist does not affect generated code.
+// RUN: echo "src:*" > %t-all.blacklist
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
 void caller(void (*f)()) {
   f();
 }
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3120,11 +3120,16 @@
 SanitizerMask Mask = CheckKindMaskPair.second;
 llvm::Value *Cond =
 Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind));
-if (CGM.getLangOpts().Sanitize.has(Mask))
+if (CGM.getLangOpts().Sanitize.has(Mask)) {
+  // This sanitizer may have been disabled in blacklist. This function does
+  // not have a source location, but "src:*" would still apply. Enable it
+  // back.
+  SanOpts.Mask |= Mask;
   EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {},
 {Data, Addr, ValidVtable});
-else
+} else {
   EmitTrapCheck(Cond);
+}
   }
 
   FinishFunction();


Index: clang/test/CodeGen/cfi-check-fail2.c
===
--- clang/test/CodeGen/cfi-check-fail2.c
+++ clang/test/CodeGen/cfi-check-fail2.c
@@ -3,6 +3,12 @@
 // RUN: -fsanitize=cfi-vcall \
 // RUN: -emit-llvm -o - %s | FileCheck %s
 
+// Check that blacklist does not affect generated code.
+// RUN: echo "src:*" > %t-all.blacklist
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
 void caller(void (*f)()) {
   f();
 }
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3120,11 +3120,16 @@
 SanitizerMask Mask = CheckKindMaskPair.second;
 llvm::Value *Cond =
 Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind));
-if (CGM.getLangOpts().Sanitize.has(Mask))
+if (CGM.getLangOpts().Sanitize.has(Mask)) {
+  // This sanitizer may have been disabled in blacklist. This function does
+  // not have a source location, but "src:*" would still apply. Enable it
+  // back.
+  SanOpts.Mask |= Mask;
   EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {},
 {Data, Addr, ValidVtable});
-else
+} else {
   EmitTrapCheck(Cond);
+}
   }
 
   FinishFunction();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48455: Remove hip.amdgcn.bc hc.amdgcn.bc from HIP Toolchains

2018-06-21 Thread Aaron En Ye Shi via Phabricator via cfe-commits
ashi1 created this revision.
ashi1 added a reviewer: yaxunl.
ashi1 added projects: clang, AMDGPU.
Herald added a subscriber: cfe-commits.

Removing hip.amdgcn.bc and hc.amdgcn.bc from HIP ToolChains. These need to be 
removed in VDI build.


Repository:
  rC Clang

https://reviews.llvm.org/D48455

Files:
  lib/Driver/ToolChains/HIP.cpp


Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -75,12 +75,12 @@
 std::string ISAVerBC =
 "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc";

-BCLibs.append({"hip.amdgcn.bc", "hc.amdgcn.bc", "opencl.amdgcn.bc",
+BCLibs.append({"opencl.amdgcn.bc",
"ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
"oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
-   "oclc_unsafe_math_off.amdgcn.bc", "hc.amdgcn.bc", 
ISAVerBC});
+   "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);


Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -75,12 +75,12 @@
 std::string ISAVerBC =
 "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc";

-BCLibs.append({"hip.amdgcn.bc", "hc.amdgcn.bc", "opencl.amdgcn.bc",
+BCLibs.append({"opencl.amdgcn.bc",
"ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
"oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
-   "oclc_unsafe_math_off.amdgcn.bc", "hc.amdgcn.bc", ISAVerBC});
+   "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37442: [C++17] Disallow lambdas in template parameters (PR33696).

2018-06-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Please also change the `EnterExpressionEvaluationContext` in 
`TreeTransform::TransformTemplateArgument` to specify `EK_TemplateArgument` 
(though that doesn't actually matter for the lambda diagnostics because we'll 
find all the problems in the template definition context). Then this LGTM. 
Thanks!




Comment at: include/clang/Sema/Sema.h:984
+enum ExpressionKind {
+  EK_Decltype, EK_TemplateParameter, EK_Other
+} ExprContext;

Should `EK_TemplateParameter` be `EK_TemplateArgument`?


https://reviews.llvm.org/D37442



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


  1   2   >