summaryrefslogtreecommitdiff
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
* [clang-format] Ignore first token when finding MustBreakEmilia Kond2023-05-181-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | When in ColumnLimit 0, the formatter looks for MustBreakBefore in the line in order to check if a line is allowed to be merged onto one line. However, since MustBreakBefore is really a property of the gap between the token and the one previously, I belive the check is erroneous in checking all the tokens in a line, since whether the previous line ended with a forced line break should have no effect on whether the current line is allowed to merge with the next one. This patch changes the check to skip the first token in `LineJoiner.containsMustBreak`. This patch also changes a test, which is not ideal, but I believe the test also suffered from this bug. The test case in question sets AllowShortFunctionsOnASingleLine to "Empty", but the empty function in said test case isn't merged to a single line, because of the very same bug this patch fixes. Fixes https://github.com/llvm/llvm-project/issues/62721 Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay Differential Revision: https://reviews.llvm.org/D150614
* [clang-format] Don't allow template to be preceded by closing braceEmilia Kond2023-05-172-0/+18
| | | | | | | | | | | | | | This check is similar to the right paren check right below it, but it doesn't need the overloaded operator check. This patch prevents brace-initialized objects that are being compared from being mis-annotated as template parameters. Fixes https://github.com/llvm/llvm-project/issues/57004 Reviewed By: owenpan, MyDeveloperDay Differential Revision: https://reviews.llvm.org/D150629
* [clang-format] Handle <chrono> ud suffixes in IntegerLiteralSeparatorOwen Pan2023-05-161-0/+18
| | | | | | Fixes #62679. Differential Revision: https://reviews.llvm.org/D150539
* Revert "[clang-repl] Introduce Value to capture expression results"Jun Zhang2023-05-162-100/+2
| | | | | This reverts commit a423b7f1d7ca8b263af85944f57a69aa08fc942c. See https://lab.llvm.org/buildbot/#/changes/95083
* [clang-repl] Introduce Value to capture expression resultsJun Zhang2023-05-162-2/+100
| | | | | | | | | | | | | | | | | | | | | | | | | This is the second part of the below RFC: https://discourse.llvm.org/t/rfc-handle-execution-results-in-clang-repl/68493 This patch implements a Value class that can be used to carry expression results in clang-repl. In other words, when we see a top expression without semi, it will be captured and stored to a Value object. You can explicitly specify where you want to store the object, like: ``` Value V; llvm::cantFail(Interp->ParseAndExecute("int x = 42;")); llvm::cantFail(Interp->ParseAndExecute("x", &V)); ``` `V` now stores some useful infomation about `x`, you can get its real value (42), it's `clang::QualType` or anything interesting. However, if you don't specify the optional argument, it will be captured to a local variable, and automatically called `Value::dump`, which is not implemented yet in this patch. Signed-off-by: Jun Zhang <jun@junz.org>
* [clang-format] Stop comment disrupting indentation of Verilog portssstwcw2023-05-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` module x #( // parameter x) ( // input y); endmodule ``` After: ``` module x #(// parameter x) (// input y); endmodule ``` If the first line in a port or parameter list is not a comment, the following lines will be aligned to the first line as intended: ``` module x #(parameter x1, parameter x2) (input y, input y2); endmodule ``` Previously, the indentation would be changed to an extra continuation indentation relative to the start of the parenthesis or the hash if the first token inside the parentheses was a comment. It is a feature introduced in ddaa9be97839. The feature enabled one to insert a `//` comment right after an opening parentheses to put the function arguments on a new line with a small indentation regardless of how long the function name is, like this: ``` someFunction(anotherFunction( // Force break. parameter)); ``` People are unlikely to use this feature in a Verilog port list because the formatter already puts the port list on its own lines. A comment at the start of a port list is probably a comment for the port on the next line. We also removed the space before the comment so that its indentation would be same as that for a line comment anywhere else in the port list. Reviewed By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D149562
* Revert "[clang][deps] Only cache files with specific extension"Jan Svoboda2023-05-151-127/+0
| | | | | | This reverts commit d1e00b6f136ec71a4c95a7eb4fd81ec0ab547962. Internally, there were issues with caching stat failures for .framework directories. We need some time for investigation to pinpoint what exactly was going wrong.
* clang-format: [JS] terminate import sorting on `export type X = Y`Jan Kuhle2023-05-151-0/+9
| | | | | | | | | | Contributed by @jankuehle! https://reviews.llvm.org/D150116 introduced a bug. `export type X = Y` was considered an export declaration and took part in import sorting. This is not correct. With this change `export type X = Y` properly terminates import sorting. Reviewed By: krasimir Differential Revision: https://reviews.llvm.org/D150563
* [clang][dataflow] Don't analyze templated declarations.Martin Braenne2023-05-153-33/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Attempting to analyze templated code doesn't have a good cost-benefit ratio. We have so far done a best-effort attempt at this, but maintaining this support has an ongoing high maintenance cost because the AST for templates can violate a lot of the invariants that otherwise hold for the AST of concrete code. As just one example, in concrete code the operand of a UnaryOperator '*' is always a prvalue (https://godbolt.org/z/s3e5xxMd1), but in templates this isn't true (https://godbolt.org/z/6W9xxGvoM). Further rationale for not analyzing templates: * The semantics of a template itself are weakly defined; semantics can depend strongly on the concrete template arguments. Analyzing the template itself (as opposed to an instantiation) therefore has limited value. * Analyzing templates requires a lot of special-case code that isn't necessary for concrete code because dependent types are hard to deal with and the AST violates invariants that otherwise hold for concrete code (see above). * There's precedent in that neither Clang Static Analyzer nor the flow-sensitive warnings in Clang (such as uninitialized variables) support analyzing templates. Reviewed By: gribozavr2, xazax.hun Differential Revision: https://reviews.llvm.org/D150352
* [clang][dataflow] Eliminate `SkipPast::ReferenceThenPointer`.Martin Braenne2023-05-151-4/+2
| | | | | | | | | | | | | | | | | | | | As a replacement, we provide the accessors `getImplicitObjectLocation()` and `getBaseObjectLocation()`, which are higher-level constructs that cover the use cases in which `SkipPast::ReferenceThenPointer` was typically used. Unfortunately, it isn't possible to use these accessors in UncheckedOptionalAccessModel.cpp; I've added a FIXME to the code explaining the details. I initially attempted to resolve the issue as part of this patch, but it turned out to be non-trivial to fix. Instead, I have therefore added a lower-level replacement for `SkipPast::ReferenceThenPointer` that is used only within this file. The wider context of this change is that `SkipPast` will be going away entirely. See also the RFC at https://discourse.llvm.org/t/70086. Reviewed By: ymandel, gribozavr2 Differential Revision: https://reviews.llvm.org/D149838
* clang-format: [JS] support import/export typeJan Kuhle2023-05-102-0/+51
| | | | | | | | | | | | | | | | | | | | | | | Contributed by @jankuehle! Users can choose to only import/export the type of the symbol (not value nor namespace) by adding a `type` keyword, e.g.: ``` import type {x} from 'y'; import {type x} from 'y'; export type {x}; export {type x}; ``` Previously, this was not handled and would: - Terminate import sorting - Remove the space before the curly bracket in `export type {` With this change, both formatting and import sorting work as expected. Reviewed By: MyDeveloperDay, krasimir Differential Revision: https://reviews.llvm.org/D150116
* [clang-format] Put a "trailing" space back in a unit testOwen Pan2023-05-091-1/+1
| | | | | | Put an intentional "trailing" space back in FormatTestComments.SplitCommentIntroducers. It was removed in a4c87f8ccacc by mistake.
* [clang][deps] Teach dep directive scanner about _PragmaBen Langmuir2023-05-091-3/+95
| | | | | | | | | | | | | | | | While we cannot handle `_Pragma` used inside macros, we can handle this at the top level, and it some projects use the `_Pragma("once")` spelling like that, which was causing spurious failures in the scanner. Limitations * Cannot handle #define ONCE _Pragma("once"), same issue as using @import in a macro -- ideally we should diagnose this in obvious cases * Our LangOpts are currently fixed, so we are not handling u"" strings or R"()" strings that require C11/C++11. rdar://108629982 Differential Revision: https://reviews.llvm.org/D149884
* [clang] Evaluate non-type default template argument when it is requiredMariya Podchishchaeva2023-05-091-2/+0
| | | | | | | | | | | | | Before this change a default template argument for a non-type template parameter was evaluated and checked immediately after it is met by parser. In some cases it is too early. Fixes https://github.com/llvm/llvm-project/issues/62224 Fixes https://github.com/llvm/llvm-project/issues/62596 Reviewed By: shafik, erichkeane, cor3ntin Differential Revision: https://reviews.llvm.org/D150108
* [clang][dataflow][NFC] Remove `SkipPast` param from `getValue(const ↵Martin Braenne2023-05-096-283/+216
| | | | | | | | | | ValueDecl &)`. This parameter was already a no-op, so removing it doesn't change behavior. Reviewed By: ymandel Differential Revision: https://reviews.llvm.org/D150137
* [clang-format] Fix consecutive alignments in #else blocksOwen Pan2023-05-082-2/+47
| | | | | | | | | | | | | | | | | | | Since 3.8 or earlier, clang-format has been lumping all #else, #elif, etc blocks together when doing whitespace replacements and causing consecutive alignments across #else blocks. Commit c077975 partially addressed the problem but also triggered "regressions". This patch fixes the root cause of the problem and "reverts" c077975 (except for the unit tests). Fixes #36070. Fixes #55265. Fixes #60721. Fixes #61498. Differential Revision: https://reviews.llvm.org/D150057
* [clang][dataflow][NFC] Remove `SkipPast` parameter from ↵Martin Braenne2023-05-084-129/+106
| | | | | | | | | | | | `getStorageLocation(const ValueDecl &). This parameter was already a no-op, so removing it doesn't change behavior. Depends On D149144 Reviewed By: ymandel, xazax.hun, gribozavr2 Differential Revision: https://reviews.llvm.org/D149151
* [clang-format] Don't indent Verilog `begin` keyword on its own linesstwcw2023-05-071-0/+33
| | | | | | | | | When the line is too long and the `begin` keyword wraps to the next line, it shouldn't be indented. Reviewed By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D149657
* [clang-format] Recognize Verilog edge identifierssstwcw2023-05-072-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the event expression would be misidentified as a port list. A line break would be added after the comma. The events can be separated with either a comma or the `or` keyword, and a line break would not be inserted if the `or` keyword was used. We changed the behavior of the comma to match the `or` keyword. Before: ``` always @(posedge x, posedge y) x <= x; always @(posedge x or posedge y) x <= x; ``` After: ``` always @(posedge x, posedge y) x <= x; always @(posedge x or posedge y) x <= x; ``` Reviewed By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D149561
* [clang] Replace None with std::nullopt in comments (NFC)Kazu Hirata2023-05-042-2/+3
| | | | | | | This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
* [clang][dataflow] Eliminate intermediate `ReferenceValue`s from ↵Martin Braenne2023-05-041-41/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Environment::DeclToLoc`. For the wider context of this change, see the RFC at https://discourse.llvm.org/t/70086. After this change, global and local variables of reference type are associated directly with the `StorageLocation` of the referenced object instead of the `StorageLocation` of a `ReferenceValue`. Some tests that explicitly check for an existence of `ReferenceValue` for a variable of reference type have been modified accordingly. As discussed in the RFC, I have added an assertion to `Environment::join()` to check that if both environments contain an entry for the same declaration in `DeclToLoc`, they both map to the same `StorageLocation`. As discussed in https://discourse.llvm.org/t/70086/5, this also necessitates removing declarations from `DeclToLoc` when they go out of scope. In the RFC, I proposed a gradual migration for this change, but it appears that all of the callers of `Environment::setStorageLocation(const ValueDecl &, SkipPast` are in the dataflow framework itself, and that there are only a few of them. As this is the function whose semantics are changing in a way that callers potentially need to adapt to, I've decided to change the semantics of the function directly. The semantics of `getStorageLocation(const ValueDecl &, SkipPast SP` now no longer depend on the behavior of the `SP` parameter. (There don't appear to be any callers that use `SkipPast::ReferenceThenPointer`, so I've added an assertion that forbids this usage.) This patch adds a default argument for the `SP` parameter and removes the explicit `SP` argument at the callsites that are touched by this change. A followup patch will remove the argument from the remaining callsites, allowing the `SkipPast` parameter to be removed entirely. (I don't want to do that in this patch so that semantics-changing changes can be reviewed separately from semantics-neutral changes.) Reviewed By: ymandel, xazax.hun, gribozavr2 Differential Revision: https://reviews.llvm.org/D149144
* [clang-format] Correctly limit formatted ranges when specifying qualifier ↵Colin Ogilvie2023-05-041-0/+23
| | | | | | | | | | | alignment The qualifier alignment fixer appeared to ignore any ranges specified for limiting formatting. This change ensures that it only formats affected lines to avoid unexpected changes. Fixes #54888. Differential Revision: https://reviews.llvm.org/D149643
* [clang][deps] Teach dep directive scanner about #pragma clang system_headerBen Langmuir2023-05-031-2/+4
| | | | | | | | | | | | This ensures we get the correct FileCharacteristic during scanning. In a yet-to-be-upstreamed branch this fixes observable failures, but it's also good to handle this on principle: the FileCharacteristic is a property of the file that is observable in the scanner, so there is nothing preventing us from depending on it. rdar://108627403 Differential Revision: https://reviews.llvm.org/D149777
* [clang][dataflow] Change PruneTriviallyFalseEdges for building CFGKinuko Yasuda2023-05-031-1/+19
| | | | | | | | | | | | | Keeping this false could end up with extra iterations on a lot of loops that aren't real ones (e.g. they could be a do-while-false for macros), and makes the analyses very slow. This patch changes the default for CFG::BuildOptions.PruneTriviallyFalseEdges to true to avoid it. Reviewed By: ymandel, xazax.hun, gribozavr2 Differential Revision: https://reviews.llvm.org/D149640
* [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.Samira Bazuzi2023-05-022-7/+10
| | | | | | | | This will eliminate the need for more pass-through APIs. Also replace pass-through usages with this exposure. Reviewed By: ymandel, gribozavr2, xazax.hun Differential Revision: https://reviews.llvm.org/D149464
* [clang-format] Recognize Verilog type dimension in module headersstwcw2023-04-302-0/+13
| | | | | | | | | | We had the function `verilogGroupDecl` for that. However, the type name would be incorrectly annotated in `isStartOfName` when it was not a C++ keyword and followed another identifier. Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay Differential Revision: https://reviews.llvm.org/D149352
* [clang-format] Correctly format goto labels followed by blockssstwcw2023-04-302-2/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There doesn't seem to be an issue on GitHub. But previously, a space would be inserted before the goto colon in the code below. switch (x) { case 0: goto_0: { action(); break; } } Previously, the colon following a goto label would be annotated as `TT_InheritanceColon`. A goto label followed by an opening brace wasn't recognized. It is easy to add another line to have `spaceRequiredBefore` function recognize the case, but I believed it is more proper to avoid doing the same thing in `UnwrappedLineParser` and `TokenAnnotator`. So now the label colons would be labeled in `UnwrappedLineParser`, and `spaceRequiredBefore` would rely on that. Previously we had the type `TT_GotoLabelColon` intended for both goto labels and case labels. But since handling of goto labels and case labels differ somewhat, I split it into separate types for goto and case labels. This patch doesn't change the behavior for case labels. I added the lines annotating case labels because they would previously be mistakenly annotated as `TT_InheritanceColon` just like goto labels. And since I added the annotations, the checks for the `case` and `default` keywords in `spaceRequiredBefore` are not necessary anymore. Reviewed By: MyDeveloperDay Differential Revision: https://reviews.llvm.org/D148484
* [clang-format] Add BracedInitializerIndentWidth optionJon Phillips2023-04-292-0/+187
| | | | | | | | | The option allows users to specify how many columns to use to indent the contents of initializer lists. Closes #51070. Differential Revision: https://reviews.llvm.org/D146101
* [dataflow] HTMLLogger - show the value of the current exprSam McCall2023-04-261-0/+1
| | | | Differential Revision: https://reviews.llvm.org/D148949
* [clang-format] Hanlde leading whitespaces for JSON filesOwen Pan2023-04-201-0/+20
| | | | | | | Fixes #62228. Fixes #62229. Differential Revision: https://reviews.llvm.org/D148777
* [CMake] Reduce depsNAKAMURA Takumi2023-04-202-2/+0
|
* [dataflow] add HTML logger: browse code/cfg/analysis timeline/stateSam McCall2023-04-191-3/+33
| | | | | | | | | | | | | | | | | | | | With -dataflow-log=/dir we will write /dir/0.html etc for each function analyzed. These files show the function's code and CFG, and the path through the CFG taken by the analysis. At each analysis point we can see the lattice state. Currently the lattice state dump is not terribly useful but we can improve this: showing values associated with the current Expr, simplifying flow condition, highlighting changes etc. (Trying not to let this patch scope-creep too much, so I ripped out the half-finished features) Demo: https://htmlpreview.github.io/?https://gist.githubusercontent.com/sam-mccall/1746985bf13406bd19181af281aea9ff/raw/9718fdd48406dabccb3092acd983b4bd55da9dfa/analysis.html Differential Revision: https://reviews.llvm.org/D146591
* [dataflow] Extract arena for Value/StorageLocation out of ↵Sam McCall2023-04-193-437/+177
| | | | | | | | | | | | | | | | | DataflowAnalysisContext DataflowAnalysisContext has a few too many responsibilities, this narrows them. It also allows the Arena to be shared with analysis steps, which need to create Values, without exposing the whole DACtx API (flow conditions etc). This means Environment no longer needs to proxy all these methods. (For now it still does, because there are many callsites to update, and maybe if we separate bool formulas from values we can avoid churning them twice) In future, if we untangle the concepts of Values from boolean formulas/atoms, Arena would also be responsible for creating formulas and managing atom IDs. Differential Revision: https://reviews.llvm.org/D148554
* [clang-format] C# short ternary operator misinterpreted as a CSharpNullablemydeveloperday2023-04-181-0/+28
| | | | | | | | | | | Refactor the CSharpNullable assignment code to be a little easier to read (Honestly I don't like it when an if expression get really long and complicated). Handle the case where '?' is actually a ternary operator. Fixes: #58067 Reviewed By: owenpan, HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D148473
* [clang][dataflow] Associate `FunctionToPointerDecay` nodes with a value.Martin Braenne2023-04-181-0/+39
| | | | | | | | | To ensure that we have a pointee for the `PointerValue`, we also create storage locations for `FunctionDecl`s referenced in the function under analysis. Reviewed By: gribozavr2 Differential Revision: https://reviews.llvm.org/D148006
* [clang][dataflow] Add support for new expressions.Martin Braenne2023-04-181-0/+62
| | | | | | Reviewed By: xazax.hun, gribozavr2 Differential Revision: https://reviews.llvm.org/D147698
* [clang-format] CSharp don't allow there not to be a space between `is` and `[`mydeveloperday2023-04-171-0/+8
| | | | | | | | | | | | as `is` is a keyword in C# ensure there is always a space before the `[` regardless of `SpaceBeforeSquareBrackets` setting Fixes: #61965 https://github.com/llvm/llvm-project/issues/61965 Reviewed By: owenpan, HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D148472
* [clang][dataflow] Drop optional model's dependency on libc++ internals.Yitzhak Mandelbaum2023-04-171-6/+7
| | | | | | | | Adjusts the matchers in the optional model to avoid dependency on internal implementation details of libc++'s `std::optional`. In the process, factors out the code to check the name of these types so that it's shared throughout. Differential Revision: https://reviews.llvm.org/D148377
* [clang][dataflow] Refine matching of optional types to anchor at top level.Yitzhak Mandelbaum2023-04-171-0/+19
| | | | | | | | | | | | This patch refines the matching of the relevant optional types to anchor on the global namespace. Previously, we could match anything with the right name (e.g. `base::Optional`) even if nested within other namespaces. This over matching resulted in an assertion violation when _different_ `base::Optional` was encountered nested inside another namespace. Fixes issue #57036. Differential Revision: https://reviews.llvm.org/D148344
* [clang-format] Fix regression with AlignTrailingComments set to trueOwen Pan2023-04-161-5/+5
| | | | | | Fixes #62161. Differential Revision: https://reviews.llvm.org/D148447
* [clang-format][NFC] Output tokens on test assertsstwcw2023-04-161-7/+7
| | | | | | Reviewed By: rymiel Differential Revision: https://reviews.llvm.org/D148482
* [clang-format] Handle Verilog assertions and loopssstwcw2023-04-162-0/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Assert statements in Verilog can optionally have an else part. We handle them like for `if` statements, except that an `if` statement in the else part of an `assert` statement doesn't get merged with the `else` keyword. Like this: assert (x) $info(); else if (y) $info(); else if (z) $info(); else $info(); `foreach` and `repeat` are now handled like for or while loops. We used the type `TT_ConditionLParen` to mark the condition part so they are handled in the same way as the condition part of an `if` statement. When the code being formatted is not in Verilog, it is only set for `if` statements, not loops. It's because loop conditions are currently handled slightly differently, and existing behavior is not supposed to change. We formatted all files ending in `.cpp` and `.h` in the repository with and without this change. It showed that setting the type for `if` statements doesn't change existing behavior. And we noticed that we forgot to make the program print the list of tokens when the number is not correct in `TokenAnnotatorTest`. It's fixed now. Reviewed By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D147895
* [CMake] Cleanup depsNAKAMURA Takumi2023-04-171-1/+0
|
* [CMake] Reorder and reformat depsNAKAMURA Takumi2023-04-175-8/+8
|
* [clang-format] Dont interpret variable named interface as keyword for C++Jorge Pinto Sousa2023-04-161-0/+7
| | | | | | Fixes #53173. Differential Revision: https://reviews.llvm.org/D148437
* [clang-repl] JITTargetAddress --> ExecutorAddr, NFCJun Zhang2023-04-162-4/+5
| | | | | | | | | Most of Orc and JITLink are movinng away from JITTargetAddress and use ExecutorAddr instead. Signed-off-by: Jun Zhang <jun@junz.org> Differential Revision: https://reviews.llvm.org/D148434
* [clang-format] Correctly indent comment above finalized PPDirectiveOwen Pan2023-04-141-0/+7
| | | | | | Fixes #62107. Differential Revision: https://reviews.llvm.org/D148200
* Revert "[clang-format] Handle object instansiation in if-statements"Tobias Hieta2023-04-141-12/+0
| | | | | | This reverts commit 70de684d44135b4025d92b2b36ad387cf5ab8b5a. This causes a regression as described in #61785
* [clang] fix an unused variable warning after ↵Krasimir Georgiev2023-04-131-1/+0
| | | | 9d0b55f0e4ca55d04ee8abfdf021913ea3c30082
* [clang] Ensure that Attr::Create(Implicit) chooses a valid syntaxRichard Sandiford2023-04-131-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The purpose of this patch and follow-on patches is to ensure that AttributeCommonInfos always have a syntax that is appropriate for their kind (i.e. that it matches one of the entries in Attr.td). The attribute-specific Create and CreateImplicit methods had four overloads, based on their tail arguments: (1) no extra arguments (2) an AttributeCommonInfo (3) a SourceRange (4) a SourceRange, a syntax, and (where necessary) a spelling When (4) had a spelling argument, it defaulted to SpellingNotCalculated. One disadvantage of this was that (1) and (3) zero-initialized the syntax field of the AttributeCommonInfo, which corresponds to AS_GNU. But AS_GNU isn't always listed as a possibility in Attr.td. This patch therefore removes (1) and (3) and instead provides the same functionality using default arguments on (4) (a bit like the existing default argument for the spelling). The default syntax is taken from the attribute's first valid spelling. Doing that raises the question: what should happen for attributes like AlignNatural and CUDAInvalidTarget that are only ever created implicitly, and so have no source-code manifestation at all? The patch adds a new AS_Implicit "syntax" for that case. The patch also removes the syntax argument for these attributes, since the syntax must always be AS_Implicit. For similar reasons, the patch removes the syntax argument if there is exactly one valid spelling. Doing this means that AttributeCommonInfo no longer needs the single-argument constructors. It is always given a syntax instead. Differential Revision: https://reviews.llvm.org/D148101