IntegerLiteral.cpp 1001 B

1234567891011121314151617181920212223242526272829303132
  1. //===- unittest/Tooling/RecursiveASTVisitorTests/IntegerLiteral.cpp -------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "TestVisitor.h"
  9. using namespace clang;
  10. namespace {
  11. // Check to ensure that implicit default argument expressions are visited.
  12. class IntegerLiteralVisitor
  13. : public ExpectedLocationVisitor<IntegerLiteralVisitor> {
  14. public:
  15. bool VisitIntegerLiteral(const IntegerLiteral *IL) {
  16. Match("literal", IL->getLocation());
  17. return true;
  18. }
  19. };
  20. TEST(RecursiveASTVisitor, DefaultArgumentsAreVisited) {
  21. IntegerLiteralVisitor Visitor;
  22. Visitor.ExpectMatch("literal", 1, 15, 2);
  23. EXPECT_TRUE(Visitor.runOver("int f(int i = 1);\n"
  24. "static int k = f();\n"));
  25. }
  26. } // end anonymous namespace