[PATCH] D58375: [Clang][NewPM] Disable tests that are broken under new PM

2019-02-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: chandlerc.
Herald added subscribers: cfe-commits, jdoerfert, kbarton, eraman, javed.absar, 
mgorny, nemanjai.
Herald added a reviewer: serge-sans-paille.
Herald added a project: clang.

Not every pass has been ported to new PM which is breaking some Clang
tests, disable those for now when new PM is enabled by default.


Repository:
  rC Clang

https://reviews.llvm.org/D58375

Files:
  clang/test/CMakeLists.txt
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-perm.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/available-externally-suppress.c
  clang/test/CodeGen/avx-builtins.c
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c
  clang/test/CodeGen/builtin-movdir.c
  clang/test/CodeGen/builtins-ppc-p9vector.c
  clang/test/CodeGen/builtins-ppc-vsx.c
  clang/test/CodeGen/callback_annotated.c
  clang/test/CodeGen/cfi-icall-cross-dso.c
  clang/test/CodeGen/complex-math.c
  clang/test/CodeGen/dllimport.c
  clang/test/CodeGen/flatten.c
  clang/test/CodeGen/inline2.c
  clang/test/CodeGen/lifetime.c
  clang/test/CodeGen/pgo-instrumentation.c
  clang/test/CodeGen/pgo-sample.c
  clang/test/CodeGen/sanitize-address-field-padding.cpp
  clang/test/CodeGen/split-debug-single-file.c
  clang/test/CodeGen/sse-builtins.c
  clang/test/CodeGen/sse2-builtins.c
  clang/test/CodeGen/tbaa-for-vptr.cpp
  clang/test/CodeGen/x86_64-instrument-functions.c
  clang/test/CodeGenCXX/atomicinit.cpp
  clang/test/CodeGenCXX/cfi-speculative-vtable.cpp
  clang/test/CodeGenCXX/conditional-temporaries.cpp
  clang/test/CodeGenCXX/debug-info-class-optzns.cpp
  clang/test/CodeGenCXX/dllimport-members.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/dso-local-executable.cpp
  clang/test/CodeGenCXX/flatten.cpp
  clang/test/CodeGenCXX/init-invariant.cpp
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  clang/test/CodeGenCXX/merge-functions.cpp
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp
  clang/test/CodeGenObjC/os_log.m
  clang/test/CodeGenObjCXX/nrvo.mm
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/CoverageMapping/unused_names.c
  clang/test/Driver/asan.c
  clang/test/Driver/esan.c
  clang/test/Driver/msan.c
  clang/test/Driver/tsan.c
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/optimization-remark-with-hotness.c
  clang/test/Frontend/optimization-remark.c
  clang/test/Misc/pr32207.c
  clang/test/OpenMP/for_codegen.cpp
  clang/test/Profile/c-captured.c
  clang/test/Profile/c-general.c
  clang/test/Profile/c-generate.c
  clang/test/Profile/c-indirect-call.c
  clang/test/Profile/c-linkage-available_externally.c
  clang/test/Profile/c-linkage.c
  clang/test/Profile/c-ternary.c
  clang/test/Profile/c-unreachable-after-switch.c
  clang/test/Profile/cxx-class.cpp
  clang/test/Profile/cxx-implicit.cpp
  clang/test/Profile/cxx-indirect-call.cpp
  clang/test/Profile/cxx-lambda.cpp
  clang/test/Profile/cxx-linkage.cpp
  clang/test/Profile/cxx-rangefor.cpp
  clang/test/Profile/cxx-stmt-initializers.cpp
  clang/test/Profile/cxx-structors.cpp
  clang/test/Profile/cxx-templates.cpp
  clang/test/Profile/cxx-throws.cpp
  clang/test/Profile/cxx-virtual-destructor-calls.cpp
  clang/test/Profile/def-assignop.cpp
  clang/test/Profile/def-ctors.cpp
  clang/test/Profile/def-dtors.cpp
  clang/test/Profile/gcc-flag-compatibility.c
  clang/test/Profile/objc-general.m
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in

Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -24,6 +24,7 @@
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
+config.enable_experimental_new_pass_manager = @ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -99,6 +99,9 @@
 if config.clang_staticanalyzer_z3 == '1':
 config.available_features.add('z3')
 
+if config.enable_experimental_new_pass_manager:
+

[PATCH] D58374: [Clang][NewPM] Don't bail out if the target machine is empty

2019-02-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: chandlerc.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This matches the behavior of the old pass manager. There are some
targets that don't have target machine at all (e.g. le32, spir) which
whose tests would never run with new pass manager. Similarly, we would
need to disable tests for targets that are disabled.


Repository:
  rC Clang

https://reviews.llvm.org/D58374

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -947,13 +947,15 @@
   TimeRegion Region(FrontendTimesIsEnabled ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
-  // The new pass manager always makes a target machine available to passes
-  // during construction.
-  CreateTargetMachine(/*MustCreateTM*/ true);
-  if (!TM)
-// This will already be diagnosed, just bail.
+  bool UsesCodeGen = (Action != Backend_EmitNothing &&
+  Action != Backend_EmitBC &&
+  Action != Backend_EmitLL);
+  CreateTargetMachine(UsesCodeGen);
+
+  if (UsesCodeGen && !TM)
 return;
-  TheModule->setDataLayout(TM->createDataLayout());
+  if (TM)
+TheModule->setDataLayout(TM->createDataLayout());
 
   Optional PGOOpt;
 


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -947,13 +947,15 @@
   TimeRegion Region(FrontendTimesIsEnabled ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
-  // The new pass manager always makes a target machine available to passes
-  // during construction.
-  CreateTargetMachine(/*MustCreateTM*/ true);
-  if (!TM)
-// This will already be diagnosed, just bail.
+  bool UsesCodeGen = (Action != Backend_EmitNothing &&
+  Action != Backend_EmitBC &&
+  Action != Backend_EmitLL);
+  CreateTargetMachine(UsesCodeGen);
+
+  if (UsesCodeGen && !TM)
 return;
-  TheModule->setDataLayout(TM->createDataLayout());
+  if (TM)
+TheModule->setDataLayout(TM->createDataLayout());
 
   Optional PGOOpt;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58368: [analyzer] MIGChecker: Implement bug reporter visitors.

2019-02-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

This adds two visitors to the checker:

- `trackExpressionValue()` in order to highlight where does the return value 
come from when it's not a literal.
- A tag-based visitor (as in D58367 ) that 
explains where parameters are deallocated.


Repository:
  rC Clang

https://reviews.llvm.org/D58368

Files:
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/test/Analysis/mig.cpp


Index: clang/test/Analysis/mig.cpp
===
--- clang/test/Analysis/mig.cpp
+++ clang/test/Analysis/mig.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,alpha.osx.MIG -verify %s
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,alpha.osx.MIG\
+// RUN:   -analyzer-output=text -verify %s
+
 
 // XNU APIs.
 
@@ -16,9 +18,11 @@
 
 MIG_SERVER_ROUTINE
 kern_return_t basic_test(mach_port_name_t port, vm_address_t address, 
vm_size_t size) {
-  vm_deallocate(port, address, size);
-  if (size > 10) {
+  vm_deallocate(port, address, size); // expected-note{{Deallocating object 
passed through parameter 'address'}}
+  if (size > 10) { // expected-note{{Assuming 'size' is > 10}}
+   // expected-note@-1{{Taking true branch}}
 return KERN_ERROR; // expected-warning{{MIG callback fails with error 
after deallocating argument value. This is use-after-free vulnerability because 
caller will try to deallocate it again}}
+   // expected-note@-1{{MIG callback fails with error 
after deallocating argument value. This is use-after-free vulnerability because 
caller will try to deallocate it again}}
   }
   return KERN_SUCCESS;
 }
@@ -28,3 +32,15 @@
 kern_return_t no_crash(mach_port_name_t port, vm_address_t address, vm_size_t 
size) {
   vm_deallocate(port, address, size);
 }
+
+// When releasing two parameters, add a note for both of them.
+// Also when returning a variable, explain why do we think that it contains
+// a non-success code.
+MIG_SERVER_ROUTINE
+kern_return_t release_twice(mach_port_name_t port, vm_address_t addr1, 
vm_address_t addr2, vm_size_t size) {
+  kern_return_t ret = KERN_ERROR; // expected-note{{'ret' initialized to 1}}
+  vm_deallocate(port, addr1, size); // expected-note{{Deallocating object 
passed through parameter 'addr1'}}
+  vm_deallocate(port, addr2, size); // expected-note{{Deallocating object 
passed through parameter 'addr2'}}
+  return ret; // expected-warning{{MIG callback fails with error after 
deallocating argument value. This is use-after-free vulnerability because 
caller will try to deallocate it again}}
+ // expected-note@-1{{MIG callback fails with error after 
deallocating argument value. This is use-after-free vulnerability because 
caller will try to deallocate it again}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -45,14 +45,17 @@
 
 REGISTER_TRAIT_WITH_PROGRAMSTATE(ReleasedParameter, bool);
 
-static bool isCurrentArgSVal(SVal V, CheckerContext ) {
+static const ParmVarDecl *getOriginParam(SVal V, CheckerContext ) {
   SymbolRef Sym = V.getAsSymbol();
   if (!Sym)
-return false;
+return nullptr;
 
   const auto *VR = dyn_cast_or_null(Sym->getOriginRegion());
-  return VR && VR->hasStackParametersStorage() &&
- VR->getStackFrame()->inTopFrame();
+  if (VR && VR->hasStackParametersStorage() &&
+ VR->getStackFrame()->inTopFrame())
+return cast(VR->getDecl());
+
+  return nullptr;
 }
 
 static bool isInMIGCall(const LocationContext *LC) {
@@ -86,8 +89,18 @@
 
   // TODO: Unhardcode "1".
   SVal Arg = Call.getArgSVal(1);
-  if (isCurrentArgSVal(Arg, C))
-C.addTransition(C.getState()->set(true));
+  const ParmVarDecl *PVD = getOriginParam(Arg, C);
+  if (!PVD)
+return;
+
+  const NoteTag *T = C.getNoteTag([PVD]() -> std::string {
+SmallString<64> Str;
+llvm::raw_svector_ostream OS(Str);
+OS << "Deallocating object passed through parameter '" << PVD->getName()
+   << '\'';
+return OS.str();
+  });
+  C.addTransition(C.getState()->set(true), T);
 }
 
 void MIGChecker::checkPreStmt(const ReturnStmt *RS, CheckerContext ) const {
@@ -129,6 +142,8 @@
   "deallocate it again",
   N);
 
+  R->addRange(RS->getSourceRange());
+  bugreporter::trackExpressionValue(N, RS->getRetValue(), *R, false);
   C.emitReport(std::move(R));
 }
 


Index: clang/test/Analysis/mig.cpp
===
--- clang/test/Analysis/mig.cpp
+++ clang/test/Analysis/mig.cpp
@@ -1,4 +1,6 @@
-// RUN: 

[PATCH] D58367: [analyzer] NFC: Improve upon the concept of BugReporterVisitor.

2019-02-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware.
Herald added subscribers: cfe-commits, jdoerfert, dkrupp, donat.nagy, 
a.sidorin, szepet.
Herald added a project: clang.

As i mentioned in D58067#1393674 , i 
dislike the way bug reporter visitors have to reverse-engineer the checker's 
behavior instead of asking the checker what happened directly.

The approach suggested here is to allow the checker to take notes of what 
happens as it adds transitions, and then when the report is thrown, reconstruct 
path messages from these notes.

Because for the sake of future-proofness such messages should probably be 
allowed to be expensive to construct (even though i'm not aware of any specific 
examples of expensive-to-construct messages), the checker notes are defined to 
be lambdas that simply capture the necessary information but don't process it 
until a report is actually emitted. As a useful side effect, this allows the 
message to depend on the `BugReport` object itself, which is completely 
essential because most checkers won't emit path messages for every state update 
they make. For instance, when MallocChecker diagnoses a use-after-free, it only 
emits the "memory is freed" path message for the symbol that was accessed after 
free, but not for other symbols that were allocated or deallocated along the 
path. With lambda notes, we can check if the symbol is marked as "interesting" 
in the BugReport before emitting the path message. In the future we may want to 
extend the BugReport object to carry arbitrary Checker-specific data that the 
checker can take advantage of within its note lambdas.

Checker notes from which path messages are constructed are implemented as 
`ProgramPointTags` of special sub-kind: `NoteTag`. Then a special visitor is 
added to every report in order to scan the report for those tags and invoke the 
lambdas.

Here's how it looks in the checker in my next patch that actually makes use of 
the new functionality:

  const NoteTag *T = C.getNoteTag([PVD]() -> std::string {
SmallString<64> Str;
llvm::raw_svector_ostream OS(Str);
OS << "Deallocating object passed through parameter '" << PVD->getName() << 
'\'';
return OS.str();
  });
  
  C.addTransition(C.getState()->set(true), T);

And there's no need to write all of this anymore:

  class MyVisitor: public BugReporterVisitor {
  /*Manual captures...*/
  public:
MyVisitor(/*Manual captures...*/) { ... }
  
void Profile(llvm::FoldingSetNodeID ) {
  // The usual static int business.
  // And mention all manual captures.
  // Or maybe almost all, depends.
}
  
std::shared_ptr VisitNode(const ExplodedNode *N,
 BugReporterContext ,
 BugReport ) override {
  // The usual GDM update reverse-engineering idiom.
  if (N->getState()->get(...) != 
N->getFirstPred()->get(...)) {
 // Then the same message generating code.
  
 // Then a bunch of boilerplate to generate the piece itself:
 const Stmt *S = PathDiagnosticLocation::getStmt(N);
 if (!S)
   return nullptr;
 PathDiagnosticLocation Loc = PathDiagnosticLocation::create(S);
 return std::make_shared(Loc, OS.str());
  }
}
  };
  
  ...
  
  BR.addVisitor(MyVisitor(/*Manual captures...*/));


Repository:
  rC Clang

https://reviews.llvm.org/D58367

Files:
  clang/include/clang/Analysis/ProgramPoint.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2461,6 +2461,30 @@
   return nullptr;
 }
 
+int NoteTag::Kind = 0;
+
+void TagVisitor::Profile(llvm::FoldingSetNodeID ) const {
+  static int Tag = 0;
+  ID.AddPointer();
+}
+
+std::shared_ptr
+TagVisitor::VisitNode(const ExplodedNode *N, BugReporterContext ,
+  BugReport ) {
+  ProgramPoint PP = N->getLocation();
+  const NoteTag *T = dyn_cast_or_null(PP.getTag());
+  if (!T)
+return nullptr;
+
+  if (Optional Msg = T->getNote(BRC, R)) {
+PathDiagnosticLocation Loc =
+PathDiagnosticLocation::create(PP, BRC.getSourceManager());
+return std::make_shared(Loc, *Msg);
+  }
+
+  return nullptr;
+}
+
 void FalsePositiveRefutationBRVisitor::Profile(
 llvm::FoldingSetNodeID ) const {
   static int Tag = 0;
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp

[PATCH] D58366: [analyzer] MIGChecker: Make use of the server routine annotation.

2019-02-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

The attribute that's added in D58365  allows 
us to avoid making unreliable guesses on whether the current function is a MIG 
server routine.


Repository:
  rC Clang

https://reviews.llvm.org/D58366

Files:
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/test/Analysis/mig.cpp


Index: clang/test/Analysis/mig.cpp
===
--- clang/test/Analysis/mig.cpp
+++ clang/test/Analysis/mig.cpp
@@ -12,6 +12,9 @@
 
 kern_return_t vm_deallocate(mach_port_name_t, vm_address_t, vm_size_t);
 
+#define MIG_SERVER_ROUTINE __attribute__((mig_server_routine))
+
+MIG_SERVER_ROUTINE
 kern_return_t basic_test(mach_port_name_t port, vm_address_t address, 
vm_size_t size) {
   vm_deallocate(port, address, size);
   if (size > 10) {
@@ -21,6 +24,7 @@
 }
 
 // Make sure we don't crash when they forgot to write the return statement.
+MIG_SERVER_ROUTINE
 kern_return_t no_crash(mach_port_name_t port, vm_address_t address, vm_size_t 
size) {
   vm_deallocate(port, address, size);
 }
Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -55,7 +55,6 @@
  VR->getStackFrame()->inTopFrame();
 }
 
-// This function will probably be replaced with looking up annotations.
 static bool isInMIGCall(const LocationContext *LC) {
   const StackFrameContext *SFC;
   // Find the top frame.
@@ -64,17 +63,15 @@
 LC = SFC->getParent();
   }
 
-  const auto *FD = dyn_cast(SFC->getDecl());
+  const FunctionDecl *FD = dyn_cast(SFC->getDecl());
   if (!FD)
 return false;
 
-  // FIXME: This is an unreliable (even if surprisingly reliable) heuristic.
-  // The real solution here is to make MIG annotate its callbacks in
-  // autogenerated headers so that we didn't need to think hard if it's
-  // actually a MIG callback.
-  QualType T = FD->getReturnType();
-  return T.getCanonicalType()->isIntegerType() &&
- T.getAsString() == "kern_return_t";
+  // Even though there's a Sema warning when the return type of an annotated
+  // function is not a kern_return_t, this warning isn't an error, so we need
+  // an extra sanity check here.
+  return FD->hasAttr() &&
+ FD->getReturnType().getCanonicalType()->isSignedIntegerType();
 }
 
 void MIGChecker::checkPostCall(const CallEvent , CheckerContext ) const 
{


Index: clang/test/Analysis/mig.cpp
===
--- clang/test/Analysis/mig.cpp
+++ clang/test/Analysis/mig.cpp
@@ -12,6 +12,9 @@
 
 kern_return_t vm_deallocate(mach_port_name_t, vm_address_t, vm_size_t);
 
+#define MIG_SERVER_ROUTINE __attribute__((mig_server_routine))
+
+MIG_SERVER_ROUTINE
 kern_return_t basic_test(mach_port_name_t port, vm_address_t address, vm_size_t size) {
   vm_deallocate(port, address, size);
   if (size > 10) {
@@ -21,6 +24,7 @@
 }
 
 // Make sure we don't crash when they forgot to write the return statement.
+MIG_SERVER_ROUTINE
 kern_return_t no_crash(mach_port_name_t port, vm_address_t address, vm_size_t size) {
   vm_deallocate(port, address, size);
 }
Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -55,7 +55,6 @@
  VR->getStackFrame()->inTopFrame();
 }
 
-// This function will probably be replaced with looking up annotations.
 static bool isInMIGCall(const LocationContext *LC) {
   const StackFrameContext *SFC;
   // Find the top frame.
@@ -64,17 +63,15 @@
 LC = SFC->getParent();
   }
 
-  const auto *FD = dyn_cast(SFC->getDecl());
+  const FunctionDecl *FD = dyn_cast(SFC->getDecl());
   if (!FD)
 return false;
 
-  // FIXME: This is an unreliable (even if surprisingly reliable) heuristic.
-  // The real solution here is to make MIG annotate its callbacks in
-  // autogenerated headers so that we didn't need to think hard if it's
-  // actually a MIG callback.
-  QualType T = FD->getReturnType();
-  return T.getCanonicalType()->isIntegerType() &&
- T.getAsString() == "kern_return_t";
+  // Even though there's a Sema warning when the return type of an annotated
+  // function is not a kern_return_t, this warning isn't an error, so we need
+  // an extra sanity check here.
+  return FD->hasAttr() &&
+ FD->getReturnType().getCanonicalType()->isSignedIntegerType();
 }
 
 void MIGChecker::checkPostCall(const CallEvent , CheckerContext ) const {
___
cfe-commits mailing list

[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: aaron.ballman, dcoughlin, george.karpenkov.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Continuing the trend started in D54912 , i'd 
like to stuff one more XNU/Mach/Darwin-specific attribute into there. This 
one's fairly simple and is designed in order to be respected by the Static 
Analyzer's Mach Interface Generator calling convention checker that's getting 
added in D57558 .

@aaron.ballman, are you actually interested in reviewing these attributes? 
'Cause George added you on his reviews but i totally understand that these are 
fairly exotic.


Repository:
  rC Clang

https://reviews.llvm.org/D58365

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-mig.c
  clang/test/Sema/attr-mig.cpp

Index: clang/test/Sema/attr-mig.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-mig.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+typedef kern_return_t IOReturn;
+#define KERN_SUCCESS 0
+#define kIOReturnSuccess KERN_SUCCESS
+
+class MyServer {
+public:
+  virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
+  virtual __attribute__((mig_server_routine)) void anotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to functions that return a kernel return code}}
+  virtual __attribute__((mig_server_routine)) int yetAnotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to functions that return a kernel return code}}
+};
+
+IOReturn MyServer::externalMethod() {
+  return kIOReturnSuccess;
+}
Index: clang/test/Sema/attr-mig.c
===
--- /dev/null
+++ clang/test/Sema/attr-mig.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+#define KERN_SUCCESS 0
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // expected-warning-re{{'mig_server_routine' attribute only applies to functions{{$
+
+__attribute__((mig_server_routine)) void foo_void(); // expected-warning{{'mig_server_routine' attribute only applies to functions that return a kernel return code}}
+__attribute__((mig_server_routine)) int foo_int(); // expected-warning{{'mig_server_routine' attribute only applies to functions that return a kernel return code}}
+
+__attribute__((mig_server_routine)) kern_return_t bar_extern(); // no-warning
+__attribute__((mig_server_routine)) kern_return_t bar_forward(); // no-warning
+
+__attribute__((mig_server_routine)) kern_return_t bar_definition() { // no-warning
+  return KERN_SUCCESS;
+}
+
+kern_return_t bar_forward() { // no-warning
+  return KERN_SUCCESS;
+}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -60,6 +60,7 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: Lockable (SubjectMatchRule_record)
+// CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function)
 // CHECK-NEXT: MSStruct (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: MinSize (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6396,6 +6396,25 @@
   handleSimpleAttribute(S, D, AL);
 }
 
+static void handleMIGServerRoutineAttr(Sema , Decl *D, const ParsedAttr ) {
+  // Check that the return type is a `typedef int kern_return_t` or a typedef
+  // around it, because otherwise calling convention checks make no sense.
+  QualType T = cast(D)->getReturnType();
+  bool IsKernReturnT = false;
+  while (const auto *TT = T->getAs()) {
+IsKernReturnT = (TT->getDecl()->getName() == "kern_return_t");
+T = TT->desugar();
+  }
+  if (!IsKernReturnT || T.getCanonicalType() != S.getASTContext().IntTy) {
+S.Diag(D->getBeginLoc(),
+   diag::warn_mig_server_routine_does_not_return_kern_return_t)
+<< AL.getName()->getName();
+return;
+  }
+
+  handleSimpleAttribute(S, D, AL);
+}
+
 //===--===//
 // Top Level Sema Entry Points
 //===--===//
@@ -7119,6 +7138,11 @@
   case 

[PATCH] D55250: [clangd] Enhance macro hover to see full definition

2019-02-18 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

Ping?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55250



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


LLVM buildmaster will be updated and restarted tonight

2019-02-18 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 7PM Pacific time today.

Thanks

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


[PATCH] D57540: [C++17] Don't crash while diagnosing different access specifier of a deduction guide.

2019-02-18 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete abandoned this revision.
Rakete added a comment.
Herald added a subscriber: jdoerfert.

This revision has been superseded :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D57540



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


[PATCH] D58065: [analyzer] Document the frontend library

2019-02-18 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

High-level feedback: mixing of abstraction levels is wrong for the "bundled" 
documentation. This might also work better as a blogpost, if you want to jump 
from topic to topic.




Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:11-13
+This document will describe the frontend of the Static Analyzer, basically
+everything from compiling the analyzer from source, through it's invocation up
+to the beginning of the analysis. It will touch on topics such as

NoQ wrote:
> First of all, "frontend" is, as far as i understand, a weird word to use with 
> respect to this library in general. I think what they were trying to say was 
> something like "The Static Analyzer-specific part of the C Front End's 
> command-line flags" (as opposed to Driver flags), but calling this UI "The 
> Frontend" is a bit weird. We probablyshould try to somehow avoid confusion 
> with the "compiler frontend" concept throughout this document.
+1, not sure what the word "frontend" adds here.
IMO "frontend" in folder/library name is more of a relic in this case.



Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:57-88
+Following this, the compilation goes on as usual. The fastest way of obtaining
+the analyzer for development is by configuring CMake with the following 
options:
+
+* Use the `Ninja` build system
+* Build in `Release` with asserts enabled (Only recommended for slower
+  computers!)
+* Build shared libraries

NoQ wrote:
> For the above reason i think this text deserves a better document to be put 
> into; this is definitely important to know for a much wider audience than 
> developers of libStaticAnalyzerFrontend.
Strictly speaking for tests it's better to use `check-clang-analyzer`.
Also again strictly speaking it's not possible to compile analyzer without 
compiling `clang`.



Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:85
+-fuse-ld=lld \
+../llvm
+

Information on compiling LLVM IMO should not be here.
Also, why Sphinx? Why X86? Why LLD and not gold?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58065



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


r354296 - [clang][test] Fix FileManagerTest.getFileDontOpenRealPath for Windows

2019-02-18 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Feb 18 15:12:29 2019
New Revision: 354296

URL: http://llvm.org/viewvc/llvm-project?rev=354296=rev
Log:
[clang][test] Fix FileManagerTest.getFileDontOpenRealPath for Windows

Modified:
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354296=354295=354296=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Mon Feb 18 15:12:29 2019
@@ -362,17 +362,21 @@ TEST_F(FileManagerTest, getFileDontOpenR
   FileSystemOptions Opts;
   FileManager Manager(Opts, FS);
 
+  // Inject fake files into the file system.
   auto statCache = llvm::make_unique();
-  statCache->InjectDirectory("/tmp/abc", 42);
-  SmallString<64> Path("/tmp/abc/foo.cpp");
-  statCache->InjectFile(Path.str().str().c_str(), 43);
-  manager.setStatCache(std::move(statCache));
+  statCache->InjectDirectory("/tmp", 42);
+  statCache->InjectFile("/tmp/test", 43);
 
-  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
+  Manager.setStatCache(std::move(statCache));
 
+  // Check for real path.
+  const FileEntry *file = Manager.getFile("/tmp/test", /*OpenFile=*/false);
   ASSERT_TRUE(file != nullptr);
+  ASSERT_TRUE(file->isValid());
+  SmallString<64> ExpectedResult = CustomWorkingDir;
 
-  ASSERT_EQ(file->tryGetRealPathName(), Path);
+  llvm::sys::path::append(ExpectedResult, "tmp", "test");
+  EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
 } // anonymous namespace


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


r354291 - Reland "[clang][FileManager] fillRealPathName even if we aren't opening the file"

2019-02-18 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Feb 18 14:33:40 2019
New Revision: 354291

URL: http://llvm.org/viewvc/llvm-project?rev=354291=rev
Log:
Reland "[clang][FileManager] fillRealPathName even if we aren't opening the 
file"

This reverts commit e2bb3121fd4ab5b01f9ec1d2e3e9877db9c6a54c.
+ fixed test for Windows

Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354291=354290=354291=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Mon Feb 18 14:33:40 2019
@@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
   if (UFE.File) {
 if (auto PathName = UFE.File->getName())
   fillRealPathName(, *PathName);
+  } else if (!openFile) {
+// We should still fill the path even if we aren't opening the file.
+fillRealPathName(, InterndFileName);
   }
   return 
 }

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354291=354290=354291=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Mon Feb 18 14:33:40 2019
@@ -346,4 +346,33 @@ TEST_F(FileManagerTest, getVirtualFileFi
   EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
+TEST_F(FileManagerTest, getFileDontOpenRealPath) {
+  SmallString<64> CustomWorkingDir;
+#ifdef _WIN32
+  CustomWorkingDir = "C:/";
+#else
+  CustomWorkingDir = "/";
+#endif
+
+  auto FS = IntrusiveRefCntPtr(
+  new llvm::vfs::InMemoryFileSystem);
+  // setCurrentworkingdirectory must finish without error.
+  ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
+
+  FileSystemOptions Opts;
+  FileManager Manager(Opts, FS);
+
+  auto statCache = llvm::make_unique();
+  statCache->InjectDirectory("/tmp/abc", 42);
+  SmallString<64> Path("/tmp/abc/foo.cpp");
+  statCache->InjectFile(Path.str().str().c_str(), 43);
+  manager.setStatCache(std::move(statCache));
+
+  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
+
+  ASSERT_TRUE(file != nullptr);
+
+  ASSERT_EQ(file->tryGetRealPathName(), Path);
+}
+
 } // anonymous namespace


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


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-18 Thread Jan Korous via cfe-commits
Hi Nico,

I didn't think it necessary as the change doesn't introduce any interaction 
with filesystem - it's just copying a string.

Do you mean it causes a performance regression?

Thanks.

Jan

> On Feb 15, 2019, at 6:15 AM, Nico Weber  wrote:
> 
> Did you do any performance testing to check if this slows down clang?
> 
> On Thu, Feb 14, 2019 at 6:02 PM Jan Korous via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Thu Feb 14 15:02:35 2019
> New Revision: 354075
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=354075=rev 
> 
> Log:
> [clang][FileManager] fillRealPathName even if we aren't opening the file
> 
> The pathname wasn't previously filled when the getFile() method was called 
> with openFile = false.
> We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused 
> the problem.
> 
> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
> 
> rdar://47536127
> 
> Differential Revision: https://reviews.llvm.org/D58213 
> 
> 
> Modified:
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
> 
> Modified: cfe/trunk/lib/Basic/FileManager.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075=354074=354075=diff
>  
> 
> ==
> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>if (UFE.File) {
>  if (auto PathName = UFE.File->getName())
>fillRealPathName(, *PathName);
> +  } else if (!openFile) {
> +// We should still fill the path even if we aren't opening the file.
> +fillRealPathName(, InterndFileName);
>}
>return 
>  }
> 
> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075=354074=354075=diff
>  
> 
> ==
> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>  }
> 
> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
> +  auto statCache = llvm::make_unique();
> +  statCache->InjectDirectory("/tmp/abc", 42);
> +  SmallString<64> Path("/tmp/abc/foo.cpp");
> +  statCache->InjectFile(Path.str().str().c_str(), 43);
> +  manager.setStatCache(std::move(statCache));
> +
> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
> +
> +  ASSERT_TRUE(file != nullptr);
> +
> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
> +}
> +
>  } // anonymous namespace
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 

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


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-18 Thread Jan Korous via cfe-commits
Hi all,

Sorry, my bad, I was out on Friday.

Will re-land patch with fixed test shortly.

Jan

> On Feb 15, 2019, at 12:47 PM, Reid Kleckner  wrote:
> 
> Reverted:
> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/4351 
> 
> On Fri, Feb 15, 2019 at 11:07 AM Galina Kistanova via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Hello Jan,
> 
> It looks like this commit broke tests on couple of win builders:
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/23655
>  
> 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win 
> 
> . . .
> Failing Tests (1):
> Clang-Unit :: 
> Basic/./BasicTests.exe/FileManagerTest.getFileDontOpenRealPath
> 
> Please have a look ASAP?
> 
> Thanks
> 
> Galina
> 
> On Thu, Feb 14, 2019 at 3:02 PM Jan Korous via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jkorous
> Date: Thu Feb 14 15:02:35 2019
> New Revision: 354075
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=354075=rev 
> 
> Log:
> [clang][FileManager] fillRealPathName even if we aren't opening the file
> 
> The pathname wasn't previously filled when the getFile() method was called 
> with openFile = false.
> We are caching FileEntry-s in ParsedAST::Includes in clangd and this caused 
> the problem.
> 
> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
> 
> rdar://47536127
> 
> Differential Revision: https://reviews.llvm.org/D58213 
> 
> 
> Modified:
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
> 
> Modified: cfe/trunk/lib/Basic/FileManager.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075=354074=354075=diff
>  
> 
> ==
> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>if (UFE.File) {
>  if (auto PathName = UFE.File->getName())
>fillRealPathName(, *PathName);
> +  } else if (!openFile) {
> +// We should still fill the path even if we aren't opening the file.
> +fillRealPathName(, InterndFileName);
>}
>return 
>  }
> 
> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075=354074=354075=diff
>  
> 
> ==
> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>  }
> 
> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
> +  auto statCache = llvm::make_unique();
> +  statCache->InjectDirectory("/tmp/abc", 42);
> +  SmallString<64> Path("/tmp/abc/foo.cpp");
> +  statCache->InjectFile(Path.str().str().c_str(), 43);
> +  manager.setStatCache(std::move(statCache));
> +
> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
> +
> +  ASSERT_TRUE(file != nullptr);
> +
> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
> +}
> +
>  } // anonymous namespace
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 

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


[PATCH] D58291: [clangd] Include textual diagnostic ID as Diagnostic.code.

2019-02-18 Thread Jan Korous via Phabricator via cfe-commits
jkorous requested changes to this revision.
jkorous added a comment.
This revision now requires changes to proceed.

Hi Sam, this looks good! 
I found just one small detail.




Comment at: clangd/Diagnostics.cpp:281
+if (auto* Name = getDiagnosticCode(D.ID))
+  Main.code = Name;
 if (Opts.EmbedFixesInDiagnostics) {

It seems to me that in case `ID` is undefined (hits the default case in 
`getDiagnosticCode`) we are calling `std::string` non-explicit constructor with 
`nullptr` which is UB.
How about changing `char* getDiagnosticCode` to `Optional 
getDiagnosticCode` or similar to make it less error-prone?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58291



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


[PATCH] D58185: [clangd] Handle unresolved scope specifier when fixing includes.

2019-02-18 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Hi Eric, I have just couple details.




Comment at: clangd/IncludeFixer.cpp:188
+// first character after the unresolved name in \p Code. For the example below,
+// this returns "::X::Y" that is qualfied by unresolved name "clangd":
+// clang::clangd::X::Y

qualfied -> qualified



Comment at: clangd/IncludeFixer.cpp:193
+  size_t Offset) {
+  auto IsValidIdentifierChar = [](char C) {
+return ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||

It seems to me that calling Lexer would be better indeed.



Comment at: clangd/IncludeFixer.cpp:216
+  // resolved form not its typed form (think `namespace clang { clangd::x }` 
-->
+  // `clang::clangd::`). This is not done lazily because `SS` can get out of
+  // scope and it's relatively cheap.

Maybe move the comment about work done eagerly to the function?



Comment at: clangd/IncludeFixer.cpp:251
+// namespace clang { clangd::X; }
+// In this case, we use the "typo" qualifier as extra scope instead
+// of using the scope assumed by sema.

Does this work with anonymous namespaces?



Comment at: clangd/IncludeFixer.cpp:263
+Result.Resolved = printNamespaceScope(*ANS->getNamespace());
+  else
+// We don't fix symbols in scopes that are not top-level e.g. class

I'd personally prefer to add parentheses here to have the if/else if/else 
consistent. Up to you though.



Comment at: clangd/IncludeFixer.cpp:271
+  if (IsUnrsolvedSpecifier) {
+// If the unresolved name is a qualifier e.g.
+//  clang::clangd::X

Is the term `qualifier` applicable here? (Honest question.)

It seems like C++ grammar uses `specifier` (same as you in 
`IsUnrsolvedSpecifier `)
http://www.nongnu.org/hcb/#nested-name-specifier



Comment at: unittests/clangd/DiagnosticsTests.cpp:452
 
+TEST(IncludeFixerTest, UnresolvedNameAsQualifier) {
+  Annotations Test(R"cpp(

If (see above) we decide `qualifier` should be replaced by `specifier` or smth 
else please replace here as well, otherwise ignore this.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58185



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


[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-02-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 2 inline comments as done.
Anastasia added inline comments.



Comment at: lib/Sema/SemaCast.cpp:2224
+  } else if (IsLValueCast) {
 Kind = CK_LValueBitCast;
   } else if (DestType->isObjCObjectPointerType()) {

ebevhan wrote:
> This might not be applicable to this patch, but just something I noticed.
> 
> So `reinterpret_cast` only operates on pointers when dealing with address 
> spaces. What about something like
> ```
> T a;
> T& a_ref = reinterpret_cast(a);
> ```
> `reinterpret_cast` on an lvalue like this is equivalent to 
> `*reinterpret_cast()`. So for AS code:
> ```
> __private T x;
> __generic T& ref = reinterpret_cast<__generic T&>(x);
> ```
> This should work, since `*reinterpret_cast<__generic T*>()` is valid, 
> correct?
> 
> What if we have the reference cast case with a different address space like 
> this? Doesn't the `IsLValueCast` check need to be first?
> 
> What if we have the reference cast case with a different address space like 
> this? Doesn't the IsLValueCast check need to be first?

Ok, let me see if I understand you. I changed `__generic` -> `__global` since 
it's invalid and the error is produced as follows:
  test.cl:7:21: error: reinterpret_cast from 'int' to '__global int &' is not 
allowed
  __global int& ref = reinterpret_cast<__global int&>(x);

Is this not what we are expecting here?



Comment at: lib/Sema/SemaCast.cpp:2309
+auto DestPointeeTypeWithoutAS = Self.Context.removeAddrSpaceQualType(
+DestPointeeType.getCanonicalType());
+return Self.Context.hasSameType(SrcPointeeTypeWithoutAS,

ebevhan wrote:
> Maybe I'm mistaken, but won't getting the canonical type here drop qualifiers 
> (like cv) in nested pointers? If so, an addrspace_cast might strip qualifiers 
> by mistake.
Yes, indeed I will need to extend this to nested pointers when we are ready. 
But for now I can try to change this bit... however I am not sure it will work 
w/o canonical types when we have typedef. I will try to create an example and 
see.


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

https://reviews.llvm.org/D58346



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


[PATCH] D57687: [clang-format] Add style option AllowShortLambdasOnASingleLine

2019-02-18 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler updated this revision to Diff 187260.

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

https://reviews.llvm.org/D57687

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11966,6 +11966,43 @@
   "> {\n"
   "  //\n"
   "});");
+
+  FormatStyle DoNotMerge = getLLVMStyle();
+  DoNotMerge.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+  verifyFormat("auto c = []() {\n"
+   "  return b;\n"
+   "};",
+   "auto c = []() { return b; };", DoNotMerge);
+  verifyFormat("auto c = []() {\n"
+   "};",
+   " auto c = []() {};", DoNotMerge);
+
+  FormatStyle MergeEmptyOnly = getLLVMStyle();
+  MergeEmptyOnly.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Empty;
+  verifyFormat("auto c = []() {\n"
+   "  return b;\n"
+   "};",
+   "auto c = []() {\n"
+   "  return b;\n"
+   " };",
+   MergeEmptyOnly);
+  verifyFormat("auto c = []() {};",
+   "auto c = []() {\n"
+   "};",
+   MergeEmptyOnly);
+
+  FormatStyle MergeInline = getLLVMStyle();
+  MergeInline.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Inline;
+  verifyFormat("auto c = []() {\n"
+   "  return b;\n"
+   "};",
+   "auto c = []() { return b; };", MergeInline);
+  verifyFormat("function([]() { return b; })", "function([]() { return b; })",
+   MergeInline);
+  verifyFormat("function([]() { return b; }, a)",
+   "function([]() { return b; }, a)", MergeInline);
+  verifyFormat("function(a, []() { return b; })",
+   "function(a, []() { return b; })", MergeInline);
 }
 
 TEST_F(FormatTest, EmptyLinesInLambdas) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1436,6 +1436,7 @@
   return true;
 }
   }
+  FormatTok->Type = TT_LambdaLBrace;
   LSquare.Type = TT_LambdaLSquare;
   parseChildBlock();
   return true;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -365,7 +365,7 @@
   // specifier parameter, although this is technically valid:
   // [[foo(:)]]
   if (AttrTok->is(tok::colon) ||
-  AttrTok->startsSequence(tok::identifier, tok::identifier) || 
+  AttrTok->startsSequence(tok::identifier, tok::identifier) ||
   AttrTok->startsSequence(tok::r_paren, tok::identifier))
 return false;
   if (AttrTok->is(tok::ellipsis))
@@ -1142,11 +1142,11 @@
 
 // Reset token type in case we have already looked at it and then
 // recovered from an error (e.g. failure to find the matching >).
-if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_ForEachMacro,
-   TT_FunctionLBrace, TT_ImplicitStringLiteral,
-   TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
-   TT_OverloadedOperator, TT_RegexLiteral,
-   TT_TemplateString, TT_ObjCStringLiteral))
+if (!CurrentToken->isOneOf(
+TT_LambdaLSquare, TT_LambdaLBrace, TT_ForEachMacro,
+TT_FunctionLBrace, TT_ImplicitStringLiteral, TT_InlineASMBrace,
+TT_JsFatArrow, TT_LambdaArrow, TT_OverloadedOperator,
+TT_RegexLiteral, TT_TemplateString, TT_ObjCStringLiteral))
   CurrentToken->Type = TT_Unknown;
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;
@@ -2839,7 +2839,7 @@
 // Returns 'true' if 'Tok' is a brace we'd want to break before in Allman style.
 static bool isAllmanBrace(const FormatToken ) {
   return Tok.is(tok::l_brace) && Tok.BlockKind == BK_Block &&
- !Tok.isOneOf(TT_ObjCBlockLBrace, TT_DictLiteral);
+ !Tok.isOneOf(TT_ObjCBlockLBrace, TT_LambdaLBrace, TT_DictLiteral);
 }
 
 bool TokenAnnotator::mustBreakBefore(const AnnotatedLine ,
@@ -2967,6 +2967,18 @@
   if (Left.is(TT_ObjCBlockLBrace) && !Style.AllowShortBlocksOnASingleLine)
 return true;
 
+  if (Left.is(TT_LambdaLBrace)) {
+if (Left.MatchingParen && Left.MatchingParen->Next &&
+Left.MatchingParen->Next->isOneOf(tok::comma, tok::r_paren) &&
+Style.AllowShortLambdasOnASingleLine == FormatStyle::SLS_Inline)
+  

[PATCH] D58185: [clangd] Handle unresolved scope specifier when fixing includes.

2019-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! The layering is *much* clearer now.
I can still suggest a couple of tweaks, but they're pretty much cosmetic.




Comment at: clangd/IncludeFixer.cpp:190
+// clang::clangd::X::Y
+//~~
+llvm::Optional qualifiedByUnresolved(llvm::StringRef Code,

you're showing a range here, it should be a point though?



Comment at: clangd/IncludeFixer.cpp:191
+//~~
+llvm::Optional qualifiedByUnresolved(llvm::StringRef Code,
+  size_t Offset) {

this isn't wrong per se (conservative, bails out e.g. on unicode)
But is it much harder to call Lexer::findNextToken twice and expect a raw 
identifier and ::?



Comment at: clangd/IncludeFixer.cpp:231
+const SourceManager , CXXScopeSpec *SS, llvm::StringRef UnresolvedName,
+SourceLocation UnresolvedLoc, bool IsUnrsolvedSpecifier) {
+  bool Invalid = false;

Unrsolved -> Unresolved

emphasis might be clearer as `UnresolvedIsSpecifier` - there's always an 
unresolved entity, the boolean is indicating that it's a specifier



Comment at: clangd/IncludeFixer.cpp:256
+std::string Spelling = (Code.substr(B, E - B) + "::").str();
+vlog("Spelling scope: {0}, SpecifiedNS: {1}", Spelling, SpecifiedNS);
+if (llvm::StringRef(SpecifiedNS).endswith(Spelling))

I don't think this vlog is useful as-is (quite far down the stack with no 
context)
Did you intend to remove it?



Comment at: clangd/IncludeFixer.cpp:322
 UnresolvedName Unresolved;
 Unresolved.Name = Typo.getAsString();
 Unresolved.Loc = Typo.getBeginLoc();

Following up on our offline discussion :-)
I think that since `extractSpecifiedScopes` can want to modify the name, we 
should just expand that function's signature/responsibility to always determine 
the name.

So we'd pass the `const DeclarationNameInfo&` to `extractSpecifiedScopes`, and 
it would return a struct `{optional ResolvedScope; optional 
UnresolvedScope; string Name}`. 
Maybe need to call them `CheapUnresolvedName`/`extractUnresolvedNameCheaply` or 
 similar.
But I think the code change is small.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58185



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


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-18 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau marked an inline comment as done.
pgousseau added inline comments.



Comment at: include/clang/Basic/Sanitizers.h:43
+  // Low bits of mask value.
+  uint64_t maskLo;
+  // High bits of mask value.

riccibruno wrote:
> Why not use a fixed size array of `uint64_t`s, and then compute the index 
> without any branch with `ArrayIndex = BitPosition / 64` (with an assertion 
> that `ArrayIndex < MaxArrayIndex` ? This has the advantage that in the future 
> all that is needed to do is bump up the size of the array.
Sounds good! I will give it a try.


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

https://reviews.llvm.org/D57914



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


[PATCH] D58293: [clang][Index] Enable indexing of Template Type Parameters behind a flag

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Index/IndexingContext.cpp:51
+
 bool IndexingContext::handleDecl(const Decl *D,
  SymbolRoleSet Roles,

Do we call `handleDecl` for template parameters now too?



Comment at: unittests/Index/IndexTests.cpp:141
+template  struct Foo {
+  T t = I;
+};

could we add a template template parameter into the test too?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58293



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


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-18 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: include/clang/Basic/Sanitizers.h:43
+  // Low bits of mask value.
+  uint64_t maskLo;
+  // High bits of mask value.

Why not use a fixed size array of `uint64_t`s, and then compute the index 
without any branch with `ArrayIndex = BitPosition / 64` (with an assertion that 
`ArrayIndex < MaxArrayIndex` ? This has the advantage that in the future all 
that is needed to do is bump up the size of the array.


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

https://reviews.llvm.org/D57914



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


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-18 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D57914#1401367 , @pgousseau wrote:

> Updated patch to not use APInt for representing the mask as it feels like a 
> hammer solution.


Ah! I was going to say exactly this.


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

https://reviews.llvm.org/D57914



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a subscriber: arsenm.
Anastasia added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6996
+  "|%diff{casting $ to type $|casting between types}0,1}2"
+  " changes address space of nested pointer">;
 def err_typecheck_incompatible_ownership : Error<

ebevhan wrote:
> Anastasia wrote:
> > I am wondering if we could just unify with the diagnostic above?
> > 
> > We could add another select at the end:
> >   " changes address space of %select{nested|}3 pointer"
> That is doable, but all of the 'typecheck' errors/warnings are made to be 
> regular. If I add another parameter, there needs to be a special case in 
> DiagnoseAssignmentResult for that error in particular.
Oh I see... might not worth it?



Comment at: test/CodeGenOpenCL/numbered-address-space.cl:17
-void test_numbered_as_to_builtin(__attribute__((address_space(42))) int 
*arbitary_numbered_ptr, float src) {
-  volatile float result = __builtin_amdgcn_ds_fmaxf(arbitary_numbered_ptr, 
src, 0, 0, false);
-}

ebevhan wrote:
> Anastasia wrote:
> > Does this not compile any more?
> No, these tests were a bit shaky. I'm not even sure what they're supposed to 
> be testing. It's trying to pass an arbitrary `AS int *` pointer to a function 
> that takes `__local float *`. That AS conversion is illegal (implicitly), but 
> the illegal conversion was 'shadowed' by the 'incompatible pointer' warning, 
> so we didn't get an error. This is one of the things this patch fixes.
> 
> Since it's a codegen test, it should be producing something, but I'm not 
> really sure what is interesting to produce here, so I just removed it.
Ok, I will just loop in @arsenm  to confirm. OpenCL doesn't regulate arbitrary 
address spaces. And C doesn't regulate OpenCL ones. So interplay between those 
two has undefined behavior in my opinion. However, OpenCL code can make use of 
arbitrary address spaces since it's a valid Clang extension... But I am not 
sure what happens with this undefined behaviors.

For this specific case I would rather expect an error... but not sure it's 
worth testing this anyway.

May be Matt can provide us some more insights!



Comment at: test/SemaOpenCL/address-spaces.cl:89
+  __local int * __global * __private * lll;
+  lll = gg; // expected-warning {{incompatible pointer types assigning to 
'__local int *__global **' from '__global int **'}}
+}

ebevhan wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > ebevhan wrote:
> > > > This doesn't seem entirely correct still, but I'm not sure what to do 
> > > > about it.
> > > Is it because `Sema::IncompatiblePointer` has priority? We might want to 
> > > change that. I think it was ok before because qualifier's mismatch was 
> > > only a warning but now with the address spaces we are giving an error. I 
> > > wonder if adding a separate enum item for address spaces (something like 
> > > `Sema::IncompatibleNestedPointerAddressSpace`) would simplify things.
> > > Is it because `Sema::IncompatiblePointer` has priority?
> > 
> > Sort of. The problem is that the AS pointee qualifiers match up until the 
> > 'end' of the RHS pointer chain (LHS: `private->global->local`, RHS: 
> > `private->global`), so we never get an 'incompatible address space' to 
> > begin with. We only get that if 1) the bottommost type is equal after 
> > unwrapping pointers (as far as both sides go), or 2) any of the 'shared' AS 
> > qualifiers (as far as both sides go) were different.
> > 
> > The idea is that stopping when either side is no longer a pointer will 
> > produce 'incompatible pointers' when you have different pointer depths, but 
> > it doesn't consider anything below the 'shallowest' side of the pointer 
> > chain, so we miss out on any AS mismatches further down.
> > 
> > (Not that there's anything to mismatch, really. There is no matching 
> > pointer on the other side, so what is really the error?)
> > 
> > What should the criteria be for when the pointer types 'run out'? I could 
> > have it keep digging through the other pointer until it hits a different 
> > AS? This would mean that this:
> > ```
> > int  a;
> > int ** b = a;
> > ```
> > could give a different warning than it does today, though (incompatible 
> > nested qualifiers instead of incompatible pointers, which doesn't make 
> > sense...) . We would have to skip the `lhptee == rhptee` check if we 'kept 
> > going' despite one side not being a pointer type. So I don't know if that's 
> > the right approach in general.
> > 
> > Or should we be searching 'backwards' instead, starting from the innermost 
> > pointee? I don't know.
> > 
> > It really feels like the whole `checkPointerTypesForAssignment` routine and 
> > everything surrounding it is a bit messy. It relies on an implicit result 
> > from another function (`typesAreCompatible`) and then tries to deduce why 
> > that function thought the types weren't 

[PATCH] D58294: [clangd] Enable indexing of template type parameters

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

It feels that storing template parameters in the index is a waste, one can only 
access them through the scope they are introduced in (there are out-of-line 
definitions of a function, but I think we treat every redeclaration of template 
headers separately).
Can we get the information from the AST whenever we need it?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58294



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


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-18 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau updated this revision to Diff 187258.
pgousseau edited the summary of this revision.
pgousseau added a comment.

Updated patch to not use APInt for representing the mask as it feels like a 
hammer solution.


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

https://reviews.llvm.org/D57914

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/Sanitizers.def
  include/clang/Basic/Sanitizers.h
  include/clang/Driver/ToolChain.h
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/Sanitizers.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6199,7 +6199,8 @@
 if (!S.checkStringLiteralArgumentAttr(AL, I, SanitizerName, ))
   return;
 
-if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) == 0)
+if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) ==
+SanitizerMask())
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
 else if (isGlobalVar(D) && SanitizerName != "address")
   S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -551,7 +551,7 @@
 DiagnosticsEngine , SanitizerSet ) {
   for (const auto  : Sanitizers) {
 SanitizerMask K = parseSanitizerValue(Sanitizer, /*AllowGroups=*/false);
-if (K == 0)
+if (K == SanitizerMask())
   Diags.Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
 else
   S.set(K, true);
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -25,29 +25,32 @@
 using namespace clang::driver;
 using namespace llvm::opt;
 
-enum : SanitizerMask {
-  NeedsUbsanRt = Undefined | Integer | ImplicitConversion | Nullability | CFI,
-  NeedsUbsanCxxRt = Vptr | CFI,
-  NotAllowedWithTrap = Vptr,
-  NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow | HWAddress | Scudo,
-  NeedsUnwindTables = Address | HWAddress | Thread | Memory | DataFlow,
-  SupportsCoverage = Address | HWAddress | KernelAddress | KernelHWAddress |
- Memory | KernelMemory | Leak | Undefined | Integer |
- ImplicitConversion | Nullability | DataFlow | Fuzzer |
- FuzzerNoLink,
-  RecoverableByDefault = Undefined | Integer | ImplicitConversion | Nullability,
-  Unrecoverable = Unreachable | Return,
-  AlwaysRecoverable = KernelAddress | KernelHWAddress,
-  LegacyFsanitizeRecoverMask = Undefined | Integer,
-  NeedsLTO = CFI,
-  TrappingSupported = (Undefined & ~Vptr) | UnsignedIntegerOverflow |
-  ImplicitConversion | Nullability | LocalBounds | CFI,
-  TrappingDefault = CFI,
-  CFIClasses =
-  CFIVCall | CFINVCall | CFIMFCall | CFIDerivedCast | CFIUnrelatedCast,
-  CompatibleWithMinimalRuntime = TrappingSupported | Scudo | ShadowCallStack,
-};
+SanitizerMask NeedsUbsanRt =
+Undefined | Integer | ImplicitConversion | Nullability | CFI;
+SanitizerMask NeedsUbsanCxxRt = Vptr | CFI;
+SanitizerMask NotAllowedWithTrap = Vptr;
+SanitizerMask NotAllowedWithMinimalRuntime = Vptr;
+SanitizerMask RequiresPIE = DataFlow | HWAddress | Scudo;
+SanitizerMask NeedsUnwindTables =
+Address | HWAddress | Thread | Memory | DataFlow;
+SanitizerMask SupportsCoverage =
+Address | HWAddress | KernelAddress | KernelHWAddress | Memory |
+KernelMemory | Leak | Undefined | Integer | ImplicitConversion |
+Nullability | DataFlow | Fuzzer | FuzzerNoLink;
+SanitizerMask RecoverableByDefault =
+Undefined | Integer | ImplicitConversion | Nullability;
+SanitizerMask Unrecoverable = Unreachable | Return;
+SanitizerMask AlwaysRecoverable = KernelAddress | KernelHWAddress;
+SanitizerMask LegacyFsanitizeRecoverMask = Undefined | Integer;
+SanitizerMask NeedsLTO = CFI;
+SanitizerMask TrappingSupported = (Undefined & ~Vptr) |
+  UnsignedIntegerOverflow | ImplicitConversion |
+  Nullability | LocalBounds | CFI;
+SanitizerMask TrappingDefault = CFI;
+SanitizerMask CFIClasses =
+CFIVCall | CFINVCall | CFIMFCall | CFIDerivedCast | CFIUnrelatedCast;
+SanitizerMask CompatibleWithMinimalRuntime =
+TrappingSupported | Scudo | ShadowCallStack;
 
 enum CoverageFeature {
   CoverageFunc = 1 << 0,
@@ -136,10 +139,10 @@
 
 static SanitizerMask parseSanitizeTrapArgs(const Driver ,
const llvm::opt::ArgList ) {
-  SanitizerMask TrapRemove = 0; // During the loop below, the accumulated set of
+  SanitizerMask TrapRemove; // 

[PATCH] D58341: [clangd] Index UsingDecls

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D58341#1401295 , @hokein wrote:

> std::strcmp is a fair case here. Sema seems not returning using-decls as part 
> of code completion results, it this an intended behavior?


Yeah, I think it is. There's an explicit code path that takes the target decls 
of a using. Arguably, that's good if you to show signatures of the methods.

> Is it possible for us to extend Sema to support it?

We could, but then we'd loose the signatures of the targets functions, which is 
sad :-(

> If we decide to provide using-decl results from index, I think we should make 
> sure the code completion information (e.g. signature) is correct.

The problem is that using-decls have multiple signatures. They can introduce 
more than one name into the scope, so the question is which one should we pick 
and how should we store them.
In any case, it feels like any solution we can come up with would require 
storing using declarations in the index in one form or the other, so this patch 
definitely makes sense: it gives us hooks we can use to handle usings in clangd.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341



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


[PATCH] D57978: [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-02-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur marked an inline comment as done.
Meinersbur added inline comments.



Comment at: lib/CodeGen/CGLoopInfo.cpp:107
+  FollowupLoopProperties.push_back(
+  MDNode::get(Ctx, MDString::get(Ctx, "llvm.loop.unroll.disable")));
+

Anastasia wrote:
> Will this end up emitted in the final module?
This MDNode is emitted in the module generated by clang -- as a follow-up 
attribute -- in case there is another transformation after partial unrolling 
(currently just pipelining).


Repository:
  rC Clang

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

https://reviews.llvm.org/D57978



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


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

2019-02-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@djasper and @klimek you both look relatively inactive in the last couple of 
weeks/month, is there anyone else who acts as a gate keeper for clang-format or 
can anyone add a LGTM?


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

https://reviews.llvm.org/D28462



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


[PATCH] D58344: Enablement for AMD znver2 architecture - skeleton

2019-02-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D58344



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


[PATCH] D57896: Variable names rule

2019-02-18 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings marked an inline comment as done.
michaelplatings added inline comments.



Comment at: llvm/docs/CodingStandards.rst:1195
+  be camel case, and start with a lower case letter (e.g. ``leader`` or
+  ``boats``). It is also acceptable to use ``UpperCamelCase`` for consistency
+  with existing code.

rupprecht wrote:
> It would be nice for this section to be expanded a bit, just to avoid 
> inevitable code review churn, e.g. if I'm adding 50 lines to a 200 line file, 
> am I allowed to change the existing var names elsewhere in the file or 
> method, or is that outside the scope of my change? If I'm reviewing that 
> patch, do I tell the author they have to be consistent and revert other 
> changes? etc.
> 
> Is there any plan to use clang-tidy to do a global cleanup, or is this going 
> to be a totally ad-hoc migration -- variables use the new scheme only when 
> the code is updated?
I've had a go at expanding it. Please let me know if you have other suggestions.

> Is there any plan to use clang-tidy to do a global cleanup, or is this going 
> to be a totally ad-hoc migration -- variables use the new scheme only when 
> the code is updated?

The latter. Given that the code doesn't keep to the existing .clang-tidy rules 
I'm not optimistic that we could persuade code owners to start now. That's not 
to say it couldn't happen eventually, but my aim at this point in time is to 
make it easier to use good variable names and I don't want perfect to be the 
enemy of better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57896



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


[PATCH] D57896: Variable names rule

2019-02-18 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 187252.
michaelplatings added a comment.

Update .clang-tidy files to use aNy_CasE until camelBackOrCase is available.
Add more guidance around acronyms.
Add more guidance around consistency with existing CamelCase variable names.
Change other code examples to camelBack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57896

Files:
  .clang-tidy
  clang/.clang-tidy
  llvm/.clang-tidy
  llvm/docs/CodingStandards.rst

Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -311,13 +311,13 @@
 
.. code-block:: c++
 
- Object.emitName(nullptr);
+ object.emitName(nullptr);
 
An in-line C-style comment makes the intent obvious:
 
.. code-block:: c++
 
- Object.emitName(/*Prefix=*/nullptr);
+ object.emitName(/*prefix=*/nullptr);
 
 Commenting out large blocks of code is discouraged, but if you really have to do
 this (for documentation purposes or as a suggestion for debug printing), use
@@ -355,8 +355,8 @@
 
 .. code-block:: c++
 
-  /// Sets the xyzzy property to \p Baz.
-  void setXyzzy(bool Baz);
+  /// Sets the xyzzy property to \p baz.
+  void setXyzzy(bool baz);
 
 A documentation comment that uses all Doxygen features in a preferred way:
 
@@ -364,18 +364,18 @@
 
   /// Does foo and bar.
   ///
-  /// Does not do foo the usual way if \p Baz is true.
+  /// Does not do foo the usual way if \p baz is true.
   ///
   /// Typical usage:
   /// \code
-  ///   fooBar(false, "quux", Res);
+  ///   fooBar(false, "quux", res);
   /// \endcode
   ///
-  /// \param Quux kind of foo to do.
+  /// \param quux kind of foo to do.
   /// \param [out] Result filled with bar sequence on foo success.
   ///
   /// \returns true on success.
-  bool fooBar(bool Baz, StringRef Quux, std::vector );
+  bool fooBar(bool baz, StringRef quux, std::vector );
 
 Don't duplicate the documentation comment in the header file and in the
 implementation file.  Put the documentation comments for public APIs into the
@@ -568,16 +568,16 @@
 .. code-block:: c++
 
   dyn_switch(V->stripPointerCasts(),
- [] (PHINode *PN) {
+ [] (PHINode *phiNode) {
// process phis...
  },
- [] (SelectInst *SI) {
+ [] (SelectInst *selectInst) {
// process selects...
  },
- [] (LoadInst *LI) {
+ [] (LoadInst *loadInst) {
// process loads...
  },
- [] (AllocaInst *AI) {
+ [] (AllocaInst *allocaInst) {
// process allocas...
  });
 
@@ -603,7 +603,7 @@
 
   foo({a, b, c}, {1, 2, 3});
 
-  llvm::Constant *Mask[] = {
+  llvm::Constant *mask[] = {
   llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), 0),
   llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), 1),
   llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), 2)};
@@ -633,7 +633,7 @@
 
 .. code-block:: c++
 
-  if (V = getValue()) {
+  if (v = getValue()) {
 ...
   }
 
@@ -644,7 +644,7 @@
 
 .. code-block:: c++
 
-  if ((V = getValue())) {
+  if ((v = getValue())) {
 ...
   }
 
@@ -736,7 +736,7 @@
   class Foo;
 
   // Breaks mangling in MSVC.
-  struct Foo { int Data; };
+  struct Foo { int data; };
 
 * As a rule of thumb, ``struct`` should be kept to structures where *all*
   members are declared public.
@@ -746,17 +746,17 @@
   // Foo feels like a class... this is strange.
   struct Foo {
   private:
-int Data;
+int data;
   public:
-Foo() : Data(0) { }
-int getData() const { return Data; }
-void setData(int D) { Data = D; }
+Foo() : data(0) { }
+int getData() const { return data; }
+void setData(int d) { data = d; }
   };
 
   // Bar isn't POD, but it does look like a struct.
   struct Bar {
-int Data;
-Bar() : Data(0) { }
+int data;
+Bar() : data(0) { }
   };
 
 Do not use Braced Initializer Lists to Call a Constructor
@@ -780,7 +780,7 @@
 Foo(std::string filename);
 
 // Construct a Foo by looking up the Nth element of some global data ...
-Foo(int N);
+Foo(int n);
 
 // ...
   };
@@ -789,7 +789,7 @@
   std::fill(foo.begin(), foo.end(), Foo("name"));
 
   // The pair is just being constructed like an aggregate, use braces.
-  bar_map.insert({my_key, my_value});
+  bar_map.insert({myKey, myValue});
 
 If you use a braced initializer list when initializing a variable, use an equals before the open curly brace:
 
@@ -821,15 +821,15 @@
 .. code-block:: c++
 
   // Typically there's no reason to copy.
-  for (const auto  : Container) { observe(Val); }
-  for (auto  : Container) { Val.change(); }
+  for (const auto  : container) { observe(val); }
+  for (auto  : container) { val.change(); }
 
   // Remove 

[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan marked an inline comment as done.
ebevhan added inline comments.



Comment at: test/SemaOpenCL/address-spaces.cl:89
+  __local int * __global * __private * lll;
+  lll = gg; // expected-warning {{incompatible pointer types assigning to 
'__local int *__global **' from '__global int **'}}
+}

ebevhan wrote:
> Anastasia wrote:
> > ebevhan wrote:
> > > This doesn't seem entirely correct still, but I'm not sure what to do 
> > > about it.
> > Is it because `Sema::IncompatiblePointer` has priority? We might want to 
> > change that. I think it was ok before because qualifier's mismatch was only 
> > a warning but now with the address spaces we are giving an error. I wonder 
> > if adding a separate enum item for address spaces (something like 
> > `Sema::IncompatibleNestedPointerAddressSpace`) would simplify things.
> > Is it because `Sema::IncompatiblePointer` has priority?
> 
> Sort of. The problem is that the AS pointee qualifiers match up until the 
> 'end' of the RHS pointer chain (LHS: `private->global->local`, RHS: 
> `private->global`), so we never get an 'incompatible address space' to begin 
> with. We only get that if 1) the bottommost type is equal after unwrapping 
> pointers (as far as both sides go), or 2) any of the 'shared' AS qualifiers 
> (as far as both sides go) were different.
> 
> The idea is that stopping when either side is no longer a pointer will 
> produce 'incompatible pointers' when you have different pointer depths, but 
> it doesn't consider anything below the 'shallowest' side of the pointer 
> chain, so we miss out on any AS mismatches further down.
> 
> (Not that there's anything to mismatch, really. There is no matching pointer 
> on the other side, so what is really the error?)
> 
> What should the criteria be for when the pointer types 'run out'? I could 
> have it keep digging through the other pointer until it hits a different AS? 
> This would mean that this:
> ```
> int  a;
> int ** b = a;
> ```
> could give a different warning than it does today, though (incompatible 
> nested qualifiers instead of incompatible pointers, which doesn't make 
> sense...) . We would have to skip the `lhptee == rhptee` check if we 'kept 
> going' despite one side not being a pointer type. So I don't know if that's 
> the right approach in general.
> 
> Or should we be searching 'backwards' instead, starting from the innermost 
> pointee? I don't know.
> 
> It really feels like the whole `checkPointerTypesForAssignment` routine and 
> everything surrounding it is a bit messy. It relies on an implicit result 
> from another function (`typesAreCompatible`) and then tries to deduce why 
> that function thought the types weren't compatible. Then another function 
> later on (`DiagnoseAssignmentResult`) tries to deduce why THIS function 
> thought something was wrong.
> 
> > I wonder if adding a separate enum item for address spaces (something like 
> > `Sema::IncompatibleNestedPointerAddressSpace`) would simplify things.
> 
> This would simplify the logic on the error emission side, since we don't need 
> to duplicate the logic for determining what went wrong, but doesn't help with 
> diagnosing the actual problem. Probably a good idea to add it anyway, I just 
> wanted to avoid adding a new enum member since that means updating a lot of 
> code elsewhere.
> We only get that if 1) the bottommost type is equal after unwrapping pointers 
> (as far as both sides go), or 2) any of the 'shared' AS qualifiers (as far as 
> both sides go) were different.

Sorry, should only be 2) here. Was focused on the whole 'incompatible nested 
qualifiers' result.


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

https://reviews.llvm.org/D58236



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan marked 5 inline comments as done.
ebevhan added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6996
+  "|%diff{casting $ to type $|casting between types}0,1}2"
+  " changes address space of nested pointer">;
 def err_typecheck_incompatible_ownership : Error<

Anastasia wrote:
> I am wondering if we could just unify with the diagnostic above?
> 
> We could add another select at the end:
>   " changes address space of %select{nested|}3 pointer"
That is doable, but all of the 'typecheck' errors/warnings are made to be 
regular. If I add another parameter, there needs to be a special case in 
DiagnoseAssignmentResult for that error in particular.



Comment at: lib/Sema/SemaCast.cpp:2294
+
+  // FIXME: C++ might want to emit different errors here.
   if (Self.getLangOpts().OpenCL) {

Anastasia wrote:
> I think my patch is divorcing C++ from here https://reviews.llvm.org/D58346.
> 
> Although, I might need to update it to add the same checks. I can do it once 
> your patch is finalized. :)
Yes, I noticed that you weren't calling checkAddressSpaceCast any longer in one 
of the code paths.

I suspect that your patch might already be doing the same thing... though not 
explicitly. TryAddressSpaceCast will only check compatibility on the top level 
pointee, and then it goes on to check type similarity, and if the types are not 
similar, it bails. Types with different nested pointer address spaces are not 
(should not be?) considered compatible, so we should get the same outcome. We 
won't get the 'nested' error, though.



Comment at: lib/Sema/SemaExpr.cpp:14199
+// qualifiers.
+// XXX: Canonical types?
+const Type *SrcPtr = SrcType->getPointeeType().getTypePtr();

Anastasia wrote:
> May be, since if we are using a typedef that is a pointer type 
> `isPointerType()` might not return true? I would just extend a test case with 
> typedef to a pointer type as one of the nested levels.
It sort of depends on what `checkPointerTypesForAssignment` considers invalid.

I think maybe I should throw this logic away and instead simply add a new enum 
member to AssignmentResult.



Comment at: test/CodeGenOpenCL/numbered-address-space.cl:17
-void test_numbered_as_to_builtin(__attribute__((address_space(42))) int 
*arbitary_numbered_ptr, float src) {
-  volatile float result = __builtin_amdgcn_ds_fmaxf(arbitary_numbered_ptr, 
src, 0, 0, false);
-}

Anastasia wrote:
> Does this not compile any more?
No, these tests were a bit shaky. I'm not even sure what they're supposed to be 
testing. It's trying to pass an arbitrary `AS int *` pointer to a function that 
takes `__local float *`. That AS conversion is illegal (implicitly), but the 
illegal conversion was 'shadowed' by the 'incompatible pointer' warning, so we 
didn't get an error. This is one of the things this patch fixes.

Since it's a codegen test, it should be producing something, but I'm not really 
sure what is interesting to produce here, so I just removed it.



Comment at: test/SemaOpenCL/address-spaces.cl:89
+  __local int * __global * __private * lll;
+  lll = gg; // expected-warning {{incompatible pointer types assigning to 
'__local int *__global **' from '__global int **'}}
+}

Anastasia wrote:
> ebevhan wrote:
> > This doesn't seem entirely correct still, but I'm not sure what to do about 
> > it.
> Is it because `Sema::IncompatiblePointer` has priority? We might want to 
> change that. I think it was ok before because qualifier's mismatch was only a 
> warning but now with the address spaces we are giving an error. I wonder if 
> adding a separate enum item for address spaces (something like 
> `Sema::IncompatibleNestedPointerAddressSpace`) would simplify things.
> Is it because `Sema::IncompatiblePointer` has priority?

Sort of. The problem is that the AS pointee qualifiers match up until the 'end' 
of the RHS pointer chain (LHS: `private->global->local`, RHS: 
`private->global`), so we never get an 'incompatible address space' to begin 
with. We only get that if 1) the bottommost type is equal after unwrapping 
pointers (as far as both sides go), or 2) any of the 'shared' AS qualifiers (as 
far as both sides go) were different.

The idea is that stopping when either side is no longer a pointer will produce 
'incompatible pointers' when you have different pointer depths, but it doesn't 
consider anything below the 'shallowest' side of the pointer chain, so we miss 
out on any AS mismatches further down.

(Not that there's anything to mismatch, really. There is no matching pointer on 
the other side, so what is really the error?)

What should the criteria be for when the pointer types 'run out'? I could have 
it keep digging through the other pointer until it hits a different AS? This 
would mean that this:
```
int  a;
int ** b = a;
```
could give a 

[PATCH] D58341: [clangd] Index UsingDecls

2019-02-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D58341#1401212 , @ilya-biryukov 
wrote:

> For context: @hokein mentioned problems in the clangd's code completion if we 
> would index these symbols.
>  This patch in itself does not hurt much, users of the indexing API can 
> decide how to deal with `UsingDecl` on their own, clangd is just one of the 
> clients.
>
> >   I wonder how does merge work with Sema results? See the case below, IIUC 
> > our indexer has one symbol for this using decl, but the code completion 
> > result from Sema contains two symbols. The symbol ids of these 3 symbols 
> > are different, so we will end up with 3 completion results.
>
> That's true, but we're not sure how much this would hurt in practice. 
> Currently we don't show any results from dynamic index for `std::strcmp`, 
> which is arguably worse than showing an extra completion item for the using.


std::strcmp is a fair case here. Sema seems not returning using-decls as part 
of code completion results, it this an intended behavior? Is it possible for us 
to extend Sema to support it?

If we decide to provide using-decl results from index, I think we should make 
sure the code completion information (e.g. signature) is correct.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341



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


[PATCH] D58278: Prepare ground for re-lexing modular headers.

2019-02-18 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added a comment.

+cc myself


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58278



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


[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/index/CanonicalIncludes.cpp:123
 
   static const std::vector>
   SystemHeaderMap = {

hokein wrote:
> ioeric wrote:
> > Can we remove the suffix header mapping now? Is it for the `std::chrono::` 
> > symbols? What are the reasons not to include them in this patch? 
> Ideally, we could remove it once we get a perfect symbol mapping but I'd 
> prefer to keep it (it serves as a fallback when we don't find symbols in the 
> symbol mapping), so that we could add new symbol mapping increasingly without 
> changing the current behavior.
> 
> Removing it should be done carefully without introducing regression, and is 
> outside the scope of this patch.
We do need fallback heuristics. We should conisder cases:
 - for known `std::` symbols mapped to one system header, we don't need a 
fallback
 - for known `std::` mapped to multiple system headers (`std::move`), we need 
some fallback. There are probably few enough of these that it doesn't justify 
listing *all* system header paths.
 - for known `std::` symbols with a primary template in one file and 
specializations/overloads in another (swap?) always inserting the primary seems 
fine 
 - For "random" unknown symbols from system header `foo/bits/_bar.h`, we can 
not insert, correct to ``, or use the full path name. I don't have a 
strong preference here, maybe we should do what's easiest.
 - for c standard library (`::printf` --> `` etc) we probably want 
mappings just like in this patch, I think cppreference has them.
 - other "standardish" headers (POSIX etc) - hmm, unclear.

Thinking about all these cases, I'm thinking the nicest solution would be 
having the symbol -> header mapping, having a small (symbol,header) -> header 
mapping **only** for ambiguous cases, and not inserting "system" headers that 
aren't in the main mapping at all. Then we can improve coverage of posix, 
windows etc headers over time.
Question is, how can we recognize "system" headers?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58345



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


[PATCH] D57978: [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-02-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia resigned from this revision.
Anastasia added a comment.

This seems like an interesting change. So far in OpenCL we have actively used 
only unroll. I will let others to assess in more details.




Comment at: lib/CodeGen/CGLoopInfo.cpp:107
+  FollowupLoopProperties.push_back(
+  MDNode::get(Ctx, MDString::get(Ctx, "llvm.loop.unroll.disable")));
+

Will this end up emitted in the final module?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57978



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


[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-02-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Sema/SemaCast.cpp:2224
+  } else if (IsLValueCast) {
 Kind = CK_LValueBitCast;
   } else if (DestType->isObjCObjectPointerType()) {

This might not be applicable to this patch, but just something I noticed.

So `reinterpret_cast` only operates on pointers when dealing with address 
spaces. What about something like
```
T a;
T& a_ref = reinterpret_cast(a);
```
`reinterpret_cast` on an lvalue like this is equivalent to 
`*reinterpret_cast()`. So for AS code:
```
__private T x;
__generic T& ref = reinterpret_cast<__generic T&>(x);
```
This should work, since `*reinterpret_cast<__generic T*>()` is valid, correct?

What if we have the reference cast case with a different address space like 
this? Doesn't the `IsLValueCast` check need to be first?




Comment at: lib/Sema/SemaCast.cpp:2309
+auto DestPointeeTypeWithoutAS = Self.Context.removeAddrSpaceQualType(
+DestPointeeType.getCanonicalType());
+return Self.Context.hasSameType(SrcPointeeTypeWithoutAS,

Maybe I'm mistaken, but won't getting the canonical type here drop qualifiers 
(like cv) in nested pointers? If so, an addrspace_cast might strip qualifiers 
by mistake.


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

https://reviews.llvm.org/D58346



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


[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-02-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

In D58345#1401040 , @ioeric wrote:

> Looks great! Thanks for doing this.
>
> Could you also check in the tool that is used to generate the mapping? We 
> need a way to update the mapping when cppreference is updated.


The tool is not ready yet, I'm still polishing it, but the results are good, I 
think this patch should not be blocked by the tool.




Comment at: clangd/index/CanonicalIncludes.cpp:123
 
   static const std::vector>
   SystemHeaderMap = {

ioeric wrote:
> Can we remove the suffix header mapping now? Is it for the `std::chrono::` 
> symbols? What are the reasons not to include them in this patch? 
Ideally, we could remove it once we get a perfect symbol mapping but I'd prefer 
to keep it (it serves as a fallback when we don't find symbols in the symbol 
mapping), so that we could add new symbol mapping increasingly without changing 
the current behavior.

Removing it should be done carefully without introducing regression, and is 
outside the scope of this patch.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58345



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


[PATCH] D58341: [clangd] Index UsingDecls

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

For context: @hokein mentioned problems in the clangd's code completion if we 
would index these symbols.
This patch in itself does not hurt much, users of the indexing API can decide 
how to deal with `UsingDecl` on their own, clangd is just one of the clients.

>   I wonder how does merge work with Sema results? See the case below, IIUC 
> our indexer has one symbol for this using decl, but the code completion 
> result from Sema contains two symbols. The symbol ids of these 3 symbols are 
> different, so we will end up with 3 completion results.

That's true, but we're not sure how much this would hurt in practice. Currently 
we don't show any results from dynamic index for `std::strcmp`, which is 
arguably worse than showing an extra completion item for the using.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341



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


[PATCH] D58277: [OpenCL] Change type of block pointer for OpenCL

2019-02-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks! This totally makes sense! I think we inherited that from ObjC but 
never adapted fully. This change has low risk of breaking backwards 
compatibility but might need some minor update in tools.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58277



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


[PATCH] D58275: [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extension

2019-02-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

I think we need to  update the comment in the SymbolLocation::Column.




Comment at: clangd/tool/ClangdMain.cpp:9
 
+#include 
"/usr/local/google/home/sammccall/src/llvm/tools/clang/tools/extra/clangd/Protocol.h"
 #include "Features.inc"

the #include introduced by global code completion seems not get shortened.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58275



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6996
+  "|%diff{casting $ to type $|casting between types}0,1}2"
+  " changes address space of nested pointer">;
 def err_typecheck_incompatible_ownership : Error<

I am wondering if we could just unify with the diagnostic above?

We could add another select at the end:
  " changes address space of %select{nested|}3 pointer"



Comment at: lib/Sema/SemaCast.cpp:2294
+
+  // FIXME: C++ might want to emit different errors here.
   if (Self.getLangOpts().OpenCL) {

I think my patch is divorcing C++ from here https://reviews.llvm.org/D58346.

Although, I might need to update it to add the same checks. I can do it once 
your patch is finalized. :)



Comment at: lib/Sema/SemaCast.cpp:2295
+  // FIXME: C++ might want to emit different errors here.
   if (Self.getLangOpts().OpenCL) {
+const Type *DestPtr, *SrcPtr;

ebevhan wrote:
> I'd also like to petition to remove the guard on OpenCL here. Maybe an RFC 
> for formalizing the support for address space conversion semantics is in 
> order?
Yes, I'd support that! It would be good to generalize the rules as much as we 
can rather than adding extra checks for languages (the semantic is very 
similar).

As a matter of fact I tried to do the same in https://reviews.llvm.org/D58346 
in `TryAddressSpaceCast` and some C++ tests fail. So I had to add OpenCL check 
for now. :( Perhaps, they could just be changed but needs agreement with the 
community first.



Comment at: lib/Sema/SemaExpr.cpp:14199
+// qualifiers.
+// XXX: Canonical types?
+const Type *SrcPtr = SrcType->getPointeeType().getTypePtr();

May be, since if we are using a typedef that is a pointer type 
`isPointerType()` might not return true? I would just extend a test case with 
typedef to a pointer type as one of the nested levels.



Comment at: test/CodeGenOpenCL/numbered-address-space.cl:17
-void test_numbered_as_to_builtin(__attribute__((address_space(42))) int 
*arbitary_numbered_ptr, float src) {
-  volatile float result = __builtin_amdgcn_ds_fmaxf(arbitary_numbered_ptr, 
src, 0, 0, false);
-}

Does this not compile any more?



Comment at: test/SemaOpenCL/address-spaces.cl:89
+  __local int * __global * __private * lll;
+  lll = gg; // expected-warning {{incompatible pointer types assigning to 
'__local int *__global **' from '__global int **'}}
+}

ebevhan wrote:
> This doesn't seem entirely correct still, but I'm not sure what to do about 
> it.
Is it because `Sema::IncompatiblePointer` has priority? We might want to change 
that. I think it was ok before because qualifier's mismatch was only a warning 
but now with the address spaces we are giving an error. I wonder if adding a 
separate enum item for address spaces (something like 
`Sema::IncompatibleNestedPointerAddressSpace`) would simplify things.


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

https://reviews.llvm.org/D58236



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


[PATCH] D58341: [clangd] Index UsingDecls

2019-02-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

I wonder how does merge work with Sema results? See the case below, IIUC our 
indexer has one symbol for this using decl,  but the code completion result 
from Sema contains two symbols. The symbol ids of these 3 symbols are 
different, so we will end up with 3 completion results.

  namespace abc {
  int foo(int);
  int foo(double);
  };
  
  namespace std {
  using abc::foo;
  }
  
  void f() {
std::^
  }


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341



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


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

2019-02-18 Thread vit9696 via Phabricator via cfe-commits
vit9696 added a comment.

@jhibbits, @kthomsen, it appears that current patchset has issues when handling 
&& on me. I have it applied over llvm 8.0.0 rc2, and the following code returns 
0 to me with -O2 and below:

  #include 
  
  #define FEQUAL(x,y) (((x) - (y)) < 0.01) // could put fabs if needed
  
  typedef struct {
float x;
float y;
  } float2;
  
  static bool __attribute__((noinline)) equals(float2* f40, float2* f41) {
  return FEQUAL(f40->x, f41->x) && FEQUAL(f40->y, f41->y);
  }
  
  int main() {
  float2 a = {0.721569, 0.1234};
  float2 b = {0.721569, 0.1234};
  
  printf("%d\n", equals(, ));
  }

Does it reproduce for you?

GCC output (working):

  # _Bool __fastcall equals(float2 *f40, float2 *f41)
  .globl equals
  equals:
lwz   r9, 0(r3)
lis   r10, -0x7FFF
lwz   r8, 0(r4)
addi  r10, r10, -0x7198 # 0x80008E68
evldd r10, 0(r10)
efssubr9, r9, r8
efdcfsr9, r9
efdcmplt  cr7, r9, r10
ble   cr7, loc_8048
lwz   r3, 4(r3)
lwz   r9, 4(r4)
efssubr3, r3, r9
efdcfsr3, r3
efdcmplt  cr7, r3, r10
mfcr  r3
extrwir3, r3, 1,29
clrlwir3, r3, 24
blr
  loc_8048:
lir3, 0
blr

LLVM output (not working):

  # _Bool __fastcall equals(float2 *f40, float2 *f41)
  .globl equals
  equals:
lwz   r6, 0(r3)
lwz   r7, 0(r4)
lir5, -0x6160
lis   r8, -0x7FFF
evlddxr5, r8, r5
efssubr6, r6, r7
efdcfsr6, r6
efdcmplt  cr0, r6, r5
bge   loc_82B0
lwz   r3, 4(r3)
lwz   r4, 4(r4)
efssubr3, r3, r4
efdcfsr3, r3
efdcmplt  cr0, r3, r5
b loc_82B4
  loc_82B0:
crclr gt
  loc_82B4:
lir3, 0
lir4, 1
bgt   loc_82C4
blr
  loc_82C4:
addi  r3, r4, 0
blr


Repository:
  rC Clang

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

https://reviews.llvm.org/D49754



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


[PATCH] D53754: [Analyzer] Skip symbolic regions based on conjured symbols in comparison of the containers of iterators

2019-02-18 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.
Herald added a subscriber: jdoerfert.

In D53754#1315247 , @NoQ wrote:

> What makes you think that conjured symbols are special?
>
> Doesn't the same problem appear in the following example?:
>
>   void foo(std::vector , std::vector ) {
> v2.erase(v1.cbegin());
>   }
>
>
> In this example if `foo()` is analyzed as a top level function, the 
> respective symbols would be of `SymbolRegionValue` kind. It is also easy to 
> come up with a test case that involves `SymbolDerived`.


I think that here the main difference is that if we analyze this function as 
top level, then we find a true positive: the regions for `v1` and `v2` //may 
be// the same but generally they are difference (hence the different 
parameters). However, we do not know anything about the sameness of the regions 
of different `SymbolDerived`s, thus those findings may be false or true 
positives as well.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53754



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


[PATCH] D58190: [clangd] Add tests for template specializations

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354272: [clangd] Add tests for template specializations 
(authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58190

Files:
  clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
@@ -350,6 +350,58 @@
  FF();
  void f() { T^est a; }
   )cpp",
+
+  R"cpp(// explicit template specialization
+template 
+struct Foo { void bar() {} };
+
+template <>
+struct [[Foo]] { void bar() {} };
+
+void foo() {
+  Foo abc;
+  Fo^o b;
+}
+  )cpp",
+
+  R"cpp(// implicit template specialization
+template 
+struct [[Foo]] { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Fo^o abc;
+  Foo b;
+}
+  )cpp",
+
+  R"cpp(// partial template specialization
+template 
+struct Foo { void bar() {} };
+template 
+struct [[Foo]] { void bar() {} };
+^Foo x;
+  )cpp",
+
+  R"cpp(// function template specializations
+template 
+void foo(T) {}
+template <>
+void [[foo]](int) {}
+void bar() {
+  fo^o(10);
+}
+  )cpp",
+
+  R"cpp(// variable template decls
+template 
+T var = T();
+
+template <>
+double [[var]] = 10;
+
+double y = va^r;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
@@ -350,6 +350,58 @@
  FF();
  void f() { T^est a; }
   )cpp",
+
+  R"cpp(// explicit template specialization
+template 
+struct Foo { void bar() {} };
+
+template <>
+struct [[Foo]] { void bar() {} };
+
+void foo() {
+  Foo abc;
+  Fo^o b;
+}
+  )cpp",
+
+  R"cpp(// implicit template specialization
+template 
+struct [[Foo]] { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Fo^o abc;
+  Foo b;
+}
+  )cpp",
+
+  R"cpp(// partial template specialization
+template 
+struct Foo { void bar() {} };
+template 
+struct [[Foo]] { void bar() {} };
+^Foo x;
+  )cpp",
+
+  R"cpp(// function template specializations
+template 
+void foo(T) {}
+template <>
+void [[foo]](int) {}
+void bar() {
+  fo^o(10);
+}
+  )cpp",
+
+  R"cpp(// variable template decls
+template 
+T var = T();
+
+template <>
+double [[var]] = 10;
+
+double y = va^r;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r354272 - [clangd] Add tests for template specializations

2019-02-18 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Feb 18 06:23:19 2019
New Revision: 354272

URL: http://llvm.org/viewvc/llvm-project?rev=354272=rev
Log:
[clangd] Add tests for template specializations

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

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=354272=354271=354272=diff
==
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Mon Feb 18 06:23:19 
2019
@@ -350,6 +350,58 @@ TEST(LocateSymbol, All) {
  FF();
  void f() { T^est a; }
   )cpp",
+
+  R"cpp(// explicit template specialization
+template 
+struct Foo { void bar() {} };
+
+template <>
+struct [[Foo]] { void bar() {} };
+
+void foo() {
+  Foo abc;
+  Fo^o b;
+}
+  )cpp",
+
+  R"cpp(// implicit template specialization
+template 
+struct [[Foo]] { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Fo^o abc;
+  Foo b;
+}
+  )cpp",
+
+  R"cpp(// partial template specialization
+template 
+struct Foo { void bar() {} };
+template 
+struct [[Foo]] { void bar() {} };
+^Foo x;
+  )cpp",
+
+  R"cpp(// function template specializations
+template 
+void foo(T) {}
+template <>
+void [[foo]](int) {}
+void bar() {
+  fo^o(10);
+}
+  )cpp",
+
+  R"cpp(// variable template decls
+template 
+T var = T();
+
+template <>
+double [[var]] = 10;
+
+double y = va^r;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


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


[PATCH] D58190: [clangd] Add tests for template specializations

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 187237.
kadircet marked an inline comment as done.
kadircet added a comment.

- Fix typo and make comments start with 2 slashes


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58190

Files:
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -350,6 +350,58 @@
  FF();
  void f() { T^est a; }
   )cpp",
+
+  R"cpp(// explicit template specialization
+template 
+struct Foo { void bar() {} };
+
+template <>
+struct [[Foo]] { void bar() {} };
+
+void foo() {
+  Foo abc;
+  Fo^o b;
+}
+  )cpp",
+
+  R"cpp(// implicit template specialization
+template 
+struct [[Foo]] { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Fo^o abc;
+  Foo b;
+}
+  )cpp",
+
+  R"cpp(// partial template specialization
+template 
+struct Foo { void bar() {} };
+template 
+struct [[Foo]] { void bar() {} };
+^Foo x;
+  )cpp",
+
+  R"cpp(// function template specializations
+template 
+void foo(T) {}
+template <>
+void [[foo]](int) {}
+void bar() {
+  fo^o(10);
+}
+  )cpp",
+
+  R"cpp(// variable template decls
+template 
+T var = T();
+
+template <>
+double [[var]] = 10;
+
+double y = va^r;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -350,6 +350,58 @@
  FF();
  void f() { T^est a; }
   )cpp",
+
+  R"cpp(// explicit template specialization
+template 
+struct Foo { void bar() {} };
+
+template <>
+struct [[Foo]] { void bar() {} };
+
+void foo() {
+  Foo abc;
+  Fo^o b;
+}
+  )cpp",
+
+  R"cpp(// implicit template specialization
+template 
+struct [[Foo]] { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Fo^o abc;
+  Foo b;
+}
+  )cpp",
+
+  R"cpp(// partial template specialization
+template 
+struct Foo { void bar() {} };
+template 
+struct [[Foo]] { void bar() {} };
+^Foo x;
+  )cpp",
+
+  R"cpp(// function template specializations
+template 
+void foo(T) {}
+template <>
+void [[foo]](int) {}
+void bar() {
+  fo^o(10);
+}
+  )cpp",
+
+  R"cpp(// variable template decls
+template 
+T var = T();
+
+template <>
+double [[var]] = 10;
+
+double y = va^r;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55007: [Analyzer] Constraint Manager - Calculate Effective Range for Differences

2019-02-18 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D55007#1322335 , @NoQ wrote:

> I just generally wish for a function that would return the most specific 
> known range for the given arbitrary symbol. This is something we can put, for 
> example, into visitor path notes.
>
> Eg., imagine "Assuming x is greater than 5" -> "Tainted array index 
> constrained to [5, 6] U {8} U [10, 12]" -> "Potential buffer overflow: 
> accessing array of 11 elements with a tainted index".
>
> `getRange()` is a great name for such function. For now i think it kinda 
> works for atomic symbols with a few extra goodies on top of that. If we 
> generally move towards that goal, i think it would be great.


I think my patch is exactly about this for symbol differences: it returns the 
most specific known range for the difference by intersecting the range stored 
for the differences with the range stored for the negated difference.

It may be better not to store the difference for the negated range at all, but 
it is a bigger change in the code. (See my options 1 and 2.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D55007



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


[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 187236.
kadircet added a comment.

- Address comments


Repository:
  rC Clang

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

https://reviews.llvm.org/D58340

Files:
  lib/Index/IndexDecl.cpp
  lib/Index/USRGeneration.cpp
  test/Index/usrs.cpp
  unittests/Index/IndexTests.cpp


Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -134,6 +134,19 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/usrs.cpp
===
--- test/Index/usrs.cpp
+++ test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -111,7 +111,12 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@UD@";
+
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
+(void)EmittedDeclName;
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -580,9 +580,10 @@
   }
 
   bool VisitUsingDecl(const UsingDecl *D) {
+IndexCtx.handleDecl(D);
+
 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
 const NamedDecl *Parent = dyn_cast(DC);
-
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
 for (const auto *I : D->shadows())


Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -134,6 +134,19 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/usrs.cpp
===
--- test/Index/usrs.cpp
+++ test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -111,7 +111,12 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@UD@";
+
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
+(void)EmittedDeclName;
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -580,9 +580,10 @@
   }
 
   bool VisitUsingDecl(const UsingDecl *D) {
+IndexCtx.handleDecl(D);
+
 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
 const NamedDecl *Parent = dyn_cast(DC);
-
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
 for (const auto *I : D->shadows())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58341: [clangd] Index UsingDecls

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Could we also add a test for code completion to make sure we return the new 
decls there?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341



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


[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

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

LGTM, but we need to make sure the variable is used in configs without 
assertions, otherwise we'll break buildbots.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58340



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


[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Index/IndexDecl.cpp:586
 
+IndexCtx.handleDecl(D);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,

NIT: maybe put it at the very first line of the function, before the `DC` and 
`Parent` decls?
To keep the variable declarations closer to their usages.



Comment at: lib/Index/USRGeneration.cpp:118
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
   }

add `(void)EmittedDeclName` to avoid unused warning with assertions disabled.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58340



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


[PATCH] D58190: [clangd] Add tests for template specializations

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

LGTM with a typo-nit :-)




Comment at: unittests/clangd/XRefsTests.cpp:378
+
+  R"cpp(// partial tmeplate specialization
+template 

s/tmeplate/template


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58190



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan marked 6 inline comments as done.
ebevhan added inline comments.



Comment at: lib/Sema/SemaCast.cpp:2295
+  // FIXME: C++ might want to emit different errors here.
   if (Self.getLangOpts().OpenCL) {
+const Type *DestPtr, *SrcPtr;

I'd also like to petition to remove the guard on OpenCL here. Maybe an RFC for 
formalizing the support for address space conversion semantics is in order?



Comment at: lib/Sema/SemaExpr.cpp:14206
+// XXX: Should this be a different variation of the error, like
+// 'changes address space in nested pointer qualifiers'?
+DiagKind = diag::err_typecheck_incompatible_address_space;

rjmccall wrote:
> Yeah, I think that would be more straightforward.
I ended up not making it that different from the original one. Perhaps it's not 
different enough?


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

https://reviews.llvm.org/D58236



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan updated this revision to Diff 187230.

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

https://reviews.llvm.org/D58236

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/numbered-address-space.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/event_t_overload.cl
  test/SemaOpenCL/numbered-address-space.cl
  test/SemaOpenCL/queue_t_overload.cl

Index: test/SemaOpenCL/queue_t_overload.cl
===
--- test/SemaOpenCL/queue_t_overload.cl
+++ test/SemaOpenCL/queue_t_overload.cl
@@ -7,6 +7,6 @@
   queue_t q;
   foo(q, src1);
   foo(0, src2);
-  foo(q, src3); // expected-error {{call to 'foo' is ambiguous}}
+  foo(q, src3); // expected-error {{no matching function for call to 'foo'}}
   foo(1, src3); // expected-error {{no matching function for call to 'foo'}}
 }
Index: test/SemaOpenCL/numbered-address-space.cl
===
--- test/SemaOpenCL/numbered-address-space.cl
+++ test/SemaOpenCL/numbered-address-space.cl
@@ -26,6 +26,6 @@
 
 void test_generic_as_to_builtin_parameterimplicit_cast_numeric(__attribute__((address_space(3))) int *as3_ptr, float src) {
   generic int* generic_ptr = as3_ptr;
-  volatile float result = __builtin_amdgcn_ds_fmaxf(generic_ptr, src, 0, 0, false); // expected-warning {{incompatible pointer types passing '__generic int *' to parameter of type '__local float *'}}
+  volatile float result = __builtin_amdgcn_ds_fmaxf(generic_ptr, src, 0, 0, false); // expected-error {{passing '__generic int *' to parameter of type '__local float *' changes address space of pointer}}
 }
 
Index: test/SemaOpenCL/event_t_overload.cl
===
--- test/SemaOpenCL/event_t_overload.cl
+++ test/SemaOpenCL/event_t_overload.cl
@@ -7,5 +7,5 @@
   event_t evt;
   foo(evt, src1);
   foo(0, src2);
-  foo(evt, src3); // expected-error {{call to 'foo' is ambiguous}}
+  foo(evt, src3); // expected-error {{no matching function for call to 'foo'}}
 }
Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -52,6 +52,76 @@
   p = (__private int *)p2;
 }
 
+#if !__OPENCL_CPP_VERSION__
+void nested(__global int *g, __global int * __private *gg, __local int *l, __local int * __private *ll, __global float * __private *gg_f) {
+  g = gg;// expected-error {{assigning '__global int **' to '__global int *' changes address space of pointer}}
+  g = l; // expected-error {{assigning '__local int *' to '__global int *' changes address space of pointer}}
+  g = ll;// expected-error {{assigning '__local int **' to '__global int *' changes address space of pointer}}
+  g = gg_f;  // expected-error {{assigning '__global float **' to '__global int *' changes address space of pointer}}
+  g = (__global int *)gg_f; // expected-error {{casting '__global float **' to type '__global int *' changes address space of pointer}}
+
+  gg = g;// expected-error {{assigning '__global int *' to '__global int **' changes address space of pointer}}
+  gg = l;// expected-error {{assigning '__local int *' to '__global int **' changes address space of pointer}}
+  gg = ll;   // expected-error {{assigning '__local int **' to '__global int **' changes address space of nested pointer}}
+  gg = gg_f; // expected-warning {{incompatible pointer types assigning to '__global int **' from '__global float **'}}
+  gg = (__global int * __private *)gg_f;
+
+  l = g; // expected-error {{assigning '__global int *' to '__local int *' changes address space of pointer}}
+  l = gg;// expected-error {{assigning '__global int **' to '__local int *' changes address space of pointer}}
+  l = ll;// expected-error {{assigning '__local int **' to '__local int *' changes address space of pointer}}
+  l = gg_f;  // expected-error {{assigning '__global float **' to '__local int *' changes address space of pointer}}
+  l = (__local int *)gg_f; // expected-error {{casting '__global float **' to type '__local int *' changes address space of pointer}}
+
+  ll = g;// expected-error {{assigning '__global int *' to '__local int **' changes address space of pointer}}
+  ll = gg;   // expected-error {{assigning '__global int **' to '__local int **' changes address space of nested pointer}}
+  ll = l;// expected-error {{assigning '__local int *' to '__local int **' changes address space of pointer}}
+  ll = gg_f; // expected-error {{assigning '__global float **' to '__local int **' changes address space of nested pointer}}
+  ll = (__local int * __private *)gg_f; // expected-error {{casting '__global float **' to type '__local int **' changes address space of nested pointer}}
+
+  gg_f = g;  // expected-error {{assigning '__global int *' to '__global float 

[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-02-18 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, ebevhan.
Herald added a subscriber: jdoerfert.

This patch adds a new diagnostic for mismatching address spaces to be used for 
C++ casts (TODO: only enabled in C style cast for now, the rest will follow!).

This change extends C-style cast rules to account for address spaces. It also 
adds a separate function for address space cast checking that can be used to 
map from a separate address space cast operator `addrspace_cast` (to be added 
as a follow up patch).

Note, that after this change clang will no longer allows arbitrary address 
space conversions in `reinterpret_casts` because they can lead to accidental 
errors. The implicit safe conversions would still be allowed.

See RFC for more details: 
http://lists.llvm.org/pipermail/cfe-dev/2018-December/060546.html


https://reviews.llvm.org/D58346

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/SemaCXX/address-space-conversion.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl

Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -26,24 +26,96 @@
 }
 
 void explicit_cast(__global int *g, __local int *l, __constant int *c, __private int *p, const __constant int *cc) {
-  g = (__global int *)l;  // expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)c;  // expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)cc; // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)p;  // expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
-
-  l = (__local int *)g;  // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)c;  // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)cc; // expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)p;  // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
-
-  c = (__constant int *)g; // expected-error {{casting '__global int *' to type '__constant int *' changes address space of pointer}}
-  c = (__constant int *)l; // expected-error {{casting '__local int *' to type '__constant int *' changes address space of pointer}}
-  c = (__constant int *)p; // expected-error {{casting 'int *' to type '__constant int *' changes address space of pointer}}
-
-  p = (__private int *)g;  // expected-error {{casting '__global int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)l;  // expected-error {{casting '__local int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)c;  // expected-error {{casting '__constant int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)cc; // expected-error {{casting 'const __constant int *' to type 'int *' changes address space of pointer}}
+  g = (__global int *)l;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__local int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__local int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)c;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__constant int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)cc;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'const __constant int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)p;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)g;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__global int *' to type '__local int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__global int *' to '__local int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)c;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__constant int 

[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-18 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354268: [clangd] Cache include fixes for diagnostics caused 
by the same unresolved name… (authored by ioeric, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58239

Files:
  clang-tools-extra/trunk/clangd/IncludeFixer.cpp
  clang-tools-extra/trunk/clangd/IncludeFixer.h
  clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
@@ -449,6 +449,44 @@
   UnorderedElementsAre(Diag(Test.range(), "no member named 'xy' in 'X'")));
 }
 
+TEST(IncludeFixerTest, UseCachedIndexResults) {
+  // As index results for the identical request are cached, more than 5 fixes
+  // are generated.
+  Annotations Test(R"cpp(
+$insert[[]]void foo() {
+  $x1[[X]] x;
+  $x2[[X]] x;
+  $x3[[X]] x;
+  $x4[[X]] x;
+  $x5[[X]] x;
+  $x6[[X]] x;
+  $x7[[X]] x;
+}
+
+class X;
+void bar(X *x) {
+  x$a1[[->]]f();
+  x$a2[[->]]f();
+  x$a3[[->]]f();
+  x$a4[[->]]f();
+  x$a5[[->]]f();
+  x$a6[[->]]f();
+  x$a7[[->]]f();
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index =
+  buildIndexWithSymbol(SymbolWithHeader{"X", "unittest:///a.h", "\"a.h\""});
+  TU.ExternalIndex = Index.get();
+
+  auto Parsed = TU.build();
+  for (const auto  : Parsed.getDiagnostics()) {
+EXPECT_EQ(D.Fixes.size(), 1u);
+EXPECT_EQ(D.Fixes[0].Message,
+  std::string("Add include \"a.h\" for symbol X"));
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/IncludeFixer.h
===
--- clang-tools-extra/trunk/clangd/IncludeFixer.h
+++ clang-tools-extra/trunk/clangd/IncludeFixer.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 
@@ -51,7 +52,7 @@
   std::vector fixIncompleteType(const Type ) const;
 
   /// Generates header insertion fixes for all symbols. Fixes are deduplicated.
-  std::vector fixesForSymbols(llvm::ArrayRef Syms) const;
+  std::vector fixesForSymbols(const SymbolSlab ) const;
 
   struct UnresolvedName {
 std::string Name;   // E.g. "X" in foo::X.
@@ -79,6 +80,17 @@
   // These collect the last unresolved name so that we can associate it with the
   // diagnostic.
   llvm::Optional LastUnresolvedName;
+
+  // There can be multiple diagnostics that are caused by the same unresolved
+  // name or incomplete type in one parse, especially when code is
+  // copy-and-pasted without #includes. We cache the index results based on
+  // index requests.
+  mutable llvm::StringMap FuzzyFindCache;
+  mutable llvm::DenseMap LookupCache;
+  // Returns None if the number of index requests has reached the limit.
+  llvm::Optional
+  fuzzyFindCached(const FuzzyFindRequest ) const;
+  llvm::Optional lookupCached(const SymbolID ) const;
 };
 
 } // namespace clangd
Index: clang-tools-extra/trunk/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/trunk/clangd/IncludeFixer.cpp
+++ clang-tools-extra/trunk/clangd/IncludeFixer.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -57,8 +58,6 @@
 
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic ) const {
-  if (IndexRequestCount >= IndexRequestLimit)
-return {}; // Avoid querying index too many times in a single parse.
   switch (Info.getID()) {
   case diag::err_incomplete_type:
   case diag::err_incomplete_member_access:
@@ -118,26 +117,21 @@
   auto ID = getSymbolID(TD);
   if (!ID)
 return {};
-  ++IndexRequestCount;
-  // FIXME: consider batching the requests for all diagnostics.
-  // FIXME: consider caching the lookup results.
-  LookupRequest Req;
-  Req.IDs.insert(*ID);
-  llvm::Optional Matched;
-  Index.lookup(Req, [&](const Symbol ) {
-if (Matched)
-  return;
-Matched = Sym;
-  });
-
-  if (!Matched || Matched->IncludeHeaders.empty() || !Matched->Definition ||
-  Matched->CanonicalDeclaration.FileURI != Matched->Definition.FileURI)
+  llvm::Optional Symbols = lookupCached(*ID);
+  if (!Symbols)
 return {};
-  return fixesForSymbols({*Matched});
+  const SymbolSlab  = **Symbols;
+  std::vector Fixes;
+  if (!Syms.empty()) {

[clang-tools-extra] r354268 - [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-18 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Feb 18 05:12:10 2019
New Revision: 354268

URL: http://llvm.org/viewvc/llvm-project?rev=354268=rev
Log:
[clangd] Cache include fixes for diagnostics caused by the same unresolved name 
or incomplete type.

Summary:
Multiple diagnostics can be caused by the same unresolved name or incomplete 
type,
especially if the code is copy-pasted without #includes. The cache can avoid 
making
repetitive index requests, and thus reduce latency and allow more diagnostics 
to be
fixed (we limit the number of index requests for each parse).

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/IncludeFixer.cpp
clang-tools-extra/trunk/clangd/IncludeFixer.h
clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp

Modified: clang-tools-extra/trunk/clangd/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/IncludeFixer.cpp?rev=354268=354267=354268=diff
==
--- clang-tools-extra/trunk/clangd/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/clangd/IncludeFixer.cpp Mon Feb 18 05:12:10 2019
@@ -27,6 +27,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -57,8 +58,6 @@ private:
 
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic ) const {
-  if (IndexRequestCount >= IndexRequestLimit)
-return {}; // Avoid querying index too many times in a single parse.
   switch (Info.getID()) {
   case diag::err_incomplete_type:
   case diag::err_incomplete_member_access:
@@ -118,26 +117,21 @@ std::vector IncludeFixer::fixIncomp
   auto ID = getSymbolID(TD);
   if (!ID)
 return {};
-  ++IndexRequestCount;
-  // FIXME: consider batching the requests for all diagnostics.
-  // FIXME: consider caching the lookup results.
-  LookupRequest Req;
-  Req.IDs.insert(*ID);
-  llvm::Optional Matched;
-  Index.lookup(Req, [&](const Symbol ) {
-if (Matched)
-  return;
-Matched = Sym;
-  });
-
-  if (!Matched || Matched->IncludeHeaders.empty() || !Matched->Definition ||
-  Matched->CanonicalDeclaration.FileURI != Matched->Definition.FileURI)
+  llvm::Optional Symbols = lookupCached(*ID);
+  if (!Symbols)
 return {};
-  return fixesForSymbols({*Matched});
+  const SymbolSlab  = **Symbols;
+  std::vector Fixes;
+  if (!Syms.empty()) {
+auto  = *Syms.begin();
+if (!Matched.IncludeHeaders.empty() && Matched.Definition &&
+Matched.CanonicalDeclaration.FileURI == Matched.Definition.FileURI)
+  Fixes = fixesForSymbols(Syms);
+  }
+  return Fixes;
 }
 
-std::vector
-IncludeFixer::fixesForSymbols(llvm::ArrayRef Syms) const {
+std::vector IncludeFixer::fixesForSymbols(const SymbolSlab ) const {
   auto Inserted = [&](const Symbol , llvm::StringRef Header)
   -> llvm::Expected> {
 auto ResolvedDeclaring =
@@ -289,6 +283,24 @@ std::vector IncludeFixer::fixUnreso
   Req.RestrictForCodeCompletion = true;
   Req.Limit = 100;
 
+  if (llvm::Optional Syms = fuzzyFindCached(Req))
+return fixesForSymbols(**Syms);
+
+  return {};
+}
+
+
+llvm::Optional
+IncludeFixer::fuzzyFindCached(const FuzzyFindRequest ) const {
+  auto ReqStr = llvm::formatv("{0}", toJSON(Req)).str();
+  auto I = FuzzyFindCache.find(ReqStr);
+  if (I != FuzzyFindCache.end())
+return >second;
+
+  if (IndexRequestCount >= IndexRequestLimit)
+return llvm::None;
+  IndexRequestCount++;
+
   SymbolSlab::Builder Matches;
   Index.fuzzyFind(Req, [&](const Symbol ) {
 if (Sym.Name != Req.Query)
@@ -297,7 +309,37 @@ std::vector IncludeFixer::fixUnreso
   Matches.insert(Sym);
   });
   auto Syms = std::move(Matches).build();
-  return fixesForSymbols(std::vector(Syms.begin(), Syms.end()));
+  auto E = FuzzyFindCache.try_emplace(ReqStr, std::move(Syms));
+  return >second;
+}
+
+llvm::Optional
+IncludeFixer::lookupCached(const SymbolID ) const {
+  LookupRequest Req;
+  Req.IDs.insert(ID);
+
+  auto I = LookupCache.find(ID);
+  if (I != LookupCache.end())
+return >second;
+
+  if (IndexRequestCount >= IndexRequestLimit)
+return llvm::None;
+  IndexRequestCount++;
+
+  // FIXME: consider batching the requests for all diagnostics.
+  SymbolSlab::Builder Matches;
+  Index.lookup(Req, [&](const Symbol ) { Matches.insert(Sym); });
+  auto Syms = std::move(Matches).build();
+
+  std::vector Fixes;
+  if (!Syms.empty()) {
+auto  = *Syms.begin();
+if (!Matched.IncludeHeaders.empty() && Matched.Definition &&
+Matched.CanonicalDeclaration.FileURI == Matched.Definition.FileURI)
+  Fixes = fixesForSymbols(Syms);
+  

[PATCH] D57910: [ASTImporter] Find previous friend function template

2019-02-18 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354267: [ASTImporter] Find previous friend function template 
(authored by martong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57910?vs=187212=187228#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57910

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5540,7 +5540,7 @@
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
   if (!LexicalDC->isFunctionOrMethod()) {
-unsigned IDNS = Decl::IDNS_Ordinary;
+unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
   if (!FoundDecl->isInIdentifierNamespace(IDNS))
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -5390,6 +5390,33 @@
   EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
 }
 
+struct ImportFriendFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  class X {
+template  friend void foo();
+  };
+  )",
+  Lang_CXX);
+  auto *Friend = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl(hasName("foo")));
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  void foo();
+  )",
+  Lang_CXX);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("foo")));
+  auto *Imported = Import(FromFoo, Lang_CXX);
+
+  // FIXME Currently chains of FunctionTemplateDecls are not implemented.
+  //EXPECT_EQ(Imported->getPreviousDecl(), Friend);
+  EXPECT_EQ(Imported, Friend);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5408,6 +5435,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClasses,
 DefaultTestValuesForRunOptions, );
 


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5540,7 +5540,7 @@
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
   if (!LexicalDC->isFunctionOrMethod()) {
-unsigned IDNS = Decl::IDNS_Ordinary;
+unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
   if (!FoundDecl->isInIdentifierNamespace(IDNS))
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -5390,6 +5390,33 @@
   EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
 }
 
+struct ImportFriendFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  class X {
+template  friend void foo();
+  };
+  )",
+  Lang_CXX);
+  auto *Friend = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl(hasName("foo")));
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  void foo();
+  )",
+  Lang_CXX);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("foo")));
+  auto *Imported = Import(FromFoo, Lang_CXX);
+
+  // FIXME Currently chains of FunctionTemplateDecls are not implemented.
+  //EXPECT_EQ(Imported->getPreviousDecl(), Friend);
+  EXPECT_EQ(Imported, Friend);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5408,6 +5435,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClasses,
 DefaultTestValuesForRunOptions, );
 

r354267 - [ASTImporter] Find previous friend function template

2019-02-18 Thread Gabor Marton via cfe-commits
Author: martong
Date: Mon Feb 18 05:09:27 2019
New Revision: 354267

URL: http://llvm.org/viewvc/llvm-project?rev=354267=rev
Log:
[ASTImporter] Find previous friend function template

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=354267=354266=354267=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Feb 18 05:09:27 2019
@@ -5540,7 +5540,7 @@ ASTNodeImporter::VisitFunctionTemplateDe
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
   if (!LexicalDC->isFunctionOrMethod()) {
-unsigned IDNS = Decl::IDNS_Ordinary;
+unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
   if (!FoundDecl->isInIdentifierNamespace(IDNS))

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=354267=354266=354267=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Feb 18 05:09:27 2019
@@ -5390,6 +5390,33 @@ TEST_P(ASTImporterOptionSpecificTestBase
   EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
 }
 
+struct ImportFriendFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  class X {
+template  friend void foo();
+  };
+  )",
+  Lang_CXX);
+  auto *Friend = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl(hasName("foo")));
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  void foo();
+  )",
+  Lang_CXX);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("foo")));
+  auto *Imported = Import(FromFoo, Lang_CXX);
+
+  // FIXME Currently chains of FunctionTemplateDecls are not implemented.
+  //EXPECT_EQ(Imported->getPreviousDecl(), Friend);
+  EXPECT_EQ(Imported, Friend);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5408,6 +5435,9 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTes
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClasses,
 DefaultTestValuesForRunOptions, );
 


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


[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 187226.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- pulled cached index queries into functions


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58239

Files:
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -449,6 +449,44 @@
   UnorderedElementsAre(Diag(Test.range(), "no member named 'xy' in 'X'")));
 }
 
+TEST(IncludeFixerTest, UseCachedIndexResults) {
+  // As index results for the identical request are cached, more than 5 fixes
+  // are generated.
+  Annotations Test(R"cpp(
+$insert[[]]void foo() {
+  $x1[[X]] x;
+  $x2[[X]] x;
+  $x3[[X]] x;
+  $x4[[X]] x;
+  $x5[[X]] x;
+  $x6[[X]] x;
+  $x7[[X]] x;
+}
+
+class X;
+void bar(X *x) {
+  x$a1[[->]]f();
+  x$a2[[->]]f();
+  x$a3[[->]]f();
+  x$a4[[->]]f();
+  x$a5[[->]]f();
+  x$a6[[->]]f();
+  x$a7[[->]]f();
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index =
+  buildIndexWithSymbol(SymbolWithHeader{"X", "unittest:///a.h", "\"a.h\""});
+  TU.ExternalIndex = Index.get();
+
+  auto Parsed = TU.build();
+  for (const auto  : Parsed.getDiagnostics()) {
+EXPECT_EQ(D.Fixes.size(), 1u);
+EXPECT_EQ(D.Fixes[0].Message,
+  std::string("Add include \"a.h\" for symbol X"));
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/IncludeFixer.h
===
--- clangd/IncludeFixer.h
+++ clangd/IncludeFixer.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 
@@ -51,7 +52,7 @@
   std::vector fixIncompleteType(const Type ) const;
 
   /// Generates header insertion fixes for all symbols. Fixes are deduplicated.
-  std::vector fixesForSymbols(llvm::ArrayRef Syms) const;
+  std::vector fixesForSymbols(const SymbolSlab ) const;
 
   struct UnresolvedName {
 std::string Name;   // E.g. "X" in foo::X.
@@ -79,6 +80,17 @@
   // These collect the last unresolved name so that we can associate it with the
   // diagnostic.
   llvm::Optional LastUnresolvedName;
+
+  // There can be multiple diagnostics that are caused by the same unresolved
+  // name or incomplete type in one parse, especially when code is
+  // copy-and-pasted without #includes. We cache the index results based on
+  // index requests.
+  mutable llvm::StringMap FuzzyFindCache;
+  mutable llvm::DenseMap LookupCache;
+  // Returns None if the number of index requests has reached the limit.
+  llvm::Optional
+  fuzzyFindCached(const FuzzyFindRequest ) const;
+  llvm::Optional lookupCached(const SymbolID ) const;
 };
 
 } // namespace clangd
Index: clangd/IncludeFixer.cpp
===
--- clangd/IncludeFixer.cpp
+++ clangd/IncludeFixer.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -57,8 +58,6 @@
 
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic ) const {
-  if (IndexRequestCount >= IndexRequestLimit)
-return {}; // Avoid querying index too many times in a single parse.
   switch (Info.getID()) {
   case diag::err_incomplete_type:
   case diag::err_incomplete_member_access:
@@ -118,26 +117,21 @@
   auto ID = getSymbolID(TD);
   if (!ID)
 return {};
-  ++IndexRequestCount;
-  // FIXME: consider batching the requests for all diagnostics.
-  // FIXME: consider caching the lookup results.
-  LookupRequest Req;
-  Req.IDs.insert(*ID);
-  llvm::Optional Matched;
-  Index.lookup(Req, [&](const Symbol ) {
-if (Matched)
-  return;
-Matched = Sym;
-  });
-
-  if (!Matched || Matched->IncludeHeaders.empty() || !Matched->Definition ||
-  Matched->CanonicalDeclaration.FileURI != Matched->Definition.FileURI)
+  llvm::Optional Symbols = lookupCached(*ID);
+  if (!Symbols)
 return {};
-  return fixesForSymbols({*Matched});
+  const SymbolSlab  = **Symbols;
+  std::vector Fixes;
+  if (!Syms.empty()) {
+auto  = *Syms.begin();
+if (!Matched.IncludeHeaders.empty() && Matched.Definition &&
+Matched.CanonicalDeclaration.FileURI == Matched.Definition.FileURI)
+  Fixes = fixesForSymbols(Syms);
+  }
+  return Fixes;
 }
 
-std::vector
-IncludeFixer::fixesForSymbols(llvm::ArrayRef Syms) const {
+std::vector IncludeFixer::fixesForSymbols(const SymbolSlab ) const {
   auto Inserted = 

[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-02-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Looks great! Thanks for doing this.

Could you also check in the tool that is used to generate the mapping? We need 
a way to update the mapping when cppreference is updated.




Comment at: clangd/index/CanonicalIncludes.cpp:123
 
   static const std::vector>
   SystemHeaderMap = {

Can we remove the suffix header mapping now? Is it for the `std::chrono::` 
symbols? What are the reasons not to include them in this patch? 


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58345



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


[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-02-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 187225.
hokein added a comment.

Fix style.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58345

Files:
  clangd/StdSymbolMap.imp
  clangd/index/CanonicalIncludes.cpp
  clangd/index/CanonicalIncludes.h

Index: clangd/index/CanonicalIncludes.h
===
--- clangd/index/CanonicalIncludes.h
+++ clangd/index/CanonicalIncludes.h
@@ -44,10 +44,10 @@
   void addPathSuffixMapping(llvm::StringRef Suffix,
 llvm::StringRef CanonicalPath);
 
-  /// Sets the canonical include for any symbol with \p QualifiedName.
+  /// Sets the canonical includes for any symbol with \p QualifiedName.
   /// Symbol mappings take precedence over header mappings.
   void addSymbolMapping(llvm::StringRef QualifiedName,
-llvm::StringRef CanonicalPath);
+llvm::SmallVector CanonicalPaths);
 
   /// Returns the canonical include for symbol with \p QualifiedName.
   /// \p Headers is the include stack: Headers.front() is the file declaring the
@@ -64,7 +64,8 @@
   /// Used to reduce the number of lookups into SuffixHeaderMapping.
   int MaxSuffixComponents = 0;
   /// A map from fully qualified symbol names to header names.
-  llvm::StringMap SymbolMapping;
+  llvm::DenseMap>
+  SymbolMapping;
 };
 
 /// Returns a CommentHandler that parses pragma comment on include files to
Index: clangd/index/CanonicalIncludes.cpp
===
--- clangd/index/CanonicalIncludes.cpp
+++ clangd/index/CanonicalIncludes.cpp
@@ -31,9 +31,10 @@
   FullPathMapping[Path] = CanonicalPath;
 }
 
-void CanonicalIncludes::addSymbolMapping(llvm::StringRef QualifiedName,
- llvm::StringRef CanonicalPath) {
-  this->SymbolMapping[QualifiedName] = CanonicalPath;
+void CanonicalIncludes::addSymbolMapping(
+llvm::StringRef QualifiedName,
+llvm::SmallVector CanonicalPaths) {
+  this->SymbolMapping[QualifiedName] = std::move(CanonicalPaths);
 }
 
 llvm::StringRef
@@ -41,8 +42,13 @@
  llvm::StringRef QualifiedName) const {
   assert(!Headers.empty());
   auto SE = SymbolMapping.find(QualifiedName);
+  // FIXME: support multple-header cases. STL symbols may come from different
+  // headers (e.g. std::move from  and ), using
+  // qualified name can not disambiguate headers. Instead we should return all
+  // headers and do the disambiguation in clangd side.
   if (SE != SymbolMapping.end())
-return SE->second;
+return SE->second.front();
+
   // Find the first header such that the extension is not '.inc', and isn't a
   // recognized non-header file
   auto I = llvm::find_if(Headers, [](llvm::StringRef Include) {
@@ -106,55 +112,11 @@
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
-  static const std::vector> SymbolMap = {
-  {"std::addressof", ""},
-  // Map symbols in  to their preferred includes.
-  {"std::basic_filebuf", ""},
-  {"std::basic_fstream", ""},
-  {"std::basic_ifstream", ""},
-  {"std::basic_ofstream", ""},
-  {"std::filebuf", ""},
-  {"std::fstream", ""},
-  {"std::ifstream", ""},
-  {"std::ofstream", ""},
-  {"std::wfilebuf", ""},
-  {"std::wfstream", ""},
-  {"std::wifstream", ""},
-  {"std::wofstream", ""},
-  {"std::basic_ios", ""},
-  {"std::ios", ""},
-  {"std::wios", ""},
-  {"std::basic_iostream", ""},
-  {"std::iostream", ""},
-  {"std::wiostream", ""},
-  {"std::basic_istream", ""},
-  {"std::istream", ""},
-  {"std::wistream", ""},
-  {"std::istreambuf_iterator", ""},
-  {"std::ostreambuf_iterator", ""},
-  {"std::basic_ostream", ""},
-  {"std::ostream", ""},
-  {"std::wostream", ""},
-  {"std::basic_istringstream", ""},
-  {"std::basic_ostringstream", ""},
-  {"std::basic_stringbuf", ""},
-  {"std::basic_stringstream", ""},
-  {"std::istringstream", ""},
-  {"std::ostringstream", ""},
-  {"std::string", ""},
-  {"std::stringbuf", ""},
-  {"std::stringstream", ""},
-  {"std::wistringstream", ""},
-  {"std::wostringstream", ""},
-  {"std::wstringbuf", ""},
-  {"std::wstringstream", ""},
-  {"std::basic_streambuf", ""},
-  {"std::streambuf", ""},
-  {"std::wstreambuf", ""},
-  {"std::uint_least16_t", ""}, //  redeclares these
-  {"std::uint_least32_t", ""},
-  {"std::declval", ""},
-  };
+  static const std::vector<
+  std::pair>>
+  SymbolMap = {
+#include "StdSymbolMap.imp"
+  };
   for (const auto  : SymbolMap)
 Includes->addSymbolMapping(Pair.first, Pair.second);
 
Index: clangd/StdSymbolMap.imp
===
--- /dev/null
+++ clangd/StdSymbolMap.imp
@@ -0,0 +1,1301 @@
+//===-- 

[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-02-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a reviewer: jfb.
Herald added subscribers: jdoerfert, jfb, kadircet, arphaman, mgrang, jkorous, 
MaskRay, ioeric, ilya-biryukov.
Herald added a project: clang.

Using suffix path mapping relies on the STL implementations, and it is
not portable. This patch is using symbol nampe mapping, which should
work with different STL implementations, fix clangd/clangd#9.

To generate the symbol mapping, we parse the cppreference symbol index
page to build a lookup table.

The mapping is not completed, a few TODOs:

- support symbols from different headers (e.g. std::move)
- support STL macros
- support symbols from std's sub-namespaces (e.g. chrono)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58345

Files:
  clangd/StdSymbolMap.imp
  clangd/index/CanonicalIncludes.cpp
  clangd/index/CanonicalIncludes.h

Index: clangd/index/CanonicalIncludes.h
===
--- clangd/index/CanonicalIncludes.h
+++ clangd/index/CanonicalIncludes.h
@@ -44,10 +44,10 @@
   void addPathSuffixMapping(llvm::StringRef Suffix,
 llvm::StringRef CanonicalPath);
 
-  /// Sets the canonical include for any symbol with \p QualifiedName.
+  /// Sets the canonical includes for any symbol with \p QualifiedName.
   /// Symbol mappings take precedence over header mappings.
   void addSymbolMapping(llvm::StringRef QualifiedName,
-llvm::StringRef CanonicalPath);
+llvm::SmallVector CanonicalPaths);
 
   /// Returns the canonical include for symbol with \p QualifiedName.
   /// \p Headers is the include stack: Headers.front() is the file declaring the
@@ -64,7 +64,8 @@
   /// Used to reduce the number of lookups into SuffixHeaderMapping.
   int MaxSuffixComponents = 0;
   /// A map from fully qualified symbol names to header names.
-  llvm::StringMap SymbolMapping;
+  llvm::DenseMap>
+  SymbolMapping;
 };
 
 /// Returns a CommentHandler that parses pragma comment on include files to
Index: clangd/index/CanonicalIncludes.cpp
===
--- clangd/index/CanonicalIncludes.cpp
+++ clangd/index/CanonicalIncludes.cpp
@@ -32,8 +32,8 @@
 }
 
 void CanonicalIncludes::addSymbolMapping(llvm::StringRef QualifiedName,
- llvm::StringRef CanonicalPath) {
-  this->SymbolMapping[QualifiedName] = CanonicalPath;
+ llvm::SmallVector CanonicalPaths) {
+  this->SymbolMapping[QualifiedName] = std::move(CanonicalPaths);
 }
 
 llvm::StringRef
@@ -41,8 +41,13 @@
  llvm::StringRef QualifiedName) const {
   assert(!Headers.empty());
   auto SE = SymbolMapping.find(QualifiedName);
+  // FIXME: support multple-header cases. STL symbols may come from different
+  // headers (e.g. std::move from  and ), using
+  // qualified name can not disambiguate headers. Instead we should return all
+  // headers and do the disambiguation in clangd side.
   if (SE != SymbolMapping.end())
-return SE->second;
+return SE->second.front();
+
   // Find the first header such that the extension is not '.inc', and isn't a
   // recognized non-header file
   auto I = llvm::find_if(Headers, [](llvm::StringRef Include) {
@@ -106,55 +111,11 @@
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
-  static const std::vector> SymbolMap = {
-  {"std::addressof", ""},
-  // Map symbols in  to their preferred includes.
-  {"std::basic_filebuf", ""},
-  {"std::basic_fstream", ""},
-  {"std::basic_ifstream", ""},
-  {"std::basic_ofstream", ""},
-  {"std::filebuf", ""},
-  {"std::fstream", ""},
-  {"std::ifstream", ""},
-  {"std::ofstream", ""},
-  {"std::wfilebuf", ""},
-  {"std::wfstream", ""},
-  {"std::wifstream", ""},
-  {"std::wofstream", ""},
-  {"std::basic_ios", ""},
-  {"std::ios", ""},
-  {"std::wios", ""},
-  {"std::basic_iostream", ""},
-  {"std::iostream", ""},
-  {"std::wiostream", ""},
-  {"std::basic_istream", ""},
-  {"std::istream", ""},
-  {"std::wistream", ""},
-  {"std::istreambuf_iterator", ""},
-  {"std::ostreambuf_iterator", ""},
-  {"std::basic_ostream", ""},
-  {"std::ostream", ""},
-  {"std::wostream", ""},
-  {"std::basic_istringstream", ""},
-  {"std::basic_ostringstream", ""},
-  {"std::basic_stringbuf", ""},
-  {"std::basic_stringstream", ""},
-  {"std::istringstream", ""},
-  {"std::ostringstream", ""},
-  {"std::string", ""},
-  {"std::stringbuf", ""},
-  {"std::stringstream", ""},
-  {"std::wistringstream", ""},
-  {"std::wostringstream", ""},
-  {"std::wstringbuf", ""},
-  {"std::wstringstream", ""},
-  {"std::basic_streambuf", ""},
-  {"std::streambuf", ""},
-  {"std::wstreambuf", ""},
-  

[clang-tools-extra] r354266 - [clang-tidy] Fix links in docs.

2019-02-18 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Feb 18 04:50:35 2019
New Revision: 354266

URL: http://llvm.org/viewvc/llvm-project?rev=354266=rev
Log:
[clang-tidy] Fix links in docs.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=354266=354265=354266=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Mon Feb 18 04:50:35 2019
@@ -264,13 +264,14 @@ Suppressing Undesired Diagnostics
 adhere to a coding standard, or is otherwise problematic in some way.  However,
 if the code is known to be correct, it may be useful to silence the warning.
 Some clang-tidy checks provide a check-specific way to silence the diagnostics,
-e.g.  `bugprone-use-after-move `_ can be
+e.g.  `bugprone-use-after-move `_ can be
 silenced by re-initializing the variable after it has been moved out,
 `bugprone-string-integer-assignment
-`_ can be suppressed by explicitly
-casting the integer to ``char``, `readability-implicit-bool-conversion
-`_ can also be suppressed by using
-explicit casts, etc.
+`_ can be suppressed by
+explicitly casting the integer to ``char``,
+`readability-implicit-bool-conversion
+`_ can also be suppressed by
+using explicit casts, etc.
 
 If a specific suppression mechanism is not available for a certain warning, or
 its use is not desired for some reason, :program:`clang-tidy` has a generic


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


[PATCH] D58185: [clangd] Handle unresolved scope specifier when fixing includes.

2019-02-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 187222.
ioeric marked 9 inline comments as done.
ioeric added a comment.

- address review comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58185

Files:
  clangd/IncludeFixer.cpp
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -20,6 +20,7 @@
 namespace clangd {
 namespace {
 
+using testing::_;
 using testing::ElementsAre;
 using testing::Field;
 using testing::IsEmpty;
@@ -369,6 +370,8 @@
 $insert[[]]namespace ns {
 void foo() {
   $unqualified1[[X]] x;
+  // No fix if the unresolved type is used as qualifier. (ns::)X::Nested will be
+  // considered the unresolved type.
   $unqualified2[[X]]::Nested n;
 }
 }
@@ -391,10 +394,7 @@
   AllOf(Diag(Test.range("unqualified1"), "unknown type name 'X'"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
 "Add include \"x.h\" for symbol ns::X"))),
-  AllOf(Diag(Test.range("unqualified2"),
- "use of undeclared identifier 'X'"),
-WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
-"Add include \"x.h\" for symbol ns::X"))),
+  Diag(Test.range("unqualified2"), "use of undeclared identifier 'X'"),
   AllOf(Diag(Test.range("qualified1"),
  "no type named 'X' in namespace 'ns'"),
 WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
@@ -449,6 +449,87 @@
   UnorderedElementsAre(Diag(Test.range(), "no member named 'xy' in 'X'")));
 }
 
+TEST(IncludeFixerTest, UnresolvedNameAsQualifier) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+}
+void g() {  ns::$[[scope]]::X_Y();  }
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  SymbolWithHeader{"ns::scope::X_Y", "unittest:///x.h", "\"x.h\""});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range(), "no member named 'scope' in namespace 'ns'"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol ns::scope::X_Y");
+}
+
+TEST(IncludeFixerTest, UnresolvedQualifierWithSemaCorrection) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace clang {
+void f() {
+  // "clangd::" will be corrected to "clang::" by Sema.
+  $q1[[clangd]]::$x[[X]] x;
+  $q2[[clangd]]::$ns[[ns]]::Y y;
+}
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"clang::clangd::X", "unittest:///x.h", "\"x.h\""},
+   SymbolWithHeader{"clang::clangd::ns::Y", "unittest:///y.h", "\"y.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(
+  Diag(Test.range("q1"), "use of undeclared identifier 'clangd'; "
+ "did you mean 'clang'?"),
+  WithFix(_, // change clangd to clang
+  Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol clang::clangd::X"))),
+  AllOf(
+  Diag(Test.range("x"), "no type named 'X' in namespace 'clang'"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+  "Add include \"x.h\" for symbol clang::clangd::X"))),
+  AllOf(
+  Diag(Test.range("q2"), "use of undeclared identifier 'clangd'; "
+ "did you mean 'clang'?"),
+  WithFix(
+  _, // change clangd to clangd
+  Fix(Test.range("insert"), "#include \"y.h\"\n",
+  "Add include \"y.h\" for symbol clang::clangd::ns::Y"))),
+  AllOf(Diag(Test.range("ns"),
+ "no member named 'ns' in namespace 'clang'"),
+WithFix(Fix(
+Test.range("insert"), "#include \"y.h\"\n",
+"Add include \"y.h\" for symbol clang::clangd::ns::Y");
+}
+TEST(IncludeFixerTest, SpecifiedScopeIsNamespaceAlias) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace a {}
+namespace b = a;
+namespace c {
+  b::$[[X]] x;
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  SymbolWithHeader{"a::X", "unittest:///x.h", "\"x.h\""});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range(), "no type named 'X' in namespace 'a'"),
+  WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+ 

[PATCH] D23610: [ARM] Add pre-defined macros for ROPI and RWPI

2019-02-18 Thread Oliver Stannard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354265: [ARM] Add pre-defined macros for ROPI and RWPI 
(authored by olista01, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D23610?vs=91990=187220#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D23610

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets/ARM.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Preprocessor/arm-pic-predefines.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3810,6 +3810,13 @@
   CmdArgs.push_back("-pic-is-pie");
   }
 
+  if (RelocationModel == llvm::Reloc::ROPI ||
+  RelocationModel == llvm::Reloc::ROPI_RWPI)
+CmdArgs.push_back("-fropi");
+  if (RelocationModel == llvm::Reloc::RWPI ||
+  RelocationModel == llvm::Reloc::ROPI_RWPI)
+CmdArgs.push_back("-frwpi");
+
   if (Arg *A = Args.getLastArg(options::OPT_meabi)) {
 CmdArgs.push_back("-meabi");
 CmdArgs.push_back(A->getValue());
Index: cfe/trunk/lib/Basic/Targets/ARM.cpp
===
--- cfe/trunk/lib/Basic/Targets/ARM.cpp
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp
@@ -652,6 +652,12 @@
   if (SoftFloat)
 Builder.defineMacro("__SOFTFP__");
 
+  // ACLE position independent code macros.
+  if (Opts.ROPI)
+Builder.defineMacro("__ARM_ROPI", "1");
+  if (Opts.RWPI)
+Builder.defineMacro("__ARM_RWPI", "1");
+
   if (ArchKind == llvm::ARM::ArchKind::XSCALE)
 Builder.defineMacro("__XSCALE__");
 
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2662,6 +2662,8 @@
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, 
Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+  Opts.ROPI = Args.hasArg(OPT_fropi);
+  Opts.RWPI = Args.hasArg(OPT_frwpi);
   Opts.PIE = Args.hasArg(OPT_pic_is_pie);
   Opts.Static = Args.hasArg(OPT_static_define);
   Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -170,6 +170,8 @@
 VALUE_LANGOPT(AlignDouble, 1, 0, "Controls if doubles should be 
aligned to 8 bytes (x86 only)")
 COMPATIBLE_VALUE_LANGOPT(PICLevel, 2, 0, "__PIC__ level")
 COMPATIBLE_VALUE_LANGOPT(PIE , 1, 0, "is pie")
+LANGOPT(ROPI , 1, 0, "Read-only position independence")
+LANGOPT(RWPI , 1, 0, "Read-write position 
independence")
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
 COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro")
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1606,9 +1606,9 @@
   HelpText<"Use the PLT to make function calls">;
 def fno_plt : Flag<["-"], "fno-plt">, Group, Flags<[CC1Option]>,
   HelpText<"Do not use the PLT to make function calls">;
-def fropi : Flag<["-"], "fropi">, Group;
+def fropi : Flag<["-"], "fropi">, Group, Flags<[CC1Option]>;
 def fno_ropi : Flag<["-"], "fno-ropi">, Group;
-def frwpi : Flag<["-"], "frwpi">, Group;
+def frwpi : Flag<["-"], "frwpi">, Group, Flags<[CC1Option]>;
 def fno_rwpi : Flag<["-"], "fno-rwpi">, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
Index: cfe/trunk/test/Preprocessor/arm-pic-predefines.c
===
--- cfe/trunk/test/Preprocessor/arm-pic-predefines.c
+++ cfe/trunk/test/Preprocessor/arm-pic-predefines.c
@@ -0,0 +1,14 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang -target armv8--none-eabi   -x c -E -dM %s -o -   | 
FileCheck %s --check-prefix=NO-ROPI --check-prefix=NO-RWPI
+// RUN: %clang -target armv8--none-eabi   -x c -E -dM %s -o - -fropi| 
FileCheck %s --check-prefix=ROPI--check-prefix=NO-RWPI
+// RUN: %clang -target armv8--none-eabi   -x c -E -dM %s -o - -frwpi| 
FileCheck %s --check-prefix=NO-ROPI 

[PATCH] D58185: [clangd] Handle unresolved scope specifier when fixing includes.

2019-02-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/IncludeFixer.cpp:235
+  std::string Spelling = (Code.substr(B, E - B) + "::").str();
+  if (llvm::StringRef(SpecifiedNS).endswith(Spelling))
+SpecifiedScope = SpecifiedNS;

sammccall wrote:
> hmm, won't this heuristic have false positives?
> ```
> // indexed-header.h
> namespace a { int X; }
> 
> // main-file.cc
> namespace b = a;
> namespace c { int Y = b::x; }
> ```
> I worry spelling is going to be "b::" here, while SpecifiedNS is going to be 
> "a::".
Thanks for pointing this out! I completely missed the namespace alias case. 
Fixed and added a test.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58185



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


[PATCH] D23610: [ARM] Add pre-defined macros for ROPI and RWPI

2019-02-18 Thread Oliver Stannard via Phabricator via cfe-commits
olista01 added a comment.

Yes, the back-end work was all done years ago, I just also forgot about these 
while waiting for the ACLE to be published.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D23610



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


r354265 - [ARM] Add pre-defined macros for ROPI and RWPI

2019-02-18 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Mon Feb 18 04:39:47 2019
New Revision: 354265

URL: http://llvm.org/viewvc/llvm-project?rev=354265=rev
Log:
[ARM] Add pre-defined macros for ROPI and RWPI

This adds ACLE-defined macros to test for code being compiled in the ROPI and
RWPI position-independence modes.

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


Added:
cfe/trunk/test/Preprocessor/arm-pic-predefines.c
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=354265=354264=354265=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Feb 18 04:39:47 2019
@@ -170,6 +170,8 @@ VALUE_LANGOPT(MaxTypeAlign  , 32, 0,
 VALUE_LANGOPT(AlignDouble, 1, 0, "Controls if doubles should be 
aligned to 8 bytes (x86 only)")
 COMPATIBLE_VALUE_LANGOPT(PICLevel, 2, 0, "__PIC__ level")
 COMPATIBLE_VALUE_LANGOPT(PIE , 1, 0, "is pie")
+LANGOPT(ROPI , 1, 0, "Read-only position independence")
+LANGOPT(RWPI , 1, 0, "Read-write position 
independence")
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
 COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro")
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=354265=354264=354265=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 18 04:39:47 2019
@@ -1606,9 +1606,9 @@ def fplt : Flag<["-"], "fplt">, Group;
 def fno_plt : Flag<["-"], "fno-plt">, Group, Flags<[CC1Option]>,
   HelpText<"Do not use the PLT to make function calls">;
-def fropi : Flag<["-"], "fropi">, Group;
+def fropi : Flag<["-"], "fropi">, Group, Flags<[CC1Option]>;
 def fno_ropi : Flag<["-"], "fno-ropi">, Group;
-def frwpi : Flag<["-"], "frwpi">, Group;
+def frwpi : Flag<["-"], "frwpi">, Group, Flags<[CC1Option]>;
 def fno_rwpi : Flag<["-"], "fno-rwpi">, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=354265=354264=354265=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Mon Feb 18 04:39:47 2019
@@ -652,6 +652,12 @@ void ARMTargetInfo::getTargetDefines(con
   if (SoftFloat)
 Builder.defineMacro("__SOFTFP__");
 
+  // ACLE position independent code macros.
+  if (Opts.ROPI)
+Builder.defineMacro("__ARM_ROPI", "1");
+  if (Opts.RWPI)
+Builder.defineMacro("__ARM_RWPI", "1");
+
   if (ArchKind == llvm::ARM::ArchKind::XSCALE)
 Builder.defineMacro("__XSCALE__");
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=354265=354264=354265=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Feb 18 04:39:47 2019
@@ -3810,6 +3810,13 @@ void Clang::ConstructJob(Compilation ,
   CmdArgs.push_back("-pic-is-pie");
   }
 
+  if (RelocationModel == llvm::Reloc::ROPI ||
+  RelocationModel == llvm::Reloc::ROPI_RWPI)
+CmdArgs.push_back("-fropi");
+  if (RelocationModel == llvm::Reloc::RWPI ||
+  RelocationModel == llvm::Reloc::ROPI_RWPI)
+CmdArgs.push_back("-frwpi");
+
   if (Arg *A = Args.getLastArg(options::OPT_meabi)) {
 CmdArgs.push_back("-meabi");
 CmdArgs.push_back(A->getValue());

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=354265=354264=354265=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Feb 18 04:39:47 2019
@@ -2662,6 +2662,8 @@ static void ParseLangArgs(LangOptions 
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, 
Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 

[PATCH] D58344: Enablement for AMD znver2 architecture - skeleton

2019-02-18 Thread Ganesh Gopalasubramanian via Phabricator via cfe-commits
GGanesh created this revision.
GGanesh added reviewers: RKSimon, craig.topper.
GGanesh created this object with visibility "All Users".
GGanesh added a project: clang.
Herald added a subscriber: cfe-commits.

This patch enables the following

1. AMD family 17h "znver2" tune flag (-march, -mcpu).
2. ISAs that are enabled for "znver2" architecture.
3. For the time being, it uses the znver1 scheduler model.
4. Tests are updated.


Repository:
  rC Clang

https://reviews.llvm.org/D58344

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  test/CodeGen/attr-target-mv.c
  test/CodeGen/target-builtin-noerror.c
  test/Driver/x86-march.c
  test/Frontend/x86-target-cpu.c
  test/Misc/target-invalid-cpu-note.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -2676,8 +2676,102 @@
 // CHECK_ZNVER1_M64: #define __znver1 1
 // CHECK_ZNVER1_M64: #define __znver1__ 1

+// RUN: %clang -march=znver2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER2_M32
+// CHECK_ZNVER2_M32-NOT: #define __3dNOW_A__ 1
+// CHECK_ZNVER2_M32-NOT: #define __3dNOW__ 1
+// CHECK_ZNVER2_M32: #define __ADX__ 1
+// CHECK_ZNVER2_M32: #define __AES__ 1
+// CHECK_ZNVER2_M32: #define __AVX2__ 1
+// CHECK_ZNVER2_M32: #define __AVX__ 1
+// CHECK_ZNVER2_M32: #define __BMI2__ 1
+// CHECK_ZNVER2_M32: #define __BMI__ 1
+// CHECK_ZNVER2_M32: #define __CLFLUSHOPT__ 1
+// CHECK_ZNVER2_M32: #define __CLWB__ 1
+// CHECK_ZNVER2_M32: #define __CLZERO__ 1
+// CHECK_ZNVER2_M32: #define __F16C__ 1
+// CHECK_ZNVER2_M32: #define __FMA__ 1
+// CHECK_ZNVER2_M32: #define __FSGSBASE__ 1
+// CHECK_ZNVER2_M32: #define __LZCNT__ 1
+// CHECK_ZNVER2_M32: #define __MMX__ 1
+// CHECK_ZNVER2_M32: #define __PCLMUL__ 1
+// CHECK_ZNVER2_M32: #define __POPCNT__ 1
+// CHECK_ZNVER2_M32: #define __PRFCHW__ 1
+// CHECK_ZNVER2_M32: #define __RDPID__ 1
+// CHECK_ZNVER2_M32: #define __RDRND__ 1
+// CHECK_ZNVER2_M32: #define __RDSEED__ 1
+// CHECK_ZNVER2_M32: #define __SHA__ 1
+// CHECK_ZNVER2_M32: #define __SSE2_MATH__ 1
+// CHECK_ZNVER2_M32: #define __SSE2__ 1
+// CHECK_ZNVER2_M32: #define __SSE3__ 1
+// CHECK_ZNVER2_M32: #define __SSE4A__ 1
+// CHECK_ZNVER2_M32: #define __SSE4_1__ 1
+// CHECK_ZNVER2_M32: #define __SSE4_2__ 1
+// CHECK_ZNVER2_M32: #define __SSE_MATH__ 1
+// CHECK_ZNVER2_M32: #define __SSE__ 1
+// CHECK_ZNVER2_M32: #define __SSSE3__ 1
+// CHECK_ZNVER2_M32: #define __WBNOINVD__ 1
+// CHECK_ZNVER2_M32: #define __XSAVEC__ 1
+// CHECK_ZNVER2_M32: #define __XSAVEOPT__ 1
+// CHECK_ZNVER2_M32: #define __XSAVES__ 1
+// CHECK_ZNVER2_M32: #define __XSAVE__ 1
+// CHECK_ZNVER2_M32: #define __i386 1
+// CHECK_ZNVER2_M32: #define __i386__ 1
+// CHECK_ZNVER2_M32: #define __tune_znver2__ 1
+// CHECK_ZNVER2_M32: #define __znver2 1
+// CHECK_ZNVER2_M32: #define __znver2__ 1
+
+// RUN: %clang -march=znver2 -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER2_M64
+// CHECK_ZNVER2_M64-NOT: #define __3dNOW_A__ 1
+// CHECK_ZNVER2_M64-NOT: #define __3dNOW__ 1
+// CHECK_ZNVER2_M64: #define __ADX__ 1
+// CHECK_ZNVER2_M64: #define __AES__ 1
+// CHECK_ZNVER2_M64: #define __AVX2__ 1
+// CHECK_ZNVER2_M64: #define __AVX__ 1
+// CHECK_ZNVER2_M64: #define __BMI2__ 1
+// CHECK_ZNVER2_M64: #define __BMI__ 1
+// CHECK_ZNVER2_M64: #define __CLFLUSHOPT__ 1
+// CHECK_ZNVER2_M64: #define __CLWB__ 1
+// CHECK_ZNVER2_M64: #define __CLZERO__ 1
+// CHECK_ZNVER2_M64: #define __F16C__ 1
+// CHECK_ZNVER2_M64: #define __FMA__ 1
+// CHECK_ZNVER2_M64: #define __FSGSBASE__ 1
+// CHECK_ZNVER2_M64: #define __LZCNT__ 1
+// CHECK_ZNVER2_M64: #define __MMX__ 1
+// CHECK_ZNVER2_M64: #define __PCLMUL__ 1
+// CHECK_ZNVER2_M64: #define __POPCNT__ 1
+// CHECK_ZNVER2_M64: #define __PRFCHW__ 1
+// CHECK_ZNVER2_M64: #define __RDPID__ 1
+// CHECK_ZNVER2_M64: #define __RDRND__ 1
+// CHECK_ZNVER2_M64: #define __RDSEED__ 1
+// CHECK_ZNVER2_M64: #define __SHA__ 1
+// CHECK_ZNVER2_M64: #define __SSE2_MATH__ 1
+// CHECK_ZNVER2_M64: #define __SSE2__ 1
+// CHECK_ZNVER2_M64: #define __SSE3__ 1
+// CHECK_ZNVER2_M64: #define __SSE4A__ 1
+// CHECK_ZNVER2_M64: #define __SSE4_1__ 1
+// CHECK_ZNVER2_M64: #define __SSE4_2__ 1
+// CHECK_ZNVER2_M64: #define __SSE_MATH__ 1
+// CHECK_ZNVER2_M64: #define __SSE__ 1
+// CHECK_ZNVER2_M64: #define __SSSE3__ 1
+// CHECK_ZNVER2_M64: #define __WBNOINVD__ 1
+// CHECK_ZNVER2_M64: #define __XSAVEC__ 1
+// CHECK_ZNVER2_M64: #define __XSAVEOPT__ 1
+// CHECK_ZNVER2_M64: #define __XSAVES__ 1
+// CHECK_ZNVER2_M64: #define __XSAVE__ 1
+// CHECK_ZNVER2_M64: #define __amd64 1
+// CHECK_ZNVER2_M64: #define __amd64__ 1
+// CHECK_ZNVER2_M64: #define __tune_znver2__ 1
+// CHECK_ZNVER2_M64: #define __x86_64 1
+// CHECK_ZNVER2_M64: 

[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

SymbolSlab is much cleaner, nice!




Comment at: clangd/IncludeFixer.cpp:122
 
-  if (!Matched || Matched->IncludeHeaders.empty() || !Matched->Definition ||
-  Matched->CanonicalDeclaration.FileURI != Matched->Definition.FileURI)
+  auto I = LookupCache.find(*ID);
+  if (I != LookupCache.end())

extract  a function that maps `SymbolID -> const SymbolSlab&` and takes care of 
the caching?
(likewise for fuzzyfind)



Comment at: clangd/IncludeFixer.h:87
+  // copy-and-pasted without #includes. We cache the index results based on
+  // index requests (assuming index results are consistent during the single 
AST
+  // parse).

nit: maybe drop the parenthetical here? I think it's more confusing than 
enlightening.

("assuming" can mean either "and we assume" or "if" in this context. Also it's 
not clear there's a better behavior even if results did change and queries are 
free.)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58239



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


[PATCH] D58189: [clang][Index] Fix usage of IndexImplicitInstantiation

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354262: [clang][Index] Fix usage of 
IndexImplicitInstantiation (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58189

Files:
  cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
  cfe/trunk/test/Index/Core/index-source.cpp
  cfe/trunk/test/Index/index-refs.cpp
  cfe/trunk/unittests/Index/IndexTests.cpp

Index: cfe/trunk/test/Index/Core/index-source.cpp
===
--- cfe/trunk/test/Index/Core/index-source.cpp
+++ cfe/trunk/test/Index/Core/index-source.cpp
@@ -212,7 +212,7 @@
 };
 // CHECK: [[@LINE-2]]:54 | class(Gen)/C++ | InnerClass | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass |  | Def,RelChild | rel: 1
 // CHECK-NEXT: RelChild
-// CHECK: [[@LINE-4]]:7 | class(Gen)/C++ | PseudoOverridesInSpecializations | c:@ST>2#T#T@PseudoOverridesInSpecializations |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-4]]:7 | class(Gen,TS)/C++ | PseudoOverridesInSpecializations | c:@S@PseudoOverridesInSpecializations>#d#I |  | Ref,RelCont | rel: 1
 // CHECK-NEXT: RelCont
 
 template
@@ -285,13 +285,13 @@
 class SpecializationDecl;
 // CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#I |  | Decl,RelSpecialization | rel: 1
 // CHECK-NEXT: RelSpecialization | SpecializationDecl | c:@ST>1#T@SpecializationDecl
-// CHECK: [[@LINE-3]]:7 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK: [[@LINE-3]]:7 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#I |  | Ref | rel: 0
 
 template<>
 class SpecializationDecl { };
 // CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#I |  | Def,RelSpecialization | rel: 1
 // CHECK-NEXT: RelSpecialization | SpecializationDecl | c:@ST>1#T@SpecializationDecl
-// CHECK-NEXT: [[@LINE-3]]:7 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-3]]:7 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#I |  | Ref | rel: 0
 
 template
 class PartialSpecilizationClass;
@@ -306,7 +306,7 @@
 // CHECK-NEXT: RelSpecialization | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass
 // CHECK-NEXT: [[@LINE-3]]:45 | class/C++ | Cls | c:@S@Cls |  | Ref,RelBase,RelCont | rel: 1
 // CHECK-NEXT: RelBase,RelCont | PartialSpecilizationClass | c:@S@PartialSpecilizationClass>#$@S@Cls#S0_
-// CHECK-NEXT: [[@LINE-5]]:7 | class(Gen)/C++ | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass |  | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-5]]:7 | class(Gen,TS)/C++ | PartialSpecilizationClass | c:@S@PartialSpecilizationClass>#$@S@Cls#S0_ |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-6]]:33 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-7]]:38 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 
@@ -321,7 +321,7 @@
 void functionSp, Record::C>() {
 // CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | __Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | rel: 1
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:36 | class/C++ | Cls | c:@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-5]]:50 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-6]]:42 | struct/C++ | Record | c:@S@Record |  | Ref,RelCont | rel: 1
@@ -332,7 +332,7 @@
 
 template<>
 class ClassWithCorrectSpecialization, Record::C> { };
-// CHECK: [[@LINE-1]]:38 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK: [[@LINE-1]]:38 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#$@S@Cls |  | Ref | rel: 0
 // CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls |  | Ref | rel: 0
 // CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,Read | rel: 0
 // CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record |  | Ref | rel: 0
@@ -494,7 +494,7 @@
 // CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont | rel: 1
 // CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
 // CHECK-NOT: localBinding
-// LOCAL: [[@LINE-4]]:9 | variable(local)/C++ | localBinding1 | 

r354262 - [clang][Index] Fix usage of IndexImplicitInstantiation

2019-02-18 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Feb 18 03:30:43 2019
New Revision: 354262

URL: http://llvm.org/viewvc/llvm-project?rev=354262=rev
Log:
[clang][Index] Fix usage of IndexImplicitInstantiation

Summary:
Indexing context was skipping explicit template instantiations as well.
This patch makes sure it only skips implicit ones.

Subscribers: arphaman, jdoerfert, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
cfe/trunk/test/Index/Core/index-source.cpp
cfe/trunk/test/Index/index-refs.cpp
cfe/trunk/unittests/Index/IndexTests.cpp

Modified: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp?rev=354262=354261=354262=diff
==
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp (original)
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp Mon Feb 18 03:30:43 2019
@@ -129,10 +129,10 @@ public:
   template
   bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
 if (const auto *T = TL.getTypePtr()) {
-  if (IndexCtx.shouldIndexImplicitInstantiation()) {
-if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
-  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
-   Parent, ParentDC, SymbolRoleSet(), 
Relations);
+  if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
+if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
+  IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
+   ParentDC, SymbolRoleSet(), Relations);
   return true;
 }
   }

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=354262=354261=354262=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Mon Feb 18 03:30:43 2019
@@ -212,7 +212,7 @@ class PseudoOverridesInSpecializations#d#I@ST>1#T@InnerClass |  | 
Def,RelChild | rel: 1
 // CHECK-NEXT: RelChild
-// CHECK: [[@LINE-4]]:7 | class(Gen)/C++ | PseudoOverridesInSpecializations | 
c:@ST>2#T#T@PseudoOverridesInSpecializations |  | Ref,RelCont | rel: 
1
+// CHECK: [[@LINE-4]]:7 | class(Gen,TS)/C++ | PseudoOverridesInSpecializations 
| c:@S@PseudoOverridesInSpecializations>#d#I |  | Ref,RelCont | rel: 
1
 // CHECK-NEXT: RelCont
 
 template
@@ -285,13 +285,13 @@ template<>
 class SpecializationDecl;
 // CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#I |  | Decl,RelSpecialization | rel: 1
 // CHECK-NEXT: RelSpecialization | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl
-// CHECK: [[@LINE-3]]:7 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK: [[@LINE-3]]:7 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#I |  | Ref | rel: 0
 
 template<>
 class SpecializationDecl { };
 // CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#I |  | Def,RelSpecialization | rel: 1
 // CHECK-NEXT: RelSpecialization | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl
-// CHECK-NEXT: [[@LINE-3]]:7 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-3]]:7 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#I |  | Ref | rel: 0
 
 template
 class PartialSpecilizationClass;
@@ -306,7 +306,7 @@ class PartialSpecilizationClass2#T#T@PartialSpecilizationClass
 // CHECK-NEXT: [[@LINE-3]]:45 | class/C++ | Cls | c:@S@Cls |  | 
Ref,RelBase,RelCont | rel: 1
 // CHECK-NEXT: RelBase,RelCont | PartialSpecilizationClass | 
c:@S@PartialSpecilizationClass>#$@S@Cls#S0_
-// CHECK-NEXT: [[@LINE-5]]:7 | class(Gen)/C++ | PartialSpecilizationClass | 
c:@ST>2#T#T@PartialSpecilizationClass |  | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-5]]:7 | class(Gen,TS)/C++ | PartialSpecilizationClass | 
c:@S@PartialSpecilizationClass>#$@S@Cls#S0_ |  | Ref | rel: 0
 // CHECK-NEXT: [[@LINE-6]]:33 | class/C++ | Cls | c:@S@Cls |  | Ref 
| rel: 0
 // CHECK-NEXT: [[@LINE-7]]:38 | class/C++ | Cls | c:@S@Cls |  | Ref 
| rel: 0
 
@@ -321,7 +321,7 @@ template<>
 void functionSp, Record::C>() {
 // CHECK: [[@LINE-1]]:6 | function(Gen,TS)/C++ | functionSp | 
c:@F@functionSp<#$@S@SpecializationDecl>#$@S@Cls#VI2># | 
__Z10functionSpI18SpecializationDeclI3ClsELi2EEvv | Def,RelSpecialization | 
rel: 1
 // CHECK:   RelSpecialization | functionSp | c:@FT@>2#T#NIfunctionSp#v#
-// CHECK: [[@LINE-3]]:17 | class(Gen)/C++ | SpecializationDecl | 
c:@ST>1#T@SpecializationDecl |  | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:17 | class(Gen,TS)/C++ | SpecializationDecl | 
c:@S@SpecializationDecl>#$@S@Cls |  | Ref,RelCont | rel: 1
 // CHECK: 

[PATCH] D58190: [clangd] Add tests for template specializations

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 187213.
kadircet added a comment.

- Add more testcases


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58190

Files:
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -350,6 +350,58 @@
  FF();
  void f() { T^est a; }
   )cpp",
+
+  R"cpp(
+template 
+struct Foo { void bar() {} };
+
+template <>
+struct [[Foo]] { void bar() {} };
+
+void foo() {
+  Foo abc;
+  Fo^o b;
+}
+  )cpp",
+
+  R"cpp(
+template 
+struct [[Foo]] { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Fo^o abc;
+  Foo b;
+}
+  )cpp",
+
+  R"cpp(// partial tmeplate specialization
+template 
+struct Foo { void bar() {} };
+template 
+struct [[Foo]] { void bar() {} };
+^Foo x;
+  )cpp",
+
+  R"cpp(/// function template specializations
+template 
+void foo(T) {}
+template <>
+void [[foo]](int) {}
+void bar() {
+  fo^o(10);
+}
+  )cpp",
+
+  R"cpp(/// variable template decls
+template 
+T var = T();
+
+template <>
+double [[var]] = 10;
+
+double y = va^r;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -350,6 +350,58 @@
  FF();
  void f() { T^est a; }
   )cpp",
+
+  R"cpp(
+template 
+struct Foo { void bar() {} };
+
+template <>
+struct [[Foo]] { void bar() {} };
+
+void foo() {
+  Foo abc;
+  Fo^o b;
+}
+  )cpp",
+
+  R"cpp(
+template 
+struct [[Foo]] { void bar() {} };
+template <>
+struct Foo { void bar() {} };
+void foo() {
+  Fo^o abc;
+  Foo b;
+}
+  )cpp",
+
+  R"cpp(// partial tmeplate specialization
+template 
+struct Foo { void bar() {} };
+template 
+struct [[Foo]] { void bar() {} };
+^Foo x;
+  )cpp",
+
+  R"cpp(/// function template specializations
+template 
+void foo(T) {}
+template <>
+void [[foo]](int) {}
+void bar() {
+  fo^o(10);
+}
+  )cpp",
+
+  R"cpp(/// variable template decls
+template 
+T var = T();
+
+template <>
+double [[var]] = 10;
+
+double y = va^r;
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23610: [ARM] Add pre-defined macros for ROPI and RWPI

2019-02-18 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

Sorry for the delay, this fell out of my radar and just saw the ping now.

Given it's in ACLE and there are only mechanical (obvious) changes, LGTM.

I'm assuming those two parameters are already accepted in the LLVM back-end, 
right?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D23610



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


[PATCH] D57910: [ASTImporter] Find previous friend function template

2019-02-18 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 187212.
martong added a comment.

Rebase to master


Repository:
  rC Clang

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

https://reviews.llvm.org/D57910

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -5390,6 +5390,33 @@
   EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
 }
 
+struct ImportFriendFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  class X {
+template  friend void foo();
+  };
+  )",
+  Lang_CXX);
+  auto *Friend = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl(hasName("foo")));
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  void foo();
+  )",
+  Lang_CXX);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("foo")));
+  auto *Imported = Import(FromFoo, Lang_CXX);
+
+  // FIXME Currently chains of FunctionTemplateDecls are not implemented.
+  //EXPECT_EQ(Imported->getPreviousDecl(), Friend);
+  EXPECT_EQ(Imported, Friend);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5408,6 +5435,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClasses,
 DefaultTestValuesForRunOptions, );
 
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5540,7 +5540,7 @@
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
   if (!LexicalDC->isFunctionOrMethod()) {
-unsigned IDNS = Decl::IDNS_Ordinary;
+unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
   if (!FoundDecl->isInIdentifierNamespace(IDNS))


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -5390,6 +5390,33 @@
   EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
 }
 
+struct ImportFriendFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  class X {
+template  friend void foo();
+  };
+  )",
+  Lang_CXX);
+  auto *Friend = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl(hasName("foo")));
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  void foo();
+  )",
+  Lang_CXX);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("foo")));
+  auto *Imported = Import(FromFoo, Lang_CXX);
+
+  // FIXME Currently chains of FunctionTemplateDecls are not implemented.
+  //EXPECT_EQ(Imported->getPreviousDecl(), Friend);
+  EXPECT_EQ(Imported, Friend);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5408,6 +5435,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClasses,
 DefaultTestValuesForRunOptions, );
 
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5540,7 +5540,7 @@
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
   if (!LexicalDC->isFunctionOrMethod()) {
-unsigned IDNS = Decl::IDNS_Ordinary;
+unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
   if (!FoundDecl->isInIdentifierNamespace(IDNS))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57910: [ASTImporter] Find previous friend function template

2019-02-18 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 187211.
martong added a comment.

- Add FIXME


Repository:
  rC Clang

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

https://reviews.llvm.org/D57910

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -5083,6 +5083,33 @@
 ParameterizedTests, CanonicalRedeclChain,
 ::testing::Values(ArgVector()),);
 
+struct ImportFriendFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  class X {
+template  friend void foo();
+  };
+  )",
+  Lang_CXX);
+  auto *Friend = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl(hasName("foo")));
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  void foo();
+  )",
+  Lang_CXX);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("foo")));
+  auto *Imported = Import(FromFoo, Lang_CXX);
+
+  // FIXME Currently chains of FunctionTemplateDecls are not implemented.
+  //EXPECT_EQ(Imported->getPreviousDecl(), Friend);
+  EXPECT_EQ(Imported, Friend);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5101,6 +5128,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClasses,
 DefaultTestValuesForRunOptions, );
 
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5529,7 +5529,7 @@
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
   if (!LexicalDC->isFunctionOrMethod()) {
-unsigned IDNS = Decl::IDNS_Ordinary;
+unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
   if (!FoundDecl->isInIdentifierNamespace(IDNS))


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -5083,6 +5083,33 @@
 ParameterizedTests, CanonicalRedeclChain,
 ::testing::Values(ArgVector()),);
 
+struct ImportFriendFunctionTemplates : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportFriendFunctionTemplates, LookupShouldFindPreviousFriend) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  class X {
+template  friend void foo();
+  };
+  )",
+  Lang_CXX);
+  auto *Friend = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl(hasName("foo")));
+
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  void foo();
+  )",
+  Lang_CXX);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("foo")));
+  auto *Imported = Import(FromFoo, Lang_CXX);
+
+  // FIXME Currently chains of FunctionTemplateDecls are not implemented.
+  //EXPECT_EQ(Imported->getPreviousDecl(), Friend);
+  EXPECT_EQ(Imported, Friend);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5101,6 +5128,9 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFriendFunctionTemplates,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClasses,
 DefaultTestValuesForRunOptions, );
 
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -5529,7 +5529,7 @@
   // Try to find a function in our own ("to") context with the same name, same
   // type, and in the same context as the function we're importing.
   if (!LexicalDC->isFunctionOrMethod()) {
-unsigned IDNS = Decl::IDNS_Ordinary;
+unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_OrdinaryFriend;
 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
 for (auto *FoundDecl : FoundDecls) {
   if (!FoundDecl->isInIdentifierNamespace(IDNS))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354259 - [ASTImporter] Unify redecl chain tests as type parameterized tests

2019-02-18 Thread Gabor Marton via cfe-commits
Author: martong
Date: Mon Feb 18 03:09:56 2019
New Revision: 354259

URL: http://llvm.org/viewvc/llvm-project?rev=354259=rev
Log:
[ASTImporter] Unify redecl chain tests as type parameterized tests

Summary:
This patch unifies all those tests which check the correctness of the
redecl chains. Previously we had several structurally very similar test
cases for each language construct (class, function, variable, function
template, ...).

We still use value-parameterized tests for the different AST
compatibility switches (-fdelayed-template-parsing, -fms-compatibility).
Gtest makes it possible to have either value-parameterized or
type-parameterized fixtures. However, we cannot have both value- and
type-parameterized test fixtures. So we use a value-parameterized test
fixture in the gtest sense. We intend to mimic gtest's type-parameters
via the type template parameter. We manually instantiate the different
tests with the each types.

After this patch I am planning to put the "generic redecl chain" related
tests into their own separate test file (in another patch).

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

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

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=354259=354258=354259=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Feb 18 03:09:56 2019
@@ -2008,33 +2008,6 @@ TEST_P(ASTImporterOptionSpecificTestBase
 
 struct ImportFunctions : ASTImporterOptionSpecificTestBase {};
 
-TEST_P(ImportFunctions,
-   DefinitionShouldBeImportedAsDefintionWhenThereIsAPrototype) {
-  Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD = // Definition
-  LastDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions, DefinitionShouldBeImportedAsADefinition) {
-  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, ImportPrototypeOfRecursiveFunction) {
   Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX);
   auto Pattern = functionDecl(hasName("f"));
@@ -2071,138 +2044,6 @@ TEST_P(ImportFunctions, ImportDefinition
   EXPECT_EQ(To1->getPreviousDecl(), To0);
 }
 
-TEST_P(ImportFunctions, ImportPrototypes) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  auto *To1 = LastDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_FALSE(To0->doesThisDeclarationHaveABody());
-  EXPECT_FALSE(To1->doesThisDeclarationHaveABody());
-  EXPECT_EQ(To1->getPreviousDecl(), To0);
-}
-
-TEST_P(ImportFunctions, ImportDefinitions) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f(){};", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_TRUE(To0->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions, ImportDefinitionThenPrototype) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-ImportedD = Import(FromD, 

[PATCH] D57236: [ASTImporter] Unify redecl chain tests as type parameterized tests

2019-02-18 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354259: [ASTImporter] Unify redecl chain tests as type 
parameterized tests (authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57236

Files:
  cfe/trunk/unittests/AST/ASTImporterTest.cpp

Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -2008,33 +2008,6 @@
 
 struct ImportFunctions : ASTImporterOptionSpecificTestBase {};
 
-TEST_P(ImportFunctions,
-   DefinitionShouldBeImportedAsDefintionWhenThereIsAPrototype) {
-  Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD = // Definition
-  LastDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions, DefinitionShouldBeImportedAsADefinition) {
-  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, ImportPrototypeOfRecursiveFunction) {
   Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX);
   auto Pattern = functionDecl(hasName("f"));
@@ -2071,138 +2044,6 @@
   EXPECT_EQ(To1->getPreviousDecl(), To0);
 }
 
-TEST_P(ImportFunctions, ImportPrototypes) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  auto *To1 = LastDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_FALSE(To0->doesThisDeclarationHaveABody());
-  EXPECT_FALSE(To1->doesThisDeclarationHaveABody());
-  EXPECT_EQ(To1->getPreviousDecl(), To0);
-}
-
-TEST_P(ImportFunctions, ImportDefinitions) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f(){};", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_TRUE(To0->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions, ImportDefinitionThenPrototype) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  auto *To1 = LastDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_TRUE(To0->doesThisDeclarationHaveABody());
-  EXPECT_FALSE(To1->doesThisDeclarationHaveABody());
-  EXPECT_EQ(To1->getPreviousDecl(), To0);
-}
-
-TEST_P(ImportFunctions, ImportPrototypeThenDefinition) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input0.cc");
-FunctionDecl *FromD =
-FirstDeclMatcher().match(FromTU, Pattern);
-
-Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input1.cc");
-FunctionDecl *FromD =
-FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl 

[PATCH] D23610: [ARM] Add pre-defined macros for ROPI and RWPI

2019-02-18 Thread Oliver Stannard via Phabricator via cfe-commits
olista01 added a comment.

These macros have been in the published ACLE for a while now: 
https://developer.arm.com/products/software-development-tools/compilers/arm-compiler-5/docs/101028/latest/5-feature-test-macros#position-independent-code


Repository:
  rL LLVM

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

https://reviews.llvm.org/D23610



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


[PATCH] D58341: [clangd] Index UsingDecls

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 187209.
kadircet added a comment.

- Update USR to include "UD"


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341

Files:
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/SymbolInfoTests.cpp


Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -167,7 +167,8 @@
 )cpp",
   {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"),
CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"),
-   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}},
+   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"),
+   CreateExpectedSymbolDetails("foo", "bar::", 
"c:@N@bar@UD@foo")}},
   {
   R"cpp( // Multiple symbols returned - implicit conversion
   struct foo {};
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -325,9 +325,6 @@
 // Namespace alias
 namespace baz = bar;
 
-// FIXME: using declaration is not supported as the IndexAction will ignore
-// implicit declarations (the implicit using shadow declaration) by 
default,
-// and there is no way to customize this behavior at the moment.
 using bar::v2;
 } // namespace foo
   )";
@@ -354,6 +351,7 @@
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+   AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
 }
 
@@ -1118,6 +1116,17 @@
   AllOf(QName("Public"), Not(ImplementationDetail();
 }
 
+TEST_F(SymbolCollectorTest, UsingDecl) {
+  const std::string Header = R"(
+  void foo();
+  namespace std {
+using ::foo;
+  }
+  )";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -167,7 +167,8 @@
 )cpp",
   {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"),
CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"),
-   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}},
+   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"),
+   CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@UD@foo")}},
   {
   R"cpp( // Multiple symbols returned - implicit conversion
   struct foo {};
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -325,9 +325,6 @@
 // Namespace alias
 namespace baz = bar;
 
-// FIXME: using declaration is not supported as the IndexAction will ignore
-// implicit declarations (the implicit using shadow declaration) by default,
-// and there is no way to customize this behavior at the moment.
 using bar::v2;
 } // namespace foo
   )";
@@ -354,6 +351,7 @@
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+   AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
 }
 
@@ -1118,6 +1116,17 @@
   AllOf(QName("Public"), Not(ImplementationDetail();
 }
 
+TEST_F(SymbolCollectorTest, UsingDecl) {
+  const std::string Header = R"(
+  void foo();
+  namespace std {
+using ::foo;
+  }
+  )";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57236: [ASTImporter] Unify redecl chain tests as type parameterized tests

2019-02-18 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 187206.
martong marked 2 inline comments as done.
martong added a comment.

Rebase to master


Repository:
  rC Clang

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

https://reviews.llvm.org/D57236

Files:
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -2008,33 +2008,6 @@
 
 struct ImportFunctions : ASTImporterOptionSpecificTestBase {};
 
-TEST_P(ImportFunctions,
-   DefinitionShouldBeImportedAsDefintionWhenThereIsAPrototype) {
-  Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD = // Definition
-  LastDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions, DefinitionShouldBeImportedAsADefinition) {
-  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, ImportPrototypeOfRecursiveFunction) {
   Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX);
   auto Pattern = functionDecl(hasName("f"));
@@ -2071,138 +2044,6 @@
   EXPECT_EQ(To1->getPreviousDecl(), To0);
 }
 
-TEST_P(ImportFunctions, ImportPrototypes) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  auto *To1 = LastDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_FALSE(To0->doesThisDeclarationHaveABody());
-  EXPECT_FALSE(To1->doesThisDeclarationHaveABody());
-  EXPECT_EQ(To1->getPreviousDecl(), To0);
-}
-
-TEST_P(ImportFunctions, ImportDefinitions) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f(){};", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_TRUE(To0->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions, ImportDefinitionThenPrototype) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  Decl *ImportedD;
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input0.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-ImportedD = Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input1.cc");
-auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  auto *To0 = FirstDeclMatcher().match(ToTU, Pattern);
-  auto *To1 = LastDeclMatcher().match(ToTU, Pattern);
-  EXPECT_TRUE(ImportedD == To0);
-  EXPECT_TRUE(To0->doesThisDeclarationHaveABody());
-  EXPECT_FALSE(To1->doesThisDeclarationHaveABody());
-  EXPECT_EQ(To1->getPreviousDecl(), To0);
-}
-
-TEST_P(ImportFunctions, ImportPrototypeThenDefinition) {
-  auto Pattern = functionDecl(hasName("f"));
-
-  {
-Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input0.cc");
-FunctionDecl *FromD =
-FirstDeclMatcher().match(FromTU, Pattern);
-
-Import(FromD, Lang_CXX);
-  }
-  {
-Decl *FromTU = getTuDecl("void f(){}", Lang_CXX, "input1.cc");
-FunctionDecl *FromD =
-FirstDeclMatcher().match(FromTU, Pattern);
-Import(FromD, Lang_CXX);
-  }
-
-  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
-  ASSERT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-  FunctionDecl *ProtoD = FirstDeclMatcher().match(ToTU, Pattern);
-  

[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 187208.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rC Clang

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

https://reviews.llvm.org/D58340

Files:
  lib/Index/IndexDecl.cpp
  lib/Index/USRGeneration.cpp
  test/Index/usrs.cpp
  unittests/Index/IndexTests.cpp


Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -134,6 +134,19 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/usrs.cpp
===
--- test/Index/usrs.cpp
+++ test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -111,7 +111,11 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@UD@";
+
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -583,6 +583,7 @@
 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
 const NamedDecl *Parent = dyn_cast(DC);
 
+IndexCtx.handleDecl(D);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
 for (const auto *I : D->shadows())


Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -134,6 +134,19 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/usrs.cpp
===
--- test/Index/usrs.cpp
+++ test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -111,7 +111,11 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@UD@";
+
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -583,6 +583,7 @@
 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
 const NamedDecl *Parent = dyn_cast(DC);
 
+IndexCtx.handleDecl(D);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
 for (const auto *I : D->shadows())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58190: [clangd] Add tests for template specializations

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: unittests/clangd/XRefsTests.cpp:376
+}
+  )cpp",
   };

While here, could wee add tests for a few more cases? They are all represented 
by different classes in a hierarchy in clang, so each could potentially break:
```
/// partial template specialization
template 
struct Foo {};
^Foo x;

/// function template specializations
template 
void foo(T);
template <>
void foo(int);

int x = fo^o(10);

/// variable template decls
template 
T var = T();

template <>
double var = 10;

double y = va^r;
```


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58190



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


[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/IncludeFixer.h:85
+  // name or incomplete type in one parse, especially when code is
+  // copy-and-pasted without #includes. As fixes are purely dependent on index
+  // requests and index results at this point, we can cache fixes by index

sammccall wrote:
> This seems pretty messy (the assumption that Fix depends only on the index 
> lookup).
> It saves some code now at the expense of being magic. If we want to e.g. 
> insert qualifiers too, I worry it's going to (stop us || return incorrect 
> cached results || lead to unneccesary cache misses) depending on what we do.
> 
> What would we need to store to calculate Fix?
> Maybe a struct ResolvedSymbol with {scope, name, inserted header}? (or even 
> the edit to insert the header)
> If it's not hugely complicated, that seems both cleaner and more extensible - 
> wdyt?
Yeah, surely this was too hacky ;)

Instead of a new struct, how about simply storing `SymbolSlab`s?  We are 
already building symbol slabs for fuzzy find results. And there are some 
helpers that take only `Symbol`. WDYT?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58239



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


[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 187205.
ioeric marked 4 inline comments as done.
ioeric added a comment.

- address review comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58239

Files:
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -449,6 +449,44 @@
   UnorderedElementsAre(Diag(Test.range(), "no member named 'xy' in 'X'")));
 }
 
+TEST(IncludeFixerTest, UseCachedIndexResults) {
+  // As index results for the identical request are cached, more than 5 fixes
+  // are generated.
+  Annotations Test(R"cpp(
+$insert[[]]void foo() {
+  $x1[[X]] x;
+  $x2[[X]] x;
+  $x3[[X]] x;
+  $x4[[X]] x;
+  $x5[[X]] x;
+  $x6[[X]] x;
+  $x7[[X]] x;
+}
+
+class X;
+void bar(X *x) {
+  x$a1[[->]]f();
+  x$a2[[->]]f();
+  x$a3[[->]]f();
+  x$a4[[->]]f();
+  x$a5[[->]]f();
+  x$a6[[->]]f();
+  x$a7[[->]]f();
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index =
+  buildIndexWithSymbol(SymbolWithHeader{"X", "unittest:///a.h", "\"a.h\""});
+  TU.ExternalIndex = Index.get();
+
+  auto Parsed = TU.build();
+  for (const auto  : Parsed.getDiagnostics()) {
+EXPECT_EQ(D.Fixes.size(), 1u);
+EXPECT_EQ(D.Fixes[0].Message,
+  std::string("Add include \"a.h\" for symbol X"));
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/IncludeFixer.h
===
--- clangd/IncludeFixer.h
+++ clangd/IncludeFixer.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 
@@ -51,7 +52,7 @@
   std::vector fixIncompleteType(const Type ) const;
 
   /// Generates header insertion fixes for all symbols. Fixes are deduplicated.
-  std::vector fixesForSymbols(llvm::ArrayRef Syms) const;
+  std::vector fixesForSymbols(const SymbolSlab ) const;
 
   struct UnresolvedName {
 std::string Name;   // E.g. "X" in foo::X.
@@ -79,6 +80,14 @@
   // These collect the last unresolved name so that we can associate it with the
   // diagnostic.
   llvm::Optional LastUnresolvedName;
+
+  // There can be multiple diagnostics that are caused by the same unresolved
+  // name or incomplete type in one parse, especially when code is
+  // copy-and-pasted without #includes. We cache the index results based on
+  // index requests (assuming index results are consistent during the single AST
+  // parse).
+  mutable llvm::StringMap FuzzyFindCache;
+  mutable llvm::DenseMap LookupCache;
 };
 
 } // namespace clangd
Index: clangd/IncludeFixer.cpp
===
--- clangd/IncludeFixer.cpp
+++ clangd/IncludeFixer.cpp
@@ -57,8 +57,6 @@
 
 std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic ) const {
-  if (IndexRequestCount >= IndexRequestLimit)
-return {}; // Avoid querying index too many times in a single parse.
   switch (Info.getID()) {
   case diag::err_incomplete_type:
   case diag::err_incomplete_member_access:
@@ -118,26 +116,34 @@
   auto ID = getSymbolID(TD);
   if (!ID)
 return {};
-  ++IndexRequestCount;
-  // FIXME: consider batching the requests for all diagnostics.
-  // FIXME: consider caching the lookup results.
   LookupRequest Req;
   Req.IDs.insert(*ID);
-  llvm::Optional Matched;
-  Index.lookup(Req, [&](const Symbol ) {
-if (Matched)
-  return;
-Matched = Sym;
-  });
 
-  if (!Matched || Matched->IncludeHeaders.empty() || !Matched->Definition ||
-  Matched->CanonicalDeclaration.FileURI != Matched->Definition.FileURI)
+  auto I = LookupCache.find(*ID);
+  if (I != LookupCache.end())
+return fixesForSymbols(I->second);
+
+  if (IndexRequestCount >= IndexRequestLimit)
 return {};
-  return fixesForSymbols({*Matched});
+  IndexRequestCount++;
+
+  // FIXME: consider batching the requests for all diagnostics.
+  SymbolSlab::Builder Matches;
+  Index.lookup(Req, [&](const Symbol ) { Matches.insert(Sym); });
+  auto Syms = std::move(Matches).build();
+
+  std::vector Fixes;
+  if (!Syms.empty()) {
+auto  = *Syms.begin();
+if (!Matched.IncludeHeaders.empty() && Matched.Definition &&
+Matched.CanonicalDeclaration.FileURI == Matched.Definition.FileURI)
+  Fixes = fixesForSymbols(Syms);
+  }
+  LookupCache[*ID] = std::move(Syms);
+  return Fixes;
 }
 
-std::vector
-IncludeFixer::fixesForSymbols(llvm::ArrayRef Syms) const {
+std::vector IncludeFixer::fixesForSymbols(const SymbolSlab ) const {
   auto Inserted = [&](const Symbol , llvm::StringRef Header)
   -> llvm::Expected> {

[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Index/IndexDecl.cpp:588
  D->getLexicalDeclContext());
+IndexCtx.handleDecl(D);
 for (const auto *I : D->shadows())

Any reason to add this to the middle of the function?
Could we move it to the end or to the start of the function instead? 

So that the function logically reads as 
```
visitDecl();
traverseSubdecls();
processReferences();
```



Comment at: lib/Index/USRGeneration.cpp:115
+VisitDeclContext(D->getDeclContext());
+Out << "@";
+

We need to add a unique tag character here, e.g. namespace aliases are tagged 
as `"@NA@"`, `"@UD@"` should be a good fit for using-decls.



Comment at: lib/Index/USRGeneration.cpp:118
+if (EmitDeclName(D)) {
+  // The string can be empty if the declaration has no name; e.g., it is
+  // the ParmDecl with no name for declaration of a function pointer type,

This comment does not make sense for the using-decl, `ParmDecl` is not a 
using-decl.
If there are other cases where it may fail, let's put them into the comment.
If `EmitDeclName` should not fail for `UsingDecl`, let's add an assertion.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58340



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


[PATCH] D58185: [clangd] Handle unresolved scope specifier when fixing includes.

2019-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/IncludeFixer.cpp:208
+SM.getBufferData(SM.getDecomposedLoc(Typo.getLoc()).first, );
+assert(!Invalid);
 // Extract the typed scope. This is not done lazily because `SS` can get

No idea when this can be invalid, but we could just return here?



Comment at: clangd/IncludeFixer.cpp:211
 // out of scope and it's relatively cheap.
 llvm::Optional SpecifiedScope;
+// Extra scope to append to the query scopes. This is useful, for example,

We can be more precise about this now I think: IIUC this is the **resolved** 
specified scope.
in two senses: it's the part of what was typed that was resolved, and it's in 
its resolved form not its typed form (think `namespace clang { clangd::x }` --> 
`clang::clangd::`)



Comment at: clangd/IncludeFixer.cpp:212
 llvm::Optional SpecifiedScope;
+// Extra scope to append to the query scopes. This is useful, for example,
+// when the unresolved name is a qualier, in which case we use the name 
that

nit: I don't think this is an example, it's the only case right?

Consider calling this UnresolvedSpecifiedScope



Comment at: clangd/IncludeFixer.cpp:213
+// Extra scope to append to the query scopes. This is useful, for example,
+// when the unresolved name is a qualier, in which case we use the name 
that
+// comes after it as the name to resolve and use the qualifier as the extra

nit: qualier -> qualifier
accissible -> accessible



Comment at: clangd/IncludeFixer.cpp:216
+// scope in the accissible scopes.
+llvm::Optional ExtraScope;
 if (SS && SS->isNotEmpty()) { // "::" or "ns::"

I'm a bit concerned about how this mixes extraction of scopes from the source 
code/AST (which is now *really* complicated) with building the query and 
assembling the correction.

Can we reasonably extract the former to a helper function? Not sure exactly 
what the signature would be, but it would be helpful to find out.

The other thing is I think this has a lot in common with the scope-wrangling 
code in CodeComplete, and could *maybe* be unified a bit once isolated.



Comment at: clangd/IncludeFixer.cpp:235
+  std::string Spelling = (Code.substr(B, E - B) + "::").str();
+  if (llvm::StringRef(SpecifiedNS).endswith(Spelling))
+SpecifiedScope = SpecifiedNS;

hmm, won't this heuristic have false positives?
```
// indexed-header.h
namespace a { int X; }

// main-file.cc
namespace b = a;
namespace c { int Y = b::x; }
```
I worry spelling is going to be "b::" here, while SpecifiedNS is going to be 
"a::".



Comment at: clangd/IncludeFixer.cpp:315
 private:
+  // Returns the idenfiers qualified by an unresolved name. \p Offset is the
+  // first character after the unresolved name in \p Code. For the example

identifiers



Comment at: clangd/IncludeFixer.cpp:320
+  //~~
+  llvm::Optional qualifiedByUnresolved(llvm::StringRef Code,
+size_t Offset) const {

this only depends on the params right?
This could be static or even moved out of the class.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58185



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


[PATCH] D58341: [clangd] Index UsingDecls

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, jdoerfert, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.
Herald added a project: clang.

D58340  enables indexing of USRs, this makes 
sure test in clangd are
aligned with the change


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58341

Files:
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/SymbolInfoTests.cpp


Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -167,7 +167,8 @@
 )cpp",
   {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"),
CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"),
-   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}},
+   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"),
+   CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@foo")}},
   {
   R"cpp( // Multiple symbols returned - implicit conversion
   struct foo {};
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -325,9 +325,6 @@
 // Namespace alias
 namespace baz = bar;
 
-// FIXME: using declaration is not supported as the IndexAction will ignore
-// implicit declarations (the implicit using shadow declaration) by 
default,
-// and there is no way to customize this behavior at the moment.
 using bar::v2;
 } // namespace foo
   )";
@@ -354,6 +351,7 @@
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+   AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
 }
 
@@ -1118,6 +1116,17 @@
   AllOf(QName("Public"), Not(ImplementationDetail();
 }
 
+TEST_F(SymbolCollectorTest, UsingDecl) {
+  const std::string Header = R"(
+  void foo();
+  namespace std {
+using ::foo;
+  }
+  )";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -167,7 +167,8 @@
 )cpp",
   {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"),
CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"),
-   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}},
+   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"),
+   CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@foo")}},
   {
   R"cpp( // Multiple symbols returned - implicit conversion
   struct foo {};
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -325,9 +325,6 @@
 // Namespace alias
 namespace baz = bar;
 
-// FIXME: using declaration is not supported as the IndexAction will ignore
-// implicit declarations (the implicit using shadow declaration) by default,
-// and there is no way to customize this behavior at the moment.
 using bar::v2;
 } // namespace foo
   )";
@@ -354,6 +351,7 @@
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+   AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
 }
 
@@ -1118,6 +1116,17 @@
   AllOf(QName("Public"), Not(ImplementationDetail();
 }
 
+TEST_F(SymbolCollectorTest, UsingDecl) {
+  const std::string Header = R"(
+  void foo();
+  namespace std {
+using ::foo;
+  }
+  )";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: ilya-biryukov, akyrtzi.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

Add indexing of UsingDecl itself.
Also enable generation of USRs for UsingDecls, using the qualified name of the
decl.


Repository:
  rC Clang

https://reviews.llvm.org/D58340

Files:
  lib/Index/IndexDecl.cpp
  lib/Index/USRGeneration.cpp
  test/Index/usrs.cpp
  unittests/Index/IndexTests.cpp


Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -134,6 +134,19 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/usrs.cpp
===
--- test/Index/usrs.cpp
+++ test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -111,7 +111,16 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@";
+
+if (EmitDeclName(D)) {
+  // The string can be empty if the declaration has no name; e.g., it is
+  // the ParmDecl with no name for declaration of a function pointer type,
+  // e.g.: void  (*f)(void *);
+  // In this case, don't generate a USR.
+  IgnoreResults = true;
+}
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -585,6 +585,7 @@
 
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
+IndexCtx.handleDecl(D);
 for (const auto *I : D->shadows())
   IndexCtx.handleReference(I->getUnderlyingDecl(), D->getLocation(), 
Parent,
D->getLexicalDeclContext(), SymbolRoleSet());


Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -134,6 +134,19 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/usrs.cpp
===
--- test/Index/usrs.cpp
+++ test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -111,7 +111,16 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@";
+
+if (EmitDeclName(D)) {
+  // The string can be empty if the declaration has no name; e.g., it is
+  // the ParmDecl with no name for declaration of a function pointer type,
+  // e.g.: void  (*f)(void *);
+  // In this case, don't generate a USR.
+  IgnoreResults = true;
+}
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -585,6 +585,7 @@
 
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
+

[PATCH] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-18 Thread Hans Wennborg via Phabricator via cfe-commits
hans removed a subscriber: hansw.
hans added a comment.

In D57948#1399683 , @riccibruno wrote:

> Done, thanks!


That was https://bugs.llvm.org/show_bug.cgi?id=40742 and it's now been merged.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57948



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


Re: r354147 - Variable auto-init of blocks capturing self after init bugfix

2019-02-18 Thread Hans Wennborg via cfe-commits
Merged to release_80 in r354248.

On Fri, Feb 15, 2019 at 6:25 PM JF Bastien via cfe-commits
 wrote:
>
> Author: jfb
> Date: Fri Feb 15 09:26:29 2019
> New Revision: 354147
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354147=rev
> Log:
> Variable auto-init of blocks capturing self after init bugfix
>
> Summary:
> Blocks that capture themselves (and escape) after initialization currently 
> codegen wrong because this:
>
>   bool capturedByInit =
>   Init && emission.IsEscapingByRef && isCapturedBy(D, Init);
>
>   Address Loc =
>   capturedByInit ? emission.Addr : emission.getObjectAddress(*this);
>
> Already adjusts Loc from thr alloca to a GEP. This code:
>
> if (emission.IsEscapingByRef)
>   Loc = emitBlockByrefAddress(Loc, , /*follow=*/false);
>
> Was trying to do the same adjustment, and a GEP on a GEP (returning an int) 
> triggers an assertion.
>
> 
>
> Reviewers: ahatanak
>
> Subscribers: jkorous, dexonsmith, cfe-commits, rjmccall
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D58218
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDecl.cpp
> cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=354147=354146=354147=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Feb 15 09:26:29 2019
> @@ -1620,8 +1620,9 @@ void CodeGenFunction::EmitAutoVarInit(co
>bool capturedByInit =
>Init && emission.IsEscapingByRef && isCapturedBy(D, Init);
>
> -  Address Loc =
> -  capturedByInit ? emission.Addr : emission.getObjectAddress(*this);
> +  bool locIsByrefHeader = !capturedByInit;
> +  const Address Loc =
> +  locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
>
>// Note: constexpr already initializes everything correctly.
>LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
> @@ -1637,7 +1638,7 @@ void CodeGenFunction::EmitAutoVarInit(co
>return;
>
>  // Only initialize a __block's storage: we always initialize the header.
> -if (emission.IsEscapingByRef)
> +if (emission.IsEscapingByRef && !locIsByrefHeader)
>Loc = emitBlockByrefAddress(Loc, , /*follow=*/false);
>
>  CharUnits Size = getContext().getTypeSizeInChars(type);
> @@ -1744,10 +1745,9 @@ void CodeGenFunction::EmitAutoVarInit(co
>}
>
>llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace());
> -  if (Loc.getType() != BP)
> -Loc = Builder.CreateBitCast(Loc, BP);
> -
> -  emitStoresForConstant(CGM, D, Loc, isVolatile, Builder, constant);
> +  emitStoresForConstant(
> +  CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP),
> +  isVolatile, Builder, constant);
>  }
>
>  /// Emit an expression as an initializer for an object (variable, field, 
> etc.)
>
> Modified: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp?rev=354147=354146=354147=diff
> ==
> --- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp Fri Feb 15 09:26:29 
> 2019
> @@ -45,14 +45,35 @@ void test_block() {
>  // PATTERN:   %captured1 = getelementptr inbounds 
> %struct.__block_byref_captured, %struct.__block_byref_captured* %captured, 
> i32 0, i32 4
>  // PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
> %struct.XYZ*), %struct.XYZ** %captured1, align 8
>  // PATTERN:   %call = call %struct.XYZ* @create(
> +using Block = void (^)();
> +typedef struct XYZ {
> +  Block block;
> +} * xyz_t;
>  void test_block_self_init() {
> -  using Block = void (^)();
> -  typedef struct XYZ {
> -Block block;
> -  } * xyz_t;
>extern xyz_t create(Block block);
>__block xyz_t captured = create(^() {
> -(void)captured;
> +used(captured);
> +  });
> +}
> +
> +// Capturing with escape after initialization is also an edge case.
> +//
> +// UNINIT-LABEL:  test_block_captures_self_after_init(
> +// ZERO-LABEL:test_block_captures_self_after_init(
> +// ZERO:  %block = alloca <{ i8*, i32, i32, i8*, 
> %struct.__block_descriptor*, i8* }>, align 8
> +// ZERO:  %captured1 = getelementptr inbounds 
> %struct.__block_byref_captured.1, %struct.__block_byref_captured.1* 
> %captured, i32 0, i32 4
> +// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8
> +// ZERO:  %call = call %struct.XYZ* @create(
> +// PATTERN-LABEL: test_block_captures_self_after_init(
> +// PATTERN:   %block = alloca <{ i8*, i32, i32, i8*, 
> %struct.__block_descriptor*, i8* }>, align 8
> +// PATTERN:   %captured1 = getelementptr inbounds 
> %struct.__block_byref_captured.1, 

Re: r354035 - [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-18 Thread Hans Wennborg via cfe-commits
Merged to release_80 in r354247.

On Thu, Feb 14, 2019 at 4:42 PM Bruno Ricci via cfe-commits
 wrote:
>
> Author: brunoricci
> Date: Thu Feb 14 07:43:17 2019
> New Revision: 354035
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354035=rev
> Log:
> [Sema] Fix a regression introduced in "[AST][Sema] Remove 
> CallExpr::setNumArgs"
>
> D54902 removed CallExpr::setNumArgs in preparation of tail-allocating the
> arguments of CallExpr. It did this by allocating storage for
> max(number of arguments, number of parameters in the prototype). The
> temporarily nulled arguments however causes issues in BuildResolvedCallExpr
> when typo correction is done just after the creation of the call expression.
>
> This was unfortunately missed by the tests /:
>
> To fix this, delay setting the number of arguments to
> max(number of arguments, number of parameters in the prototype) until we are
> ready for it. It would be nice to have this encapsulated in CallExpr but this
> is the best I can come up with under the constraint that we cannot add
> anything the CallExpr.
>
> Fixes PR40286.
>
> Differential Revision: https://reviews.llvm.org/D57948
>
> Reviewed By: aaron.ballman
>
>
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/test/Sema/typo-correction.c
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=354035=354034=354035=diff
> ==
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Thu Feb 14 07:43:17 2019
> @@ -2610,6 +2610,11 @@ public:
>  NumArgs = NewNumArgs;
>}
>
> +  /// Bluntly set a new number of arguments without doing any checks 
> whatsoever.
> +  /// Only used during construction of a CallExpr in a few places in Sema.
> +  /// FIXME: Find a way to remove it.
> +  void setNumArgsUnsafe(unsigned NewNumArgs) { NumArgs = NewNumArgs; }
> +
>typedef ExprIterator arg_iterator;
>typedef ConstExprIterator const_arg_iterator;
>typedef llvm::iterator_range arg_range;
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=354035=354034=354035=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Feb 14 07:43:17 2019
> @@ -5793,18 +5793,36 @@ ExprResult Sema::BuildResolvedCallExpr(E
>}
>
>if (!getLangOpts().CPlusPlus) {
> +// Forget about the nulled arguments since typo correction
> +// do not handle them well.
> +TheCall->shrinkNumArgs(Args.size());
>  // C cannot always handle TypoExpr nodes in builtin calls and direct
>  // function calls as their argument checking don't necessarily handle
>  // dependent types properly, so make sure any TypoExprs have been
>  // dealt with.
>  ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
>  if (!Result.isUsable()) return ExprError();
> +CallExpr *TheOldCall = TheCall;
>  TheCall = dyn_cast(Result.get());
> +bool CorrectedTypos = TheCall != TheOldCall;
>  if (!TheCall) return Result;
> -// TheCall at this point has max(Args.size(), NumParams) arguments,
> -// with extra arguments nulled. We don't want to introduce nulled
> -// arguments in Args and so we only take the first Args.size() arguments.
> -Args = llvm::makeArrayRef(TheCall->getArgs(), Args.size());
> +Args = llvm::makeArrayRef(TheCall->getArgs(), TheCall->getNumArgs());
> +
> +// A new call expression node was created if some typos were corrected.
> +// However it may not have been constructed with enough storage. In this
> +// case, rebuild the node with enough storage. The waste of space is
> +// immaterial since this only happens when some typos were corrected.
> +if (CorrectedTypos && Args.size() < NumParams) {
> +  if (Config)
> +TheCall = CUDAKernelCallExpr::Create(
> +Context, Fn, cast(Config), Args, ResultTy, VK_RValue,
> +RParenLoc, NumParams);
> +  else
> +TheCall = CallExpr::Create(Context, Fn, Args, ResultTy, VK_RValue,
> +   RParenLoc, NumParams, UsesADL);
> +}
> +// We can now handle the nulled arguments for the default arguments.
> +TheCall->setNumArgsUnsafe(std::max(Args.size(), NumParams));
>}
>
>// Bail out early if calling a builtin with custom type checking.
>
> Modified: cfe/trunk/test/Sema/typo-correction.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=354035=354034=354035=diff
> ==
> --- cfe/trunk/test/Sema/typo-correction.c (original)
> +++ cfe/trunk/test/Sema/typo-correction.c Thu Feb 14 07:43:17 2019
> @@ 

[PATCH] D57087: [clang-tidy] add OverrideMacro to modernize-use-override check

2019-02-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D57087#1400578 , @malcolm.parsons 
wrote:

> Some Clang warnings use PP.getLastMacroWithSpelling() to determine the user's 
> macro automatically.


This would be a neat trick, but mainly I think users would either be using 
override/final or they would know what they were using say OVERRIDE/FINAL 
because it might be set by a convention for a code base, so maybe its better if 
they are explicit in their tidy options


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

https://reviews.llvm.org/D57087



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-18 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Yeah, it seems upstream has moved away due to @Szelethus' implementation of a 
much more manageable "checker dependency" system. You most likely will have to 
rebase your patch first, then check what you missed which got added to other 
merged, existing checkers.


Repository:
  rC Clang

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

https://reviews.llvm.org/D50488



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